@esri/hub-common 9.15.0 → 9.18.0

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.
Files changed (84) hide show
  1. package/dist/es2017/Hub.js +6 -10
  2. package/dist/es2017/Hub.js.map +1 -1
  3. package/dist/es2017/HubError.js +2 -1
  4. package/dist/es2017/HubError.js.map +1 -1
  5. package/dist/es2017/content/_internal.js +12 -0
  6. package/dist/es2017/content/_internal.js.map +1 -1
  7. package/dist/es2017/content/index.js +17 -1
  8. package/dist/es2017/content/index.js.map +1 -1
  9. package/dist/es2017/core/types/IHubItemEntityManager.js +1 -0
  10. package/dist/es2017/core/types/IHubItemEntityManager.js.map +1 -0
  11. package/dist/es2017/items/index.js +1 -0
  12. package/dist/es2017/items/index.js.map +1 -1
  13. package/dist/es2017/items/setItemThumbnail.js +31 -0
  14. package/dist/es2017/items/setItemThumbnail.js.map +1 -0
  15. package/dist/es2017/items/slugs.js +39 -15
  16. package/dist/es2017/items/slugs.js.map +1 -1
  17. package/dist/es2017/models/index.js +13 -0
  18. package/dist/es2017/models/index.js.map +1 -1
  19. package/dist/es2017/projects/HubProjectManager.js +40 -4
  20. package/dist/es2017/projects/HubProjectManager.js.map +1 -1
  21. package/dist/es2017/projects/HubProjects.js +91 -18
  22. package/dist/es2017/projects/HubProjects.js.map +1 -1
  23. package/dist/esm/Hub.js +6 -10
  24. package/dist/esm/Hub.js.map +1 -1
  25. package/dist/esm/HubError.js +2 -1
  26. package/dist/esm/HubError.js.map +1 -1
  27. package/dist/esm/content/_internal.js +14 -0
  28. package/dist/esm/content/_internal.js.map +1 -1
  29. package/dist/esm/content/index.js +17 -1
  30. package/dist/esm/content/index.js.map +1 -1
  31. package/dist/esm/core/types/IHubItemEntityManager.js +1 -0
  32. package/dist/esm/core/types/IHubItemEntityManager.js.map +1 -0
  33. package/dist/esm/items/index.js +1 -0
  34. package/dist/esm/items/index.js.map +1 -1
  35. package/dist/esm/items/setItemThumbnail.js +46 -0
  36. package/dist/esm/items/setItemThumbnail.js.map +1 -0
  37. package/dist/esm/items/slugs.js +39 -15
  38. package/dist/esm/items/slugs.js.map +1 -1
  39. package/dist/esm/models/index.js +23 -1
  40. package/dist/esm/models/index.js.map +1 -1
  41. package/dist/esm/projects/HubProjectManager.js +58 -4
  42. package/dist/esm/projects/HubProjectManager.js.map +1 -1
  43. package/dist/esm/projects/HubProjects.js +100 -21
  44. package/dist/esm/projects/HubProjects.js.map +1 -1
  45. package/dist/node/Hub.js +6 -10
  46. package/dist/node/Hub.js.map +1 -1
  47. package/dist/node/HubError.js +5 -4
  48. package/dist/node/HubError.js.map +1 -1
  49. package/dist/node/content/_internal.js +13 -1
  50. package/dist/node/content/_internal.js.map +1 -1
  51. package/dist/node/content/index.js +17 -1
  52. package/dist/node/content/index.js.map +1 -1
  53. package/dist/node/core/types/IHubItemEntityManager.js +3 -0
  54. package/dist/node/core/types/IHubItemEntityManager.js.map +1 -0
  55. package/dist/node/items/index.js +1 -0
  56. package/dist/node/items/index.js.map +1 -1
  57. package/dist/node/items/setItemThumbnail.js +35 -0
  58. package/dist/node/items/setItemThumbnail.js.map +1 -0
  59. package/dist/node/items/slugs.js +42 -17
  60. package/dist/node/items/slugs.js.map +1 -1
  61. package/dist/node/models/index.js +15 -1
  62. package/dist/node/models/index.js.map +1 -1
  63. package/dist/node/projects/HubProjectManager.js +38 -2
  64. package/dist/node/projects/HubProjectManager.js.map +1 -1
  65. package/dist/node/projects/HubProjects.js +91 -17
  66. package/dist/node/projects/HubProjects.js.map +1 -1
  67. package/dist/types/Hub.d.ts +7 -11
  68. package/dist/types/HubError.d.ts +1 -1
  69. package/dist/types/content/_internal.d.ts +10 -1
  70. package/dist/types/content/index.d.ts +10 -1
  71. package/dist/types/core/types/IHubEntityManager.d.ts +16 -0
  72. package/dist/types/core/types/IHubItemEntityManager.d.ts +15 -0
  73. package/dist/types/items/index.d.ts +1 -0
  74. package/dist/types/items/setItemThumbnail.d.ts +9 -0
  75. package/dist/types/items/slugs.d.ts +20 -1
  76. package/dist/types/models/index.d.ts +8 -0
  77. package/dist/types/projects/HubProjectManager.d.ts +21 -3
  78. package/dist/types/projects/HubProjects.d.ts +3 -1
  79. package/dist/types/search/types.d.ts +2 -0
  80. package/dist/umd/common.umd.js +298 -47
  81. package/dist/umd/common.umd.js.map +1 -1
  82. package/dist/umd/common.umd.min.js +1 -1
  83. package/dist/umd/common.umd.min.js.map +1 -1
  84. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
