@agility/content-fetch 2.0.8 → 2.0.10

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/browser.js CHANGED
@@ -217,15 +217,16 @@
217
217
  if ([
218
218
  "eq",
219
219
  "ne",
220
- "gt",
221
- "gte",
222
220
  "lt",
223
221
  "lte",
222
+ "gt",
223
+ "gte",
224
+ "range",
224
225
  "like",
225
226
  "in",
226
227
  "contains"
227
228
  ].indexOf(filter.operator.toLowerCase()) < 0) {
228
- throw new TypeError2(JSON.stringify(filter) + "Operator must be one of ['eq','ne','gt','gte','lt','lte','like', 'in', 'contains'].", validateRequestParams4);
229
+ throw new TypeError2(JSON.stringify(filter) + "Operator must be one of ['eq','ne','lt','lte','gt','gte','range','like','in','contains'].", validateRequestParams4);
229
230
  }
230
231
  }
231
232
  } else if (requestParams.filtersLogicOperator && requestParams.filtersLogicOperator.toLowerCase() !== "and" && requestParams.filtersLogicOperator.toLowerCase() !== "or") {
@@ -453,7 +454,10 @@
453
454
  FilterOperators2["LESS_THAN_OR_EQUAL_TO"] = "lte";
454
455
  FilterOperators2["GREATER_THAN"] = "gt";
455
456
  FilterOperators2["GREATER_THAN_OR_EQUAL_TO"] = "gte";
457
+ FilterOperators2["RANGE"] = "range";
456
458
  FilterOperators2["LIKE"] = "like";
459
+ FilterOperators2["IN"] = "in";
460
+ FilterOperators2["CONTAINS"] = "contains";
457
461
  return FilterOperators2;
458
462
  })(FilterOperators || {});
459
463
  var FilterOperator_default = FilterOperators;
@@ -488,23 +492,25 @@
488
492
  //caching disabled by default
489
493
  }
490
494
  };
