@esri/hub-common 14.104.0 → 14.105.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/items/follow.js +102 -0
- package/dist/esm/items/follow.js.map +1 -0
- package/dist/esm/items/index.js +2 -0
- package/dist/esm/items/index.js.map +1 -1
- package/dist/esm/surveys/utils/get-s123-edit-url.js +4 -0
- package/dist/esm/surveys/utils/get-s123-edit-url.js.map +1 -0
- package/dist/esm/surveys/utils/index.js +1 -0
- package/dist/esm/surveys/utils/index.js.map +1 -1
- package/dist/node/items/follow.js +109 -0
- package/dist/node/items/follow.js.map +1 -0
- package/dist/node/items/index.js +2 -0
- package/dist/node/items/index.js.map +1 -1
- package/dist/node/surveys/utils/get-s123-edit-url.js +8 -0
- package/dist/node/surveys/utils/get-s123-edit-url.js.map +1 -0
- package/dist/node/surveys/utils/index.js +1 -0
- package/dist/node/surveys/utils/index.js.map +1 -1
- package/dist/types/items/follow.d.ts +50 -0
- package/dist/types/items/index.d.ts +2 -0
- package/dist/types/surveys/utils/get-s123-edit-url.d.ts +2 -0
- package/dist/types/surveys/utils/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { joinGroup, leaveGroup } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { fetchHubEntity } from "../core";
|
|
3
|
+
/**
|
|
4
|
+
* Get the entity's followers group id
|
|
5
|
+
* @param entityId entity id
|
|
6
|
+
* @param entityType entity type
|
|
7
|
+
* @param context context used to support fetchHubEntity so it has access
|
|
8
|
+
* to different types of request options based on the entity type
|
|
9
|
+
* @returns {string} entity's followers group id
|
|
10
|
+
*/
|
|
11
|
+
export async function getEntityFollowersGroupId(entityId, entityType, context) {
|
|
12
|
+
// entity's type is IWithFollowers as we only want to accept hub entities
|
|
13
|
+
// backed by item entities which extend IWithFollowers
|
|
14
|
+
let entity;
|
|
15
|
+
try {
|
|
16
|
+
entity = (await fetchHubEntity(entityType, entityId, context));
|
|
17
|
+
return entity.followersGroupId;
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
throw new Error(`Error fetching entity followers group ID: ${e}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether the user is currently following the entity
|
|
25
|
+
* @param entityOrId hub entity or entity id, type is IWithFollowers
|
|
26
|
+
* as we only want to accept hub entities backed by item entities which
|
|
27
|
+
* extend IWithFollowers
|
|
28
|
+
* @param user
|
|
29
|
+
* @param entityType
|
|
30
|
+
* @param context
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
33
|
+
export async function isUserFollowing(entityOrId, user, entityType, context) {
|
|
34
|
+
// get the entity's followers group id
|
|
35
|
+
let groupId;
|
|
36
|
+
if (typeof entityOrId === "string") {
|
|
37
|
+
groupId = await getEntityFollowersGroupId(entityOrId, entityType, context);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
groupId = entityOrId.followersGroupId;
|
|
41
|
+
}
|
|
42
|
+
// looks through the users group list and find the same group
|
|
43
|
+
const group = user.groups.find((g) => g.id === groupId);
|
|
44
|
+
return !!group;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Follow an entity
|
|
48
|
+
* @param entityId entity id
|
|
49
|
+
* @param user user who attempts to follow the entity
|
|
50
|
+
* @param entityType optional if entityOrId is a string
|
|
51
|
+
* @param context optional if entityOrId is a string
|
|
52
|
+
* @returns promise that resolves { success: true, username: user.username }
|
|
53
|
+
* or rejects with an error
|
|
54
|
+
*/
|
|
55
|
+
export async function followEntity(entityId, user, entityType, context) {
|
|
56
|
+
const isFollowing = await isUserFollowing(entityId, user, entityType, context);
|
|
57
|
+
// don't update if user is already following
|
|
58
|
+
if (isFollowing) {
|
|
59
|
+
return Promise.reject("User is already following this entity.");
|
|
60
|
+
}
|
|
61
|
+
const groupId = await getEntityFollowersGroupId(entityId, entityType, context);
|
|
62
|
+
try {
|
|
63
|
+
await joinGroup({
|
|
64
|
+
id: groupId,
|
|
65
|
+
authentication: context.hubRequestOptions.authentication,
|
|
66
|
+
});
|
|
67
|
+
// successfully joined the group
|
|
68
|
+
return { success: true, username: user.username };
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw new Error(`Error joining group: ${error}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Unfollow an entity
|
|
76
|
+
* @param entityId entity id
|
|
77
|
+
* @param user user who attempts to unfollow the entity
|
|
78
|
+
* @param entityType optional if entityOrId is a string
|
|
79
|
+
* @param context optional if entityOrId is a string
|
|
80
|
+
* @returns promise that resolves { success: true, username: user.username } or
|
|
81
|
+
* rejects with an error
|
|
82
|
+
*/
|
|
83
|
+
export async function unfollowEntity(entityId, user, entityType, context) {
|
|
84
|
+
const isFollowing = await isUserFollowing(entityId, user, entityType, context);
|
|
85
|
+
// don't update if user is not following
|
|
86
|
+
if (!isFollowing) {
|
|
87
|
+
return Promise.reject("User is not following this entity.");
|
|
88
|
+
}
|
|
89
|
+
const groupId = await getEntityFollowersGroupId(entityId, entityType, context);
|
|
90
|
+
try {
|
|
91
|
+
await leaveGroup({
|
|
92
|
+
id: groupId,
|
|
93
|
+
authentication: context.hubRequestOptions.authentication,
|
|
94
|
+
});
|
|
95
|
+
// successfully left the group
|
|
96
|
+
return { success: true, username: user.username };
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new Error(`Error leaving group: ${error}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=follow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../../../src/items/follow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,SAAS,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAiB,cAAc,EAAE,MAAM,SAAS,CAAC;AAIxD;;;;;;;G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AG,MAAM,yBAAyB,CAC7C,QAAQ,EACR,UAAU,EACV,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,SAAS,CAAC;YACd,EAAE,EAAE,OAAO;YACX,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC,cAAc;SACzD,CAAC,CAAC;QACH,gCAAgC;QAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;KACnD;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAC;KAClD;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAgB,EAChB,IAAW,EACX,UAA0B,EAC1B,OAAwB;IAExB,MAAM,WAAW,GAAG,MAAM,eAAe,CACvC,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,OAAO,CACR,CAAC;IACF,wCAAwC;IACxC,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,OAAO,CAAC,MAAM,CAAC,oCAAoC,CAAC,CAAC;KAC7D;IACD,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAC7C,QAAQ,EACR,UAAU,EACV,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,UAAU,CAAC;YACf,EAAE,EAAE,OAAO;YACX,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC,cAAc;SACzD,CAAC,CAAC;QACH,8BAA8B;QAC9B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;KACnD;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAC;KAClD;AACH,CAAC"}
|
package/dist/esm/items/index.js
CHANGED
|
@@ -24,6 +24,8 @@ export * from "./uploadImageResource";
|
|
|
24
24
|
export * from "./is-services-directory-disabled";
|
|
25
25
|
export * from "./getItemIdentifier";
|
|
26
26
|
export * from "./deleteItemThumbnail";
|
|
27
|
+
export * from "./deleteItemThumbnail";
|
|
28
|
+
export * from "./follow";
|
|
27
29
|
// No longer exported as the only App Hub needed this for was a Site
|
|
28
30
|
// and that registration is now done in the domain service with a
|
|
29
31
|
// signed HMAC request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/items/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,oCAAoC,CAAC;AACnD,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,oEAAoE;AACpE,iEAAiE;AACjE,uBAAuB;AACvB,wCAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/items/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,oCAAoC,CAAC;AACnD,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,oEAAoE;AACpE,iEAAiE;AACjE,uBAAuB;AACvB,wCAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-s123-edit-url.js","sourceRoot":"","sources":["../../../../src/surveys/utils/get-s123-edit-url.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,OAAuB;IAChE,OAAO,GAAG,OAAO,CAAC,YAAY,YAAY,EAAE,cAAc,kBAAkB,CAC1E,OAAO,CAAC,SAAS,CAClB,EAAE,CAAC;AACN,CAAC"}
|
|
@@ -3,6 +3,7 @@ export * from "./get-form-info-json";
|
|
|
3
3
|
export * from "./get-form-json";
|
|
4
4
|
export * from "./get-input-feature-service-model";
|
|
5
5
|
export * from "./get-map-question";
|
|
6
|
+
export * from "./get-s123-edit-url";
|
|
6
7
|
export * from "./get-s123-share-url";
|
|
7
8
|
export * from "./get-source-feature-service-model-from-fieldworker";
|
|
8
9
|
export * from "./get-stakeholder-model";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/surveys/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mCAAmC,CAAC;AAClD,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qDAAqD,CAAC;AACpE,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/surveys/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mCAAmC,CAAC;AAClD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qDAAqD,CAAC;AACpE,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unfollowEntity = exports.followEntity = exports.isUserFollowing = exports.getEntityFollowersGroupId = void 0;
|
|
4
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
5
|
+
const core_1 = require("../core");
|
|
6
|
+
/**
|
|
7
|
+
* Get the entity's followers group id
|
|
8
|
+
* @param entityId entity id
|
|
9
|
+
* @param entityType entity type
|
|
10
|
+
* @param context context used to support fetchHubEntity so it has access
|
|
11
|
+
* to different types of request options based on the entity type
|
|
12
|
+
* @returns {string} entity's followers group id
|
|
13
|
+
*/
|
|
14
|
+
async function getEntityFollowersGroupId(entityId, entityType, context) {
|
|
15
|
+
// entity's type is IWithFollowers as we only want to accept hub entities
|
|
16
|
+
// backed by item entities which extend IWithFollowers
|
|
17
|
+
let entity;
|
|
18
|
+
try {
|
|
19
|
+
entity = (await core_1.fetchHubEntity(entityType, entityId, context));
|
|
20
|
+
return entity.followersGroupId;
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new Error(`Error fetching entity followers group ID: ${e}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.getEntityFollowersGroupId = getEntityFollowersGroupId;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the user is currently following the entity
|
|
29
|
+
* @param entityOrId hub entity or entity id, type is IWithFollowers
|
|
30
|
+
* as we only want to accept hub entities backed by item entities which
|
|
31
|
+
* extend IWithFollowers
|
|
32
|
+
* @param user
|
|
33
|
+
* @param entityType
|
|
34
|
+
* @param context
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
async function isUserFollowing(entityOrId, user, entityType, context) {
|
|
38
|
+
// get the entity's followers group id
|
|
39
|
+
let groupId;
|
|
40
|
+
if (typeof entityOrId === "string") {
|
|
41
|
+
groupId = await getEntityFollowersGroupId(entityOrId, entityType, context);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
groupId = entityOrId.followersGroupId;
|
|
45
|
+
}
|
|
46
|
+
// looks through the users group list and find the same group
|
|
47
|
+
const group = user.groups.find((g) => g.id === groupId);
|
|
48
|
+
return !!group;
|
|
49
|
+
}
|
|
50
|
+
exports.isUserFollowing = isUserFollowing;
|
|
51
|
+
/**
|
|
52
|
+
* Follow an entity
|
|
53
|
+
* @param entityId entity id
|
|
54
|
+
* @param user user who attempts to follow the entity
|
|
55
|
+
* @param entityType optional if entityOrId is a string
|
|
56
|
+
* @param context optional if entityOrId is a string
|
|
57
|
+
* @returns promise that resolves { success: true, username: user.username }
|
|
58
|
+
* or rejects with an error
|
|
59
|
+
*/
|
|
60
|
+
async function followEntity(entityId, user, entityType, context) {
|
|
61
|
+
const isFollowing = await isUserFollowing(entityId, user, entityType, context);
|
|
62
|
+
// don't update if user is already following
|
|
63
|
+
if (isFollowing) {
|
|
64
|
+
return Promise.reject("User is already following this entity.");
|
|
65
|
+
}
|
|
66
|
+
const groupId = await getEntityFollowersGroupId(entityId, entityType, context);
|
|
67
|
+
try {
|
|
68
|
+
await arcgis_rest_portal_1.joinGroup({
|
|
69
|
+
id: groupId,
|
|
70
|
+
authentication: context.hubRequestOptions.authentication,
|
|
71
|
+
});
|
|
72
|
+
// successfully joined the group
|
|
73
|
+
return { success: true, username: user.username };
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw new Error(`Error joining group: ${error}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.followEntity = followEntity;
|
|
80
|
+
/**
|
|
81
|
+
* Unfollow an entity
|
|
82
|
+
* @param entityId entity id
|
|
83
|
+
* @param user user who attempts to unfollow the entity
|
|
84
|
+
* @param entityType optional if entityOrId is a string
|
|
85
|
+
* @param context optional if entityOrId is a string
|
|
86
|
+
* @returns promise that resolves { success: true, username: user.username } or
|
|
87
|
+
* rejects with an error
|
|
88
|
+
*/
|
|
89
|
+
async function unfollowEntity(entityId, user, entityType, context) {
|
|
90
|
+
const isFollowing = await isUserFollowing(entityId, user, entityType, context);
|
|
91
|
+
// don't update if user is not following
|
|
92
|
+
if (!isFollowing) {
|
|
93
|
+
return Promise.reject("User is not following this entity.");
|
|
94
|
+
}
|
|
95
|
+
const groupId = await getEntityFollowersGroupId(entityId, entityType, context);
|
|
96
|
+
try {
|
|
97
|
+
await arcgis_rest_portal_1.leaveGroup({
|
|
98
|
+
id: groupId,
|
|
99
|
+
authentication: context.hubRequestOptions.authentication,
|
|
100
|
+
});
|
|
101
|
+
// successfully left the group
|
|
102
|
+
return { success: true, username: user.username };
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw new Error(`Error leaving group: ${error}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.unfollowEntity = unfollowEntity;
|
|
109
|
+
//# sourceMappingURL=follow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../../../src/items/follow.ts"],"names":[],"mappings":";;;AAAA,iEAAwE;AACxE,kCAAwD;AAIxD;;;;;;;GAOG;AACI,KAAK,UAAU,yBAAyB,CAC7C,QAAgB,EAChB,UAAyB,EACzB,OAAuB;IAEvB,yEAAyE;IACzE,sDAAsD;IACtD,IAAI,MAAsB,CAAC;IAC3B,IAAI;QACF,MAAM,GAAG,CAAC,MAAM,qBAAc,CAC5B,UAAU,EACV,QAAQ,EACR,OAAO,CACR,CAAmB,CAAC;QACrB,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,EAAE,CAAC,CAAC;KACnE;AACH,CAAC;AAlBD,8DAkBC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,eAAe,CACnC,UAAmC,EACnC,IAAW,EACX,UAA0B,EAC1B,OAAwB;IAExB,sCAAsC;IACtC,IAAI,OAAe,CAAC;IACpB,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,GAAG,MAAM,yBAAyB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;KAC5E;SAAM;QACL,O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AM,CAAC,oCAAoC,CAAC,CAAC;KAC7D;IACD,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAC7C,QAAQ,EACR,UAAU,EACV,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,+BAAU,CAAC;YACf,EAAE,EAAE,OAAO;YACX,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC,cAAc;SACzD,CAAC,CAAC;QACH,8BAA8B;QAC9B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;KACnD;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAC;KAClD;AACH,CAAC;AA/BD,wCA+BC"}
|
package/dist/node/items/index.js
CHANGED
|
@@ -27,6 +27,8 @@ tslib_1.__exportStar(require("./uploadImageResource"), exports);
|
|
|
27
27
|
tslib_1.__exportStar(require("./is-services-directory-disabled"), exports);
|
|
28
28
|
tslib_1.__exportStar(require("./getItemIdentifier"), exports);
|
|
29
29
|
tslib_1.__exportStar(require("./deleteItemThumbnail"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./deleteItemThumbnail"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./follow"), exports);
|
|
30
32
|
// No longer exported as the only App Hub needed this for was a Site
|
|
31
33
|
// and that registration is now done in the domain service with a
|
|
32
34
|
// signed HMAC request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/items/index.ts"],"names":[],"mappings":";;;AAAA,uEAA6C;AAC7C,sEAA4C;AAC5C,wDAA8B;AAC9B,6DAAmC;AACnC,mEAAyC;AACzC,wDAA8B;AAC9B,gEAAsC;AACtC,4DAAkC;AAClC,iEAAuC;AACvC,4DAAkC;AAClC,qEAA2C;AAC3C,uEAA6C;AAC7C,kEAAwC;AACxC,4DAAkC;AAClC,mEAAyC;AACzC,kDAAwB;AACxB,6EAAmD;AACnD,6DAAmC;AACnC,+DAAqC;AACrC,kEAAwC;AACxC,iEAAuC;AACvC,yEAA+C;AAC/C,gEAAsC;AACtC,2EAAiD;AACjD,8DAAoC;AACpC,gEAAsC;AACtC,oEAAoE;AACpE,iEAAiE;AACjE,uBAAuB;AACvB,wCAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/items/index.ts"],"names":[],"mappings":";;;AAAA,uEAA6C;AAC7C,sEAA4C;AAC5C,wDAA8B;AAC9B,6DAAmC;AACnC,mEAAyC;AACzC,wDAA8B;AAC9B,gEAAsC;AACtC,4DAAkC;AAClC,iEAAuC;AACvC,4DAAkC;AAClC,qEAA2C;AAC3C,uEAA6C;AAC7C,kEAAwC;AACxC,4DAAkC;AAClC,mEAAyC;AACzC,kDAAwB;AACxB,6EAAmD;AACnD,6DAAmC;AACnC,+DAAqC;AACrC,kEAAwC;AACxC,iEAAuC;AACvC,yEAA+C;AAC/C,gEAAsC;AACtC,2EAAiD;AACjD,8DAAoC;AACpC,gEAAsC;AACtC,gEAAsC;AACtC,mDAAyB;AACzB,oEAAoE;AACpE,iEAAiE;AACjE,uBAAuB;AACvB,wCAAwC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getS123EditUrl = void 0;
|
|
4
|
+
function getS123EditUrl(id, context) {
|
|
5
|
+
return `${context.survey123Url}/surveys/${id}?portalUrl=${encodeURIComponent(context.portalUrl)}`;
|
|
6
|
+
}
|
|
7
|
+
exports.getS123EditUrl = getS123EditUrl;
|
|
8
|
+
//# sourceMappingURL=get-s123-edit-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-s123-edit-url.js","sourceRoot":"","sources":["../../../../src/surveys/utils/get-s123-edit-url.ts"],"names":[],"mappings":";;;AAEA,SAAgB,cAAc,CAAC,EAAU,EAAE,OAAuB;IAChE,OAAO,GAAG,OAAO,CAAC,YAAY,YAAY,EAAE,cAAc,kBAAkB,CAC1E,OAAO,CAAC,SAAS,CAClB,EAAE,CAAC;AACN,CAAC;AAJD,wCAIC"}
|
|
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("./get-form-info-json"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./get-form-json"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./get-input-feature-service-model"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./get-map-question"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./get-s123-edit-url"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./get-s123-share-url"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./get-source-feature-service-model-from-fieldworker"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./get-stakeholder-model"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/surveys/utils/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,+DAAqC;AACrC,0DAAgC;AAChC,4EAAkD;AAClD,6DAAmC;AACnC,+DAAqC;AACrC,8FAAoE;AACpE,kEAAwC;AACxC,8DAAoC;AACpC,6DAAmC;AACnC,gEAAsC;AACtC,4DAAkC;AAClC,6DAAmC;AACnC,iEAAuC;AACvC,oEAA0C;AAC1C,+DAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/surveys/utils/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,+DAAqC;AACrC,0DAAgC;AAChC,4EAAkD;AAClD,6DAAmC;AACnC,8DAAoC;AACpC,+DAAqC;AACrC,8FAAoE;AACpE,kEAAwC;AACxC,8DAAoC;AACpC,6DAAmC;AACnC,gEAAsC;AACtC,4DAAkC;AAClC,6DAAmC;AACnC,iEAAuC;AACvC,oEAA0C;AAC1C,+DAAqC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IUser } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { HubEntityType } from "../core";
|
|
3
|
+
import { IWithFollowers } from "../core/traits/IWithFollowers";
|
|
4
|
+
import { IArcGISContext } from "../ArcGISContext";
|
|
5
|
+
/**
|
|
6
|
+
* Get the entity's followers group id
|
|
7
|
+
* @param entityId entity id
|
|
8
|
+
* @param entityType entity type
|
|
9
|
+
* @param context context used to support fetchHubEntity so it has access
|
|
10
|
+
* to different types of request options based on the entity type
|
|
11
|
+
* @returns {string} entity's followers group id
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEntityFollowersGroupId(entityId: string, entityType: HubEntityType, context: IArcGISContext): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the user is currently following the entity
|
|
16
|
+
* @param entityOrId hub entity or entity id, type is IWithFollowers
|
|
17
|
+
* as we only want to accept hub entities backed by item entities which
|
|
18
|
+
* extend IWithFollowers
|
|
19
|
+
* @param user
|
|
20
|
+
* @param entityType
|
|
21
|
+
* @param context
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export declare function isUserFollowing(entityOrId: IWithFollowers | string, user: IUser, entityType?: HubEntityType, context?: IArcGISContext): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Follow an entity
|
|
27
|
+
* @param entityId entity id
|
|
28
|
+
* @param user user who attempts to follow the entity
|
|
29
|
+
* @param entityType optional if entityOrId is a string
|
|
30
|
+
* @param context optional if entityOrId is a string
|
|
31
|
+
* @returns promise that resolves { success: true, username: user.username }
|
|
32
|
+
* or rejects with an error
|
|
33
|
+
*/
|
|
34
|
+
export declare function followEntity(entityId: string, user: IUser, entityType?: HubEntityType, context?: IArcGISContext): Promise<{
|
|
35
|
+
success: boolean;
|
|
36
|
+
username: string;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Unfollow an entity
|
|
40
|
+
* @param entityId entity id
|
|
41
|
+
* @param user user who attempts to unfollow the entity
|
|
42
|
+
* @param entityType optional if entityOrId is a string
|
|
43
|
+
* @param context optional if entityOrId is a string
|
|
44
|
+
* @returns promise that resolves { success: true, username: user.username } or
|
|
45
|
+
* rejects with an error
|
|
46
|
+
*/
|
|
47
|
+
export declare function unfollowEntity(entityId: string, user: IUser, entityType?: HubEntityType, context?: IArcGISContext): Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
username: string;
|
|
50
|
+
}>;
|
|
@@ -3,6 +3,7 @@ export * from "./get-form-info-json";
|
|
|
3
3
|
export * from "./get-form-json";
|
|
4
4
|
export * from "./get-input-feature-service-model";
|
|
5
5
|
export * from "./get-map-question";
|
|
6
|
+
export * from "./get-s123-edit-url";
|
|
6
7
|
export * from "./get-s123-share-url";
|
|
7
8
|
export * from "./get-source-feature-service-model-from-fieldworker";
|
|
8
9
|
export * from "./get-stakeholder-model";
|