@uniformdev/canvas 19.61.1-alpha.10 → 19.61.1-alpha.18

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.esm.js CHANGED
@@ -478,10 +478,20 @@ var CanvasClient = class extends ApiClient {
478
478
  this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
479
479
  }
480
480
  /** Fetches lists of Canvas compositions, optionally by type */
481
- async getCompositionList(options) {
481
+ async getCompositionList(params = {}) {
482
482
  const { projectId } = this.options;
483
- const fetchUri = this.createUrl(CANVAS_URL, { ...options, projectId });
484
- return await this.apiClient(fetchUri);
483
+ const { resolveData, ...originParams } = params;
484
+ if (!resolveData) {
485
+ const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId });
486
+ return this.apiClient(fetchUri);
487
+ }
488
+ const edgeParams = {
489
+ ...originParams,
490
+ projectId,
491
+ ...params.diagnostics ? { diagnostics: "true" } : {}
492
+ };
493
+ const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
494
+ return this.apiClient(edgeUrl);
485
495
  }
486
496
  getCompositionByNodePath(options) {
487
497
  return this.getOneComposition(options);
@@ -499,12 +509,12 @@ var CanvasClient = class extends ApiClient {
499
509
  return this.getOneComposition(options);
500
510
  }
501
511
  /** Fetches historical versions of a composition or pattern */
502
- async unstable_getCompositionHistory(options) {
503
- const edgeUrl = this.createUrl("/api/v1/canvas-history", {
512
+ async getCompositionHistory(options) {
513
+ const historyUrl = this.createUrl("/api/v1/canvas-history", {
504
514
  ...options,
505
515
  projectId: this.options.projectId
506
516
  });
507
- return this.apiClient(edgeUrl);
517
+ return this.apiClient(historyUrl);
508
518
  }
509
519
  getOneComposition({
510
520
  skipDataResolution,
@@ -546,7 +556,7 @@ var CanvasClient = class extends ApiClient {
546
556
  async getComponentDefinitions(options) {
547
557
  const { projectId } = this.options;
548
558
  const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
549
- return await this.apiClient(fetchUri);
559
+ return this.apiClient(fetchUri);
550
560
  }
551
561
  /** Updates or creates a Canvas component definition */
552
562
  async updateComponentDefinition(body) {
@@ -699,12 +709,21 @@ var _ContentClient = class _ContentClient extends ApiClient4 {
699
709
  const fetchUri = skipDataResolution ? this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, projectId }) : this.createUrl(__privateGet(_ContentClient, _entriesUrl), this.getEdgeOptions(params), this.edgeApiHost);
700
710
  return this.apiClient(fetchUri);
701
711
  }
702
- async upsertContentType(body) {
712
+ /** Fetches historical versions of an entry */
713
+ async getEntryHistory(options) {
714
+ const historyUrl = this.createUrl("/api/v1/entries-history", {
715
+ ...options,
716
+ projectId: this.options.projectId
717
+ });
718
+ return this.apiClient(historyUrl);
719
+ }
720
+ async upsertContentType(body, opts = {}) {
703
721
  const fetchUri = this.createUrl(__privateGet(_ContentClient, _contentTypesUrl));
704
722
  await this.apiClient(fetchUri, {
705
723
  method: "PUT",
706
724
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
707
- expectNoContent: true
725
+ expectNoContent: true,
726
+ headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
708
727
  });
709
728
  }
710
729
  async upsertEntry(body) {
@@ -963,6 +982,7 @@ var CANVAS_EDITOR_STATE = 63;
963
982
  var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
964
983
  var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
965
984
  var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
985
+ var SECRET_QUERY_STRING_PARAM = "secret";
966
986
  var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
967
987
  var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
968
988
  var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
@@ -976,13 +996,10 @@ var EMPTY_COMPOSITION = {
976
996
  _name: "An empty composition used for contextual editing",
977
997
  type: "_empty_composition_type"
978
998
  };
979
- var EDGE_MIN_CACHE_TTL = 15;
980
- var EDGE_MAX_CACHE_TTL = 600;
999
+ var EDGE_MIN_CACHE_TTL = 10;
1000
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
981
1001
  var EDGE_DEFAULT_CACHE_TTL = 30;
982
1002
  var EDGE_CACHE_DISABLED = -1;
983
- var EDGE_MIN_L2_CACHE_TTL_IN_HOURS = 1;
984
- var EDGE_MAX_L2_CACHE_TTL_IN_HOURS = 4 * 7 * 24;
985
- var EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS = 24;
986
1003
 
987
1004
  // src/utils/entryConverter.ts
988
1005
  function convertEntryToPutEntry(entry) {
@@ -991,6 +1008,7 @@ function convertEntryToPutEntry(entry) {
991
1008
  type: entry.entry.type,
992
1009
  _dataResources: entry.entry._dataResources,
993
1010
  _id: entry.entry._id,
1011
+ _name: entry.entry._name,
994
1012
  _slug: entry.entry._slug,
995
1013
  fields: entry.entry.fields
996
1014
  },
@@ -1809,7 +1827,7 @@ var createCanvasChannel = ({
1809
1827
  };
1810
1828
  postMessage(message);
1811
1829
  };
1812
- const ready = () => {
1830
+ const ready = (options) => {
1813
1831
  var _a, _b;
1814
1832
  if (typeof window === "undefined") {
1815
1833
  return;
@@ -1819,7 +1837,8 @@ var createCanvasChannel = ({
1819
1837
  const message = {
1820
1838
  type: "ready",
1821
1839
  framework,
1822
- version
1840
+ version,
1841
+ rsc: options == null ? void 0 : options.rsc
1823
1842
  };
1824
1843
  postMessage(message);
1825
1844
  };
@@ -2077,10 +2096,43 @@ function subscribeToComposition({
2077
2096
  };
2078
2097
  }
2079
2098
 
2080
- // src/RouteClient.ts
2099
+ // src/PromptClient.ts
2081
2100
  import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
2101
+ var PromptsUrl = "/api/v1/prompts";
2102
+ var PromptClient = class extends ApiClient7 {
2103
+ constructor(options) {
2104
+ super(options);
2105
+ }
2106
+ /** Fetches Prompts for a project */
2107
+ async get(options) {
2108
+ const { projectId } = this.options;
2109
+ const fetchUri = this.createUrl(PromptsUrl, { ...options, projectId });
2110
+ return await this.apiClient(fetchUri);
2111
+ }
2112
+ /** Updates or creates (based on id) a Prompt */
2113
+ async upsert(body) {
2114
+ const fetchUri = this.createUrl(PromptsUrl);
2115
+ await this.apiClient(fetchUri, {
2116
+ method: "PUT",
2117
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2118
+ expectNoContent: true
2119
+ });
2120
+ }
2121
+ /** Deletes a Prompt */
2122
+ async remove(body) {
2123
+ const fetchUri = this.createUrl(PromptsUrl);
2124
+ await this.apiClient(fetchUri, {
2125
+ method: "DELETE",
2126
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2127
+ expectNoContent: true
2128
+ });
2129
+ }
2130
+ };
2131
+
2132
+ // src/RouteClient.ts
2133
+ import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2082
2134
  var ROUTE_URL = "/api/v1/route";
2083
- var RouteClient = class extends ApiClient7 {
2135
+ var RouteClient = class extends ApiClient8 {
2084
2136
  constructor(options) {
2085
2137
  var _a;
2086
2138
  if (!options.limitPolicy) {
@@ -2196,6 +2248,9 @@ var isComponentPlaceholderId = (id) => {
2196
2248
  if (id === PLACEHOLDER_ID) {
2197
2249
  return true;
2198
2250
  }
2251
+ if (typeof id !== "string") {
2252
+ return false;
2253
+ }
2199
2254
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2200
2255
  };
2201
2256
  var generateComponentPlaceholderId = (randomId, sdkVersion) => {
@@ -2423,11 +2478,8 @@ export {
2423
2478
  DataTypeClient,
2424
2479
  EDGE_CACHE_DISABLED,
2425
2480
  EDGE_DEFAULT_CACHE_TTL,
2426
- EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
2427
2481
  EDGE_MAX_CACHE_TTL,
2428
- EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
2429
2482
  EDGE_MIN_CACHE_TTL,
2430
- EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
2431
2483
  EMPTY_COMPOSITION,
2432
2484
  EnhancerBuilder,
2433
2485
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
@@ -2438,7 +2490,9 @@ export {
2438
2490
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
2439
2491
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
2440
2492
  PLACEHOLDER_ID,
2493
+ PromptClient,
2441
2494
  RouteClient,
2495
+ SECRET_QUERY_STRING_PARAM,
2442
2496
  UncachedCanvasClient,
2443
2497
  UncachedCategoryClient,
2444
2498
  UncachedContentClient,
package/dist/index.js CHANGED
@@ -283,7 +283,7 @@ __export(src_exports, {
283
283
  ATTRIBUTE_PARAMETER_TYPE: () => ATTRIBUTE_PARAMETER_TYPE,
284
284
  ATTRIBUTE_PARAMETER_VALUE: () => ATTRIBUTE_PARAMETER_VALUE,
285
285
  ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
286
- ApiClientError: () => import_api9.ApiClientError,
286
+ ApiClientError: () => import_api10.ApiClientError,
287
287
  BatchEntry: () => BatchEntry,
288
288
  CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
289
289
  CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
@@ -309,11 +309,8 @@ __export(src_exports, {
309
309
  DataTypeClient: () => DataTypeClient,
310
310
  EDGE_CACHE_DISABLED: () => EDGE_CACHE_DISABLED,
311
311
  EDGE_DEFAULT_CACHE_TTL: () => EDGE_DEFAULT_CACHE_TTL,
312
- EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS: () => EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
313
312
  EDGE_MAX_CACHE_TTL: () => EDGE_MAX_CACHE_TTL,
314
- EDGE_MAX_L2_CACHE_TTL_IN_HOURS: () => EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
315
313
  EDGE_MIN_CACHE_TTL: () => EDGE_MIN_CACHE_TTL,
316
- EDGE_MIN_L2_CACHE_TTL_IN_HOURS: () => EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
317
314
  EMPTY_COMPOSITION: () => EMPTY_COMPOSITION,
318
315
  EnhancerBuilder: () => EnhancerBuilder,
319
316
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
@@ -324,7 +321,9 @@ __export(src_exports, {
324
321
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
325
322
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE: () => IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
326
323
  PLACEHOLDER_ID: () => PLACEHOLDER_ID,
324
+ PromptClient: () => PromptClient,
327
325
  RouteClient: () => RouteClient,
326
+ SECRET_QUERY_STRING_PARAM: () => SECRET_QUERY_STRING_PARAM,
328
327
  UncachedCanvasClient: () => UncachedCanvasClient,
329
328
  UncachedCategoryClient: () => UncachedCategoryClient,
330
329
  UncachedContentClient: () => UncachedContentClient,
@@ -591,10 +590,20 @@ var CanvasClient = class extends import_api2.ApiClient {
591
590
  this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
592
591
  }
593
592
  /** Fetches lists of Canvas compositions, optionally by type */
594
- async getCompositionList(options) {
593
+ async getCompositionList(params = {}) {
595
594
  const { projectId } = this.options;
596
- const fetchUri = this.createUrl(CANVAS_URL, { ...options, projectId });
597
- return await this.apiClient(fetchUri);
595
+ const { resolveData, ...originParams } = params;
596
+ if (!resolveData) {
597
+ const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId });
598
+ return this.apiClient(fetchUri);
599
+ }
600
+ const edgeParams = {
601
+ ...originParams,
602
+ projectId,
603
+ ...params.diagnostics ? { diagnostics: "true" } : {}
604
+ };
605
+ const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
606
+ return this.apiClient(edgeUrl);
598
607
  }
599
608
  getCompositionByNodePath(options) {
600
609
  return this.getOneComposition(options);
@@ -612,12 +621,12 @@ var CanvasClient = class extends import_api2.ApiClient {
612
621
  return this.getOneComposition(options);
613
622
  }
614
623
  /** Fetches historical versions of a composition or pattern */
615
- async unstable_getCompositionHistory(options) {
616
- const edgeUrl = this.createUrl("/api/v1/canvas-history", {
624
+ async getCompositionHistory(options) {
625
+ const historyUrl = this.createUrl("/api/v1/canvas-history", {
617
626
  ...options,
618
627
  projectId: this.options.projectId
619
628
  });
620
- return this.apiClient(edgeUrl);
629
+ return this.apiClient(historyUrl);
621
630
  }
622
631
  getOneComposition({
623
632
  skipDataResolution,
@@ -659,7 +668,7 @@ var CanvasClient = class extends import_api2.ApiClient {
659
668
  async getComponentDefinitions(options) {
660
669
  const { projectId } = this.options;
661
670
  const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
662
- return await this.apiClient(fetchUri);
671
+ return this.apiClient(fetchUri);
663
672
  }
664
673
  /** Updates or creates a Canvas component definition */
665
674
  async updateComponentDefinition(body) {
@@ -812,12 +821,21 @@ var _ContentClient = class _ContentClient extends import_api5.ApiClient {
812
821
  const fetchUri = skipDataResolution ? this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, projectId }) : this.createUrl(__privateGet(_ContentClient, _entriesUrl), this.getEdgeOptions(params), this.edgeApiHost);
813
822
  return this.apiClient(fetchUri);
814
823
  }
815
- async upsertContentType(body) {
824
+ /** Fetches historical versions of an entry */
825
+ async getEntryHistory(options) {
826
+ const historyUrl = this.createUrl("/api/v1/entries-history", {
827
+ ...options,
828
+ projectId: this.options.projectId
829
+ });
830
+ return this.apiClient(historyUrl);
831
+ }
832
+ async upsertContentType(body, opts = {}) {
816
833
  const fetchUri = this.createUrl(__privateGet(_ContentClient, _contentTypesUrl));
817
834
  await this.apiClient(fetchUri, {
818
835
  method: "PUT",
819
836
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
820
- expectNoContent: true
837
+ expectNoContent: true,
838
+ headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
821
839
  });
822
840
  }
823
841
  async upsertEntry(body) {
@@ -1076,6 +1094,7 @@ var CANVAS_EDITOR_STATE = 63;
1076
1094
  var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
1077
1095
  var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
1078
1096
  var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
1097
+ var SECRET_QUERY_STRING_PARAM = "secret";
1079
1098
  var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
1080
1099
  var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
1081
1100
  var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
@@ -1089,13 +1108,10 @@ var EMPTY_COMPOSITION = {
1089
1108
  _name: "An empty composition used for contextual editing",
1090
1109
  type: "_empty_composition_type"
1091
1110
  };
1092
- var EDGE_MIN_CACHE_TTL = 15;
1093
- var EDGE_MAX_CACHE_TTL = 600;
1111
+ var EDGE_MIN_CACHE_TTL = 10;
1112
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
1094
1113
  var EDGE_DEFAULT_CACHE_TTL = 30;
1095
1114
  var EDGE_CACHE_DISABLED = -1;
1096
- var EDGE_MIN_L2_CACHE_TTL_IN_HOURS = 1;
1097
- var EDGE_MAX_L2_CACHE_TTL_IN_HOURS = 4 * 7 * 24;
1098
- var EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS = 24;
1099
1115
 
1100
1116
  // src/utils/entryConverter.ts
1101
1117
  function convertEntryToPutEntry(entry) {
@@ -1104,6 +1120,7 @@ function convertEntryToPutEntry(entry) {
1104
1120
  type: entry.entry.type,
1105
1121
  _dataResources: entry.entry._dataResources,
1106
1122
  _id: entry.entry._id,
1123
+ _name: entry.entry._name,
1107
1124
  _slug: entry.entry._slug,
1108
1125
  fields: entry.entry.fields
1109
1126
  },
@@ -1922,7 +1939,7 @@ var createCanvasChannel = ({
1922
1939
  };
1923
1940
  postMessage(message);
1924
1941
  };
1925
- const ready = () => {
1942
+ const ready = (options) => {
1926
1943
  var _a, _b;
1927
1944
  if (typeof window === "undefined") {
1928
1945
  return;
@@ -1932,7 +1949,8 @@ var createCanvasChannel = ({
1932
1949
  const message = {
1933
1950
  type: "ready",
1934
1951
  framework,
1935
- version
1952
+ version,
1953
+ rsc: options == null ? void 0 : options.rsc
1936
1954
  };
1937
1955
  postMessage(message);
1938
1956
  };
@@ -2190,10 +2208,43 @@ function subscribeToComposition({
2190
2208
  };
2191
2209
  }
2192
2210
 
2193
- // src/RouteClient.ts
2211
+ // src/PromptClient.ts
2194
2212
  var import_api8 = require("@uniformdev/context/api");
2213
+ var PromptsUrl = "/api/v1/prompts";
2214
+ var PromptClient = class extends import_api8.ApiClient {
2215
+ constructor(options) {
2216
+ super(options);
2217
+ }
2218
+ /** Fetches Prompts for a project */
2219
+ async get(options) {
2220
+ const { projectId } = this.options;
2221
+ const fetchUri = this.createUrl(PromptsUrl, { ...options, projectId });
2222
+ return await this.apiClient(fetchUri);
2223
+ }
2224
+ /** Updates or creates (based on id) a Prompt */
2225
+ async upsert(body) {
2226
+ const fetchUri = this.createUrl(PromptsUrl);
2227
+ await this.apiClient(fetchUri, {
2228
+ method: "PUT",
2229
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2230
+ expectNoContent: true
2231
+ });
2232
+ }
2233
+ /** Deletes a Prompt */
2234
+ async remove(body) {
2235
+ const fetchUri = this.createUrl(PromptsUrl);
2236
+ await this.apiClient(fetchUri, {
2237
+ method: "DELETE",
2238
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2239
+ expectNoContent: true
2240
+ });
2241
+ }
2242
+ };
2243
+
2244
+ // src/RouteClient.ts
2245
+ var import_api9 = require("@uniformdev/context/api");
2195
2246
  var ROUTE_URL = "/api/v1/route";
2196
- var RouteClient = class extends import_api8.ApiClient {
2247
+ var RouteClient = class extends import_api9.ApiClient {
2197
2248
  constructor(options) {
2198
2249
  var _a;
2199
2250
  if (!options.limitPolicy) {
@@ -2309,6 +2360,9 @@ var isComponentPlaceholderId = (id) => {
2309
2360
  if (id === PLACEHOLDER_ID) {
2310
2361
  return true;
2311
2362
  }
2363
+ if (typeof id !== "string") {
2364
+ return false;
2365
+ }
2312
2366
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2313
2367
  };
2314
2368
  var generateComponentPlaceholderId = (randomId, sdkVersion) => {
@@ -2501,8 +2555,8 @@ function handleRichTextNodeBinding(object, options) {
2501
2555
  }
2502
2556
 
2503
2557
  // src/index.ts
2504
- var import_api9 = require("@uniformdev/context/api");
2505
- var CanvasClientError = import_api9.ApiClientError;
2558
+ var import_api10 = require("@uniformdev/context/api");
2559
+ var CanvasClientError = import_api10.ApiClientError;
2506
2560
  // Annotate the CommonJS export names for ESM import in node:
2507
2561
  0 && (module.exports = {
2508
2562
  ATTRIBUTE_COMPONENT_ID,
@@ -2537,11 +2591,8 @@ var CanvasClientError = import_api9.ApiClientError;
2537
2591
  DataTypeClient,
2538
2592
  EDGE_CACHE_DISABLED,
2539
2593
  EDGE_DEFAULT_CACHE_TTL,
2540
- EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
2541
2594
  EDGE_MAX_CACHE_TTL,
2542
- EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
2543
2595
  EDGE_MIN_CACHE_TTL,
2544
- EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
2545
2596
  EMPTY_COMPOSITION,
2546
2597
  EnhancerBuilder,
2547
2598
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
@@ -2552,7 +2603,9 @@ var CanvasClientError = import_api9.ApiClientError;
2552
2603
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
2553
2604
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
2554
2605
  PLACEHOLDER_ID,
2606
+ PromptClient,
2555
2607
  RouteClient,
2608
+ SECRET_QUERY_STRING_PARAM,
2556
2609
  UncachedCanvasClient,
2557
2610
  UncachedCategoryClient,
2558
2611
  UncachedContentClient,
package/dist/index.mjs CHANGED
@@ -478,10 +478,20 @@ var CanvasClient = class extends ApiClient {
478
478
  this.edgeApiHost = (_a = options.edgeApiHost) != null ? _a : "https://uniform.global";
479
479
  }
480
480
  /** Fetches lists of Canvas compositions, optionally by type */
481
- async getCompositionList(options) {
481
+ async getCompositionList(params = {}) {
482
482
  const { projectId } = this.options;
483
- const fetchUri = this.createUrl(CANVAS_URL, { ...options, projectId });
484
- return await this.apiClient(fetchUri);
483
+ const { resolveData, ...originParams } = params;
484
+ if (!resolveData) {
485
+ const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId });
486
+ return this.apiClient(fetchUri);
487
+ }
488
+ const edgeParams = {
489
+ ...originParams,
490
+ projectId,
491
+ ...params.diagnostics ? { diagnostics: "true" } : {}
492
+ };
493
+ const edgeUrl = this.createUrl("/api/v1/compositions", edgeParams, this.edgeApiHost);
494
+ return this.apiClient(edgeUrl);
485
495
  }
486
496
  getCompositionByNodePath(options) {
487
497
  return this.getOneComposition(options);
@@ -499,12 +509,12 @@ var CanvasClient = class extends ApiClient {
499
509
  return this.getOneComposition(options);
500
510
  }
501
511
  /** Fetches historical versions of a composition or pattern */
502
- async unstable_getCompositionHistory(options) {
503
- const edgeUrl = this.createUrl("/api/v1/canvas-history", {
512
+ async getCompositionHistory(options) {
513
+ const historyUrl = this.createUrl("/api/v1/canvas-history", {
504
514
  ...options,
505
515
  projectId: this.options.projectId
506
516
  });
507
- return this.apiClient(edgeUrl);
517
+ return this.apiClient(historyUrl);
508
518
  }
509
519
  getOneComposition({
510
520
  skipDataResolution,
@@ -546,7 +556,7 @@ var CanvasClient = class extends ApiClient {
546
556
  async getComponentDefinitions(options) {
547
557
  const { projectId } = this.options;
548
558
  const fetchUri = this.createUrl("/api/v1/canvas-definitions", { ...options, projectId });
549
- return await this.apiClient(fetchUri);
559
+ return this.apiClient(fetchUri);
550
560
  }
551
561
  /** Updates or creates a Canvas component definition */
552
562
  async updateComponentDefinition(body) {
@@ -699,12 +709,21 @@ var _ContentClient = class _ContentClient extends ApiClient4 {
699
709
  const fetchUri = skipDataResolution ? this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, projectId }) : this.createUrl(__privateGet(_ContentClient, _entriesUrl), this.getEdgeOptions(params), this.edgeApiHost);
700
710
  return this.apiClient(fetchUri);
701
711
  }
702
- async upsertContentType(body) {
712
+ /** Fetches historical versions of an entry */
713
+ async getEntryHistory(options) {
714
+ const historyUrl = this.createUrl("/api/v1/entries-history", {
715
+ ...options,
716
+ projectId: this.options.projectId
717
+ });
718
+ return this.apiClient(historyUrl);
719
+ }
720
+ async upsertContentType(body, opts = {}) {
703
721
  const fetchUri = this.createUrl(__privateGet(_ContentClient, _contentTypesUrl));
704
722
  await this.apiClient(fetchUri, {
705
723
  method: "PUT",
706
724
  body: JSON.stringify({ ...body, projectId: this.options.projectId }),
707
- expectNoContent: true
725
+ expectNoContent: true,
726
+ headers: opts.autogenerateDataTypes ? { "x-uniform-autogenerate-data-types": "true" } : {}
708
727
  });
709
728
  }
710
729
  async upsertEntry(body) {
@@ -963,6 +982,7 @@ var CANVAS_EDITOR_STATE = 63;
963
982
  var CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
964
983
  var CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
965
984
  var CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
985
+ var SECRET_QUERY_STRING_PARAM = "secret";
966
986
  var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
967
987
  var IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM = "is_incontext_editing_playground";
968
988
  var IN_CONTEXT_EDITOR_CONFIG_CHECK_QUERY_STRING_PARAM = "is_config_check";
@@ -976,13 +996,10 @@ var EMPTY_COMPOSITION = {
976
996
  _name: "An empty composition used for contextual editing",
977
997
  type: "_empty_composition_type"
978
998
  };
979
- var EDGE_MIN_CACHE_TTL = 15;
980
- var EDGE_MAX_CACHE_TTL = 600;
999
+ var EDGE_MIN_CACHE_TTL = 10;
1000
+ var EDGE_MAX_CACHE_TTL = 24 * 60 * 60;
981
1001
  var EDGE_DEFAULT_CACHE_TTL = 30;
982
1002
  var EDGE_CACHE_DISABLED = -1;
983
- var EDGE_MIN_L2_CACHE_TTL_IN_HOURS = 1;
984
- var EDGE_MAX_L2_CACHE_TTL_IN_HOURS = 4 * 7 * 24;
985
- var EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS = 24;
986
1003
 
987
1004
  // src/utils/entryConverter.ts
988
1005
  function convertEntryToPutEntry(entry) {
@@ -991,6 +1008,7 @@ function convertEntryToPutEntry(entry) {
991
1008
  type: entry.entry.type,
992
1009
  _dataResources: entry.entry._dataResources,
993
1010
  _id: entry.entry._id,
1011
+ _name: entry.entry._name,
994
1012
  _slug: entry.entry._slug,
995
1013
  fields: entry.entry.fields
996
1014
  },
@@ -1809,7 +1827,7 @@ var createCanvasChannel = ({
1809
1827
  };
1810
1828
  postMessage(message);
1811
1829
  };
1812
- const ready = () => {
1830
+ const ready = (options) => {
1813
1831
  var _a, _b;
1814
1832
  if (typeof window === "undefined") {
1815
1833
  return;
@@ -1819,7 +1837,8 @@ var createCanvasChannel = ({
1819
1837
  const message = {
1820
1838
  type: "ready",
1821
1839
  framework,
1822
- version
1840
+ version,
1841
+ rsc: options == null ? void 0 : options.rsc
1823
1842
  };
1824
1843
  postMessage(message);
1825
1844
  };
@@ -2077,10 +2096,43 @@ function subscribeToComposition({
2077
2096
  };
2078
2097
  }
2079
2098
 
2080
- // src/RouteClient.ts
2099
+ // src/PromptClient.ts
2081
2100
  import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
2101
+ var PromptsUrl = "/api/v1/prompts";
2102
+ var PromptClient = class extends ApiClient7 {
2103
+ constructor(options) {
2104
+ super(options);
2105
+ }
2106
+ /** Fetches Prompts for a project */
2107
+ async get(options) {
2108
+ const { projectId } = this.options;
2109
+ const fetchUri = this.createUrl(PromptsUrl, { ...options, projectId });
2110
+ return await this.apiClient(fetchUri);
2111
+ }
2112
+ /** Updates or creates (based on id) a Prompt */
2113
+ async upsert(body) {
2114
+ const fetchUri = this.createUrl(PromptsUrl);
2115
+ await this.apiClient(fetchUri, {
2116
+ method: "PUT",
2117
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2118
+ expectNoContent: true
2119
+ });
2120
+ }
2121
+ /** Deletes a Prompt */
2122
+ async remove(body) {
2123
+ const fetchUri = this.createUrl(PromptsUrl);
2124
+ await this.apiClient(fetchUri, {
2125
+ method: "DELETE",
2126
+ body: JSON.stringify({ ...body, projectId: this.options.projectId }),
2127
+ expectNoContent: true
2128
+ });
2129
+ }
2130
+ };
2131
+
2132
+ // src/RouteClient.ts
2133
+ import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2082
2134
  var ROUTE_URL = "/api/v1/route";
2083
- var RouteClient = class extends ApiClient7 {
2135
+ var RouteClient = class extends ApiClient8 {
2084
2136
  constructor(options) {
2085
2137
  var _a;
2086
2138
  if (!options.limitPolicy) {
@@ -2196,6 +2248,9 @@ var isComponentPlaceholderId = (id) => {
2196
2248
  if (id === PLACEHOLDER_ID) {
2197
2249
  return true;
2198
2250
  }
2251
+ if (typeof id !== "string") {
2252
+ return false;
2253
+ }
2199
2254
  return id == null ? void 0 : id.startsWith(PLACEHOLDER_ID);
2200
2255
  };
2201
2256
  var generateComponentPlaceholderId = (randomId, sdkVersion) => {
@@ -2423,11 +2478,8 @@ export {
2423
2478
  DataTypeClient,
2424
2479
  EDGE_CACHE_DISABLED,
2425
2480
  EDGE_DEFAULT_CACHE_TTL,
2426
- EDGE_DEFAULT_L2_CACHE_TTL_IN_HOURS,
2427
2481
  EDGE_MAX_CACHE_TTL,
2428
- EDGE_MAX_L2_CACHE_TTL_IN_HOURS,
2429
2482
  EDGE_MIN_CACHE_TTL,
2430
- EDGE_MIN_L2_CACHE_TTL_IN_HOURS,
2431
2483
  EMPTY_COMPOSITION,
2432
2484
  EnhancerBuilder,
2433
2485
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
@@ -2438,7 +2490,9 @@ export {
2438
2490
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
2439
2491
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
2440
2492
  PLACEHOLDER_ID,
2493
+ PromptClient,
2441
2494
  RouteClient,
2495
+ SECRET_QUERY_STRING_PARAM,
2442
2496
  UncachedCanvasClient,
2443
2497
  UncachedCategoryClient,
2444
2498
  UncachedContentClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "19.61.1-alpha.10+8aa257167",
3
+ "version": "19.61.1-alpha.18+f26189658",
4
4
  "description": "Common functionality and types for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -38,7 +38,8 @@
38
38
  "pusher-js": "8.2.0"
39
39
  },
40
40
  "dependencies": {
41
- "@uniformdev/context": "19.61.1-alpha.10+8aa257167",
41
+ "@uniformdev/assets": "19.61.1-alpha.18+f26189658",
42
+ "@uniformdev/context": "19.61.1-alpha.18+f26189658",
42
43
  "immer": "9.0.21"
43
44
  },
44
45
  "files": [
@@ -47,5 +48,5 @@
47
48
  "publishConfig": {
48
49
  "access": "public"
49
50
  },
50
- "gitHead": "8aa2571675505a90ba544863f87621dd90750c3a"
51
+ "gitHead": "f2618965881c30f1e995f45a6e880bc2f4d10ebe"
51
52
  }