491
- function buildBaseUrl(guid, region) {
492
- let baseUrlSuffixes = {
495
+ function buildBaseUrl(guid) {
496
+ const baseUrlSuffixes = {
493
497
  u: "",
494
498
  c: "-ca",
495
499
  e: "-eu",
496
500
  a: "-aus",
497
- d: "-dev"
501
+ d: "-dev",
502
+ us2: "-usa2"
498
503
  };
499
- let suffix = guid.substr(guid.length - 2, 2);
500
- let env = suffix.substr(1);
501
- if (region) {
502
- return region === "us" ? `https://api.aglty.io/${guid}` : `https://api-${region}.aglty.io/${guid}`;
503
- }
504
- if (suffix.startsWith("-") && baseUrlSuffixes.hasOwnProperty(env)) {
505
- return `https://api${baseUrlSuffixes[env]}.aglty.io/${guid}`;
504
+ const match = guid.match(/-(us2|[ucead])$/);
505
+ if (match) {
506
+ const env = match[1];
507
+ if (baseUrlSuffixes.hasOwnProperty(env)) {
508
+ const url = `https://api${baseUrlSuffixes[env]}.aglty.io/${guid}`;
509
+ return url;
510
+ }
506
511
  }
507
- return `https://${guid}-api.agilitycms.cloud`;
512
+ const legacyUrl = `https://${guid}-api.agilitycms.cloud`;
513
+ return legacyUrl;
508
514
  }
509
515
  function validateConfigParams(configParams) {
510
516
  if (!configParams.guid || configParams.guid.length == 0) {
@@ -527,7 +533,7 @@
527
533
  ...userConfig
528
534
  };
529
535
  if (!config.baseUrl) {
530
- config.baseUrl = buildBaseUrl(config?.guid || "", config?.region);
536
+ config.baseUrl = buildBaseUrl(config?.guid || "");
531
537
  } else {
532
538
  config.requiresGuidInHeaders = true;
533
539
  }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Config } from "./types/Config";
2
2
  import { ContentItem } from "./types/ContentItem";
3
3
  import { ContentList } from "./types/ContentList";
4
+ import { Filter } from "./types/Filter";
4
5
  import { Gallery } from "./types/Gallery";
5
6
  import { Page } from "./types/Page";
6
7
  import { ApiClientInstance, getApi } from "./api-client";
7
8
  import { ContentReference } from "./types/ContentReference";
8
- export type { ApiClientInstance, Config, ContentItem, ContentList, ContentReference, Gallery, Page };
9
+ export type { ApiClientInstance, Config, ContentItem, ContentList, ContentReference, Filter, Gallery, Page };
9
10
  export { getApi };
package/dist/node.js CHANGED
@@ -235,15 +235,16 @@ function validateRequestParams4(requestParams) {
235
235
  if ([
236
236
  "eq",
237
237
  "ne",
238
- "gt",
239
- "gte",
240
238
  "lt",
241
239
  "lte",
240
+ "gt",
241
+ "gte",
242
+ "range",
242
243
  "like",
243
244
  "in",
244
245
  "contains"
245
246
  ].indexOf(filter.operator.toLowerCase()) < 0) {
246
- throw new TypeError2(JSON.stringify(filter) + "Operator must be one of ['eq','ne','gt','gte','lt','lte','like', 'in', 'contains'].", validateRequestParams4);
247
+ throw new TypeError2(JSON.stringify(filter) + "Operator must be one of ['eq','ne','lt','lte','gt','gte','range','like','in','contains'].", validateRequestParams4);
247
248
  }
248
249
  }
249
250
  } else if (requestParams.filtersLogicOperator && requestParams.filtersLogicOperator.toLowerCase() !== "and" && requestParams.filtersLogicOperator.toLowerCase() !== "or") {
@@ -471,7 +472,10 @@ var FilterOperators = /* @__PURE__ */ ((FilterOperators2) => {
471
472
  FilterOperators2["LESS_THAN_OR_EQUAL_TO"] = "lte";
472
473
  FilterOperators2["GREATER_THAN"] = "gt";
473
474
  FilterOperators2["GREATER_THAN_OR_EQUAL_TO"] = "gte";
475
+ FilterOperators2["RANGE"] = "range";
474
476
  FilterOperators2["LIKE"] = "like";
477
+ FilterOperators2["IN"] = "in";
478
+ FilterOperators2["CONTAINS"] = "contains";
475
479
  return FilterOperators2;
476
480
  })(FilterOperators || {});
477
481
  var FilterOperator_default = FilterOperators;
@@ -506,23 +510,25 @@ var defaultConfig = {
506
510
  //caching disabled by default
507
511
  }
508
512
  };
509
- function buildBaseUrl(guid, region) {
510
- let baseUrlSuffixes = {
513
+ function buildBaseUrl(guid) {
514
+ const baseUrlSuffixes = {
511
515
  u: "",
512
516
  c: "-ca",
513
517
  e: "-eu",
514
518
  a: "-aus",
515
- d: "-dev"
519
+ d: "-dev",
520
+ us2: "-usa2"
516
521
  };
517
- let suffix = guid.substr(guid.length - 2, 2);
518
- let env = suffix.substr(1);
519
- if (region) {
520
- return region === "us" ? `https://api.aglty.io/${guid}` : `https://api-${region}.aglty.io/${guid}`;
521
- }
522
- if (suffix.startsWith("-") && baseUrlSuffixes.hasOwnProperty(env)) {
523
- return `https://api${baseUrlSuffixes[env]}.aglty.io/${guid}`;
522
+ const match = guid.match(/-(us2|[ucead])$/);
523
+ if (match) {
524
+ const env = match[1];
525
+ if (baseUrlSuffixes.hasOwnProperty(env)) {
526
+ const url = `https://api${baseUrlSuffixes[env]}.aglty.io/${guid}`;
527
+ return url;
528
+ }
524
529
  }
525
- return `https://${guid}-api.agilitycms.cloud`;
530
+ const legacyUrl = `https://${guid}-api.agilitycms.cloud`;
531
+ return legacyUrl;
526
532
  }
527
533
  function validateConfigParams(configParams) {
528
534
  if (!configParams.guid || configParams.guid.length == 0) {
@@ -545,7 +551,7 @@ var ApiClient = class {
545
551
  ...userConfig
546
552
  };
547
553
  if (!config.baseUrl) {
548
- config.baseUrl = buildBaseUrl(config?.guid || "", config?.region);
554
+ config.baseUrl = buildBaseUrl(config?.guid || "");
549
555
  } else {
550
556
  config.requiresGuidInHeaders = true;
551
557
  }
@@ -4,10 +4,6 @@ export interface Config {
4
4
  * This is mostly used for testing purposes.
5
5
  */
6
6
  baseUrl?: string | null;
7
- /**
8
- * Optional region for those guids which are missing a region. Use this to override.
9
- */
10
- region?: "ca" | "eu" | "us" | "aus" | "dev";
11
7
  /**
12
8
  * If true, the API will use the Preview API. If false, it will use the Fetch API. Default is false.
13
9
  * Make sure the API Key provided matches this value.
@@ -8,7 +8,7 @@
8
8
  */
9
9
  export interface Filter {
10
10
  property: string;
11
- operator: FilterOperator | "eq" | "ne" | "gt" | "lt" | "ge" | "le" | "contains" | "like" | "in";
11
+ operator: FilterOperator | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "range" | "like" | "in" | "contains";
12
12
  value: string;
13
13
  }
14
- export type FilterOperator = "eq" | "ne" | "gt" | "lt" | "ge" | "le" | "contains" | "like" | "in";
14
+ export type FilterOperator = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "range" | "like" | "in" | "contains";
@@ -22,7 +22,13 @@ declare enum FilterOperators {
22
22
  GREATER_THAN = "gt",
23
23
  /** Greater Than or Equal To */
24
24
  GREATER_THAN_OR_EQUAL_TO = "gte",
25
+ /** Range */
26
+ RANGE = "range",
25
27
  /** Like (string only) */
26
- LIKE = "like"
28
+ LIKE = "like",
29
+ /** In (multiple values) */
30
+ IN = "in",
31
+ /** Contains (string only) */
32
+ CONTAINS = "contains"
27
33
  }
28
34
  export default FilterOperators;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/content-fetch",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "JS/TS library for the Agility Fetch API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,8 @@
34
34
  "author": "Agility CMS",
35
35
  "contributors": [
36
36
  "Kevin Tran",
37
- "Joel Varty"
37
+ "Joel Varty",
38
+ "Aaron Taylor"
38
39
  ],
39
40
  "license": "MIT",
40
41
  "dependencies": {},
@@ -49,4 +50,4 @@
49
50
  "ts-jest": "^29.1.1",
50
51
  "typescript": "^5.1.6"
51
52
  }
52
- }
53
+ }