@esri/hub-common 11.0.0 → 11.3.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/esm/core/HubItemEntity.js +202 -0
- package/dist/esm/core/HubItemEntity.js.map +1 -0
- package/dist/esm/core/_internal/getBasePropertyMap.js +57 -0
- package/dist/esm/core/_internal/getBasePropertyMap.js.map +1 -0
- package/dist/esm/core/behaviors/IWithThumbnailBehavior.js +1 -0
- package/dist/esm/core/behaviors/IWithThumbnailBehavior.js.map +1 -0
- package/dist/esm/core/traits/IWithCatalog.js +1 -0
- package/dist/esm/core/traits/IWithCatalog.js.map +1 -0
- package/dist/esm/core/traits/index.js +1 -0
- package/dist/esm/core/traits/index.js.map +1 -1
- package/dist/esm/core/types/IEntityResource.js +1 -0
- package/dist/esm/core/types/IEntityResource.js.map +1 -0
- package/dist/esm/core/types/IItemResource.js +1 -0
- package/dist/esm/core/types/IItemResource.js.map +1 -0
- package/dist/esm/core/types/index.js +0 -2
- package/dist/esm/core/types/index.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/initiatives/HubInitiative.js +149 -0
- package/dist/esm/initiatives/HubInitiative.js.map +1 -0
- package/dist/esm/initiatives/HubInitiatives.js +205 -0
- package/dist/esm/initiatives/HubInitiatives.js.map +1 -0
- package/dist/esm/initiatives/defaults.js +31 -0
- package/dist/esm/initiatives/defaults.js.map +1 -0
- package/dist/esm/initiatives/index.js +3 -0
- package/dist/esm/initiatives/index.js.map +1 -0
- package/dist/esm/items/setItemThumbnail.js +1 -0
- package/dist/esm/items/setItemThumbnail.js.map +1 -1
- package/dist/esm/projects/HubProject.js +9 -65
- package/dist/esm/projects/HubProject.js.map +1 -1
- package/dist/esm/projects/HubProjects.js +13 -54
- package/dist/esm/projects/HubProjects.js.map +1 -1
- package/dist/esm/projects/defaults.js +2 -1
- package/dist/esm/projects/defaults.js.map +1 -1
- package/dist/esm/urls/get-campaign-url.js +25 -0
- package/dist/esm/urls/get-campaign-url.js.map +1 -0
- package/dist/esm/urls/index.js +1 -0
- package/dist/esm/urls/index.js.map +1 -1
- package/dist/node/core/HubItemEntity.js +206 -0
- package/dist/node/core/HubItemEntity.js.map +1 -0
- package/dist/node/core/_internal/getBasePropertyMap.js +61 -0
- package/dist/node/core/_internal/getBasePropertyMap.js.map +1 -0
- package/dist/node/core/{traits/IWithCatalogDefinition.js → behaviors/IWithThumbnailBehavior.js} +1 -1
- package/dist/node/core/behaviors/IWithThumbnailBehavior.js.map +1 -0
- package/dist/node/core/{types/IHubEntityManager.js → traits/IWithCatalog.js} +1 -1
- package/dist/node/core/traits/IWithCatalog.js.map +1 -0
- package/dist/node/core/traits/index.js +1 -0
- package/dist/node/core/traits/index.js.map +1 -1
- package/dist/node/core/types/{IHubItemEntityManager.js → IEntityResource.js} +1 -1
- package/dist/node/core/types/IEntityResource.js.map +1 -0
- package/dist/node/core/types/IItemResource.js +3 -0
- package/dist/node/core/types/IItemResource.js.map +1 -0
- package/dist/node/core/types/index.js +0 -2
- package/dist/node/core/types/index.js.map +1 -1
- package/dist/node/index.js +1 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/initiatives/HubInitiative.js +153 -0
- package/dist/node/initiatives/HubInitiative.js.map +1 -0
- package/dist/node/initiatives/HubInitiatives.js +214 -0
- package/dist/node/initiatives/HubInitiatives.js.map +1 -0
- package/dist/node/initiatives/defaults.js +34 -0
- package/dist/node/initiatives/defaults.js.map +1 -0
- package/dist/node/initiatives/index.js +6 -0
- package/dist/node/initiatives/index.js.map +1 -0
- package/dist/node/items/setItemThumbnail.js +1 -0
- package/dist/node/items/setItemThumbnail.js.map +1 -1
- package/dist/node/projects/HubProject.js +9 -65
- package/dist/node/projects/HubProject.js.map +1 -1
- package/dist/node/projects/HubProjects.js +13 -54
- package/dist/node/projects/HubProjects.js.map +1 -1
- package/dist/node/projects/defaults.js +2 -1
- package/dist/node/projects/defaults.js.map +1 -1
- package/dist/node/urls/get-campaign-url.js +29 -0
- package/dist/node/urls/get-campaign-url.js.map +1 -0
- package/dist/node/urls/index.js +1 -0
- package/dist/node/urls/index.js.map +1 -1
- package/dist/types/content/_internal.d.ts +9 -8
- package/dist/types/core/HubItemEntity.d.ts +83 -0
- package/dist/types/core/_internal/getBasePropertyMap.d.ts +7 -0
- package/dist/types/core/behaviors/IWithStoreBehavior.d.ts +10 -0
- package/dist/types/core/behaviors/IWithThumbnailBehavior.d.ts +21 -0
- package/dist/types/core/traits/{IWithCatalogDefinition.d.ts → IWithCatalog.d.ts} +0 -0
- package/dist/types/core/traits/IWithPermissions.d.ts +1 -1
- package/dist/types/core/traits/index.d.ts +1 -0
- package/dist/types/core/types/IEntityResource.d.ts +21 -0
- package/dist/types/core/types/IHubContent.d.ts +1 -1
- package/dist/types/core/types/IHubInitiative.d.ts +2 -2
- package/dist/types/core/types/IHubItemEntity.d.ts +29 -16
- package/dist/types/core/types/IHubProject.d.ts +3 -3
- package/dist/types/core/types/IItemResource.d.ts +9 -0
- package/dist/types/core/types/index.d.ts +0 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/initiatives/HubInitiative.d.ts +67 -0
- package/dist/types/initiatives/HubInitiatives.d.ts +55 -0
- package/dist/types/initiatives/defaults.d.ts +11 -0
- package/dist/types/initiatives/index.d.ts +2 -0
- package/dist/types/projects/HubProject.d.ts +7 -33
- package/dist/types/urls/get-campaign-url.d.ts +22 -0
- package/dist/types/urls/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/esm/core/traits/IWithCatalogDefinition.js +0 -1
- package/dist/esm/core/traits/IWithCatalogDefinition.js.map +0 -1
- package/dist/esm/core/types/IHubEntityManager.js +0 -1
- package/dist/esm/core/types/IHubEntityManager.js.map +0 -1
- package/dist/esm/core/types/IHubItemEntityManager.js +0 -1
- package/dist/esm/core/types/IHubItemEntityManager.js.map +0 -1
- package/dist/node/core/traits/IWithCatalogDefinition.js.map +0 -1
- package/dist/node/core/types/IHubEntityManager.js.map +0 -1
- package/dist/node/core/types/IHubItemEntityManager.js.map +0 -1
- package/dist/types/core/types/IHubEntityManager.d.ts +0 -46
- package/dist/types/core/types/IHubItemEntityManager.d.ts +0 -25
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubItemEntity = void 0;
|
|
4
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
const setItemThumbnail_1 = require("../items/setItemThumbnail");
|
|
6
|
+
const resources_1 = require("../resources");
|
|
7
|
+
const util_1 = require("../util");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const sharedWith_1 = require("./_internal/sharedWith");
|
|
10
|
+
/**
|
|
11
|
+
* Base class for all Hub Entities backed by items
|
|
12
|
+
*/
|
|
13
|
+
class HubItemEntity {
|
|
14
|
+
constructor(entity, context) {
|
|
15
|
+
this.isDestroyed = false;
|
|
16
|
+
this.thumbnailCache = null;
|
|
17
|
+
this.context = context;
|
|
18
|
+
this.entity = entity;
|
|
19
|
+
}
|
|
20
|
+
// Although we don't expose all the properties, we do expose a few for convenience
|
|
21
|
+
/**
|
|
22
|
+
* Return the entity id
|
|
23
|
+
*/
|
|
24
|
+
get id() {
|
|
25
|
+
return this.entity.id;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Return the entity owner
|
|
29
|
+
*/
|
|
30
|
+
get owner() {
|
|
31
|
+
return this.entity.owner;
|
|
32
|
+
}
|
|
33
|
+
//#region IWithStoreBehavior
|
|
34
|
+
/**
|
|
35
|
+
* Return the backing entity as an object literal
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
toJson() {
|
|
39
|
+
if (this.isDestroyed) {
|
|
40
|
+
throw new Error("Entity is already destroyed.");
|
|
41
|
+
}
|
|
42
|
+
return util_1.cloneObject(this.entity);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Can the current user edit the Entity?
|
|
46
|
+
* In order to edit an item, the user must be the owner of the item
|
|
47
|
+
* or be a member of a shared editing group, to which the item is shared.
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
async canEdit() {
|
|
51
|
+
const user = this.context.currentUser;
|
|
52
|
+
// owner can always edit
|
|
53
|
+
if (user.username === this.entity.owner) {
|
|
54
|
+
return Promise.resolve(true);
|
|
55
|
+
}
|
|
56
|
+
// Fetch the user's groups by fetching the user
|
|
57
|
+
// we do this each time to ensure we have the latest groups
|
|
58
|
+
const u = await arcgis_rest_portal_1.getUser(user.username);
|
|
59
|
+
const usersGroups = u.groups;
|
|
60
|
+
if (!usersGroups.length) {
|
|
61
|
+
// if user is not owner and not in any groups they can't have edit access
|
|
62
|
+
return Promise.resolve(false);
|
|
63
|
+
}
|
|
64
|
+
// get the groups the entity is shared to
|
|
65
|
+
const entityGroups = await this.sharedWith();
|
|
66
|
+
// filter to shared edit groups
|
|
67
|
+
const editGroupIds = entityGroups
|
|
68
|
+
.filter((g) => {
|
|
69
|
+
const caps = g.capabilities || [];
|
|
70
|
+
return caps.includes("updateitemcontrol");
|
|
71
|
+
})
|
|
72
|
+
.map((g) => g.id);
|
|
73
|
+
// get the user's groups ids
|
|
74
|
+
const usersGroupsIds = utils_1.mapBy("id", usersGroups);
|
|
75
|
+
// check for any overlap
|
|
76
|
+
let isMemberOfEditGroup = false;
|
|
77
|
+
for (const id of usersGroupsIds) {
|
|
78
|
+
isMemberOfEditGroup = editGroupIds.includes(id);
|
|
79
|
+
if (isMemberOfEditGroup) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return Promise.resolve(isMemberOfEditGroup);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Can the current user delete the Entity?
|
|
87
|
+
* In order to delete an item, the user must be the owner of the item or a full org_admin
|
|
88
|
+
* in the owner's organization.
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
async canDelete() {
|
|
92
|
+
const user = this.context.currentUser;
|
|
93
|
+
// owner can always delete
|
|
94
|
+
if (user.username === this.entity.owner) {
|
|
95
|
+
return Promise.resolve(true);
|
|
96
|
+
}
|
|
97
|
+
// if not owner, check if user is org_admin in same org as owner
|
|
98
|
+
if (user.role === "org_admin" && !user.roleId) {
|
|
99
|
+
// need to get the owner, and see if the orgid matches
|
|
100
|
+
const ownerUser = await arcgis_rest_portal_1.getUser({
|
|
101
|
+
username: this.entity.owner,
|
|
102
|
+
authentication: this.context.session,
|
|
103
|
+
});
|
|
104
|
+
// ensure owner orgId is not null and matched current user
|
|
105
|
+
const adminCanDelete = ownerUser.orgId && ownerUser.orgId === user.orgId;
|
|
106
|
+
return Promise.resolve(adminCanDelete);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// not org admin, can't edit
|
|
110
|
+
return Promise.resolve(false);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//#endregion IWithStoreBehavior
|
|
114
|
+
//#region IWithSharingBehavior
|
|
115
|
+
/**
|
|
116
|
+
* Share the Entity with the specified group id
|
|
117
|
+
* @param groupId
|
|
118
|
+
*/
|
|
119
|
+
async shareWithGroup(groupId) {
|
|
120
|
+
await arcgis_rest_portal_1.shareItemWithGroup({
|
|
121
|
+
id: this.entity.id,
|
|
122
|
+
groupId,
|
|
123
|
+
owner: this.entity.owner,
|
|
124
|
+
authentication: this.context.session,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Unshare the Entity with the specified group id
|
|
129
|
+
* @param groupId
|
|
130
|
+
*/
|
|
131
|
+
async unshareWithGroup(groupId) {
|
|
132
|
+
await arcgis_rest_portal_1.unshareItemWithGroup({
|
|
133
|
+
id: this.entity.id,
|
|
134
|
+
groupId,
|
|
135
|
+
owner: this.entity.owner,
|
|
136
|
+
authentication: this.context.session,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Set the access level of the backing item
|
|
141
|
+
* @param access
|
|
142
|
+
*/
|
|
143
|
+
async setAccess(access) {
|
|
144
|
+
await arcgis_rest_portal_1.setItemAccess({
|
|
145
|
+
id: this.entity.id,
|
|
146
|
+
access,
|
|
147
|
+
authentication: this.context.session,
|
|
148
|
+
});
|
|
149
|
+
// if this succeeded, update the entity
|
|
150
|
+
this.entity.access = access;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Return a list of groups the Entity is shared to.
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
async sharedWith() {
|
|
157
|
+
// delegate to a util that merges the three arrays returned from the api, into a single array
|
|
158
|
+
return sharedWith_1.sharedWith(this.entity.id, this.context.requestOptions);
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
/**
|
|
162
|
+
* Hook that subclasses should call to invoke shared post-save behavior
|
|
163
|
+
*/
|
|
164
|
+
async afterSave() {
|
|
165
|
+
// Handle Thumbnails
|
|
166
|
+
// check if there is a thumbnail in the cache
|
|
167
|
+
if (this.thumbnailCache) {
|
|
168
|
+
// save the thumbnail
|
|
169
|
+
await setItemThumbnail_1.setItemThumbnail(this.entity.id, this.thumbnailCache.file, this.thumbnailCache.filename, this.context.userRequestOptions);
|
|
170
|
+
// Note: updating the thumbnail alone does not update the modified date of the item
|
|
171
|
+
// thus we can just set props on the entity w/o re-fetching
|
|
172
|
+
this.entity.thumbnail = `thumbnail/${this.thumbnailCache.filename}`;
|
|
173
|
+
this.entity.thumbnailUrl = this.getThumbnailUrl();
|
|
174
|
+
// clear the thumbnail cache
|
|
175
|
+
this.thumbnailCache = null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//#region IWithThumbnailBehavior
|
|
179
|
+
/**
|
|
180
|
+
* Store thumbnail information to be sent with the next `.save()` call
|
|
181
|
+
* @param file
|
|
182
|
+
* @param filename
|
|
183
|
+
*/
|
|
184
|
+
setThumbnail(file, filename) {
|
|
185
|
+
// subclass is responsible for handling the implementation during the `.save()` call
|
|
186
|
+
this.thumbnailCache = { file, filename };
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Return the full url to the thumbnail, optionally with a width parameter
|
|
190
|
+
* @param width
|
|
191
|
+
*/
|
|
192
|
+
getThumbnailUrl(width = 200) {
|
|
193
|
+
const minimalItem = {
|
|
194
|
+
id: this.entity.id,
|
|
195
|
+
access: this.entity.access,
|
|
196
|
+
thumbnail: this.entity.thumbnail,
|
|
197
|
+
};
|
|
198
|
+
const opts = {
|
|
199
|
+
token: this.context.session.token,
|
|
200
|
+
width,
|
|
201
|
+
};
|
|
202
|
+
return resources_1.getItemThumbnailUrl(minimalItem, this.context.requestOptions, opts);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.HubItemEntity = HubItemEntity;
|
|
206
|
+
//# sourceMappingURL=HubItemEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HubItemEntity.js","sourceRoot":"","sources":["../../../src/core/HubItemEntity.ts"],"names":[],"mappings":";;;AAAA,iEAOkC;AAElC,gEAA6D;AAC7D,4CAAsE;AACtE,kCAAsC;AACtC,oCAAiC;AAIjC,uDAAoD;AAEpD;;GAEG;AACH,MAAsB,aAAa;IAWjC,YAAY,MAAS,EAAE,OAAuB;QAHpC,gBAAW,GAAY,KAAK,CAAC;QAC7B,mBAAc,GAAoC,IAAI,CAAC;QAG/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,kFAAkF;IAClF;;OAEG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,4BAA4B;IAE5B;;;OAGG;IACH,MAAM;QACJ,IAAI,IAAI,CAA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C5B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IAED,gCAAgC;IAEhC;;;;OAIG;IACH,YAAY,CAAC,IAAS,EAAE,QAAgB;QACtC,oFAAoF;QACpF,IAAI,CAAC,cAAc,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC3C,CAAC;IACD;;;OAGG;IACH,eAAe,CAAC,QAAgB,GAAG;QACjC,MAAM,WAAW,GAAG;YAClB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC1B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;SACb,CAAC;QAEtB,MAAM,IAAI,GAAsB;YAC9B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK;YACjC,KAAK;SACN,CAAC;QAEF,OAAO,+BAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAC7E,CAAC;CAEF;AAjOD,sCAiOC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBasePropertyMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns an Array of IPropertyMap objects
|
|
6
|
+
* that define the standard projection of properties from a IModel an entity interface
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
function getBasePropertyMap() {
|
|
10
|
+
const itemProps = [
|
|
11
|
+
"access",
|
|
12
|
+
"created",
|
|
13
|
+
"culture",
|
|
14
|
+
"description",
|
|
15
|
+
"extent",
|
|
16
|
+
"id",
|
|
17
|
+
"modified",
|
|
18
|
+
"owner",
|
|
19
|
+
"tags",
|
|
20
|
+
"type",
|
|
21
|
+
"typeKeywords",
|
|
22
|
+
"thumbnail",
|
|
23
|
+
"url",
|
|
24
|
+
];
|
|
25
|
+
const dataProps = ["display", "geometry", "location"];
|
|
26
|
+
const map = [];
|
|
27
|
+
itemProps.forEach((entry) => {
|
|
28
|
+
map.push({ objectKey: entry, modelKey: `item.${entry}` });
|
|
29
|
+
});
|
|
30
|
+
dataProps.forEach((entry) => {
|
|
31
|
+
map.push({ objectKey: entry, modelKey: `data.${entry}` });
|
|
32
|
+
});
|
|
33
|
+
// Deeper mappings
|
|
34
|
+
map.push({
|
|
35
|
+
objectKey: "slug",
|
|
36
|
+
modelKey: "item.properties.slug",
|
|
37
|
+
});
|
|
38
|
+
map.push({
|
|
39
|
+
objectKey: "summary",
|
|
40
|
+
modelKey: "item.snippet",
|
|
41
|
+
});
|
|
42
|
+
map.push({
|
|
43
|
+
objectKey: "schemaVersion",
|
|
44
|
+
modelKey: "item.properties.schemaVersion",
|
|
45
|
+
});
|
|
46
|
+
map.push({
|
|
47
|
+
objectKey: "orgUrlKey",
|
|
48
|
+
modelKey: "item.properties.orgUrlKey",
|
|
49
|
+
});
|
|
50
|
+
map.push({
|
|
51
|
+
objectKey: "name",
|
|
52
|
+
modelKey: "item.title",
|
|
53
|
+
});
|
|
54
|
+
map.push({
|
|
55
|
+
objectKey: "boundary",
|
|
56
|
+
modelKey: "item.properties.boundary",
|
|
57
|
+
});
|
|
58
|
+
return map;
|
|
59
|
+
}
|
|
60
|
+
exports.getBasePropertyMap = getBasePropertyMap;
|
|
61
|
+
//# sourceMappingURL=getBasePropertyMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBasePropertyMap.js","sourceRoot":"","sources":["../../../../src/core/_internal/getBasePropertyMap.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,SAAgB,kBAAkB;IAChC,MAAM,SAAS,GAAG;QAChB,QAAQ;QACR,SAAS;QACT,SAAS;QACT,aAAa;QACb,QAAQ;QACR,IAAI;QACJ,UAAU;QACV,OAAO;QACP,MAAM;QACN,MAAM;QACN,cAAc;QACd,WAAW;QACX,KAAK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["../../../../src/core/behaviors/IWithThumbnailBehavior.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IWithCatalog.js","sourceRoot":"","sources":["../../../../src/core/traits/IWithCatalog.ts"],"names":[],"mappings":""}
|
|
@@ -5,4 +5,5 @@ tslib_1.__exportStar(require("./IWithBannerImage"), exports);
|
|
|
5
5
|
tslib_1.__exportStar(require("./IWithLayout"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./IWithSlug"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./IWithPermissions"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./IWithCatalog"), exports);
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/traits/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,wDAA8B;AAC9B,sDAA4B;AAC5B,6DAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/traits/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,wDAA8B;AAC9B,sDAA4B;AAC5B,6DAAmC;AACnC,yDAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityResource.js","sourceRoot":"","sources":["../../../../src/core/types/IEntityResource.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IItemResource.js","sourceRoot":"","sources":["../../../../src/core/types/IItemResource.ts"],"names":[],"mappings":""}
|
|
@@ -4,12 +4,10 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./IHubContent"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./IHubContentEnrichments"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./IHubEntityBase"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./IHubEntityManager"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./IHubEvent"), exports);
|
|
9
8
|
tslib_1.__exportStar(require("./IHubImage"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./IHubInitiative"), exports);
|
|
11
10
|
tslib_1.__exportStar(require("./IHubItemEntity"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./IHubItemEntityManager"), exports);
|
|
13
11
|
tslib_1.__exportStar(require("./IHubLayout"), exports);
|
|
14
12
|
tslib_1.__exportStar(require("./IHubPage"), exports);
|
|
15
13
|
tslib_1.__exportStar(require("./IHubProject"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/types/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,mEAAyC;AACzC,2DAAiC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/types/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,mEAAyC;AACzC,2DAAiC;AAEjC,sDAA4B;AAC5B,sDAA4B;AAC5B,2DAAiC;AACjC,2DAAiC;AAEjC,uDAA6B;AAC7B,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,0DAAgC;AAChC,yDAA+B;AAC/B,6DAAmC;AACnC,+DAAqC;AACrC,kDAAwB;AACxB,2DAAiC"}
|
package/dist/node/index.js
CHANGED
|
@@ -21,6 +21,7 @@ tslib_1.__exportStar(require("./items"), exports);
|
|
|
21
21
|
tslib_1.__exportStar(require("./models"), exports);
|
|
22
22
|
tslib_1.__exportStar(require("./objects"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("./projects"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./initiatives"), exports);
|
|
24
25
|
tslib_1.__exportStar(require("./request"), exports);
|
|
25
26
|
tslib_1.__exportStar(require("./resources"), exports);
|
|
26
27
|
tslib_1.__exportStar(require("./search"), exports);
|
|
@@ -43,6 +44,4 @@ exports.HubError = HubError_1.default;
|
|
|
43
44
|
var abab_1 = require("abab");
|
|
44
45
|
Object.defineProperty(exports, "btoa", { enumerable: true, get: function () { return abab_1.btoa; } });
|
|
45
46
|
Object.defineProperty(exports, "atob", { enumerable: true, get: function () { return abab_1.atob; } });
|
|
46
|
-
// This will be moved to another package
|
|
47
|
-
// export * from "./Hub";
|
|
48
47
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;gBACgB;AAChB,0BAA0B;;;;AAE1B,mDAAyB;AACzB,gDAAsB;AACtB,0DAAgC;AAChC,iEAAuC;AACvC,iDAAuB;AACvB,uDAA6B;AAC7B,oDAA0B;AAC1B,iDAAuB;AACvB,sDAA4B;AAC5B,mDAAyB;AACzB,mDAAyB;AACzB,iDAAuB;AACvB,kDAAwB;AACxB,mDAAyB;AACzB,oDAA0B;AAC1B,qDAA2B;AAC3B,oDAA0B;AAC1B,sDAA4B;AAC5B,mDAAyB;AACzB,kDAAwB;AACxB,oDAA0B;AAC1B,kDAAwB;AACxB,iDAAuB;AACvB,iDAAuB;AACvB,kDAAwB;AAExB,kDAAwB;AACxB,gDAAsB;AACtB,kDAAwB;AACxB,kDAAwB;AAExB,qDAA8C;AAKrC,yBALF,wBAAc,CAKE;AAJvB,qDAA8C;AAIrB,yBAJlB,wBAAc,CAIkB;AAHvC,yCAAkC;AAGO,mBAHlC,kBAAQ,CAGkC;AACjD,6BAAkC;AAAzB,4FAAA,IAAI,OAAA;AAAE,4FAAA,IAAI,OAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;gBACgB;AAChB,0BAA0B;;;;AAE1B,mDAAyB;AACzB,gDAAsB;AACtB,0DAAgC;AAChC,iEAAuC;AACvC,iDAAuB;AACvB,uDAA6B;AAC7B,oDAA0B;AAC1B,iDAAuB;AACvB,sDAA4B;AAC5B,mDAAyB;AACzB,mDAAyB;AACzB,iDAAuB;AACvB,kDAAwB;AACxB,mDAAyB;AACzB,oDAA0B;AAC1B,qDAA2B;AAC3B,wDAA8B;AAC9B,oDAA0B;AAC1B,sDAA4B;AAC5B,mDAAyB;AACzB,kDAAwB;AACxB,oDAA0B;AAC1B,kDAAwB;AACxB,iDAAuB;AACvB,iDAAuB;AACvB,kDAAwB;AAExB,kDAAwB;AACxB,gDAAsB;AACtB,kDAAwB;AACxB,kDAAwB;AAExB,qDAA8C;AAKrC,yBALF,wBAAc,CAKE;AAJvB,qDAA8C;AAIrB,yBAJlB,wBAAc,CAIkB;AAHvC,yCAAkC;AAGO,mBAHlC,kBAAQ,CAGkC;AACjD,6BAAkC;AAAzB,4FAAA,IAAI,OAAA;AAAE,4FAAA,IAAI,OAAA"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubInitiative = void 0;
|
|
4
|
+
const defaults_1 = require("./defaults");
|
|
5
|
+
const core_1 = require("../core");
|
|
6
|
+
const HubInitiatives_1 = require("./HubInitiatives");
|
|
7
|
+
const Catalog_1 = require("../search/Catalog");
|
|
8
|
+
const HubItemEntity_1 = require("../core/HubItemEntity");
|
|
9
|
+
/**
|
|
10
|
+
* Hub Initiative Class
|
|
11
|
+
*/
|
|
12
|
+
class HubInitiative extends HubItemEntity_1.HubItemEntity {
|
|
13
|
+
/**
|
|
14
|
+
* Private constructor so we don't have `new` all over the place. Allows for
|
|
15
|
+
* more flexibility in how we create the HubInitiativeManager over time.
|
|
16
|
+
* @param context
|
|
17
|
+
*/
|
|
18
|
+
constructor(entity, context) {
|
|
19
|
+
super(entity, context);
|
|
20
|
+
this._catalog = Catalog_1.Catalog.fromJson(entity.catalog, this.context);
|
|
21
|
+
this._permissionManager = core_1.PermissionManager.fromJson(entity.permissions, this.context);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Catalog instance for this Initiative. Note: Do not hold direct references to this object; always access it from the Initiative.
|
|
25
|
+
* @returns Catalog
|
|
26
|
+
*/
|
|
27
|
+
get catalog() {
|
|
28
|
+
return this._catalog;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* PermissionManager instance for this Initiative. Note: Do not hold direct references to this object; always access it from the Initiative.
|
|
32
|
+
* @returns PermissionManager
|
|
33
|
+
*/
|
|
34
|
+
get permissions() {
|
|
35
|
+
return this._permissionManager;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create an instance from an IHubInitiative object
|
|
39
|
+
* @param json - JSON object to create a HubInitiative from
|
|
40
|
+
* @param context - ArcGIS context
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static fromJson(json, context) {
|
|
44
|
+
// merge what we have with the default values
|
|
45
|
+
const pojo = this.applyDefaults(json, context);
|
|
46
|
+
return new HubInitiative(pojo, context);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a new HubInitiative, returning a HubInitiative instance.
|
|
50
|
+
* Note: This does not persist the Initiative into the backing store
|
|
51
|
+
* @param partialInitiative
|
|
52
|
+
* @param context
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
static async create(partialInitiative, context, save = false) {
|
|
56
|
+
const pojo = this.applyDefaults(partialInitiative, context);
|
|
57
|
+
// return an instance of HubInitiative
|
|
58
|
+
const instance = HubInitiative.fromJson(pojo, context);
|
|
59
|
+
if (save) {
|
|
60
|
+
await instance.save();
|
|
61
|
+
}
|
|
62
|
+
return instance;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Fetch an Initiative from the backing store and return a HubInitiative instance.
|
|
66
|
+
* @param identifier - slug or item id
|
|
67
|
+
* @param context
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
static async fetch(identifier, context) {
|
|
71
|
+
// fetch by id or slug
|
|
72
|
+
try {
|
|
73
|
+
const entity = await HubInitiatives_1.fetchInitiative(identifier, context.requestOptions);
|
|
74
|
+
// create an instance of HubInitiative from the entity
|
|
75
|
+
return HubInitiative.fromJson(entity, context);
|
|
76
|
+
}
|
|
77
|
+
catch (ex) {
|
|
78
|
+
if (ex.message ===
|
|
79
|
+
"CONT_0001: Item does not exist or is inaccessible.") {
|
|
80
|
+
throw new Error(`Initiative not found.`);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw ex;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
static applyDefaults(partialInitiative, context) {
|
|
88
|
+
// ensure we have the orgUrlKey
|
|
89
|
+
if (!partialInitiative.orgUrlKey) {
|
|
90
|
+
partialInitiative.orgUrlKey = context.portal.urlKey;
|
|
91
|
+
}
|
|
92
|
+
// extend the partial over the defaults
|
|
93
|
+
const pojo = Object.assign(Object.assign({}, defaults_1.DEFAULT_INITIATIVE), partialInitiative);
|
|
94
|
+
return pojo;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Apply a new state to the instance
|
|
98
|
+
* @param changes
|
|
99
|
+
*/
|
|
100
|
+
update(changes) {
|
|
101
|
+
if (this.isDestroyed) {
|
|
102
|
+
throw new Error("HubInitiative is already destroyed.");
|
|
103
|
+
}
|
|
104
|
+
// merge partial onto existing entity
|
|
105
|
+
this.entity = Object.assign(Object.assign({}, this.entity), changes);
|
|
106
|
+
// update internal instances
|
|
107
|
+
if (changes.catalog) {
|
|
108
|
+
this._catalog = Catalog_1.Catalog.fromJson(this.entity.catalog, this.context);
|
|
109
|
+
}
|
|
110
|
+
if (changes.permissions) {
|
|
111
|
+
this._permissionManager = core_1.PermissionManager.fromJson(this.entity.permissions, this.context);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Save the HubInitiative to the backing store.
|
|
116
|
+
* Currently Initiatives are stored as Items in Portal
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
async save() {
|
|
120
|
+
if (this.isDestroyed) {
|
|
121
|
+
throw new Error("HubInitiative is already destroyed.");
|
|
122
|
+
}
|
|
123
|
+
// get the catalog, and permission configs
|
|
124
|
+
this.entity.catalog = this._catalog.toJson();
|
|
125
|
+
this.entity.permissions = this._permissionManager.toJson();
|
|
126
|
+
if (this.entity.id) {
|
|
127
|
+
// update it
|
|
128
|
+
this.entity = await HubInitiatives_1.updateInitiative(this.entity, this.context.userRequestOptions);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// create it
|
|
132
|
+
this.entity = await HubInitiatives_1.createInitiative(this.entity, this.context.userRequestOptions);
|
|
133
|
+
}
|
|
134
|
+
// call the after save hook on superclass
|
|
135
|
+
await super.afterSave();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Delete the HubInitiative from the store
|
|
140
|
+
* set a flag to indicate that it is destroyed
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
async delete() {
|
|
144
|
+
if (this.isDestroyed) {
|
|
145
|
+
throw new Error("HubInitiative is already destroyed.");
|
|
146
|
+
}
|
|
147
|
+
this.isDestroyed = true;
|
|
148
|
+
// Delegate to module fn
|
|
149
|
+
await HubInitiatives_1.deleteInitiative(this.entity.id, this.context.userRequestOptions);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.HubInitiative = HubInitiative;
|
|
153
|
+
//# sourceMappingURL=HubInitiative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HubInitiative.js","sourceRoot":"","sources":["../../../src/initiatives/HubInitiative.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAEhD,kCAOiB;AAEjB,qDAK0B;AAE1B,+CAA4C;AAE5C,yDAAsD;AAEtD;;GAEG;AACH,MAAa,aACX,SAAQ,6BAA6B;IASrC;;;;OAIG;IACH,YAAoB,MAAsB,EAAE,OAAuB;QACjE,KAAK,CAAC,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