@uniformdev/next-app-router 20.50.2-alpha.149 → 20.50.2-alpha.167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/component.js CHANGED
@@ -231,12 +231,12 @@ var ApiClientError = class _ApiClientError extends Error {
231
231
  `${errorMessage}
232
232
  ${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
233
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;
234
+ __publicField(this, "errorMessage", errorMessage);
235
+ __publicField(this, "fetchMethod", fetchMethod);
236
+ __publicField(this, "fetchUri", fetchUri);
237
+ __publicField(this, "statusCode", statusCode);
238
+ __publicField(this, "statusText", statusText);
239
+ __publicField(this, "requestId", requestId);
240
240
  Object.setPrototypeOf(this, _ApiClientError.prototype);
241
241
  }
242
242
  };
@@ -624,378 +624,57 @@ _url7 = /* @__PURE__ */ new WeakMap();
624
624
  __privateAdd(_TestClient, _url7, "/api/v2/test");
625
625
 
626
626
  // ../canvas/dist/index.mjs
627
- var __create2 = Object.create;
628
- var __defProp3 = Object.defineProperty;
629
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
630
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
631
- var __getProtoOf2 = Object.getPrototypeOf;
632
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
633
627
  var __typeError2 = (msg) => {
634
628
  throw TypeError(msg);
635
629
  };
636
- var __commonJS2 = (cb, mod) => function __require() {
637
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
638
- };
639
- var __copyProps2 = (to, from, except, desc) => {
640
- if (from && typeof from === "object" || typeof from === "function") {
641
- for (let key of __getOwnPropNames2(from))
642
- if (!__hasOwnProp2.call(to, key) && key !== except)
643
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
644
- }
645
- return to;
646
- };
647
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
648
- // If the importer is in node compatibility mode or this is not an ESM
649
- // file that has been converted to a CommonJS file using a Babel-
650
- // compatible transform (i.e. "__esModule" has not been set), then set
651
- // "default" to the CommonJS "module.exports" for node compatibility.
652
- isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
653
- mod
654
- ));
655
630
  var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
656
631
  var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
657
632
  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);
658
- var require_yocto_queue2 = __commonJS2({
659
- "../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
660
- "use strict";
661
- var Node = class {
662
- /// value;
663
- /// next;
664
- constructor(value) {
665
- this.value = value;
666
- this.next = void 0;
667
- }
668
- };
669
- var Queue = class {
670
- // TODO: Use private class fields when targeting Node.js 12.
671
- // #_head;
672
- // #_tail;
673
- // #_size;
674
- constructor() {
675
- this.clear();
676
- }
677
- enqueue(value) {
678
- const node = new Node(value);
679
- if (this._head) {
680
- this._tail.next = node;
681
- this._tail = node;
682
- } else {
683
- this._head = node;
684
- this._tail = node;
685
- }
686
- this._size++;
687
- }
688
- dequeue() {
689
- const current = this._head;
690
- if (!current) {
691
- return;
692
- }
693
- this._head = this._head.next;
694
- this._size--;
695
- return current.value;
696
- }
697
- clear() {
698
- this._head = void 0;
699
- this._tail = void 0;
700
- this._size = 0;
701
- }
702
- get size() {
703
- return this._size;
704
- }
705
- *[Symbol.iterator]() {
706
- let current = this._head;
707
- while (current) {
708
- yield current.value;
709
- current = current.next;
710
- }
711
- }
712
- };
713
- module2.exports = Queue;
633
+ var SELECT_QUERY_PREFIX = "select.";
634
+ function appendCsv(out, key, values) {
635
+ if (values === void 0) {
636
+ return;
714
637
  }
715
- });
716
- var require_p_limit2 = __commonJS2({
717
- "../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
718
- "use strict";
719
- var Queue = require_yocto_queue2();
720
- var pLimit2 = (concurrency) => {
721
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
722
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
723
- }
724
- const queue = new Queue();
725
- let activeCount = 0;
726
- const next = () => {
727
- activeCount--;
728
- if (queue.size > 0) {
729
- queue.dequeue()();
730
- }
731
- };
732
- const run = async (fn, resolve, ...args) => {
733
- activeCount++;
734
- const result = (async () => fn(...args))();
735
- resolve(result);
736
- try {
737
- await result;
738
- } catch (e) {
739
- }
740
- next();
741
- };
742
- const enqueue = (fn, resolve, ...args) => {
743
- queue.enqueue(run.bind(null, fn, resolve, ...args));
744
- (async () => {
745
- await Promise.resolve();
746
- if (activeCount < concurrency && queue.size > 0) {
747
- queue.dequeue()();
748
- }
749
- })();
750
- };
751
- const generator = (fn, ...args) => new Promise((resolve) => {
752
- enqueue(fn, resolve, ...args);
753
- });
754
- Object.defineProperties(generator, {
755
- activeCount: {
756
- get: () => activeCount
757
- },
758
- pendingCount: {
759
- get: () => queue.size
760
- },
761
- clearQueue: {
762
- value: () => {
763
- queue.clear();
764
- }
765
- }
766
- });
767
- return generator;
768
- };
769
- module2.exports = pLimit2;
770
- }
771
- });
772
- var require_retry_operation = __commonJS2({
773
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
774
- "use strict";
775
- function RetryOperation(timeouts, options) {
776
- if (typeof options === "boolean") {
777
- options = { forever: options };
778
- }
779
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
780
- this._timeouts = timeouts;
781
- this._options = options || {};
782
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
783
- this._fn = null;
784
- this._errors = [];
785
- this._attempts = 1;
786
- this._operationTimeout = null;
787
- this._operationTimeoutCb = null;
788
- this._timeout = null;
789
- this._operationStart = null;
790
- this._timer = null;
791
- if (this._options.forever) {
792
- this._cachedTimeouts = this._timeouts.slice(0);
793
- }
638
+ out[key] = values.join(",");
639
+ }
640
+ function projectionToQuery(spec) {
641
+ const out = {};
642
+ if (!spec) {
643
+ return out;
644
+ }
645
+ const { fields, fieldTypes, slots } = spec;
646
+ const p = SELECT_QUERY_PREFIX;
647
+ if (fields) {
648
+ appendCsv(out, `${p}fields[only]`, fields.only);
649
+ appendCsv(out, `${p}fields[except]`, fields.except);
650
+ appendCsv(out, `${p}fields[locales]`, fields.locales);
651
+ }
652
+ if (fieldTypes) {
653
+ appendCsv(out, `${p}fieldTypes[only]`, fieldTypes.only);
654
+ appendCsv(out, `${p}fieldTypes[except]`, fieldTypes.except);
655
+ }
656
+ if (slots) {
657
+ appendCsv(out, `${p}slots[only]`, slots.only);
658
+ appendCsv(out, `${p}slots[except]`, slots.except);
659
+ if (typeof slots.depth === "number") {
660
+ out[`${p}slots[depth]`] = String(slots.depth);
794
661
  }
795
- module2.exports = RetryOperation;
796
- RetryOperation.prototype.reset = function() {
797
- this._attempts = 1;
798
- this._timeouts = this._originalTimeouts.slice(0);
799
- };
800
- RetryOperation.prototype.stop = function() {
801
- if (this._timeout) {
802
- clearTimeout(this._timeout);
803
- }
804
- if (this._timer) {
805
- clearTimeout(this._timer);
806
- }
807
- this._timeouts = [];
808
- this._cachedTimeouts = null;
809
- };
810
- RetryOperation.prototype.retry = function(err) {
811
- if (this._timeout) {
812
- clearTimeout(this._timeout);
813
- }
814
- if (!err) {
815
- return false;
816
- }
817
- var currentTime = (/* @__PURE__ */ new Date()).getTime();
818
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
819
- this._errors.push(err);
820
- this._errors.unshift(new Error("RetryOperation timeout occurred"));
821
- return false;
822
- }
823
- this._errors.push(err);
824
- var timeout = this._timeouts.shift();
825
- if (timeout === void 0) {
826
- if (this._cachedTimeouts) {
827
- this._errors.splice(0, this._errors.length - 1);
828
- timeout = this._cachedTimeouts.slice(-1);
829
- } else {
830
- return false;
662
+ if (slots.named) {
663
+ const slotNames = Object.keys(slots.named).sort();
664
+ for (const slotName of slotNames) {
665
+ const named = slots.named[slotName];
666
+ if (named && typeof named.depth === "number") {
667
+ out[`${p}slots.${slotName}[depth]`] = String(named.depth);
831
668
  }
832
669
  }
833
- var self = this;
834
- this._timer = setTimeout(function() {
835
- self._attempts++;
836
- if (self._operationTimeoutCb) {
837
- self._timeout = setTimeout(function() {
838
- self._operationTimeoutCb(self._attempts);
839
- }, self._operationTimeout);
840
- if (self._options.unref) {
841
- self._timeout.unref();
842
- }
843
- }
844
- self._fn(self._attempts);
845
- }, timeout);
846
- if (this._options.unref) {
847
- this._timer.unref();
848
- }
849
- return true;
850
- };
851
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
852
- this._fn = fn;
853
- if (timeoutOps) {
854
- if (timeoutOps.timeout) {
855
- this._operationTimeout = timeoutOps.timeout;
856
- }
857
- if (timeoutOps.cb) {
858
- this._operationTimeoutCb = timeoutOps.cb;
859
- }
860
- }
861
- var self = this;
862
- if (this._operationTimeoutCb) {
863
- this._timeout = setTimeout(function() {
864
- self._operationTimeoutCb();
865
- }, self._operationTimeout);
866
- }
867
- this._operationStart = (/* @__PURE__ */ new Date()).getTime();
868
- this._fn(this._attempts);
869
- };
870
- RetryOperation.prototype.try = function(fn) {
871
- console.log("Using RetryOperation.try() is deprecated");
872
- this.attempt(fn);
873
- };
874
- RetryOperation.prototype.start = function(fn) {
875
- console.log("Using RetryOperation.start() is deprecated");
876
- this.attempt(fn);
877
- };
878
- RetryOperation.prototype.start = RetryOperation.prototype.try;
879
- RetryOperation.prototype.errors = function() {
880
- return this._errors;
881
- };
882
- RetryOperation.prototype.attempts = function() {
883
- return this._attempts;
884
- };
885
- RetryOperation.prototype.mainError = function() {
886
- if (this._errors.length === 0) {
887
- return null;
888
- }
889
- var counts = {};
890
- var mainError = null;
891
- var mainErrorCount = 0;
892
- for (var i = 0; i < this._errors.length; i++) {
893
- var error = this._errors[i];
894
- var message = error.message;
895
- var count = (counts[message] || 0) + 1;
896
- counts[message] = count;
897
- if (count >= mainErrorCount) {
898
- mainError = error;
899
- mainErrorCount = count;
900
- }
901
- }
902
- return mainError;
903
- };
904
- }
905
- });
906
- var require_retry = __commonJS2({
907
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports2) {
908
- "use strict";
909
- var RetryOperation = require_retry_operation();
910
- exports2.operation = function(options) {
911
- var timeouts = exports2.timeouts(options);
912
- return new RetryOperation(timeouts, {
913
- forever: options && (options.forever || options.retries === Infinity),
914
- unref: options && options.unref,
915
- maxRetryTime: options && options.maxRetryTime
916
- });
917
- };
918
- exports2.timeouts = function(options) {
919
- if (options instanceof Array) {
920
- return [].concat(options);
921
- }
922
- var opts = {
923
- retries: 10,
924
- factor: 2,
925
- minTimeout: 1 * 1e3,
926
- maxTimeout: Infinity,
927
- randomize: false
928
- };
929
- for (var key in options) {
930
- opts[key] = options[key];
931
- }
932
- if (opts.minTimeout > opts.maxTimeout) {
933
- throw new Error("minTimeout is greater than maxTimeout");
934
- }
935
- var timeouts = [];
936
- for (var i = 0; i < opts.retries; i++) {
937
- timeouts.push(this.createTimeout(i, opts));
938
- }
939
- if (options && options.forever && !timeouts.length) {
940
- timeouts.push(this.createTimeout(i, opts));
941
- }
942
- timeouts.sort(function(a, b) {
943
- return a - b;
944
- });
945
- return timeouts;
946
- };
947
- exports2.createTimeout = function(attempt, opts) {
948
- var random = opts.randomize ? Math.random() + 1 : 1;
949
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
950
- timeout = Math.min(timeout, opts.maxTimeout);
951
- return timeout;
952
- };
953
- exports2.wrap = function(obj, options, methods) {
954
- if (options instanceof Array) {
955
- methods = options;
956
- options = null;
957
- }
958
- if (!methods) {
959
- methods = [];
960
- for (var key in obj) {
961
- if (typeof obj[key] === "function") {
962
- methods.push(key);
963
- }
964
- }
965
- }
966
- for (var i = 0; i < methods.length; i++) {
967
- var method = methods[i];
968
- var original = obj[method];
969
- obj[method] = function retryWrapper(original2) {
970
- var op = exports2.operation(options);
971
- var args = Array.prototype.slice.call(arguments, 1);
972
- var callback = args.pop();
973
- args.push(function(err) {
974
- if (op.retry(err)) {
975
- return;
976
- }
977
- if (err) {
978
- arguments[0] = op.mainError();
979
- }
980
- callback.apply(this, arguments);
981
- });
982
- op.attempt(function() {
983
- original2.apply(obj, args);
984
- });
985
- }.bind(obj, original);
986
- obj[method].options = options;
987
- }
988
- };
989
- }
990
- });
991
- var require_retry2 = __commonJS2({
992
- "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports2, module2) {
993
- "use strict";
994
- module2.exports = require_retry();
670
+ }
995
671
  }
996
- });
997
- var import_p_limit2 = __toESM2(require_p_limit2());
998
- var import_retry = __toESM2(require_retry2(), 1);
672
+ return out;
673
+ }
674
+ var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
675
+ var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
676
+ var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
677
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
999
678
  var _contentTypesUrl;
1000
679
  var _entriesUrl;
1001
680
  var _ContentClient = class _ContentClient2 extends ApiClient {
@@ -1011,15 +690,21 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1011
690
  }
1012
691
  getEntries(options) {
1013
692
  const { projectId } = this.options;
1014
- const { skipDataResolution, filters, ...params } = options;
693
+ const { skipDataResolution, filters, select, ...params } = options;
1015
694
  const rewrittenFilters = rewriteFiltersForApi(filters);
695
+ const rewrittenSelect = projectionToQuery(select);
1016
696
  if (skipDataResolution) {
1017
- const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
697
+ const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), {
698
+ ...params,
699
+ ...rewrittenFilters,
700
+ ...rewrittenSelect,
701
+ projectId
702
+ });
1018
703
  return this.apiClient(url);
1019
704
  }
1020
705
  const edgeUrl = this.createUrl(
1021
706
  __privateGet2(_ContentClient2, _entriesUrl),
1022
- { ...this.getEdgeOptions(params), ...rewrittenFilters },
707
+ { ...this.getEdgeOptions(params), ...rewrittenFilters, ...rewrittenSelect },
1023
708
  this.edgeApiHost
1024
709
  );
1025
710
  return this.apiClient(
@@ -1096,14 +781,18 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1096
781
  constructor(options) {
1097
782
  super(options);
1098
783
  }
1099
- /** Fetches all DataTypes for a project */
1100
- async get(options) {
784
+ /** Fetches a list of DataTypes for a project */
785
+ async list(options) {
1101
786
  const { projectId } = this.options;
1102
787
  const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8), { ...options, projectId });
1103
788
  return await this.apiClient(fetchUri);
1104
789
  }
790
+ /** @deprecated Use {@link list} instead. */
791
+ async get(options) {
792
+ return this.list(options);
793
+ }
1105
794
  /** Updates or creates (based on id) a DataType */
1106
- async upsert(body) {
795
+ async save(body) {
1107
796
  const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
1108
797
  await this.apiClient(fetchUri, {
1109
798
  method: "PUT",
@@ -1111,6 +800,10 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1111
800
  expectNoContent: true
1112
801
  });
1113
802
  }
803
+ /** @deprecated Use {@link save} instead. */
804
+ async upsert(body) {
805
+ return this.save(body);
806
+ }
1114
807
  /** Deletes a DataType */
1115
808
  async remove(body) {
1116
809
  const fetchUri = this.createUrl(__privateGet2(_DataTypeClient2, _url8));
@@ -1123,10 +816,6 @@ var _DataTypeClient = class _DataTypeClient2 extends ApiClient {
1123
816
  };
1124
817
  _url8 = /* @__PURE__ */ new WeakMap();
1125
818
  __privateAdd2(_DataTypeClient, _url8, "/api/v1/data-types");
1126
- var CANVAS_INTERNAL_PARAM_PREFIX = "$internal_";
1127
- var CANVAS_COMPONENT_DISPLAY_NAME_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}displayName`;
1128
- var CANVAS_HYPOTHESIS_PARAM = `${CANVAS_INTERNAL_PARAM_PREFIX}hypothesis`;
1129
- var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1130
819
  var _baseUrl;
1131
820
  var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2 extends ApiClient {
1132
821
  constructor(options) {
@@ -1184,20 +873,28 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1184
873
  * When teamId is provided, returns a single team with its projects.
1185
874
  * When omitted, returns all accessible teams and their projects.
1186
875
  */
1187
- async getProjects(options) {
876
+ async list(options) {
1188
877
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1189
878
  return await this.apiClient(fetchUri);
1190
879
  }
880
+ /** @deprecated Use {@link list} instead. */
881
+ async getProjects(options) {
882
+ return this.list(options);
883
+ }
1191
884
  /** Updates or creates (based on id) a Project */
1192
- async upsert(body) {
885
+ async save(body) {
1193
886
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1194
887
  return await this.apiClient(fetchUri, {
1195
888
  method: "PUT",
1196
889
  body: JSON.stringify({ ...body })
1197
890
  });
1198
891
  }
892
+ /** @deprecated Use {@link save} instead. */
893
+ async upsert(body) {
894
+ return this.save(body);
895
+ }
1199
896
  /** Deletes a Project */
1200
- async delete(body) {
897
+ async remove(body) {
1201
898
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
1202
899
  await this.apiClient(fetchUri, {
1203
900
  method: "DELETE",
@@ -1205,6 +902,10 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1205
902
  expectNoContent: true
1206
903
  });
1207
904
  }
905
+ /** @deprecated Use {@link remove} instead. */
906
+ async delete(body) {
907
+ return this.remove(body);
908
+ }
1208
909
  };
1209
910
  _url22 = /* @__PURE__ */ new WeakMap();
1210
911
  _projectsUrl = /* @__PURE__ */ new WeakMap();