1
  import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
2
2
  import { IRequestOptions } from "@esri/arcgis-rest-request";
3
3
  import { ArcGISContextManager } from "../ArcGISContextManager";
4
- import { IArcGISContext } from "..";
5
- import { IHubProject, IHubEntityManager } from "../core/types";
4
+ import { Filter, IArcGISContext, IHubSearchOptions, ISearchResponse } from "..";
5
+ import { IHubEntityManager, IHubProject } from "../core/types";
6
+ import { IHubItemEntityManager } from "../core/types/IHubItemEntityManager";
6
7
  /**
7
8
  * Centralized functions used to manage IHubProject instances
8
9
  *
@@ -10,7 +11,7 @@ import { IHubProject, IHubEntityManager } from "../core/types";
10
11
  * are also directly accessible for use in scenarios where
11
12
  * classes are inconvenient.
12
13
  */
13
- export declare class HubProjectManager implements IHubEntityManager<IHubProject> {
14
+ export declare class HubProjectManager implements IHubEntityManager<IHubProject>, IHubItemEntityManager<IHubProject> {
14
15
  /**
15
16
  * Hold a context manager, which should be a single instance for
16
17
  * an application. When authentication changes, the .context
@@ -67,6 +68,7 @@ export declare class HubProjectManager implements IHubEntityManager<IHubProject>
67
68
  * @returns
68
69
  */
69
70
  destroy(id: string, requestOptions?: IUserRequestOptions): Promise<void>;
71
+ get(identifier: string, requestOptions?: IRequestOptions): Promise<IHubProject>;
70
72
  /**
71
73
  * Fetch a Project via id or it's slug
72
74
  *
@@ -78,4 +80,20 @@ export declare class HubProjectManager implements IHubEntityManager<IHubProject>
78
80
  * @returns
79
81
  */
80
82
  fetch(identifier: string, requestOptions?: IRequestOptions): Promise<IHubProject>;
83
+ /**
84
+ * Search for Projects
85
+ *
86
+ * @param filter
87
+ * @param options
88
+ */
89
+ search(filter: Filter<"content">, options: IHubSearchOptions): Promise<ISearchResponse<IHubProject>>;
90
+ /**
91
+ * Set the thumbnail for the Project
92
+ * @param id
93
+ * @param file
94
+ * @param filename
95
+ * @param requestOptions
96
+ * @returns
97
+ */
98
+ updateThumbnail(project: IHubProject, file: any, filename: string, requestOptions?: IUserRequestOptions): Promise<IHubProject>;
81
99
  }
@@ -1,4 +1,5 @@
1
1
  import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
2
+ import { Filter, IHubSearchOptions, ISearchResponse } from "..";
2
3
  import { IRequestOptions } from "@esri/arcgis-rest-request";
3
4
  import { IHubProject } from "../core/types";
4
5
  export declare const HUB_PROJECT_ITEM_TYPE = "Web Mapping Application";
@@ -22,10 +23,11 @@ export declare function updateProject(project: IHubProject, requestOptions: IUse
22
23
  * @param identifier item id or slug
23
24
  * @param requestOptions
24
25
  */
25
- export declare function getProject(identifier: string, requestOptions: IRequestOptions): Promise<IHubProject>;
26
+ export declare function fetchProject(identifier: string, requestOptions: IRequestOptions): Promise<IHubProject>;
26
27
  /**
27
28
  * Remove a Hub Project
28
29
  * @param id
29
30
  * @param requestOptions
30
31
  */
31
32
  export declare function destroyProject(id: string, requestOptions: IUserRequestOptions): Promise<void>;
33
+ export declare function searchProjects(filter: Filter<"content">, options: IHubSearchOptions): Promise<ISearchResponse<IHubProject>>;
@@ -219,6 +219,8 @@ export interface ICatalog {
219
219
  export interface ISortOption {
220
220
  label: string;
221
221
  attribute: string;
222
+ defaultOrder: string;
223
+ order: string;
222
224
  }
223
225
  /**
224
226
  * A Filter that defines a subset of a Catalog, aka a Collection
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.14.1 - Sat Feb 12 2022 14:14:18 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.17.1 - Fri Feb 18 2022 21:45:18 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -6428,6 +6428,20 @@
6428
6428
  geometry: geometry,
6429
6429
  };
6430
6430
  };
6431
+ var MAX_SIZE = 5000000;
6432
+ /**
6433
+ * Returns whether or not an item is a proxied csv
6434
+ *
6435
+ * @param item
6436
+ * @param requestOptions Hub Request Options (including whether we're in portal)
6437
+ * @returns
6438
+ */
6439
+ var isProxiedCSV = function (item, requestOptions) {
6440
+ return !requestOptions.isPortal &&
6441
+ item.access === "public" &&
6442
+ item.type === "CSV" &&
6443
+ item.size <= MAX_SIZE;
6444
+ };
6431
6445
 
6432
6446
  // private helper functions
6433
6447
  function collectionToFamily(collection) {
@@ -7295,6 +7309,22 @@
7295
7309
  var isPageContent = function (content) {
7296
7310
  return includes(["Hub Page", "Site Page"], content.type);
7297
7311
  };
7312
+ // proxied csv helpers
7313
+ /**
7314
+ * If an item is a proxied csv, returns the url for the proxying feature layer.
7315
+ * If the item is not a proxied csv, returns undefined.
7316
+ *
7317
+ * @param item
7318
+ * @param requestOptions Hub Request Options (including whether we're in portal)
7319
+ * @returns
7320
+ */
7321
+ var getProxyUrl = function (item, requestOptions) {
7322
+ var result;
7323
+ if (isProxiedCSV(item, requestOptions)) {
7324
+ result = requestOptions.hubApiUrl + "/datasets/" + item.id + "_0/FeatureServer/0";
7325
+ }
7326
+ return result;
7327
+ };
7298
7328
 
7299
7329
  /**
7300
7330
  * Implementation of atob() according to the HTML and Infra specs, except that
@@ -8245,6 +8275,28 @@
8245
8275
  return clone;
8246
8276
  });
8247
8277
  }
8278
+ /**
8279
+ * Given an Item, fetch the data json and return an IModel
8280
+ * @param item
8281
+ * @param requestOptions
8282
+ * @returns
8283
+ */
8284
+ function fetchModelFromItem(item, requestOptions) {
8285
+ return __awaiter(this, void 0, void 0, function () {
8286
+ var data;
8287
+ return __generator(this, function (_a) {
8288
+ switch (_a.label) {
8289
+ case 0: return [4 /*yield*/, getItemData(item.id, requestOptions)];
8290
+ case 1:
8291
+ data = _a.sent();
8292
+ return [2 /*return*/, {
8293
+ item: item,
8294
+ data: data,
8295
+ }];
8296
+ }
8297
+ });
8298
+ });
8299
+ }
8248
8300
 
8249
8301
  /**
8250
8302
  * To streamline passing of either a model id or the model itself, we use this function
@@ -9019,19 +9071,43 @@
9019
9071
  * @returns
9020
9072
  */
9021
9073
  function getItemBySlug(slug, requestOptions) {
9074
+ return findItemsBySlug({ slug: slug }, requestOptions).then(function (results) {
9075
+ if (results.length) {
9076
+ return results[0];
9077
+ }
9078
+ else {
9079
+ return null;
9080
+ }
9081
+ });
9082
+ }
9083
+ /**
9084
+ * Find items by slug typeKeywords.
9085
+ *
9086
+ * Optional exclude parameter accepts the id of an item we expect to
9087
+ * have this particular slug. This is used during update calls
9088
+ * where we don't know if the slug specifically has been updated, but we
9089
+ * don't want a false-postive from the item we are updating
9090
+ *
9091
+ * @param slug
9092
+ * @param requestOptions
9093
+ * @returns
9094
+ */
9095
+ function findItemsBySlug(slugInfo, requestOptions) {
9022
9096
  var opts = {
9023
9097
  q: "",
9024
- filter: "typekeywords:\"slug|" + slug + "\"",
9098
+ filter: "typekeywords:\"slug|" + slugInfo.slug + "\"",
9025
9099
  authentication: requestOptions.authentication,
9026
9100
  };
9101
+ // We need to check for other items w/ a slug during
9102
+ // the update calls. For those scenarios we are interested
9103
+ // in any _other_ items which may have a specific slug
9104
+ // but not one specific item
9105
+ if (slugInfo.exclude) {
9106
+ opts.q = "NOT id:" + slugInfo.exclude;
9107
+ }
9027
9108
  return searchItems(opts)
9028
9109
  .then(function (response) {
9029
- if (response.results.length) {
9030
- return response.results[0];
9031
- }
9032
- else {
9033
- return null;
9034
- }
9110
+ return response.results;
9035
9111
  })
9036
9112
  .catch(function (e) {
9037
9113
  throw Error("Error in getItemBySlug " + e);
@@ -9049,20 +9125,20 @@
9049
9125
  * @param step
9050
9126
  * @returns
9051
9127
  */
9052
- function getUniqueSlug(slug, requestOptions, step) {
9128
+ function getUniqueSlug(slugInfo, requestOptions, step) {
9053
9129
  if (step === void 0) { step = 0; }
9054
- var combined = slug;
9130
+ var combinedSlug = slugInfo.slug;
9055
9131
  if (step) {
9056
- combined = slug + "-" + step;
9132
+ combinedSlug = slugInfo.slug + "-" + step;
9057
9133
  }
9058
- return getItemBySlug(combined, requestOptions)
9059
- .then(function (result) {
9060
- if (result) {
9134
+ return findItemsBySlug({ slug: combinedSlug, exclude: slugInfo.existingId }, requestOptions)
9135
+ .then(function (results) {
9136
+ if (results.length) {
9061
9137
  step++;
9062
- return getUniqueSlug(slug, requestOptions, step);
9138
+ return getUniqueSlug(slugInfo, requestOptions, step);
9063
9139
  }
9064
9140
  else {
9065
- return combined;
9141
+ return combinedSlug;
9066
9142
  }
9067
9143
  })
9068
9144
  .catch(function (e) {
@@ -9113,6 +9189,48 @@
9113
9189
  return template;
9114
9190
  }
9115
9191
 
9192
+ /**
9193
+ * Upload a file to be used as the thumbnail for an item
9194
+ * @param id
9195
+ * @param file
9196
+ * @param filename
9197
+ * @param requestOptions
9198
+ */
9199
+ function setItemThumbnail(id, file, filename, requestOptions) {
9200
+ return __awaiter(this, void 0, void 0, function () {
9201
+ var opts, response, err_1;
9202
+ return __generator(this, function (_a) {
9203
+ switch (_a.label) {
9204
+ case 0:
9205
+ opts = __assign({ item: {
9206
+ id: id,
9207
+ }, params: {
9208
+ thumbnail: file,
9209
+ }, filename: filename }, requestOptions);
9210
+ _a.label = 1;
9211
+ case 1:
9212
+ _a.trys.push([1, 3, , 4]);
9213
+ return [4 /*yield*/, updateItem(opts)];
9214
+ case 2:
9215
+ response = _a.sent();
9216
+ if (!response.success) {
9217
+ throw new HubError("Set Project Thumbnail", "Unknown error setting thumbnail.");
9218
+ }
9219
+ return [3 /*break*/, 4];
9220
+ case 3:
9221
+ err_1 = _a.sent();
9222
+ if (err_1 instanceof Error) {
9223
+ throw new HubError("Set Project Thumbnail", err_1.message, err_1);
9224
+ }
9225
+ else {
9226
+ throw new HubError("Set Project Thumbnail", "Unknown error setting thumbnail.");
9227
+ }
9228
+ case 4: return [2 /*return*/];
9229
+ }
9230
+ });
9231
+ });
9232
+ }
9233
+
9116
9234
  /**
9117
9235
  * Manage forward and backward property mappings to
9118
9236
  * streamline conversion between the Hub entities, and
@@ -9216,6 +9334,7 @@
9216
9334
  name: "No title provided",
9217
9335
  tags: [],
9218
9336
  typeKeywords: ["IHubProject", "HubProject"],
9337
+ status: "inactive",
9219
9338
  };
9220
9339
  /**
9221
9340
  * Default values for a new HubProject Model
@@ -9227,7 +9346,7 @@
9227
9346
  description: "No Description Provided",
9228
9347
  snippet: "",
9229
9348
  tags: [],
9230
- typeKeywords: [],
9349
+ typeKeywords: ["Hub Project"],
9231
9350
  properties: {
9232
9351
  slug: "",
9233
9352
  },
@@ -9235,7 +9354,6 @@
9235
9354
  data: {
9236
9355
  display: "about",
9237
9356
  timeline: {},
9238
- org: {},
9239
9357
  status: "inactive",
9240
9358
  contacts: [],
9241
9359
  schemaVersion: 1,
@@ -9316,7 +9434,7 @@
9316
9434
  }
9317
9435
  // Ensure slug is unique
9318
9436
  _a = project;
9319
- return [4 /*yield*/, getUniqueSlug(project.slug, requestOptions)];
9437
+ return [4 /*yield*/, getUniqueSlug({ slug: project.slug }, requestOptions)];
9320
9438
  case 1:
9321
9439
  // Ensure slug is unique
9322
9440
  _a.slug = _b.sent();
@@ -9346,15 +9464,11 @@
9346
9464
  return __generator(this, function (_b) {
9347
9465
  switch (_b.label) {
9348
9466
  case 0:
9349
- // verify that the slug is unique
9350
- // TODO: if the slug has not changed, we don't want to do this because
9351
- // the existing item will cause this to increment
9467
+ // verify that the slug is unique, excluding the current project
9352
9468
  _a = project;
9353
- return [4 /*yield*/, getUniqueSlug(project.slug, requestOptions)];
9469
+ return [4 /*yield*/, getUniqueSlug({ slug: project.slug, existingId: project.id }, requestOptions)];
9354
9470
  case 1:
9355
- // verify that the slug is unique
9356
- // TODO: if the slug has not changed, we don't want to do this because
9357
- // the existing item will cause this to increment
9471
+ // verify that the slug is unique, excluding the current project
9358
9472
  _a.slug = _b.sent();
9359
9473
  return [4 /*yield*/, getModel(project.id, requestOptions)];
9360
9474
  case 2:
@@ -9377,7 +9491,7 @@
9377
9491
  * @param identifier item id or slug
9378
9492
  * @param requestOptions
9379
9493
  */
9380
- function getProject(identifier, requestOptions) {
9494
+ function fetchProject(identifier, requestOptions) {
9381
9495
  var getPrms;
9382
9496
  if (isGuid(identifier)) {
9383
9497
  // get item by id
@@ -9385,12 +9499,20 @@
9385
9499
  }
9386
9500
  else {
9387
9501
  // search for item using filter=typekeywords:slug|identifier
9502
+ // although we could leverage searchProjects with an appropriate filter
9503
+ // getModelBySlug is a generalized function that works for any type
9388
9504
  getPrms = getModelBySlug(identifier, requestOptions);
9389
9505
  }
9390
9506
  return getPrms.then(function (model) {
9391
9507
  // transform the model into a HubProject
9392
9508
  var mapper = new PropertyMapper(getProjectPropertyMap());
9393
9509
  var project = mapper.modelToObject(model, {});
9510
+ var token;
9511
+ if (requestOptions.authentication) {
9512
+ var us = requestOptions.authentication;
9513
+ token = us.token;
9514
+ }
9515
+ project.thumbnailUrl = getItemThumbnailUrl(model.item, requestOptions, token);
9394
9516
  return project;
9395
9517
  });
9396
9518
  }
@@ -9418,13 +9540,88 @@
9418
9540
  // i.e. delegate to searchContent or just do an item search
9419
9541
  // and convert to IHubProject objects.
9420
9542
  //
9421
- // export async function searchProjects(
9422
- // filter: Filter<"content">,
9423
- // opts: IHubSearchOptions
9424
- // ): Promise<ISearchResponse<IHubProject>> {
9425
- // return _searchContent(filter, opts).then((results) => {
9426
- // })
9427
- // }
9543
+ function searchProjects(filter, options) {
9544
+ var _a;
9545
+ return __awaiter(this, void 0, void 0, function () {
9546
+ var scopingFilter, projectFilter, expanded, so;
9547
+ return __generator(this, function (_b) {
9548
+ scopingFilter = {
9549
+ filterType: "content",
9550
+ typekeywords: {
9551
+ exact: ["HubProject"],
9552
+ },
9553
+ };
9554
+ projectFilter = mergeContentFilter([scopingFilter, filter]);
9555
+ expanded = expandContentFilter(projectFilter);
9556
+ so = serializeContentFilterForPortal(expanded);
9557
+ // Aggregations
9558
+ if ((_a = options.aggregations) === null || _a === void 0 ? void 0 : _a.length) {
9559
+ so.countFields = options.aggregations.join(",");
9560
+ so.countSize = 200;
9561
+ }
9562
+ // copy over various options
9563
+ if (options.num) {
9564
+ so.num = options.num;
9565
+ }
9566
+ if (options.sortField) {
9567
+ so.sortField = options.sortField;
9568
+ }
9569
+ if (options.sortOrder) {
9570
+ so.sortOrder = options.sortOrder;
9571
+ }
9572
+ if (options.site) {
9573
+ so.site = cloneObject$1(options.site);
9574
+ }
9575
+ if (options.authentication) {
9576
+ so.authentication = options.authentication;
9577
+ }
9578
+ return [2 /*return*/, searchPortalProjects(so)];
9579
+ });
9580
+ });
9581
+ }
9582
+ /**
9583
+ * Internal fn that takes
9584
+ * @param searchOptions
9585
+ * @returns
9586
+ */
9587
+ function searchPortalProjects(searchOptions) {
9588
+ return __awaiter(this, void 0, void 0, function () {
9589
+ var response, hasNext, modelPromises, models, mapper, token, us, projects;
9590
+ return __generator(this, function (_a) {
9591
+ switch (_a.label) {
9592
+ case 0: return [4 /*yield*/, searchItems(searchOptions)];
9593
+ case 1:
9594
+ response = _a.sent();
9595
+ hasNext = response.nextStart > -1;
9596
+ modelPromises = response.results.map(function (itm) {
9597
+ return fetchModelFromItem(itm, {
9598
+ authentication: searchOptions.authentication,
9599
+ });
9600
+ });
9601
+ return [4 /*yield*/, Promise.all(modelPromises)];
9602
+ case 2:
9603
+ models = _a.sent();
9604
+ mapper = new PropertyMapper(getProjectPropertyMap());
9605
+ if (searchOptions.authentication) {
9606
+ us = searchOptions.authentication;
9607
+ token = us.token;
9608
+ }
9609
+ projects = models.map(function (m) {
9610
+ var prj = mapper.modelToObject(m, {});
9611
+ prj.thumbnailUrl = getItemThumbnailUrl(m.item, { authentication: searchOptions.authentication }, token);
9612
+ return prj;
9613
+ });
9614
+ return [2 /*return*/, {
9615
+ total: response.total,
9616
+ results: projects,
9617
+ facets: [],
9618
+ hasNext: hasNext,
9619
+ next: getNextFunction(searchOptions, response.nextStart, response.total, searchPortalProjects),
9620
+ }];
9621
+ }
9622
+ });
9623
+ });
9624
+ }
9428
9625
 
9429
9626
  /**
9430
9627
  * Centralized functions used to manage IHubProject instances
@@ -9533,6 +9730,18 @@
9533
9730
  });
9534
9731
  });
9535
9732
  };
9733
+ // DEPRECATED IN FAVOR OF .fetch()
9734
+ // TODO: REMOVE AT NEXT MAJOR
9735
+ /* istanbul ignore next */
9736
+ HubProjectManager.prototype.get = function (identifier, requestOptions) {
9737
+ return __awaiter(this, void 0, void 0, function () {
9738
+ return __generator(this, function (_a) {
9739
+ // tslint:disable-next-line
9740
+ console.warn("HubProjectManager.get is deprecated and will be removed. Use .fetch() instead.");
9741
+ return [2 /*return*/, this.fetch(identifier, requestOptions)];
9742
+ });
9743
+ });
9744
+ };
9536
9745
  /**
9537
9746
  * Fetch a Project via id or it's slug
9538
9747
  *
@@ -9547,10 +9756,51 @@
9547
9756
  return __awaiter(this, void 0, void 0, function () {
9548
9757
  return __generator(this, function (_a) {
9549
9758
  if (requestOptions || this.context.requestOptions) {
9550
- return [2 /*return*/, getProject(identifier, requestOptions || this.context.requestOptions)];
9759
+ return [2 /*return*/, fetchProject(identifier, requestOptions || this.context.requestOptions)];
9551
9760
  }
9552
9761
  else {
9553
- throw new HubError("Get Project", "Can not retrieve context.requestOptions from Context Manager. HubProjectManager is configured incorrectly.");
9762
+ throw new HubError("Fetch Project", "Can not retrieve context.requestOptions from Context Manager. HubProjectManager is configured incorrectly.");
9763
+ }
9764
+ });
9765
+ });
9766
+ };
9767
+ /**
9768
+ * Search for Projects
9769
+ *
9770
+ * @param filter
9771
+ * @param options
9772
+ */
9773
+ HubProjectManager.prototype.search = function (filter, options) {
9774
+ return __awaiter(this, void 0, void 0, function () {
9775
+ return __generator(this, function (_a) {
9776
+ // if we were not passed auth, and we have a session, use it
9777
+ if (!options.authentication && this.context.session) {
9778
+ options.authentication = this.context.session;
9779
+ }
9780
+ return [2 /*return*/, searchProjects(filter, options)];
9781
+ });
9782
+ });
9783
+ };
9784
+ /**
9785
+ * Set the thumbnail for the Project
9786
+ * @param id
9787
+ * @param file
9788
+ * @param filename
9789
+ * @param requestOptions
9790
+ * @returns
9791
+ */
9792
+ HubProjectManager.prototype.updateThumbnail = function (project, file, filename, requestOptions) {
9793
+ return __awaiter(this, void 0, void 0, function () {
9794
+ var ro;
9795
+ return __generator(this, function (_a) {
9796
+ switch (_a.label) {
9797
+ case 0:
9798
+ ro = requestOptions || this.context.userRequestOptions;
9799
+ return [4 /*yield*/, setItemThumbnail(project.id, file, filename, ro)];
9800
+ case 1:
9801
+ _a.sent();
9802
+ // get the item so we have updated props and timestamps
9803
+ return [2 /*return*/, this.fetch(project.id, requestOptions)];
9554
9804
  }
9555
9805
  });
9556
9806
  });
@@ -12046,21 +12296,19 @@
12046
12296
  *
12047
12297
  * myHub.context.currentUser //=> {username: "casey", ...} as IUser
12048
12298
  *
12049
- * const projectStore = await myHub.getProjectStore();
12050
- *
12051
- * const pavingProject = await projectStore.create({name: "12th Street Paving"});
12299
+ * const pavingProject = await myHub.projects.create({name: "12th Street Paving"});
12052
12300
  * pavingProject.summary = "This is the 2024 planned paving of 12th Street, between 8th and 11th Ave";
12053
- * await projectStore.update(pavingProject);
12301
+ * await myHub.projects.update(pavingProject);
12054
12302
  * ```
12055
12303
  *
12056
- * This is a convenience class. Hub Stores can be created
12304
+ * This is a convenience class. Hub Managers can be created
12057
12305
  * directly, or the underlying functions can be imported an used
12058
12306
  * as need for scenarios where these class structures introduce
12059
12307
  * unwanted complexity
12060
12308
  */
12061
12309
  var Hub = /** @class */ (function () {
12062
12310
  /**
12063
- * Private so we can employ a factory function should we need
12311
+ * Private so we can employ a factory function to do
12064
12312
  * async work during creation
12065
12313
  * @param contextManager
12066
12314
  */
@@ -12068,9 +12316,7 @@
12068
12316
  this._contextManager = contextManager;
12069
12317
  }
12070
12318
  /**
12071
- * Factory function to construct a new HubProjectStore instance.
12072
- *
12073
- * Note: Used so that we could do async actions in the ctor.
12319
+ * Factory function to construct a new Hub instance.
12074
12320
  * @param contextManager
12075
12321
  * @returns
12076
12322
  */
@@ -12104,7 +12350,7 @@
12104
12350
  });
12105
12351
  Object.defineProperty(Hub.prototype, "projects", {
12106
12352
  /**
12107
- * Create a Project Store connected to the current Hub
12353
+ * HubProjectManager for the current Hub
12108
12354
  * @returns
12109
12355
  */
12110
12356
  get: function () {
@@ -12536,9 +12782,12 @@
12536
12782
  exports.fetchAndUploadThumbnail = fetchAndUploadThumbnail;
12537
12783
  exports.fetchHubTranslation = fetchHubTranslation;
12538
12784
  exports.fetchImageAsBlob = fetchImageAsBlob;
12785
+ exports.fetchModelFromItem = fetchModelFromItem;
12786
+ exports.fetchProject = fetchProject;
12539
12787
  exports.fetchSite = fetchSite;
12540
12788
  exports.filterBy = filterBy;
12541
12789
  exports.findBy = findBy;
12790
+ exports.findItemsBySlug = findItemsBySlug;
12542
12791
  exports.flattenArray = flattenArray;
12543
12792
  exports.generateRandomString = generateRandomString;
12544
12793
  exports.getCategory = getCategory;
@@ -12579,9 +12828,9 @@
12579
12828
  exports.getPortalApiUrl = getPortalApiUrl;
12580
12829
  exports.getPortalBaseFromOrgUrl = getPortalBaseFromOrgUrl;
12581
12830
  exports.getPortalUrl = getPortalUrl;
12582
- exports.getProject = getProject;
12583
12831
  exports.getProp = getProp;
12584
12832
  exports.getProps = getProps;
12833
+ exports.getProxyUrl = getProxyUrl;
12585
12834
  exports.getServiceTypeFromUrl = getServiceTypeFromUrl;
12586
12835
  exports.getSession = getSession;
12587
12836
  exports.getSiteById = getSiteById;
@@ -12650,6 +12899,7 @@
12650
12899
  exports.replaceItemId = replaceItemId;
12651
12900
  exports.runRevertableTask = runRevertableTask;
12652
12901
  exports.saveSession = saveSession;
12902
+ exports.searchProjects = searchProjects;
12653
12903
  exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
12654
12904
  exports.serializeDateRange = serializeDateRange;
12655
12905
  exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
@@ -12661,6 +12911,7 @@
12661
12911
  exports.setContentHubId = setContentHubId;
12662
12912
  exports.setContentSiteUrls = setContentSiteUrls;
12663
12913
  exports.setContentType = setContentType;
12914
+ exports.setItemThumbnail = setItemThumbnail;
12664
12915
  exports.setProp = setProp;
12665
12916
  exports.setSlugKeyword = setSlugKeyword;
12666
12917
  exports.shareItemToGroups = shareItemToGroups;