@uniformdev/canvas 20.49.3-alpha.9 → 20.49.4-alpha.102

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);
@@ -2241,11 +2225,34 @@ var stringOperatorEvaluators = {
2241
2225
  endswith: endsWithEvaluator,
2242
2226
  empty: emptyEvaluator
2243
2227
  };
2228
+ var numericOperatorEvaluators = {
2229
+ gt: (left, right) => left > right,
2230
+ lt: (left, right) => left < right
2231
+ };
2232
+ function evaluateNumericOperator(criteria, matchValue) {
2233
+ const { op, value } = criteria;
2234
+ const evaluator = numericOperatorEvaluators[op];
2235
+ if (!evaluator) {
2236
+ return null;
2237
+ }
2238
+ if (typeof matchValue === "string" && matchValue.trim() === "" || typeof value === "string" && value.trim() === "") {
2239
+ return false;
2240
+ }
2241
+ const leftNum = Number(matchValue);
2242
+ const rightNum = Number(value);
2243
+ if (isNaN(leftNum) || isNaN(rightNum)) {
2244
+ return false;
2245
+ }
2246
+ return evaluator(leftNum, rightNum);
2247
+ }
2244
2248
  function evaluateStringMatch(criteria, matchValue, allow) {
2245
2249
  const { op, value } = criteria;
2246
2250
  if (allow && !allow.has(op)) {
2247
2251
  return null;
2248
2252
  }
2253
+ if (op in numericOperatorEvaluators) {
2254
+ return evaluateNumericOperator(criteria, matchValue);
2255
+ }
2249
2256
  let opMatch = op;
2250
2257
  const negation = op.startsWith("!");
2251
2258
  if (negation) {
@@ -2294,17 +2301,49 @@ var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
2294
2301
  "endswith",
2295
2302
  "!endswith",
2296
2303
  "empty",
2297
- "!empty"
2304
+ "!empty",
2305
+ "gt",
2306
+ "lt"
2298
2307
  ]);
2299
2308
  var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
