@esri/hub-common 9.17.1 → 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.
- package/dist/es2017/Hub.js +6 -10
- package/dist/es2017/Hub.js.map +1 -1
- package/dist/es2017/core/types/IHubItemEntityManager.js +1 -0
- package/dist/es2017/core/types/IHubItemEntityManager.js.map +1 -0
- package/dist/es2017/items/index.js +1 -0
- package/dist/es2017/items/index.js.map +1 -1
- package/dist/es2017/items/setItemThumbnail.js +31 -0
- package/dist/es2017/items/setItemThumbnail.js.map +1 -0
- package/dist/es2017/items/slugs.js +39 -15
- package/dist/es2017/items/slugs.js.map +1 -1
- package/dist/es2017/models/index.js +13 -0
- package/dist/es2017/models/index.js.map +1 -1
- package/dist/es2017/projects/HubProjectManager.js +40 -4
- package/dist/es2017/projects/HubProjectManager.js.map +1 -1
- package/dist/es2017/projects/HubProjects.js +91 -18
- package/dist/es2017/projects/HubProjects.js.map +1 -1
- package/dist/esm/Hub.js +6 -10
- package/dist/esm/Hub.js.map +1 -1
- package/dist/esm/core/types/IHubItemEntityManager.js +1 -0
- package/dist/esm/core/types/IHubItemEntityManager.js.map +1 -0
- package/dist/esm/items/index.js +1 -0
- package/dist/esm/items/index.js.map +1 -1
- package/dist/esm/items/setItemThumbnail.js +46 -0
- package/dist/esm/items/setItemThumbnail.js.map +1 -0
- package/dist/esm/items/slugs.js +39 -15
- package/dist/esm/items/slugs.js.map +1 -1
- package/dist/esm/models/index.js +23 -1
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/projects/HubProjectManager.js +58 -4
- package/dist/esm/projects/HubProjectManager.js.map +1 -1
- package/dist/esm/projects/HubProjects.js +100 -21
- package/dist/esm/projects/HubProjects.js.map +1 -1
- package/dist/node/Hub.js +6 -10
- package/dist/node/Hub.js.map +1 -1
- package/dist/node/core/types/IHubItemEntityManager.js +3 -0
- package/dist/node/core/types/IHubItemEntityManager.js.map +1 -0
- package/dist/node/items/index.js +1 -0
- package/dist/node/items/index.js.map +1 -1
- package/dist/node/items/setItemThumbnail.js +35 -0
- package/dist/node/items/setItemThumbnail.js.map +1 -0
- package/dist/node/items/slugs.js +42 -17
- package/dist/node/items/slugs.js.map +1 -1
- package/dist/node/models/index.js +15 -1
- package/dist/node/models/index.js.map +1 -1
- package/dist/node/projects/HubProjectManager.js +38 -2
- package/dist/node/projects/HubProjectManager.js.map +1 -1
- package/dist/node/projects/HubProjects.js +91 -17
- package/dist/node/projects/HubProjects.js.map +1 -1
- package/dist/types/Hub.d.ts +7 -11
- package/dist/types/core/types/IHubEntityManager.d.ts +16 -0
- package/dist/types/core/types/IHubItemEntityManager.d.ts +15 -0
- package/dist/types/items/index.d.ts +1 -0
- package/dist/types/items/setItemThumbnail.d.ts +9 -0
- package/dist/types/items/slugs.d.ts +20 -1
- package/dist/types/models/index.d.ts +8 -0
- package/dist/types/projects/HubProjectManager.d.ts +21 -3
- package/dist/types/projects/HubProjects.d.ts +3 -1
- package/dist/umd/common.umd.js +267 -47
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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>>;
|
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.17.
|
|
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
|
*/
|
|
@@ -8275,6 +8275,28 @@
|
|
|
8275
8275
|
return clone;
|
|
8276
8276
|
});
|
|
8277
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
|
+
}
|
|
8278
8300
|
|
|
8279
8301
|
/**
|
|
8280
8302
|
* To streamline passing of either a model id or the model itself, we use this function
|
|
@@ -9049,19 +9071,43 @@
|
|
|
9049
9071
|
* @returns
|
|
9050
9072
|
*/
|
|
9051
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) {
|
|
9052
9096
|
var opts = {
|
|
9053
9097
|
q: "",
|
|
9054
|
-
filter: "typekeywords:\"slug|" + slug + "\"",
|
|
9098
|
+
filter: "typekeywords:\"slug|" + slugInfo.slug + "\"",
|
|
9055
9099
|
authentication: requestOptions.authentication,
|
|
9056
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
|
+
}
|
|
9057
9108
|
return searchItems(opts)
|
|
9058
9109
|
.then(function (response) {
|
|
9059
|
-
|
|
9060
|
-
return response.results[0];
|
|
9061
|
-
}
|
|
9062
|
-
else {
|
|
9063
|
-
return null;
|
|
9064
|
-
}
|
|
9110
|
+
return response.results;
|
|
9065
9111
|
})
|
|
9066
9112
|
.catch(function (e) {
|
|
9067
9113
|
throw Error("Error in getItemBySlug " + e);
|
|
@@ -9079,20 +9125,20 @@
|
|
|
9079
9125
|
* @param step
|
|
9080
9126
|
* @returns
|
|
9081
9127
|
*/
|
|
9082
|
-
function getUniqueSlug(
|
|
9128
|
+
function getUniqueSlug(slugInfo, requestOptions, step) {
|
|
9083
9129
|
if (step === void 0) { step = 0; }
|
|
9084
|
-
var
|
|
9130
|
+
var combinedSlug = slugInfo.slug;
|
|
9085
9131
|
if (step) {
|
|
9086
|
-
|
|
9132
|
+
combinedSlug = slugInfo.slug + "-" + step;
|
|
9087
9133
|
}
|
|
9088
|
-
return
|
|
9089
|
-
.then(function (
|
|
9090
|
-
if (
|
|
9134
|
+
return findItemsBySlug({ slug: combinedSlug, exclude: slugInfo.existingId }, requestOptions)
|
|
9135
|
+
.then(function (results) {
|
|
9136
|
+
if (results.length) {
|
|
9091
9137
|
step++;
|
|
9092
|
-
return getUniqueSlug(
|
|
9138
|
+
return getUniqueSlug(slugInfo, requestOptions, step);
|
|
9093
9139
|
}
|
|
9094
9140
|
else {
|
|
9095
|
-
return
|
|
9141
|
+
return combinedSlug;
|
|
9096
9142
|
}
|
|
9097
9143
|
})
|
|
9098
9144
|
.catch(function (e) {
|
|
@@ -9143,6 +9189,48 @@
|
|
|
9143
9189
|
return template;
|
|
9144
9190
|
}
|
|
9145
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
|
+
|
|
9146
9234
|
/**
|
|
9147
9235
|
* Manage forward and backward property mappings to
|
|
9148
9236
|
* streamline conversion between the Hub entities, and
|
|
@@ -9246,6 +9334,7 @@
|
|
|
9246
9334
|
name: "No title provided",
|
|
9247
9335
|
tags: [],
|
|
9248
9336
|
typeKeywords: ["IHubProject", "HubProject"],
|
|
9337
|
+
status: "inactive",
|
|
9249
9338
|
};
|
|
9250
9339
|
/**
|
|
9251
9340
|
* Default values for a new HubProject Model
|
|
@@ -9257,7 +9346,7 @@
|
|
|
9257
9346
|
description: "No Description Provided",
|
|
9258
9347
|
snippet: "",
|
|
9259
9348
|
tags: [],
|
|
9260
|
-
typeKeywords: [],
|
|
9349
|
+
typeKeywords: ["Hub Project"],
|
|
9261
9350
|
properties: {
|
|
9262
9351
|
slug: "",
|
|
9263
9352
|
},
|
|
@@ -9265,7 +9354,6 @@
|
|
|
9265
9354
|
data: {
|
|
9266
9355
|
display: "about",
|
|
9267
9356
|
timeline: {},
|
|
9268
|
-
org: {},
|
|
9269
9357
|
status: "inactive",
|
|
9270
9358
|
contacts: [],
|
|
9271
9359
|
schemaVersion: 1,
|
|
@@ -9346,7 +9434,7 @@
|
|
|
9346
9434
|
}
|
|
9347
9435
|
// Ensure slug is unique
|
|
9348
9436
|
_a = project;
|
|
9349
|
-
return [4 /*yield*/, getUniqueSlug(project.slug, requestOptions)];
|
|
9437
|
+
return [4 /*yield*/, getUniqueSlug({ slug: project.slug }, requestOptions)];
|
|
9350
9438
|
case 1:
|
|
9351
9439
|
// Ensure slug is unique
|
|
9352
9440
|
_a.slug = _b.sent();
|
|
@@ -9376,15 +9464,11 @@
|
|
|
9376
9464
|
return __generator(this, function (_b) {
|
|
9377
9465
|
switch (_b.label) {
|
|
9378
9466
|
case 0:
|
|
9379
|
-
// verify that the slug is unique
|
|
9380
|
-
// TODO: if the slug has not changed, we don't want to do this because
|
|
9381
|
-
// the existing item will cause this to increment
|
|
9467
|
+
// verify that the slug is unique, excluding the current project
|
|
9382
9468
|
_a = project;
|
|
9383
|
-
return [4 /*yield*/, getUniqueSlug(project.slug, requestOptions)];
|
|
9469
|
+
return [4 /*yield*/, getUniqueSlug({ slug: project.slug, existingId: project.id }, requestOptions)];
|
|
9384
9470
|
case 1:
|
|
9385
|
-
// verify that the slug is unique
|
|
9386
|
-
// TODO: if the slug has not changed, we don't want to do this because
|
|
9387
|
-
// the existing item will cause this to increment
|
|
9471
|
+
// verify that the slug is unique, excluding the current project
|
|
9388
9472
|
_a.slug = _b.sent();
|
|
9389
9473
|
return [4 /*yield*/, getModel(project.id, requestOptions)];
|
|
9390
9474
|
case 2:
|
|
@@ -9407,7 +9491,7 @@
|
|
|
9407
9491
|
* @param identifier item id or slug
|
|
9408
9492
|
* @param requestOptions
|
|
9409
9493
|
*/
|
|
9410
|
-
function
|
|
9494
|
+
function fetchProject(identifier, requestOptions) {
|
|
9411
9495
|
var getPrms;
|
|
9412
9496
|
if (isGuid(identifier)) {
|
|
9413
9497
|
// get item by id
|
|
@@ -9415,12 +9499,20 @@
|
|
|
9415
9499
|
}
|
|
9416
9500
|
else {
|
|
9417
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
|
|
9418
9504
|
getPrms = getModelBySlug(identifier, requestOptions);
|
|
9419
9505
|
}
|
|
9420
9506
|
return getPrms.then(function (model) {
|
|
9421
9507
|
// transform the model into a HubProject
|
|
9422
9508
|
var mapper = new PropertyMapper(getProjectPropertyMap());
|
|
9423
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);
|
|
9424
9516
|
return project;
|
|
9425
9517
|
});
|
|
9426
9518
|
}
|
|
@@ -9448,13 +9540,88 @@
|
|
|
9448
9540
|
// i.e. delegate to searchContent or just do an item search
|
|
9449
9541
|
// and convert to IHubProject objects.
|
|
9450
9542
|
//
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
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
|
+
}
|
|
9458
9625
|
|
|
9459
9626
|
/**
|
|
9460
9627
|
* Centralized functions used to manage IHubProject instances
|
|
@@ -9563,6 +9730,18 @@
|
|
|
9563
9730
|
});
|
|
9564
9731
|
});
|
|
9565
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
|
+
};
|
|
9566
9745
|
/**
|
|
9567
9746
|
* Fetch a Project via id or it's slug
|
|
9568
9747
|
*
|
|
@@ -9577,10 +9756,51 @@
|
|
|
9577
9756
|
return __awaiter(this, void 0, void 0, function () {
|
|
9578
9757
|
return __generator(this, function (_a) {
|
|
9579
9758
|
if (requestOptions || this.context.requestOptions) {
|
|
9580
|
-
return [2 /*return*/,
|
|
9759
|
+
return [2 /*return*/, fetchProject(identifier, requestOptions || this.context.requestOptions)];
|
|
9581
9760
|
}
|
|
9582
9761
|
else {
|
|
9583
|
-
throw new HubError("
|
|
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)];
|
|
9584
9804
|
}
|
|
9585
9805
|
});
|
|
9586
9806
|
});
|
|
@@ -12076,21 +12296,19 @@
|
|
|
12076
12296
|
*
|
|
12077
12297
|
* myHub.context.currentUser //=> {username: "casey", ...} as IUser
|
|
12078
12298
|
*
|
|
12079
|
-
* const
|
|
12080
|
-
*
|
|
12081
|
-
* const pavingProject = await projectStore.create({name: "12th Street Paving"});
|
|
12299
|
+
* const pavingProject = await myHub.projects.create({name: "12th Street Paving"});
|
|
12082
12300
|
* pavingProject.summary = "This is the 2024 planned paving of 12th Street, between 8th and 11th Ave";
|
|
12083
|
-
* await
|
|
12301
|
+
* await myHub.projects.update(pavingProject);
|
|
12084
12302
|
* ```
|
|
12085
12303
|
*
|
|
12086
|
-
* This is a convenience class. Hub
|
|
12304
|
+
* This is a convenience class. Hub Managers can be created
|
|
12087
12305
|
* directly, or the underlying functions can be imported an used
|
|
12088
12306
|
* as need for scenarios where these class structures introduce
|
|
12089
12307
|
* unwanted complexity
|
|
12090
12308
|
*/
|
|
12091
12309
|
var Hub = /** @class */ (function () {
|
|
12092
12310
|
/**
|
|
12093
|
-
* Private so we can employ a factory function
|
|
12311
|
+
* Private so we can employ a factory function to do
|
|
12094
12312
|
* async work during creation
|
|
12095
12313
|
* @param contextManager
|
|
12096
12314
|
*/
|
|
@@ -12098,9 +12316,7 @@
|
|
|
12098
12316
|
this._contextManager = contextManager;
|
|
12099
12317
|
}
|
|
12100
12318
|
/**
|
|
12101
|
-
* Factory function to construct a new
|
|
12102
|
-
*
|
|
12103
|
-
* Note: Used so that we could do async actions in the ctor.
|
|
12319
|
+
* Factory function to construct a new Hub instance.
|
|
12104
12320
|
* @param contextManager
|
|
12105
12321
|
* @returns
|
|
12106
12322
|
*/
|
|
@@ -12134,7 +12350,7 @@
|
|
|
12134
12350
|
});
|
|
12135
12351
|
Object.defineProperty(Hub.prototype, "projects", {
|
|
12136
12352
|
/**
|
|
12137
|
-
*
|
|
12353
|
+
* HubProjectManager for the current Hub
|
|
12138
12354
|
* @returns
|
|
12139
12355
|
*/
|
|
12140
12356
|
get: function () {
|
|
@@ -12566,9 +12782,12 @@
|
|
|
12566
12782
|
exports.fetchAndUploadThumbnail = fetchAndUploadThumbnail;
|
|
12567
12783
|
exports.fetchHubTranslation = fetchHubTranslation;
|
|
12568
12784
|
exports.fetchImageAsBlob = fetchImageAsBlob;
|
|
12785
|
+
exports.fetchModelFromItem = fetchModelFromItem;
|
|
12786
|
+
exports.fetchProject = fetchProject;
|
|
12569
12787
|
exports.fetchSite = fetchSite;
|
|
12570
12788
|
exports.filterBy = filterBy;
|
|
12571
12789
|
exports.findBy = findBy;
|
|
12790
|
+
exports.findItemsBySlug = findItemsBySlug;
|
|
12572
12791
|
exports.flattenArray = flattenArray;
|
|
12573
12792
|
exports.generateRandomString = generateRandomString;
|
|
12574
12793
|
exports.getCategory = getCategory;
|
|
@@ -12609,7 +12828,6 @@
|
|
|
12609
12828
|
exports.getPortalApiUrl = getPortalApiUrl;
|
|
12610
12829
|
exports.getPortalBaseFromOrgUrl = getPortalBaseFromOrgUrl;
|
|
12611
12830
|
exports.getPortalUrl = getPortalUrl;
|
|
12612
|
-
exports.getProject = getProject;
|
|
12613
12831
|
exports.getProp = getProp;
|
|
12614
12832
|
exports.getProps = getProps;
|
|
12615
12833
|
exports.getProxyUrl = getProxyUrl;
|
|
@@ -12681,6 +12899,7 @@
|
|
|
12681
12899
|
exports.replaceItemId = replaceItemId;
|
|
12682
12900
|
exports.runRevertableTask = runRevertableTask;
|
|
12683
12901
|
exports.saveSession = saveSession;
|
|
12902
|
+
exports.searchProjects = searchProjects;
|
|
12684
12903
|
exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
|
|
12685
12904
|
exports.serializeDateRange = serializeDateRange;
|
|
12686
12905
|
exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
|
|
@@ -12692,6 +12911,7 @@
|
|
|
12692
12911
|
exports.setContentHubId = setContentHubId;
|
|
12693
12912
|
exports.setContentSiteUrls = setContentSiteUrls;
|
|
12694
12913
|
exports.setContentType = setContentType;
|
|
12914
|
+
exports.setItemThumbnail = setItemThumbnail;
|
|
12695
12915
|
exports.setProp = setProp;
|
|
12696
12916
|
exports.setSlugKeyword = setSlugKeyword;
|
|
12697
12917
|
exports.shareItemToGroups = shareItemToGroups;
|