@agility/management-sdk 0.1.34 → 0.1.36

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.
@@ -40,6 +40,7 @@ exports.ContentMethods = void 0;
40
40
  var clientInstance_1 = require("./clientInstance");
41
41
  var batchMethods_1 = require("./batchMethods");
42
42
  var exception_1 = require("../models/exception");
43
+ var queryString_1 = require("../util/queryString");
43
44
  var ContentMethods = /** @class */ (function () {
44
45
  function ContentMethods(options) {
45
46
  this._options = options;
@@ -370,12 +371,20 @@ var ContentMethods = /** @class */ (function () {
370
371
  };
371
372
  ContentMethods.prototype.getContentItems = function (referenceName, guid, locale, listParams) {
372
373
  return __awaiter(this, void 0, void 0, function () {
373
- var apiPath, resp, err_10;
374
+ var queryParams, apiPath, resp, err_10;
374
375
  return __generator(this, function (_a) {
375
376
  switch (_a.label) {
376
377
  case 0:
377
378
  _a.trys.push([0, 2, , 3]);
378
- apiPath = "".concat(locale, "/list/").concat(referenceName, "?filter=").concat(listParams.filter, "&fields=").concat(listParams.fields, "&sortDirection=").concat(listParams.sortDirection, "&sortField=").concat(listParams.sortField, "&take=").concat(listParams.take, "&skip=").concat(listParams.skip);
379
+ queryParams = (0, queryString_1.buildQueryString)({
380
+ filter: listParams.filter,
381
+ fields: listParams.fields,
382
+ sortDirection: listParams.sortDirection,
383
+ sortField: listParams.sortField,
384
+ take: listParams.take,
385
+ skip: listParams.skip
386
+ });
387
+ apiPath = "".concat(locale, "/list/").concat(referenceName).concat(queryParams);
379
388
  return [4 /*yield*/, this._clientInstance.executeGet(apiPath, guid, this._options.token)];
380
389
  case 1:
381
390
  resp = _a.sent();
@@ -390,13 +399,21 @@ var ContentMethods = /** @class */ (function () {
390
399
  };
391
400
  ContentMethods.prototype.getContentList = function (referenceName_1, guid_1, locale_1, listParams_1) {
392
401
  return __awaiter(this, arguments, void 0, function (referenceName, guid, locale, listParams, filterObject) {
393
- var apiPath, resp, err_11;
402
+ var queryParams, apiPath, resp, err_11;
394
403
  if (filterObject === void 0) { filterObject = null; }
395
404
  return __generator(this, function (_a) {
396
405
  switch (_a.label) {
397
406
  case 0:
398
407
  _a.trys.push([0, 2, , 3]);
399
- apiPath = "".concat(locale, "/list/").concat(referenceName, "?fields=").concat(listParams.fields, "&sortDirection=").concat(listParams.sortDirection, "&sortField=").concat(listParams.sortField, "&take=").concat(listParams.take, "&skip=").concat(listParams.skip, "&showDeleted=").concat(listParams.showDeleted);
408
+ queryParams = (0, queryString_1.buildQueryString)({
409
+ fields: listParams.fields,
410
+ sortDirection: listParams.sortDirection,
411
+ sortField: listParams.sortField,
412
+ take: listParams.take,
413
+ skip: listParams.skip,
414
+ showDeleted: listParams.showDeleted
415
+ });
416
+ apiPath = "".concat(locale, "/list/").concat(referenceName).concat(queryParams);
400
417
  return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, filterObject)];
401
418
  case 1:
402
419
  resp = _a.sent();
@@ -36,10 +36,10 @@ export declare class PageMethods {
36
36
  * @param returnBatchId Whether to return the batch ID immediately
37
37
  * @param pageIDInOtherLocale The ID of the page in the other locale if you need to link it up.
38
38
  * @param otherLocale The other locale to link the page to.
39
- * @param linkExisitingComponents Whether to link existing components to the page. If not set, the page save will create new components for each content zone.
39
+ * @param linkExistingComponents Whether to link existing components to the page. If not set, the page save will create new components for each content zone.
40
40
  * @returns The IDs of the created or updated pages
41
41
  */
42
- savePage(pageItem: PageItem, guid: string, locale: string, parentPageID?: number, placeBeforePageItemID?: number, returnBatchId?: boolean, pageIDInOtherLocale?: number, otherLocale?: string, linkExisitingComponents?: boolean): Promise<number[]>;
42
+ savePage(pageItem: PageItem, guid: string, locale: string, parentPageID?: number, placeBeforePageItemID?: number, returnBatchId?: boolean, pageIDInOtherLocale?: number, otherLocale?: string, linkExistingComponents?: boolean): Promise<number[]>;
43
43
  getPageHistory(locale: string, guid: string, pageID: number, take?: number, skip?: number): Promise<PageHistory>;
44
44
  getPageComments(locale: string, guid: string, pageID: number, take?: number, skip?: number): Promise<ItemComments>;
45
45
  }
@@ -447,11 +447,11 @@ var PageMethods = /** @class */ (function () {
447
447
  * @param returnBatchId Whether to return the batch ID immediately
448
448
  * @param pageIDInOtherLocale The ID of the page in the other locale if you need to link it up.
449
449
  * @param otherLocale The other locale to link the page to.
450
- * @param linkExisitingComponents Whether to link existing components to the page. If not set, the page save will create new components for each content zone.
450
+ * @param linkExistingComponents Whether to link existing components to the page. If not set, the page save will create new components for each content zone.
451
451
  * @returns The IDs of the created or updated pages
452
452
  */
453
453
  PageMethods.prototype.savePage = function (pageItem_1, guid_1, locale_1) {
454
- return __awaiter(this, arguments, void 0, function (pageItem, guid, locale, parentPageID, placeBeforePageItemID, returnBatchId, pageIDInOtherLocale, otherLocale, linkExisitingComponents) {
454
+ return __awaiter(this, arguments, void 0, function (pageItem, guid, locale, parentPageID, placeBeforePageItemID, returnBatchId, pageIDInOtherLocale, otherLocale, linkExistingComponents) {
455
455
  var apiPath, resp, batchID_7, batch, pageIDs_7, err_15;
456
456
  var _this = this;
457
457
  if (parentPageID === void 0) { parentPageID = -1; }
@@ -459,7 +459,7 @@ var PageMethods = /** @class */ (function () {
459
459
  if (returnBatchId === void 0) { returnBatchId = false; }
460
460
  if (pageIDInOtherLocale === void 0) { pageIDInOtherLocale = -1; }
461
461
  if (otherLocale === void 0) { otherLocale = null; }
462
- if (linkExisitingComponents === void 0) { linkExisitingComponents = false; }
462
+ if (linkExistingComponents === void 0) { linkExistingComponents = false; }
463
463
  return __generator(this, function (_a) {
464
464
  switch (_a.label) {
465
465
  case 0:
@@ -470,8 +470,8 @@ var PageMethods = /** @class */ (function () {
470
470
  apiPath += "&pageIDInOtherLocale=".concat(pageIDInOtherLocale, "&otherLocale=").concat(otherLocale);
471
471
  }
472
472
  // if not set, the page save will create new components for each content zone.
473
- if (linkExisitingComponents) {
474
- apiPath += "&linkExisitingComponents=true";
473
+ if (linkExistingComponents) {
474
+ apiPath += "&linkExistingComponents=true";
475
475
  }
476
476
  return [4 /*yield*/, this._clientInstance.executePost(apiPath, guid, this._options.token, pageItem)];
477
477
  case 1:
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Builds a query string from an object of parameters.
3
+ * Only includes parameters that have actual values (skips undefined, null, and empty strings).
4
+ *
5
+ * @param params - Object containing key-value pairs for query parameters
6
+ * @returns Query string starting with '?' if parameters exist, empty string otherwise
7
+ */
8
+ export declare function buildQueryString(params: Record<string, any>): string;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildQueryString = buildQueryString;
4
+ /**
5
+ * Builds a query string from an object of parameters.
6
+ * Only includes parameters that have actual values (skips undefined, null, and empty strings).
7
+ *
8
+ * @param params - Object containing key-value pairs for query parameters
9
+ * @returns Query string starting with '?' if parameters exist, empty string otherwise
10
+ */
11
+ function buildQueryString(params) {
12
+ var queryParams = [];
13
+ for (var _i = 0, _a = Object.entries(params); _i < _a.length; _i++) {
14
+ var _b = _a[_i], key = _b[0], value = _b[1];
15
+ // Skip undefined and null values
16
+ if (value === undefined || value === null) {
17
+ continue;
18
+ }
19
+ // Skip empty strings
20
+ if (typeof value === 'string' && value === '') {
21
+ continue;
22
+ }
23
+ // Include all other values (numbers including 0, booleans including false, non-empty strings)
24
+ queryParams.push("".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)));
25
+ }
26
+ return queryParams.length > 0 ? "?".concat(queryParams.join('&')) : '';
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/management-sdk",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "description": "Agility CMS Tyescript SDK for Management API.",
5
5
  "repository": {
6
6
  "type": "git",