2309
+ function toStringValue(value) {
2310
+ if (typeof value === "string") {
2311
+ return value;
2312
+ }
2313
+ if (typeof value === "number" || typeof value === "boolean") {
2314
+ return String(value);
2315
+ }
2316
+ return "";
2317
+ }
2318
+ function toStringCriteriaValue(value) {
2319
+ if (Array.isArray(value)) {
2320
+ return value.map((v) => toStringValue(v));
2321
+ }
2322
+ return toStringValue(value);
2323
+ }
2324
+ function isUnbound(value) {
2325
+ if (value === void 0 || value === null) {
2326
+ return true;
2327
+ }
2328
+ if (typeof value === "string") {
2329
+ return hasReferencedVariables(value) > 0;
2330
+ }
2331
+ return false;
2332
+ }
2300
2333
  function createDynamicTokenVisibilityRule() {
2301
2334
  return {
2302
2335
  [CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
2303
- var _a;
2304
- if (typeof criterion.source !== "string" || hasReferencedVariables(criterion.source)) {
2336
+ const { source, value } = criterion;
2337
+ if (isUnbound(source)) {
2305
2338
  return null;
2306
2339
  }
2307
- return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
2340
+ const stringSource = toStringValue(source);
2341
+ const stringValue = toStringCriteriaValue(value);
2342
+ const stringCriterion = {
2343
+ ...criterion,
2344
+ value: stringValue
2345
+ };
2346
+ return evaluateStringMatch(stringCriterion, stringSource, dynamicTokenVisibilityOperators);
2308
2347
  }
2309
2348
  };
2310
2349
  }
@@ -3551,7 +3590,7 @@ function handleRichTextNodeBinding(object, options) {
3551
3590
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3552
3591
 
3553
3592
  // src/.version.ts
3554
- var version = "20.49.2";
3593
+ var version = "20.50.0";
3555
3594
 
3556
3595
  // src/WorkflowClient.ts
3557
3596
  import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
package/dist/index.js CHANGED
@@ -762,22 +762,6 @@ function createLimitPolicy({
762
762
  }
763
763
  var nullLimitPolicy = async (func) => await func();
764
764
 
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
765
  // src/CanvasClient.ts
782
766
  var CANVAS_URL = "/api/v1/canvas";
783
767
  var CanvasClient = class extends import_api2.ApiClient {
@@ -794,7 +778,7 @@ var CanvasClient = class extends import_api2.ApiClient {
794
778
  async getCompositionList(params = {}) {
795
779
  const { projectId } = this.options;
796
780
  const { resolveData, filters, ...originParams } = params;
797
- const rewrittenFilters = rewriteFilters(filters);
781
+ const rewrittenFilters = (0, import_api2.rewriteFiltersForApi)(filters);
798
782
  if (!resolveData) {
799
783
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
800
784
  return this.apiClient(fetchUri);
@@ -964,7 +948,7 @@ var _ContentClient = class _ContentClient extends import_api4.ApiClient {
964
948
  getEntries(options) {
965
949
  const { projectId } = this.options;
966
950
  const { skipDataResolution, filters, ...params } = options;
967
- const rewrittenFilters = rewriteFilters(filters);
951
+ const rewrittenFilters = (0, import_api4.rewriteFiltersForApi)(filters);
968
952
  if (skipDataResolution) {
969
953
  const url = this.createUrl(__privateGet(_ContentClient, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
970
954
  return this.apiClient(url);
@@ -2419,11 +2403,34 @@ var stringOperatorEvaluators = {
2419
2403
  endswith: endsWithEvaluator,
2420
2404
  empty: emptyEvaluator
2421
2405
  };
2406
+ var numericOperatorEvaluators = {
2407
+ gt: (left, right) => left > right,
2408
+ lt: (left, right) => left < right
2409
+ };
2410
+ function evaluateNumericOperator(criteria, matchValue) {
2411
+ const { op, value } = criteria;
2412
+ const evaluator = numericOperatorEvaluators[op];
2413
+ if (!evaluator) {
2414
+ return null;
2415
+ }
2416
+ if (typeof matchValue === "string" && matchValue.trim() === "" || typeof value === "string" && value.trim() === "") {
2417
+ return false;
2418
+ }
2419
+ const leftNum = Number(matchValue);
2420
+ const rightNum = Number(value);
2421
+ if (isNaN(leftNum) || isNaN(rightNum)) {
2422
+ return false;
2423
+ }
2424
+ return evaluator(leftNum, rightNum);
2425
+ }
2422
2426
  function evaluateStringMatch(criteria, matchValue, allow) {
2423
2427
  const { op, value } = criteria;
2424
2428
  if (allow && !allow.has(op)) {
2425
2429
  return null;
2426
2430
  }
2431
+ if (op in numericOperatorEvaluators) {
2432
+ return evaluateNumericOperator(criteria, matchValue);
2433
+ }
2427
2434
  let opMatch = op;
2428
2435
  const negation = op.startsWith("!");
2429
2436
  if (negation) {
@@ -2472,17 +2479,49 @@ var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
2472
2479
  "endswith",
2473
2480
  "!endswith",
2474
2481
  "empty",
2475
- "!empty"
2482
+ "!empty",
2483
+ "gt",
2484
+ "lt"
2476
2485
  ]);
2477
2486
  var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
2487
+ function toStringValue(value) {
2488
+ if (typeof value === "string") {
2489
+ return value;
2490
+ }
2491
+ if (typeof value === "number" || typeof value === "boolean") {
2492
+ return String(value);
2493
+ }
2494
+ return "";
2495
+ }
2496
+ function toStringCriteriaValue(value) {
2497
+ if (Array.isArray(value)) {
2498
+ return value.map((v) => toStringValue(v));
2499
+ }
2500
+ return toStringValue(value);
2501
+ }
2502
+ function isUnbound(value) {
2503
+ if (value === void 0 || value === null) {
2504
+ return true;
2505
+ }
2506
+ if (typeof value === "string") {
2507
+ return hasReferencedVariables(value) > 0;
2508
+ }
2509
+ return false;
2510
+ }
2478
2511
  function createDynamicTokenVisibilityRule() {
2479
2512
  return {
2480
2513
  [CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
2481
- var _a;
2482
- if (typeof criterion.source !== "string" || hasReferencedVariables(criterion.source)) {
2514
+ const { source, value } = criterion;
2515
+ if (isUnbound(source)) {
2483
2516
  return null;
2484
2517
  }
2485
- return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
2518
+ const stringSource = toStringValue(source);
2519
+ const stringValue = toStringCriteriaValue(value);
2520
+ const stringCriterion = {
2521
+ ...criterion,
2522
+ value: stringValue
2523
+ };
2524
+ return evaluateStringMatch(stringCriterion, stringSource, dynamicTokenVisibilityOperators);
2486
2525
  }
2487
2526
  };
2488
2527
  }
@@ -3729,7 +3768,7 @@ function handleRichTextNodeBinding(object, options) {
3729
3768
  var import_api18 = require("@uniformdev/context/api");
3730
3769
 
3731
3770
  // src/.version.ts
3732
- var version = "20.49.2";
3771
+ var version = "20.50.0";
3733
3772
 
3734
3773
  // src/WorkflowClient.ts
3735
3774
  var import_api17 = require("@uniformdev/context/api");
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);
@@ -2241,11 +2225,34 @@ var stringOperatorEvaluators = {
2241
2225
  endswith: endsWithEvaluator,
2242
2226
  empty: emptyEvaluator
2243
2227
  };
2228
+ var numericOperatorEvaluators = {
2229
+ gt: (left, right) => left > right,
2230
+ lt: (left, right) => left < right
2231
+ };
2232
+ function evaluateNumericOperator(criteria, matchValue) {
2233
+ const { op, value } = criteria;
2234
+ const evaluator = numericOperatorEvaluators[op];
2235
+ if (!evaluator) {
2236
+ return null;
2237
+ }
2238
+ if (typeof matchValue === "string" && matchValue.trim() === "" || typeof value === "string" && value.trim() === "") {
2239
+ return false;
2240
+ }
2241
+ const leftNum = Number(matchValue);
2242
+ const rightNum = Number(value);
2243
+ if (isNaN(leftNum) || isNaN(rightNum)) {
2244
+ return false;
2245
+ }
2246
+ return evaluator(leftNum, rightNum);
2247
+ }
2244
2248
  function evaluateStringMatch(criteria, matchValue, allow) {
2245
2249
  const { op, value } = criteria;
2246
2250
  if (allow && !allow.has(op)) {
2247
2251
  return null;
2248
2252
  }
2253
+ if (op in numericOperatorEvaluators) {
2254
+ return evaluateNumericOperator(criteria, matchValue);
2255
+ }
2249
2256
  let opMatch = op;
2250
2257
  const negation = op.startsWith("!");
2251
2258
  if (negation) {
@@ -2294,17 +2301,49 @@ var dynamicTokenVisibilityOperators = /* @__PURE__ */ new Set([
2294
2301
  "endswith",
2295
2302
  "!endswith",
2296
2303
  "empty",
2297
- "!empty"
2304
+ "!empty",
2305
+ "gt",
2306
+ "lt"
2298
2307
  ]);
2299
2308
  var CANVAS_VIZ_DYNAMIC_TOKEN_RULE = "$dt";
2309
+ function toStringValue(value) {
2310
+ if (typeof value === "string") {
2311
+ return value;
2312
+ }
2313
+ if (typeof value === "number" || typeof value === "boolean") {
2314
+ return String(value);
2315
+ }
2316
+ return "";
2317
+ }
2318
+ function toStringCriteriaValue(value) {
2319
+ if (Array.isArray(value)) {
2320
+ return value.map((v) => toStringValue(v));
2321
+ }
2322
+ return toStringValue(value);
2323
+ }
2324
+ function isUnbound(value) {
2325
+ if (value === void 0 || value === null) {
2326
+ return true;
2327
+ }
2328
+ if (typeof value === "string") {
2329
+ return hasReferencedVariables(value) > 0;
2330
+ }
2331
+ return false;
2332
+ }
2300
2333
  function createDynamicTokenVisibilityRule() {
2301
2334
  return {
2302
2335
  [CANVAS_VIZ_DYNAMIC_TOKEN_RULE]: (criterion) => {
2303
- var _a;
2304
- if (typeof criterion.source !== "string" || hasReferencedVariables(criterion.source)) {
2336
+ const { source, value } = criterion;
2337
+ if (isUnbound(source)) {
2305
2338
  return null;
2306
2339
  }
2307
- return evaluateStringMatch(criterion, (_a = criterion.source) != null ? _a : "", dynamicTokenVisibilityOperators);
2340
+ const stringSource = toStringValue(source);
2341
+ const stringValue = toStringCriteriaValue(value);
2342
+ const stringCriterion = {
2343
+ ...criterion,
2344
+ value: stringValue
2345
+ };
2346
+ return evaluateStringMatch(stringCriterion, stringSource, dynamicTokenVisibilityOperators);
2308
2347
  }
2309
2348
  };
2310
2349
  }
@@ -3551,7 +3590,7 @@ function handleRichTextNodeBinding(object, options) {
3551
3590
  import { ApiClientError as ApiClientError2 } from "@uniformdev/context/api";
3552
3591
 
3553
3592
  // src/.version.ts
3554
- var version = "20.49.2";
3593
+ var version = "20.50.0";
3555
3594
 
3556
3595
  // src/WorkflowClient.ts
3557
3596
  import { ApiClient as ApiClient16 } from "@uniformdev/context/api";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "20.49.3-alpha.9+e5b9a8ca05",
3
+ "version": "20.49.4-alpha.102+140d1a56b4",
4
4
  "description": "Common functionality and types for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -41,9 +41,9 @@
41
41
  "svix": "1.71.0"
42
42
  },
43
43
  "dependencies": {
44
- "@uniformdev/assets": "20.49.3-alpha.9+e5b9a8ca05",
45
- "@uniformdev/context": "20.49.3-alpha.9+e5b9a8ca05",
46
- "@uniformdev/richtext": "20.49.3-alpha.9+e5b9a8ca05",
44
+ "@uniformdev/assets": "20.49.4-alpha.102+140d1a56b4",
45
+ "@uniformdev/context": "20.49.4-alpha.102+140d1a56b4",
46
+ "@uniformdev/richtext": "20.49.4-alpha.102+140d1a56b4",
47
47
  "immer": "10.1.3"
48
48
  },
49
49
  "files": [
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "e5b9a8ca05d0b8b26886079b687417e53d44f9cb"
55
+ "gitHead": "140d1a56b4b45021216a166bcaf7ebe629681b0b"
56
56
  }