@agility/content-fetch 2.0.8 → 2.0.9

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,7 +492,7 @@
488
492
  //caching disabled by default
489
493
  }
490
494
  };
491
- function buildBaseUrl(guid, region) {
495
+ function buildBaseUrl(guid) {
492
496
  let baseUrlSuffixes = {
493
497
  u: "",
494
498
  c: "-ca",
@@ -498,13 +502,11 @@
498
502
  };
499
503
  let suffix = guid.substr(guid.length - 2, 2);
500
504
  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
505
  if (suffix.startsWith("-") && baseUrlSuffixes.hasOwnProperty(env)) {
505
506
  return `https://api${baseUrlSuffixes[env]}.aglty.io/${guid}`;
507
+ } else {
508
+ return `https://${guid}-api.agilitycms.cloud`;
506
509
  }
507
- return `https://${guid}-api.agilitycms.cloud`;
508
510
  }
509
511
  function validateConfigParams(configParams) {
510
512
  if (!configParams.guid || configParams.guid.length == 0) {
@@ -527,7 +529,7 @@
527
529
  ...userConfig
528
530
  };
529
531
  if (!config.baseUrl) {
530
- config.baseUrl = buildBaseUrl(config?.guid || "", config?.region);
532
+ config.baseUrl = buildBaseUrl(config?.guid || "");
531
533
  } else {
532
534
  config.requiresGuidInHeaders = true;
533
535
  }
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,7 +510,7 @@ var defaultConfig = {
506
510
  //caching disabled by default
507
511
  }
508
512
  };
509
- function buildBaseUrl(guid, region) {
513
+ function buildBaseUrl(guid) {
510
514
  let baseUrlSuffixes = {
511
515
  u: "",
512
516
  c: "-ca",
@@ -516,13 +520,11 @@ function buildBaseUrl(guid, region) {
516
520
  };
517
521
  let suffix = guid.substr(guid.length - 2, 2);
518
522
  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
523
  if (suffix.startsWith("-") && baseUrlSuffixes.hasOwnProperty(env)) {
523
524
  return `https://api${baseUrlSuffixes[env]}.aglty.io/${guid}`;
525
+ } else {
526
+ return `https://${guid}-api.agilitycms.cloud`;
524
527
  }
525
- return `https://${guid}-api.agilitycms.cloud`;
526
528
  }
527
529
  function validateConfigParams(configParams) {
528
530
  if (!configParams.guid || configParams.guid.length == 0) {
@@ -545,7 +547,7 @@ var ApiClient = class {
545
547
  ...userConfig
546
548
  };
547
549
  if (!config.baseUrl) {
548
- config.baseUrl = buildBaseUrl(config?.guid || "", config?.region);
550
+ config.baseUrl = buildBaseUrl(config?.guid || "");
549
551
  } else {
550
552
  config.requiresGuidInHeaders = true;
551
553
  }
@@ -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.9",
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
+ }