@uniformdev/canvas 20.51.0 → 20.51.1-alpha.14

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
@@ -380,7 +380,7 @@ var require_retry2 = __commonJS({
380
380
  });
381
381
 
382
382
  // src/CanvasClient.ts
383
- import { ApiClient } from "@uniformdev/context/api";
383
+ import { ApiClient, rewriteFiltersForApi } from "@uniformdev/context/api";
384
384
 
385
385
  // src/enhancement/createLimitPolicy.ts
386
386
  var import_p_limit = __toESM(require_p_limit());
@@ -584,22 +584,6 @@ function createLimitPolicy({
584
584
  }
585
585
  var nullLimitPolicy = async (func) => await func();
586
586
 
587
- // src/utils/rewriteFilters.ts
588
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
589
- function rewriteFilters(filters) {
590
- return Object.entries(filters != null ? filters : {}).reduce(
591
- (acc, [key, value]) => {
592
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
593
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
594
- return {
595
- ...acc,
596
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
597
- };
598
- },
599
- {}
600
- );
601
- }
602
-
603
587
  // src/CanvasClient.ts
604
588
  var CANVAS_URL = "/api/v1/canvas";
605
589
  var CanvasClient = class extends ApiClient {
@@ -616,7 +600,7 @@ var CanvasClient = class extends ApiClient {
616
600
  async getCompositionList(params = {}) {
617
601
  const { projectId } = this.options;
618
602
  const { resolveData, filters, ...originParams } = params;
619
- const rewrittenFilters = rewriteFilters(filters);
603
+ const rewrittenFilters = rewriteFiltersForApi(filters);
620
604
  if (!resolveData) {
621
605
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
622
606
  return this.apiClient(fetchUri);
@@ -770,7 +754,7 @@ var UncachedCategoryClient = class extends CategoryClient {
770
754
  };
771
755
 
772
756
  // src/ContentClient.ts
773
- import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
757
+ import { ApiClient as ApiClient3, rewriteFiltersForApi as rewriteFiltersForApi2 } from "@uniformdev/context/api";
774
758
  var _contentTypesUrl, _entriesUrl;
775
759
  var _ContentClient = class _ContentClient extends ApiClient3 {
776
760
  constructor(options) {
@@ -786,7 +770,7 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
786
770
  getEntries(options) {
787
771
  const { projectId } = this.options;
788
772
  const { skipDataResolution, filters, ...params } = options;
789
- const rewrittenFilters = rewriteFilters(filters);
773
+ const rewrittenFilters = rewriteFiltersForApi2(filters);
790
774
  if (skipDataResolution) {
791
775
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
792
776
  return this.apiClient(url);
@@ -2627,10 +2611,47 @@ _baseUrl = new WeakMap();
2627
2611
  __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2628
2612
  var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
2629
2613
 
2630
- // src/LocaleClient.ts
2614
+ // src/LabelClient.ts
2631
2615
  import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2616
+ var LABELS_URL = "/api/v1/labels";
2617
+ var LabelClient = class extends ApiClient8 {
2618
+ /** Fetches labels for the current project. */
2619
+ async getLabels(options) {
2620
+ const { projectId } = this.options;
2621
+ const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
2622
+ return await this.apiClient(fetchUri);
2623
+ }
2624
+ /** Updates or creates a label. */
2625
+ async upsertLabel(body) {
2626
+ const { projectId } = this.options;
2627
+ const fetchUri = this.createUrl(LABELS_URL);
2628
+ await this.apiClient(fetchUri, {
2629
+ method: "PUT",
2630
+ body: JSON.stringify({ ...body, projectId }),
2631
+ expectNoContent: true
2632
+ });
2633
+ }
2634
+ /** Deletes a label by id. */
2635
+ async removeLabel(options) {
2636
+ const { projectId } = this.options;
2637
+ const fetchUri = this.createUrl(LABELS_URL);
2638
+ await this.apiClient(fetchUri, {
2639
+ method: "DELETE",
2640
+ body: JSON.stringify({ ...options, projectId }),
2641
+ expectNoContent: true
2642
+ });
2643
+ }
2644
+ };
2645
+ var UncachedLabelClient = class extends LabelClient {
2646
+ constructor(options) {
2647
+ super({ ...options, bypassCache: true });
2648
+ }
2649
+ };
2650
+
2651
+ // src/LocaleClient.ts
2652
+ import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2632
2653
  var localesUrl = "/api/v1/locales";
2633
- var LocaleClient = class extends ApiClient8 {
2654
+ var LocaleClient = class extends ApiClient9 {
2634
2655
  constructor(options) {
2635
2656
  super(options);
2636
2657
  }
@@ -3016,10 +3037,10 @@ var createCanvasChannel = ({
3016
3037
  };
3017
3038
 
3018
3039
  // src/PreviewClient.ts
3019
- import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
3040
+ import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3020
3041
  var previewUrlsUrl = "/api/v1/preview-urls";
3021
3042
  var previewViewportsUrl = "/api/v1/preview-viewports";
3022
- var PreviewClient = class extends ApiClient9 {
3043
+ var PreviewClient = class extends ApiClient10 {
3023
3044
  constructor(options) {
3024
3045
  super(options);
3025
3046
  }
@@ -3082,9 +3103,9 @@ var PreviewClient = class extends ApiClient9 {
3082
3103
  };
3083
3104
 
3084
3105
  // src/ProjectClient.ts
3085
- import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3106
+ import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3086
3107
  var _url2, _projectsUrl;
3087
- var _ProjectClient = class _ProjectClient extends ApiClient10 {
3108
+ var _ProjectClient = class _ProjectClient extends ApiClient11 {
3088
3109
  constructor(options) {
3089
3110
  super({ ...options, bypassCache: true });
3090
3111
  }
@@ -3127,9 +3148,9 @@ __privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
3127
3148
  var ProjectClient = _ProjectClient;
3128
3149
 
3129
3150
  // src/PromptClient.ts
3130
- import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3151
+ import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3131
3152
  var PromptsUrl = "/api/v1/prompts";
3132
- var PromptClient = class extends ApiClient11 {
3153
+ var PromptClient = class extends ApiClient12 {
3133
3154
  constructor(options) {
3134
3155
  super(options);
3135
3156
  }
@@ -3160,9 +3181,9 @@ var PromptClient = class extends ApiClient11 {
3160
3181
  };
3161
3182
 
3162
3183
  // src/RelationshipClient.ts
3163
- import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3184
+ import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3164
3185
  var RELATIONSHIPS_URL = "/api/v1/relationships";
3165
- var RelationshipClient = class extends ApiClient12 {
3186
+ var RelationshipClient = class extends ApiClient13 {
3166
3187
  constructor(options) {
3167
3188
  super(options);
3168
3189
  this.get = async (options) => {
@@ -3174,9 +3195,9 @@ var RelationshipClient = class extends ApiClient12 {
3174
3195
  };
3175
3196
 
3176
3197
  // src/ReleaseClient.ts
3177
- import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3198
+ import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3178
3199
  var releasesUrl = "/api/v1/releases";
3179
- var ReleaseClient = class extends ApiClient13 {
3200
+ var ReleaseClient = class extends ApiClient14 {
3180
3201
  constructor(options) {
3181
3202
  super(options);
3182
3203
  }
@@ -3216,9 +3237,9 @@ var ReleaseClient = class extends ApiClient13 {
3216
3237
  };
3217
3238
 
3218
3239
  // src/ReleaseContentsClient.ts
3219
- import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3240
+ import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3220
3241
  var releaseContentsUrl2 = "/api/v1/release-contents";
3221
- var ReleaseContentsClient = class extends ApiClient14 {
3242
+ var ReleaseContentsClient = class extends ApiClient15 {
3222
3243
  constructor(options) {
3223
3244
  super(options);
3224
3245
  }
@@ -3240,9 +3261,9 @@ var ReleaseContentsClient = class extends ApiClient14 {
3240
3261
  };
3241
3262
 
3242
3263
  // src/RouteClient.ts
3243
- import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3264
+ import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3244
3265
  var ROUTE_URL = "/api/v1/route";
3245
- var RouteClient = class extends ApiClient15 {
3266
+ var RouteClient = class extends ApiClient16 {
3246
3267
  constructor(options) {
3247
3268
  var _a;
3248
3269
  if (!options.limitPolicy) {
@@ -3620,9 +3641,9 @@ import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3620
3641
  var version = "20.51.0";
3621
3642
 
3622
3643
  // src/WorkflowClient.ts
3623
- import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3644
+ import { ApiClient as ApiClient17 } from "@uniformdev/context/api";
3624
3645
  var workflowsUrl = "/api/v1/workflows";
3625
- var WorkflowClient = class extends ApiClient16 {
3646
+ var WorkflowClient = class extends ApiClient17 {
3626
3647
  constructor(options) {
3627
3648
  super(options);
3628
3649
  }
@@ -3726,6 +3747,7 @@ export {
3726
3747
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
3727
3748
  IntegrationPropertyEditorsClient,
3728
3749
  LOCALE_DYNAMIC_INPUT_NAME,
3750
+ LabelClient,
3729
3751
  LocaleClient,
3730
3752
  PLACEHOLDER_ID,
3731
3753
  PreviewClient,
@@ -3739,6 +3761,7 @@ export {
3739
3761
  UncachedCanvasClient,
3740
3762
  UncachedCategoryClient,
3741
3763
  UncachedContentClient,
3764
+ UncachedLabelClient,
3742
3765
  UniqueBatchEntries,
3743
3766
  WorkflowClient,
3744
3767
  autoFixParameterGroups,
package/dist/index.js CHANGED
@@ -397,7 +397,7 @@ __export(src_exports, {
397
397
  ATTRIBUTE_PARAMETER_TYPE: () => ATTRIBUTE_PARAMETER_TYPE,
398
398
  ATTRIBUTE_PARAMETER_VALUE: () => ATTRIBUTE_PARAMETER_VALUE,
399
399
  ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
400
- ApiClientError: () => import_api18.ApiClientError,
400
+ ApiClientError: () => import_api19.ApiClientError,
401
401
  BatchEntry: () => BatchEntry,
402
402
  BlockFormatError: () => BlockFormatError,
403
403
  CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
@@ -459,6 +459,7 @@ __export(src_exports, {
459
459
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE: () => IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
460
460
  IntegrationPropertyEditorsClient: () => IntegrationPropertyEditorsClient,
461
461
  LOCALE_DYNAMIC_INPUT_NAME: () => LOCALE_DYNAMIC_INPUT_NAME,
462
+ LabelClient: () => LabelClient,
462
463
  LocaleClient: () => LocaleClient,
463
464
  PLACEHOLDER_ID: () => PLACEHOLDER_ID,
464
465
  PreviewClient: () => PreviewClient,
@@ -472,6 +473,7 @@ __export(src_exports, {
472
473
  UncachedCanvasClient: () => UncachedCanvasClient,
473
474
  UncachedCategoryClient: () => UncachedCategoryClient,
474
475
  UncachedContentClient: () => UncachedContentClient,
476
+ UncachedLabelClient: () => UncachedLabelClient,
475
477
  UniqueBatchEntries: () => UniqueBatchEntries,
476
478
  WorkflowClient: () => WorkflowClient,
477
479
  autoFixParameterGroups: () => autoFixParameterGroups,
@@ -762,22 +764,6 @@ function createLimitPolicy({
762
764
  }
763
765
  var nullLimitPolicy = async (func) => await func();
764
766
 
765
- // src/utils/rewriteFilters.ts
766
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
767
- function rewriteFilters(filters) {
768
- return Object.entries(filters != null ? filters : {}).reduce(
769
- (acc, [key, value]) => {
770
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
771
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
772
- return {
773
- ...acc,
774
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
775
- };
776
- },
777
- {}
778
- );
779
- }
780
-
781
767
  // src/CanvasClient.ts
782
768
  var CANVAS_URL = "/api/v1/canvas";
783
769
  var CanvasClient = class extends import_api2.ApiClient {
@@ -794,7 +780,7 @@ var CanvasClient = class extends import_api2.ApiClient {
794
780
  async getCompositionList(params = {}) {
795
781
  const { projectId } = this.options;
796
782
  const { resolveData, filters, ...originParams } = params;
797
- const rewrittenFilters = rewriteFilters(filters);
783
+ const rewrittenFilters = (0, import_api2.rewriteFiltersForApi)(filters);
798
784
  if (!resolveData) {
799
785
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
800
786
  return this.apiClient(fetchUri);
@@ -964,7 +950,7 @@ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
964
950
  getEntries(options) {
965
951
  const { projectId } = this.options;
966
952
  const { skipDataResolution, filters, ...params } = options;
967
- const rewrittenFilters = rewriteFilters(filters);
953
+ const rewrittenFilters = (0, import_api4.rewriteFiltersForApi)(filters);
968
954
  if (skipDataResolution) {
969
955
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
970
956
  return this.apiClient(url);
@@ -2805,10 +2791,47 @@ _baseUrl = new WeakMap();
2805
2791
  __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2806
2792
  var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
2807
2793
 
2808
- // src/LocaleClient.ts
2794
+ // src/LabelClient.ts
2809
2795
  var import_api9 = require("@uniformdev/context/api");
2796
+ var LABELS_URL = "/api/v1/labels";
2797
+ var LabelClient = class extends import_api9.ApiClient {
2798
+ /** Fetches labels for the current project. */
2799
+ async getLabels(options) {
2800
+ const { projectId } = this.options;
2801
+ const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
2802
+ return await this.apiClient(fetchUri);
2803
+ }
2804
+ /** Updates or creates a label. */
2805
+ async upsertLabel(body) {
2806
+ const { projectId } = this.options;
2807
+ const fetchUri = this.createUrl(LABELS_URL);
2808
+ await this.apiClient(fetchUri, {
2809
+ method: "PUT",
2810
+ body: JSON.stringify({ ...body, projectId }),
2811
+ expectNoContent: true
2812
+ });
2813
+ }
2814
+ /** Deletes a label by id. */
2815
+ async removeLabel(options) {
2816
+ const { projectId } = this.options;
2817
+ const fetchUri = this.createUrl(LABELS_URL);
2818
+ await this.apiClient(fetchUri, {
2819
+ method: "DELETE",
2820
+ body: JSON.stringify({ ...options, projectId }),
2821
+ expectNoContent: true
2822
+ });
2823
+ }
2824
+ };
2825
+ var UncachedLabelClient = class extends LabelClient {
2826
+ constructor(options) {
2827
+ super({ ...options, bypassCache: true });
2828
+ }
2829
+ };
2830
+
2831
+ // src/LocaleClient.ts
2832
+ var import_api10 = require("@uniformdev/context/api");
2810
2833
  var localesUrl = "/api/v1/locales";
2811
- var LocaleClient = class extends import_api9.ApiClient {
2834
+ var LocaleClient = class extends import_api10.ApiClient {
2812
2835
  constructor(options) {
2813
2836
  super(options);
2814
2837
  }
@@ -3194,10 +3217,10 @@ var createCanvasChannel = ({
3194
3217
  };
3195
3218
 
3196
3219
  // src/PreviewClient.ts
3197
- var import_api10 = require("@uniformdev/context/api");
3220
+ var import_api11 = require("@uniformdev/context/api");
3198
3221
  var previewUrlsUrl = "/api/v1/preview-urls";
3199
3222
  var previewViewportsUrl = "/api/v1/preview-viewports";
3200
- var PreviewClient = class extends import_api10.ApiClient {
3223
+ var PreviewClient = class extends import_api11.ApiClient {
3201
3224
  constructor(options) {
3202
3225
  super(options);
3203
3226
  }
@@ -3260,9 +3283,9 @@ var PreviewClient = class extends import_api10.ApiClient {
3260
3283
  };
3261
3284
 
3262
3285
  // src/ProjectClient.ts
3263
- var import_api11 = require("@uniformdev/context/api");
3286
+ var import_api12 = require("@uniformdev/context/api");
3264
3287
  var _url2, _projectsUrl;
3265
- var _ProjectClient = class _ProjectClient extends import_api11.ApiClient {
3288
+ var _ProjectClient = class _ProjectClient extends import_api12.ApiClient {
3266
3289
  constructor(options) {
3267
3290
  super({ ...options, bypassCache: true });
3268
3291
  }
@@ -3305,9 +3328,9 @@ __privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
3305
3328
  var ProjectClient = _ProjectClient;
3306
3329
 
3307
3330
  // src/PromptClient.ts
3308
- var import_api12 = require("@uniformdev/context/api");
3331
+ var import_api13 = require("@uniformdev/context/api");
3309
3332
  var PromptsUrl = "/api/v1/prompts";
3310
- var PromptClient = class extends import_api12.ApiClient {
3333
+ var PromptClient = class extends import_api13.ApiClient {
3311
3334
  constructor(options) {
3312
3335
  super(options);
3313
3336
  }
@@ -3338,9 +3361,9 @@ var PromptClient = class extends import_api12.ApiClient {
3338
3361
  };
3339
3362
 
3340
3363
  // src/RelationshipClient.ts
3341
- var import_api13 = require("@uniformdev/context/api");
3364
+ var import_api14 = require("@uniformdev/context/api");
3342
3365
  var RELATIONSHIPS_URL = "/api/v1/relationships";
3343
- var RelationshipClient = class extends import_api13.ApiClient {
3366
+ var RelationshipClient = class extends import_api14.ApiClient {
3344
3367
  constructor(options) {
3345
3368
  super(options);
3346
3369
  this.get = async (options) => {
@@ -3352,9 +3375,9 @@ var RelationshipClient = class extends import_api13.ApiClient {
3352
3375
  };
3353
3376
 
3354
3377
  // src/ReleaseClient.ts
3355
- var import_api14 = require("@uniformdev/context/api");
3378
+ var import_api15 = require("@uniformdev/context/api");
3356
3379
  var releasesUrl = "/api/v1/releases";
3357
- var ReleaseClient = class extends import_api14.ApiClient {
3380
+ var ReleaseClient = class extends import_api15.ApiClient {
3358
3381
  constructor(options) {
3359
3382
  super(options);
3360
3383
  }
@@ -3394,9 +3417,9 @@ var ReleaseClient = class extends import_api14.ApiClient {
3394
3417
  };
3395
3418
 
3396
3419
  // src/ReleaseContentsClient.ts
3397
- var import_api15 = require("@uniformdev/context/api");
3420
+ var import_api16 = require("@uniformdev/context/api");
3398
3421
  var releaseContentsUrl2 = "/api/v1/release-contents";
3399
- var ReleaseContentsClient = class extends import_api15.ApiClient {
3422
+ var ReleaseContentsClient = class extends import_api16.ApiClient {
3400
3423
  constructor(options) {
3401
3424
  super(options);
3402
3425
  }
@@ -3418,9 +3441,9 @@ var ReleaseContentsClient = class extends import_api15.ApiClient {
3418
3441
  };
3419
3442
 
3420
3443
  // src/RouteClient.ts
3421
- var import_api16 = require("@uniformdev/context/api");
3444
+ var import_api17 = require("@uniformdev/context/api");
3422
3445
  var ROUTE_URL = "/api/v1/route";
3423
- var RouteClient = class extends import_api16.ApiClient {
3446
+ var RouteClient = class extends import_api17.ApiClient {
3424
3447
  constructor(options) {
3425
3448
  var _a;
3426
3449
  if (!options.limitPolicy) {
@@ -3792,15 +3815,15 @@ function handleRichTextNodeBinding(object, options) {
3792
3815
  }
3793
3816
 
3794
3817
  // src/index.ts
3795
- var import_api18 = require("@uniformdev/context/api");
3818
+ var import_api19 = require("@uniformdev/context/api");
3796
3819
 
3797
3820
  // src/.version.ts
3798
3821
  var version = "20.51.0";
3799
3822
 
3800
3823
  // src/WorkflowClient.ts
3801
- var import_api17 = require("@uniformdev/context/api");
3824
+ var import_api18 = require("@uniformdev/context/api");
3802
3825
  var workflowsUrl = "/api/v1/workflows";
3803
- var WorkflowClient = class extends import_api17.ApiClient {
3826
+ var WorkflowClient = class extends import_api18.ApiClient {
3804
3827
  constructor(options) {
3805
3828
  super(options);
3806
3829
  }
@@ -3831,7 +3854,7 @@ var WorkflowClient = class extends import_api17.ApiClient {
3831
3854
  };
3832
3855
 
3833
3856
  // src/index.ts
3834
- var CanvasClientError = import_api18.ApiClientError;
3857
+ var CanvasClientError = import_api19.ApiClientError;
3835
3858
  // Annotate the CommonJS export names for ESM import in node:
3836
3859
  0 && (module.exports = {
3837
3860
  ASSETS_SOURCE_CUSTOM_URL,
@@ -3905,6 +3928,7 @@ var CanvasClientError = import_api18.ApiClientError;
3905
3928
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
3906
3929
  IntegrationPropertyEditorsClient,
3907
3930
  LOCALE_DYNAMIC_INPUT_NAME,
3931
+ LabelClient,
3908
3932
  LocaleClient,
3909
3933
  PLACEHOLDER_ID,
3910
3934
  PreviewClient,
@@ -3918,6 +3942,7 @@ var CanvasClientError = import_api18.ApiClientError;
3918
3942
  UncachedCanvasClient,
3919
3943
  UncachedCategoryClient,
3920
3944
  UncachedContentClient,
3945
+ UncachedLabelClient,
3921
3946
  UniqueBatchEntries,
3922
3947
  WorkflowClient,
3923
3948
  autoFixParameterGroups,
package/dist/index.mjs CHANGED
@@ -380,7 +380,7 @@ var require_retry2 = __commonJS({
380
380
  });
381
381
 
382
382
  // src/CanvasClient.ts
383
- import { ApiClient } from "@uniformdev/context/api";
383
+ import { ApiClient, rewriteFiltersForApi } from "@uniformdev/context/api";
384
384
 
385
385
  // src/enhancement/createLimitPolicy.ts
386
386
  var import_p_limit = __toESM(require_p_limit());
@@ -584,22 +584,6 @@ function createLimitPolicy({
584
584
  }
585
585
  var nullLimitPolicy = async (func) => await func();
586
586
 
587
- // src/utils/rewriteFilters.ts
588
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
589
- function rewriteFilters(filters) {
590
- return Object.entries(filters != null ? filters : {}).reduce(
591
- (acc, [key, value]) => {
592
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
593
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
594
- return {
595
- ...acc,
596
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
597
- };
598
- },
599
- {}
600
- );
601
- }
602
-
603
587
  // src/CanvasClient.ts
604
588
  var CANVAS_URL = "/api/v1/canvas";
605
589
  var CanvasClient = class extends ApiClient {
@@ -616,7 +600,7 @@ var CanvasClient = class extends ApiClient {
616
600
  async getCompositionList(params = {}) {
617
601
  const { projectId } = this.options;
618
602
  const { resolveData, filters, ...originParams } = params;
619
- const rewrittenFilters = rewriteFilters(filters);
603
+ const rewrittenFilters = rewriteFiltersForApi(filters);
620
604
  if (!resolveData) {
621
605
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
622
606
  return this.apiClient(fetchUri);
@@ -770,7 +754,7 @@ var UncachedCategoryClient = class extends CategoryClient {
770
754
  };
771
755
 
772
756
  // src/ContentClient.ts
773
- import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
757
+ import { ApiClient as ApiClient3, rewriteFiltersForApi as rewriteFiltersForApi2 } from "@uniformdev/context/api";
774
758
  var _contentTypesUrl, _entriesUrl;
775
759
  var _ContentClient = class _ContentClient extends ApiClient3 {
776
760
  constructor(options) {
@@ -786,7 +770,7 @@ var _ContentClient = class _ContentClient extends ApiClient3 {
786
770
  getEntries(options) {
787
771
  const { projectId } = this.options;
788
772
  const { skipDataResolution, filters, ...params } = options;
789
- const rewrittenFilters = rewriteFilters(filters);
773
+ const rewrittenFilters = rewriteFiltersForApi2(filters);
790
774
  if (skipDataResolution) {
791
775
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
792
776
  return this.apiClient(url);
@@ -2627,10 +2611,47 @@ _baseUrl = new WeakMap();
2627
2611
  __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2628
2612
  var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
2629
2613
 
2630
- // src/LocaleClient.ts
2614
+ // src/LabelClient.ts
2631
2615
  import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
2616
+ var LABELS_URL = "/api/v1/labels";
2617
+ var LabelClient = class extends ApiClient8 {
2618
+ /** Fetches labels for the current project. */
2619
+ async getLabels(options) {
2620
+ const { projectId } = this.options;
2621
+ const fetchUri = this.createUrl(LABELS_URL, { ...options, projectId });
2622
+ return await this.apiClient(fetchUri);
2623
+ }
2624
+ /** Updates or creates a label. */
2625
+ async upsertLabel(body) {
2626
+ const { projectId } = this.options;
2627
+ const fetchUri = this.createUrl(LABELS_URL);
2628
+ await this.apiClient(fetchUri, {
2629
+ method: "PUT",
2630
+ body: JSON.stringify({ ...body, projectId }),
2631
+ expectNoContent: true
2632
+ });
2633
+ }
2634
+ /** Deletes a label by id. */
2635
+ async removeLabel(options) {
2636
+ const { projectId } = this.options;
2637
+ const fetchUri = this.createUrl(LABELS_URL);
2638
+ await this.apiClient(fetchUri, {
2639
+ method: "DELETE",
2640
+ body: JSON.stringify({ ...options, projectId }),
2641
+ expectNoContent: true
2642
+ });
2643
+ }
2644
+ };
2645
+ var UncachedLabelClient = class extends LabelClient {
2646
+ constructor(options) {
2647
+ super({ ...options, bypassCache: true });
2648
+ }
2649
+ };
2650
+
2651
+ // src/LocaleClient.ts
2652
+ import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
2632
2653
  var localesUrl = "/api/v1/locales";
2633
- var LocaleClient = class extends ApiClient8 {
2654
+ var LocaleClient = class extends ApiClient9 {
2634
2655
  constructor(options) {
2635
2656
  super(options);
2636
2657
  }
@@ -3016,10 +3037,10 @@ var createCanvasChannel = ({
3016
3037
  };
3017
3038
 
3018
3039
  // src/PreviewClient.ts
3019
- import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
3040
+ import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3020
3041
  var previewUrlsUrl = "/api/v1/preview-urls";
3021
3042
  var previewViewportsUrl = "/api/v1/preview-viewports";
3022
- var PreviewClient = class extends ApiClient9 {
3043
+ var PreviewClient = class extends ApiClient10 {
3023
3044
  constructor(options) {
3024
3045
  super(options);
3025
3046
  }
@@ -3082,9 +3103,9 @@ var PreviewClient = class extends ApiClient9 {
3082
3103
  };
3083
3104
 
3084
3105
  // src/ProjectClient.ts
3085
- import { ApiClient as ApiClient10 } from "@uniformdev/context/api";
3106
+ import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3086
3107
  var _url2, _projectsUrl;
3087
- var _ProjectClient = class _ProjectClient extends ApiClient10 {
3108
+ var _ProjectClient = class _ProjectClient extends ApiClient11 {
3088
3109
  constructor(options) {
3089
3110
  super({ ...options, bypassCache: true });
3090
3111
  }
@@ -3127,9 +3148,9 @@ __privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
3127
3148
  var ProjectClient = _ProjectClient;
3128
3149
 
3129
3150
  // src/PromptClient.ts
3130
- import { ApiClient as ApiClient11 } from "@uniformdev/context/api";
3151
+ import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3131
3152
  var PromptsUrl = "/api/v1/prompts";
3132
- var PromptClient = class extends ApiClient11 {
3153
+ var PromptClient = class extends ApiClient12 {
3133
3154
  constructor(options) {
3134
3155
  super(options);
3135
3156
  }
@@ -3160,9 +3181,9 @@ var PromptClient = class extends ApiClient11 {
3160
3181
  };
3161
3182
 
3162
3183
  // src/RelationshipClient.ts
3163
- import { ApiClient as ApiClient12 } from "@uniformdev/context/api";
3184
+ import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3164
3185
  var RELATIONSHIPS_URL = "/api/v1/relationships";
3165
- var RelationshipClient = class extends ApiClient12 {
3186
+ var RelationshipClient = class extends ApiClient13 {
3166
3187
  constructor(options) {
3167
3188
  super(options);
3168
3189
  this.get = async (options) => {
@@ -3174,9 +3195,9 @@ var RelationshipClient = class extends ApiClient12 {
3174
3195
  };
3175
3196
 
3176
3197
  // src/ReleaseClient.ts
3177
- import { ApiClient as ApiClient13 } from "@uniformdev/context/api";
3198
+ import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3178
3199
  var releasesUrl = "/api/v1/releases";
3179
- var ReleaseClient = class extends ApiClient13 {
3200
+ var ReleaseClient = class extends ApiClient14 {
3180
3201
  constructor(options) {
3181
3202
  super(options);
3182
3203
  }
@@ -3216,9 +3237,9 @@ var ReleaseClient = class extends ApiClient13 {
3216
3237
  };
3217
3238
 
3218
3239
  // src/ReleaseContentsClient.ts
3219
- import { ApiClient as ApiClient14 } from "@uniformdev/context/api";
3240
+ import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3220
3241
  var releaseContentsUrl2 = "/api/v1/release-contents";
3221
- var ReleaseContentsClient = class extends ApiClient14 {
3242
+ var ReleaseContentsClient = class extends ApiClient15 {
3222
3243
  constructor(options) {
3223
3244
  super(options);
3224
3245
  }
@@ -3240,9 +3261,9 @@ var ReleaseContentsClient = class extends ApiClient14 {
3240
3261
  };
3241
3262
 
3242
3263
  // src/RouteClient.ts
3243
- import { ApiClient as ApiClient15 } from "@uniformdev/context/api";
3264
+ import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3244
3265
  var ROUTE_URL = "/api/v1/route";
3245
- var RouteClient = class extends ApiClient15 {
3266
+ var RouteClient = class extends ApiClient16 {
3246
3267
  constructor(options) {
3247
3268
  var _a;
3248
3269
  if (!options.limitPolicy) {
@@ -3620,9 +3641,9 @@ import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3620
3641
  var version = "20.51.0";
3621
3642
 
3622
3643
  // src/WorkflowClient.ts
3623
- import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
3644
+ import { ApiClient as ApiClient17 } from "@uniformdev/context/api";
3624
3645
  var workflowsUrl = "/api/v1/workflows";
3625
- var WorkflowClient = class extends ApiClient16 {
3646
+ var WorkflowClient = class extends ApiClient17 {
3626
3647
  constructor(options) {
3627
3648
  super(options);
3628
3649
  }
@@ -3726,6 +3747,7 @@ export {
3726
3747
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
3727
3748
  IntegrationPropertyEditorsClient,
3728
3749
  LOCALE_DYNAMIC_INPUT_NAME,
3750
+ LabelClient,
3729
3751
  LocaleClient,
3730
3752
  PLACEHOLDER_ID,
3731
3753
  PreviewClient,
@@ -3739,6 +3761,7 @@ export {
3739
3761
  UncachedCanvasClient,
3740
3762
  UncachedCategoryClient,
3741
3763
  UncachedContentClient,
3764
+ UncachedLabelClient,
3742
3765
  UniqueBatchEntries,
3743
3766
  WorkflowClient,
3744
3767
  autoFixParameterGroups,