@uniformdev/canvas 20.47.2-alpha.4 → 20.48.1-alpha.11

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.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);
@@ -1398,13 +1384,19 @@ function parseVariableExpression(serialized, onToken) {
1398
1384
  bufferEndIndex = index + 1;
1399
1385
  continue;
1400
1386
  }
1401
- state = "variable";
1402
- if (bufferEndIndex > bufferStartIndex) {
1387
+ if (state === "variable") {
1388
+ const textStart = bufferStartIndex - variablePrefix.length;
1389
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1390
+ return tokenCount;
1391
+ }
1392
+ bufferStartIndex = bufferEndIndex;
1393
+ } else if (bufferEndIndex > bufferStartIndex) {
1403
1394
  if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1404
1395
  return tokenCount;
1405
1396
  }
1406
1397
  bufferStartIndex = bufferEndIndex;
1407
1398
  }
1399
+ state = "variable";
1408
1400
  index += variablePrefix.length - 1;
1409
1401
  bufferStartIndex += variablePrefix.length;
1410
1402
  continue;
@@ -1426,11 +1418,11 @@ function parseVariableExpression(serialized, onToken) {
1426
1418
  }
1427
1419
  bufferEndIndex++;
1428
1420
  }
1429
- if (bufferEndIndex > bufferStartIndex) {
1430
- if (state === "variable") {
1431
- state = "text";
1432
- bufferStartIndex -= variablePrefix.length;
1433
- }
1421
+ if (state === "variable") {
1422
+ state = "text";
1423
+ bufferStartIndex -= variablePrefix.length;
1424
+ }
1425
+ if (bufferStartIndex < serialized.length) {
1434
1426
  handleToken(serialized.substring(bufferStartIndex), state);
1435
1427
  }
1436
1428
  return tokenCount;
@@ -2413,11 +2405,34 @@ var stringOperatorEvaluators = {
2413
2405
  endswith: endsWithEvaluator,
2414
2406
  empty: emptyEvaluator
2415
2407
  };
2408
+ var numericOperatorEvaluators = {
2409
+ gt: (left, right) => left > right,
2410
+ lt: (left, right) => left < right
2411
+ };
2412
+ function evaluateNumericOperator(criteria, matchValue) {
2413
+ const { op, value } = criteria;
2414
+ const evaluator = numericOperatorEvaluators[op];
2415
+ if (!evaluator) {
2416
+ return null;
2417
+ }
2418
+ if (typeof matchValue === "string" && matchValue.trim() === "" || typeof value === "string" && value.trim() === "") {
2419
+ return false;
2420
+ }
2421
+ const leftNum = Number(matchValue);
2422
+ const rightNum = Number(value);
2423
+ if (isNaN(leftNum) || isNaN(rightNum)) {
2424
+ return false;
2425
+ }
2426
+ return evaluator(leftNum, rightNum);
2427
+ }
2416
2428
  function evaluateStringMatch(criteria, matchValue, allow) {
2417
2429
  const { op, value } = criteria;
2418
2430
  if (allow && !allow.has(op)) {
2419
2431
  return null;
2420
2432
  }
2433
+ if (op in numericOperatorEvaluators) {
2434
+ return evaluateNumericOperator(criteria, matchValue);
2435
+ }
2421
2436
  let opMatch = op;
2422
2437
  const negation = op.startsWith("!");
2423
2438
  if (negation) {
@@ -2466,17 +2481,49 @@ var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
2466
2481
  "endswith",
2467
2482
  "!endswith",
2468
2483
  "empty",
2469
- "!empty"
2484
+ "!empty",
2485
+ "gt",
2486
+ "lt"
2470
2487
  ]);
2471
2488
  var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
2489
+ function toStringValue(value) {
2490
+ if (typeof value === "string") {
2491
+ return value;
2492
+ }
2493
+ if (typeof value === "number" || typeof value === "boolean") {
2494
+ return String(value);
2495
+ }
2496
+ return "";
2497
+ }
2498
+ function toStringCriteriaValue(value) {
2499
+ if (Array.isArray(value)) {
2500
+ return value.map((v) => toStringValue(v));
2501
+ }
2502
+ return toStringValue(value);
2503
+ }
2504
+ function isUnbound(value) {
2505
+ if (value === void 0 || value === null) {
2506
+ return true;
2507
+ }
2508
+ if (typeof value === "string") {
2509
+ return hasReferencedVariables(value) > 0;
2510
+ }
2511
+ return false;
2512
+ }
2472
2513
  function createDynamicTokenVisibilityRule() {
2473
2514
  return {
2474
2515
  [CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
2475
- var _a;
2476
- if (typeof criterion.source !== "string" || hasReferencedVariables(criterion.source)) {
2516
+ const { source, value } = criterion;
2517
+ if (isUnbound(source)) {
2477
2518
  return null;
2478
2519
  }
2479
- return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
2520
+ const stringSource = toStringValue(source);
2521
+ const stringValue = toStringCriteriaValue(value);
2522
+ const stringCriterion = {
2523
+ ...criterion,
2524
+ value: stringValue
2525
+ };
2526
+ return evaluateStringMatch(stringCriterion, stringSource, dynamicTokenVisibilityOperators);
2480
2527
  }
2481
2528
  };
2482
2529
  }
@@ -2744,10 +2791,47 @@ _baseUrl = new WeakMap();
2744
2791
  __privateAdd(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
2745
2792
  var IntegrationPropertyEditorsClient = _IntegrationPropertyEditorsClient;
2746
2793
 
2747
- // src/LocaleClient.ts
2794
+ // src/LabelClient.ts
2748
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");
2749
2833
  var localesUrl = "/api/v1/locales";
2750
- var LocaleClient = class extends import_api9.ApiClient {
2834
+ var LocaleClient = class extends import_api10.ApiClient {
2751
2835
  constructor(options) {
2752
2836
  super(options);
2753
2837
  }
@@ -3133,10 +3217,10 @@ var createCanvasChannel = ({
3133
3217
  };
3134
3218
 
3135
3219
  // src/PreviewClient.ts
3136
- var import_api10 = require("@uniformdev/context/api");
3220
+ var import_api11 = require("@uniformdev/context/api");
3137
3221
  var previewUrlsUrl = "/api/v1/preview-urls";
3138
3222
  var previewViewportsUrl = "/api/v1/preview-viewports";
3139
- var PreviewClient = class extends import_api10.ApiClient {
3223
+ var PreviewClient = class extends import_api11.ApiClient {
3140
3224
  constructor(options) {
3141
3225
  super(options);
3142
3226
  }
@@ -3199,9 +3283,9 @@ var PreviewClient = class extends import_api10.ApiClient {
3199
3283
  };
3200
3284
 
3201
3285
  // src/ProjectClient.ts
3202
- var import_api11 = require("@uniformdev/context/api");
3203
- var _url2;
3204
- var _ProjectClient = class _ProjectClient extends import_api11.ApiClient {
3286
+ var import_api12 = require("@uniformdev/context/api");
3287
+ var _url2, _projectsUrl;
3288
+ var _ProjectClient = class _ProjectClient extends import_api12.ApiClient {
3205
3289
  constructor(options) {
3206
3290
  super({ ...options, bypassCache: true });
3207
3291
  }
@@ -3210,6 +3294,15 @@ var _ProjectClient = class _ProjectClient extends import_api11.ApiClient {
3210
3294
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2), { ...options });
3211
3295
  return await this.apiClient(fetchUri);
3212
3296
  }
3297
+ /**
3298
+ * Fetches projects grouped by team.
3299
+ * When teamId is provided, returns a single team with its projects.
3300
+ * When omitted, returns all accessible teams and their projects.
3301
+ */
3302
+ async getProjects(options) {
3303
+ const fetchUri = this.createUrl(__privateGet(_ProjectClient, _projectsUrl), options ? { ...options } : {});
3304
+ return await this.apiClient(fetchUri);
3305
+ }
3213
3306
  /** Updates or creates (based on id) a Project */
3214
3307
  async upsert(body) {
3215
3308
  const fetchUri = this.createUrl(__privateGet(_ProjectClient, _url2));
@@ -3229,13 +3322,15 @@ var _ProjectClient = class _ProjectClient extends import_api11.ApiClient {
3229
3322
  }
3230
3323
  };
3231
3324
  _url2 = new WeakMap();
3325
+ _projectsUrl = new WeakMap();
3232
3326
  __privateAdd(_ProjectClient, _url2, "/api/v1/project");
3327
+ __privateAdd(_ProjectClient, _projectsUrl, "/api/v1/projects");
3233
3328
  var ProjectClient = _ProjectClient;
3234
3329
 
3235
3330
  // src/PromptClient.ts
3236
- var import_api12 = require("@uniformdev/context/api");
3331
+ var import_api13 = require("@uniformdev/context/api");
3237
3332
  var PromptsUrl = "/api/v1/prompts";
3238
- var PromptClient = class extends import_api12.ApiClient {
3333
+ var PromptClient = class extends import_api13.ApiClient {
3239
3334
  constructor(options) {
3240
3335
  super(options);
3241
3336
  }
@@ -3266,9 +3361,9 @@ var PromptClient = class extends import_api12.ApiClient {
3266
3361
  };
3267
3362
 
3268
3363
  // src/RelationshipClient.ts
3269
- var import_api13 = require("@uniformdev/context/api");
3364
+ var import_api14 = require("@uniformdev/context/api");
3270
3365
  var RELATIONSHIPS_URL = "/api/v1/relationships";
3271
- var RelationshipClient = class extends import_api13.ApiClient {
3366
+ var RelationshipClient = class extends import_api14.ApiClient {
3272
3367
  constructor(options) {
3273
3368
  super(options);
3274
3369
  this.get = async (options) => {
@@ -3280,9 +3375,9 @@ var RelationshipClient = class extends import_api13.ApiClient {
3280
3375
  };
3281
3376
 
3282
3377
  // src/ReleaseClient.ts
3283
- var import_api14 = require("@uniformdev/context/api");
3378
+ var import_api15 = require("@uniformdev/context/api");
3284
3379
  var releasesUrl = "/api/v1/releases";
3285
- var ReleaseClient = class extends import_api14.ApiClient {
3380
+ var ReleaseClient = class extends import_api15.ApiClient {
3286
3381
  constructor(options) {
3287
3382
  super(options);
3288
3383
  }
@@ -3322,9 +3417,9 @@ var ReleaseClient = class extends import_api14.ApiClient {
3322
3417
  };
3323
3418
 
3324
3419
  // src/ReleaseContentsClient.ts
3325
- var import_api15 = require("@uniformdev/context/api");
3420
+ var import_api16 = require("@uniformdev/context/api");
3326
3421
  var releaseContentsUrl2 = "/api/v1/release-contents";
3327
- var ReleaseContentsClient = class extends import_api15.ApiClient {
3422
+ var ReleaseContentsClient = class extends import_api16.ApiClient {
3328
3423
  constructor(options) {
3329
3424
  super(options);
3330
3425
  }
@@ -3346,9 +3441,9 @@ var ReleaseContentsClient = class extends import_api15.ApiClient {
3346
3441
  };
3347
3442
 
3348
3443
  // src/RouteClient.ts
3349
- var import_api16 = require("@uniformdev/context/api");
3444
+ var import_api17 = require("@uniformdev/context/api");
3350
3445
  var ROUTE_URL = "/api/v1/route";
3351
- var RouteClient = class extends import_api16.ApiClient {
3446
+ var RouteClient = class extends import_api17.ApiClient {
3352
3447
  constructor(options) {
3353
3448
  var _a;
3354
3449
  if (!options.limitPolicy) {
@@ -3720,15 +3815,15 @@ function handleRichTextNodeBinding(object, options) {
3720
3815
  }
3721
3816
 
3722
3817
  // src/index.ts
3723
- var import_api18 = require("@uniformdev/context/api");
3818
+ var import_api19 = require("@uniformdev/context/api");
3724
3819
 
3725
3820
  // src/.version.ts
3726
- var version = "20.47.1";
3821
+ var version = "20.56.0";
3727
3822
 
3728
3823
  // src/WorkflowClient.ts
3729
- var import_api17 = require("@uniformdev/context/api");
3824
+ var import_api18 = require("@uniformdev/context/api");
3730
3825
  var workflowsUrl = "/api/v1/workflows";
3731
- var WorkflowClient = class extends import_api17.ApiClient {
3826
+ var WorkflowClient = class extends import_api18.ApiClient {
3732
3827
  constructor(options) {
3733
3828
  super(options);
3734
3829
  }
@@ -3759,7 +3854,7 @@ var WorkflowClient = class extends import_api17.ApiClient {
3759
3854
  };
3760
3855
 
3761
3856
  // src/index.ts
3762
- var CanvasClientError = import_api18.ApiClientError;
3857
+ var CanvasClientError = import_api19.ApiClientError;
3763
3858
  // Annotate the CommonJS export names for ESM import in node:
3764
3859
  0 && (module.exports = {
3765
3860
  ASSETS_SOURCE_CUSTOM_URL,
@@ -3833,6 +3928,7 @@ var CanvasClientError = import_api18.ApiClientError;
3833
3928
  IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
3834
3929
  IntegrationPropertyEditorsClient,
3835
3930
  LOCALE_DYNAMIC_INPUT_NAME,
3931
+ LabelClient,
3836
3932
  LocaleClient,
3837
3933
  PLACEHOLDER_ID,
3838
3934
  PreviewClient,
@@ -3846,6 +3942,7 @@ var CanvasClientError = import_api18.ApiClientError;
3846
3942
  UncachedCanvasClient,
3847
3943
  UncachedCategoryClient,
3848
3944
  UncachedContentClient,
3945
+ UncachedLabelClient,
3849
3946
  UniqueBatchEntries,
3850
3947
  WorkflowClient,
3851
3948
  autoFixParameterGroups,