@esri/hub-common 11.23.3 → 12.0.0-alpha.2

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 (247) hide show
  1. package/dist/esm/ArcGISContext.js +38 -1
  2. package/dist/esm/ArcGISContext.js.map +1 -1
  3. package/dist/esm/ArcGISContextManager.js +48 -0
  4. package/dist/esm/ArcGISContextManager.js.map +1 -1
  5. package/dist/esm/content/_internal.js +8 -18
  6. package/dist/esm/content/_internal.js.map +1 -1
  7. package/dist/esm/content/compose.js +12 -0
  8. package/dist/esm/content/compose.js.map +1 -1
  9. package/dist/esm/core/HubItemEntity.js +39 -57
  10. package/dist/esm/core/HubItemEntity.js.map +1 -1
  11. package/dist/esm/core/_internal/PropertyMapper.js +10 -2
  12. package/dist/esm/core/_internal/PropertyMapper.js.map +1 -1
  13. package/dist/esm/core/_internal/getBasePropertyMap.js +1 -0
  14. package/dist/esm/core/_internal/getBasePropertyMap.js.map +1 -1
  15. package/dist/esm/core/behaviors/IWithPermissionBehavior.js +0 -68
  16. package/dist/esm/core/behaviors/IWithPermissionBehavior.js.map +1 -1
  17. package/dist/esm/core/fetchHubEntity.js +28 -0
  18. package/dist/esm/core/fetchHubEntity.js.map +1 -0
  19. package/dist/esm/core/getTypeFromEntity.js +26 -0
  20. package/dist/esm/core/getTypeFromEntity.js.map +1 -0
  21. package/dist/esm/core/index.js +2 -1
  22. package/dist/esm/core/index.js.map +1 -1
  23. package/dist/esm/core/types/HubEntity.js +1 -0
  24. package/dist/esm/core/types/HubEntity.js.map +1 -0
  25. package/dist/esm/core/types/HubEntityType.js +1 -0
  26. package/dist/esm/core/types/HubEntityType.js.map +1 -0
  27. package/dist/esm/core/types/ISystemStatus.js +21 -0
  28. package/dist/esm/core/types/ISystemStatus.js.map +1 -0
  29. package/dist/esm/core/types/index.js +3 -2
  30. package/dist/esm/core/types/index.js.map +1 -1
  31. package/dist/esm/index.js +1 -0
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/initiatives/HubInitiative.js +0 -13
  34. package/dist/esm/initiatives/HubInitiative.js.map +1 -1
  35. package/dist/esm/permissions/HubPermissionPolicies.js +71 -0
  36. package/dist/esm/permissions/HubPermissionPolicies.js.map +1 -0
  37. package/dist/esm/permissions/_internal/checkAlphaGating.js +27 -0
  38. package/dist/esm/permissions/_internal/checkAlphaGating.js.map +1 -0
  39. package/dist/esm/permissions/_internal/checkAssertion.js +190 -0
  40. package/dist/esm/permissions/_internal/checkAssertion.js.map +1 -0
  41. package/dist/esm/permissions/_internal/checkAssertions.js +20 -0
  42. package/dist/esm/permissions/_internal/checkAssertions.js.map +1 -0
  43. package/dist/esm/permissions/_internal/checkAuthentication.js +28 -0
  44. package/dist/esm/permissions/_internal/checkAuthentication.js.map +1 -0
  45. package/dist/esm/permissions/_internal/checkEdit.js +38 -0
  46. package/dist/esm/permissions/_internal/checkEdit.js.map +1 -0
  47. package/dist/esm/permissions/_internal/checkEntityPolicy.js +68 -0
  48. package/dist/esm/permissions/_internal/checkEntityPolicy.js.map +1 -0
  49. package/dist/esm/permissions/_internal/checkLicense.js +33 -0
  50. package/dist/esm/permissions/_internal/checkLicense.js.map +1 -0
  51. package/dist/esm/permissions/_internal/checkOwner.js +36 -0
  52. package/dist/esm/permissions/_internal/checkOwner.js.map +1 -0
  53. package/dist/esm/permissions/_internal/checkPrivileges.js +31 -0
  54. package/dist/esm/permissions/_internal/checkPrivileges.js.map +1 -0
  55. package/dist/esm/permissions/_internal/getPolicyResponseCode.js +47 -0
  56. package/dist/esm/permissions/_internal/getPolicyResponseCode.js.map +1 -0
  57. package/dist/esm/permissions/checkPermission.js +89 -0
  58. package/dist/esm/permissions/checkPermission.js.map +1 -0
  59. package/dist/esm/permissions/index.js +5 -0
  60. package/dist/esm/permissions/index.js.map +1 -0
  61. package/dist/esm/permissions/types/HubLicense.js +1 -0
  62. package/dist/esm/permissions/types/HubLicense.js.map +1 -0
  63. package/dist/esm/permissions/types/IAccessResponse.js +1 -0
  64. package/dist/esm/permissions/types/IAccessResponse.js.map +1 -0
  65. package/dist/esm/permissions/types/IEntityPermissionPolicy.js +1 -0
  66. package/dist/esm/permissions/types/IEntityPermissionPolicy.js.map +1 -0
  67. package/dist/esm/permissions/types/IPermissionPolicy.js +1 -0
  68. package/dist/esm/permissions/types/IPermissionPolicy.js.map +1 -0
  69. package/dist/esm/permissions/types/IPolicyCheck.js +1 -0
  70. package/dist/esm/permissions/types/IPolicyCheck.js.map +1 -0
  71. package/dist/esm/permissions/types/Permission.js +17 -0
  72. package/dist/esm/permissions/types/Permission.js.map +1 -0
  73. package/dist/esm/permissions/types/PlatformPrivilege.js +5 -0
  74. package/dist/esm/permissions/types/PlatformPrivilege.js.map +1 -0
  75. package/dist/esm/permissions/types/PolicyResponse.js +4 -0
  76. package/dist/esm/permissions/types/PolicyResponse.js.map +1 -0
  77. package/dist/esm/permissions/types/index.js +9 -0
  78. package/dist/esm/permissions/types/index.js.map +1 -0
  79. package/dist/esm/permissions/utils.js +26 -0
  80. package/dist/esm/permissions/utils.js.map +1 -0
  81. package/dist/esm/projects/HubProject.js +0 -13
  82. package/dist/esm/projects/HubProject.js.map +1 -1
  83. package/dist/esm/projects/_internal/ProjectPermissionPolicies.js +41 -0
  84. package/dist/esm/projects/_internal/ProjectPermissionPolicies.js.map +1 -0
  85. package/dist/esm/projects/defaults.js +1 -0
  86. package/dist/esm/projects/defaults.js.map +1 -1
  87. package/dist/esm/search/Catalog.js.map +1 -1
  88. package/dist/esm/sites/HubSite.js +0 -13
  89. package/dist/esm/sites/HubSite.js.map +1 -1
  90. package/dist/esm/sites/HubSites.js +10 -12
  91. package/dist/esm/sites/HubSites.js.map +1 -1
  92. package/dist/esm/sites/_internal/SitesPermissionPolicies.js +44 -0
  93. package/dist/esm/sites/_internal/SitesPermissionPolicies.js.map +1 -0
  94. package/dist/esm/sites/_internal/applyPermissionMigration.js +52 -0
  95. package/dist/esm/sites/_internal/applyPermissionMigration.js.map +1 -0
  96. package/dist/node/ArcGISContext.js +42 -5
  97. package/dist/node/ArcGISContext.js.map +1 -1
  98. package/dist/node/ArcGISContextManager.js +48 -0
  99. package/dist/node/ArcGISContextManager.js.map +1 -1
  100. package/dist/node/content/_internal.js +8 -18
  101. package/dist/node/content/_internal.js.map +1 -1
  102. package/dist/node/content/compose.js +12 -0
  103. package/dist/node/content/compose.js.map +1 -1
  104. package/dist/node/core/HubItemEntity.js +38 -56
  105. package/dist/node/core/HubItemEntity.js.map +1 -1
  106. package/dist/node/core/_internal/PropertyMapper.js +9 -1
  107. package/dist/node/core/_internal/PropertyMapper.js.map +1 -1
  108. package/dist/node/core/_internal/getBasePropertyMap.js +1 -0
  109. package/dist/node/core/_internal/getBasePropertyMap.js.map +1 -1
  110. package/dist/node/core/behaviors/IWithPermissionBehavior.js +0 -73
  111. package/dist/node/core/behaviors/IWithPermissionBehavior.js.map +1 -1
  112. package/dist/node/core/fetchHubEntity.js +32 -0
  113. package/dist/node/core/fetchHubEntity.js.map +1 -0
  114. package/dist/node/core/getTypeFromEntity.js +30 -0
  115. package/dist/node/core/getTypeFromEntity.js.map +1 -0
  116. package/dist/node/core/index.js +2 -1
  117. package/dist/node/core/index.js.map +1 -1
  118. package/dist/node/core/types/{IHubPermission.js → HubEntity.js} +1 -1
  119. package/dist/node/core/types/HubEntity.js.map +1 -0
  120. package/dist/node/core/types/HubEntityType.js +3 -0
  121. package/dist/node/core/types/HubEntityType.js.map +1 -0
  122. package/dist/node/core/types/ISystemStatus.js +25 -0
  123. package/dist/node/core/types/ISystemStatus.js.map +1 -0
  124. package/dist/node/core/types/index.js +3 -2
  125. package/dist/node/core/types/index.js.map +1 -1
  126. package/dist/node/index.js +1 -0
  127. package/dist/node/index.js.map +1 -1
  128. package/dist/node/initiatives/HubInitiative.js +0 -13
  129. package/dist/node/initiatives/HubInitiative.js.map +1 -1
  130. package/dist/node/permissions/HubPermissionPolicies.js +75 -0
  131. package/dist/node/permissions/HubPermissionPolicies.js.map +1 -0
  132. package/dist/node/permissions/_internal/checkAlphaGating.js +31 -0
  133. package/dist/node/permissions/_internal/checkAlphaGating.js.map +1 -0
  134. package/dist/node/permissions/_internal/checkAssertion.js +194 -0
  135. package/dist/node/permissions/_internal/checkAssertion.js.map +1 -0
  136. package/dist/node/permissions/_internal/checkAssertions.js +24 -0
  137. package/dist/node/permissions/_internal/checkAssertions.js.map +1 -0
  138. package/dist/node/permissions/_internal/checkAuthentication.js +32 -0
  139. package/dist/node/permissions/_internal/checkAuthentication.js.map +1 -0
  140. package/dist/node/permissions/_internal/checkEdit.js +42 -0
  141. package/dist/node/permissions/_internal/checkEdit.js.map +1 -0
  142. package/dist/node/permissions/_internal/checkEntityPolicy.js +72 -0
  143. package/dist/node/permissions/_internal/checkEntityPolicy.js.map +1 -0
  144. package/dist/node/permissions/_internal/checkLicense.js +37 -0
  145. package/dist/node/permissions/_internal/checkLicense.js.map +1 -0
  146. package/dist/node/permissions/_internal/checkOwner.js +40 -0
  147. package/dist/node/permissions/_internal/checkOwner.js.map +1 -0
  148. package/dist/node/permissions/_internal/checkPrivileges.js +35 -0
  149. package/dist/node/permissions/_internal/checkPrivileges.js.map +1 -0
  150. package/dist/node/permissions/_internal/getPolicyResponseCode.js +51 -0
  151. package/dist/node/permissions/_internal/getPolicyResponseCode.js.map +1 -0
  152. package/dist/node/permissions/checkPermission.js +93 -0
  153. package/dist/node/permissions/checkPermission.js.map +1 -0
  154. package/dist/node/permissions/index.js +8 -0
  155. package/dist/node/permissions/index.js.map +1 -0
  156. package/dist/node/permissions/types/HubLicense.js +3 -0
  157. package/dist/node/permissions/types/HubLicense.js.map +1 -0
  158. package/dist/node/permissions/types/IAccessResponse.js +3 -0
  159. package/dist/node/permissions/types/IAccessResponse.js.map +1 -0
  160. package/dist/node/permissions/types/IEntityPermissionPolicy.js +3 -0
  161. package/dist/node/permissions/types/IEntityPermissionPolicy.js.map +1 -0
  162. package/dist/node/permissions/types/IPermissionPolicy.js +3 -0
  163. package/dist/node/permissions/types/IPermissionPolicy.js.map +1 -0
  164. package/dist/node/permissions/types/IPolicyCheck.js +3 -0
  165. package/dist/node/permissions/types/IPolicyCheck.js.map +1 -0
  166. package/dist/node/permissions/types/Permission.js +21 -0
  167. package/dist/node/permissions/types/Permission.js.map +1 -0
  168. package/dist/node/permissions/types/PlatformPrivilege.js +7 -0
  169. package/dist/node/permissions/types/PlatformPrivilege.js.map +1 -0
  170. package/dist/node/permissions/types/PolicyResponse.js +6 -0
  171. package/dist/node/permissions/types/PolicyResponse.js.map +1 -0
  172. package/dist/node/permissions/types/index.js +12 -0
  173. package/dist/node/permissions/types/index.js.map +1 -0
  174. package/dist/node/permissions/utils.js +31 -0
  175. package/dist/node/permissions/utils.js.map +1 -0
  176. package/dist/node/projects/HubProject.js +0 -13
  177. package/dist/node/projects/HubProject.js.map +1 -1
  178. package/dist/node/projects/_internal/ProjectPermissionPolicies.js +44 -0
  179. package/dist/node/projects/_internal/ProjectPermissionPolicies.js.map +1 -0
  180. package/dist/node/projects/defaults.js +1 -0
  181. package/dist/node/projects/defaults.js.map +1 -1
  182. package/dist/node/search/Catalog.js.map +1 -1
  183. package/dist/node/sites/HubSite.js +0 -13
  184. package/dist/node/sites/HubSite.js.map +1 -1
  185. package/dist/node/sites/HubSites.js +10 -12
  186. package/dist/node/sites/HubSites.js.map +1 -1
  187. package/dist/node/sites/_internal/SitesPermissionPolicies.js +47 -0
  188. package/dist/node/sites/_internal/SitesPermissionPolicies.js.map +1 -0
  189. package/dist/node/sites/_internal/applyPermissionMigration.js +56 -0
  190. package/dist/node/sites/_internal/applyPermissionMigration.js.map +1 -0
  191. package/dist/types/ArcGISContext.d.ts +33 -1
  192. package/dist/types/ArcGISContextManager.d.ts +6 -1
  193. package/dist/types/content/_internal.d.ts +15 -5
  194. package/dist/types/core/HubItemEntity.d.ts +29 -4
  195. package/dist/types/core/behaviors/IWithPermissionBehavior.d.ts +23 -35
  196. package/dist/types/core/behaviors/IWithStoreBehavior.d.ts +10 -10
  197. package/dist/types/core/fetchHubEntity.d.ts +11 -0
  198. package/dist/types/core/getTypeFromEntity.d.ts +8 -0
  199. package/dist/types/core/index.d.ts +2 -1
  200. package/dist/types/core/traits/IWithPermissions.d.ts +3 -3
  201. package/dist/types/core/types/HubEntity.d.ts +5 -0
  202. package/dist/types/core/types/HubEntityType.d.ts +1 -0
  203. package/dist/types/core/types/IHubContent.d.ts +2 -1
  204. package/dist/types/core/types/IHubItemEntity.d.ts +19 -2
  205. package/dist/types/core/types/ISystemStatus.d.ts +22 -0
  206. package/dist/types/core/types/index.d.ts +3 -2
  207. package/dist/types/index.d.ts +1 -0
  208. package/dist/types/initiatives/HubInitiative.d.ts +1 -7
  209. package/dist/types/permissions/HubPermissionPolicies.d.ts +11 -0
  210. package/dist/types/permissions/_internal/checkAlphaGating.d.ts +10 -0
  211. package/dist/types/permissions/_internal/checkAssertion.d.ts +11 -0
  212. package/dist/types/permissions/_internal/checkAssertions.d.ts +10 -0
  213. package/dist/types/permissions/_internal/checkAuthentication.d.ts +10 -0
  214. package/dist/types/permissions/_internal/checkEdit.d.ts +10 -0
  215. package/dist/types/permissions/_internal/checkEntityPolicy.d.ts +9 -0
  216. package/dist/types/permissions/_internal/checkLicense.d.ts +10 -0
  217. package/dist/types/permissions/_internal/checkOwner.d.ts +10 -0
  218. package/dist/types/permissions/_internal/checkPrivileges.d.ts +10 -0
  219. package/dist/types/permissions/_internal/getPolicyResponseCode.d.ts +7 -0
  220. package/dist/types/permissions/checkPermission.d.ts +10 -0
  221. package/dist/types/permissions/index.d.ts +4 -0
  222. package/dist/types/permissions/types/HubLicense.d.ts +4 -0
  223. package/dist/types/permissions/types/IAccessResponse.d.ts +34 -0
  224. package/dist/types/permissions/types/IEntityPermissionPolicy.d.ts +22 -0
  225. package/dist/types/permissions/types/IPermissionPolicy.d.ts +57 -0
  226. package/dist/types/permissions/types/IPolicyCheck.d.ts +25 -0
  227. package/dist/types/permissions/types/Permission.d.ts +17 -0
  228. package/dist/types/permissions/types/PlatformPrivilege.d.ts +5 -0
  229. package/dist/types/permissions/types/PolicyResponse.d.ts +4 -0
  230. package/dist/types/permissions/types/index.d.ts +8 -0
  231. package/dist/types/permissions/utils.d.ts +18 -0
  232. package/dist/types/projects/HubProject.d.ts +1 -7
  233. package/dist/types/projects/_internal/ProjectPermissionPolicies.d.ts +8 -0
  234. package/dist/types/sites/HubSite.d.ts +1 -7
  235. package/dist/types/sites/HubSites.d.ts +1 -1
  236. package/dist/types/sites/_internal/SitesPermissionPolicies.d.ts +11 -0
  237. package/dist/types/sites/_internal/applyPermissionMigration.d.ts +7 -0
  238. package/package.json +1 -1
  239. package/dist/esm/core/PermissionManager.js +0 -60
  240. package/dist/esm/core/PermissionManager.js.map +0 -1
  241. package/dist/esm/core/types/IHubPermission.js +0 -1
  242. package/dist/esm/core/types/IHubPermission.js.map +0 -1
  243. package/dist/node/core/PermissionManager.js +0 -64
  244. package/dist/node/core/PermissionManager.js.map +0 -1
  245. package/dist/node/core/types/IHubPermission.js.map +0 -1
  246. package/dist/types/core/PermissionManager.d.ts +0 -43
  247. package/dist/types/core/types/IHubPermission.d.ts +0 -23
@@ -0,0 +1,5 @@
1
+ import { IHubInitiative } from "./IHubInitiative";
2
+ import { IHubPage } from "./IHubPage";
3
+ import { IHubProject } from "./IHubProject";
4
+ import { IHubSite } from "./IHubSite";
5
+ export declare type HubEntity = IHubSite | IHubProject | IHubInitiative | IHubPage;
@@ -0,0 +1 @@
1
+ export declare type HubEntityType = "site" | "project" | "initiative" | "page";
@@ -15,7 +15,7 @@ export declare enum PublisherSource {
15
15
  /**
16
16
  * Data model for content
17
17
  */
18
- export interface IHubContent extends Omit<IHubItemEntity, "schemaVersion">, IHubContentEnrichments, IItem {
18
+ export interface IHubContent extends Omit<IHubItemEntity, "schemaVersion" | "permissions">, IHubContentEnrichments, IItem {
19
19
  /**
20
20
  * The underlying portal item referenced by this content
21
21
  */
@@ -40,6 +40,7 @@ export interface IHubContent extends Omit<IHubItemEntity, "schemaVersion">, IHub
40
40
  identifier: string;
41
41
  /**
42
42
  * Content visibility and access control, including groups
43
+ * NOTE: this needs to be reconciled with Hub permission system
43
44
  */
44
45
  permissions: {
45
46
  /** Visibility of the content */
@@ -1,11 +1,11 @@
1
1
  import { IHubEntityBase } from "./IHubEntityBase";
2
2
  import { IHubGeography } from "../../types";
3
3
  import { AccessLevel } from "./types";
4
- import { IWithViewSettings } from "../traits";
4
+ import { IWithPermissions, IWithViewSettings } from "../traits";
5
5
  /**
6
6
  * Properties exposed by Entities that are backed by Items
7
7
  */
8
- export interface IHubItemEntity extends IHubEntityBase {
8
+ export interface IHubItemEntity extends IHubEntityBase, IWithPermissions {
9
9
  /**
10
10
  * Access level of the item ("private" | "org" | "public")
11
11
  */
@@ -29,6 +29,11 @@ export interface IHubItemEntity extends IHubEntityBase {
29
29
  * Extent of the Entity
30
30
  */
31
31
  extent?: number[][];
32
+ /**
33
+ * Platform derived based on current user's access to the entity
34
+ * if defined, it means the user can edit the entity
35
+ */
36
+ itemControl: string;
32
37
  /**
33
38
  * Username of the owner of the item
34
39
  */
@@ -62,4 +67,16 @@ export interface IHubItemEntity extends IHubEntityBase {
62
67
  * Project display properties
63
68
  */
64
69
  view?: IWithViewSettings;
70
+ /**
71
+ * Can current user edit the entity
72
+ * Derived from `item.itemControl` = "admin" | "update"
73
+ * @readonly
74
+ */
75
+ canEdit: boolean;
76
+ /**
77
+ * Can current user delete the entity
78
+ * Derived from `item.itemControl` = "admin"
79
+ * @readonly
80
+ */
81
+ canDelete: boolean;
65
82
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * What is the status of a subsystem
3
+ */
4
+ export declare type SystemStatus = "online" | "offline" | "maintenance" | "not-available";
5
+ /**
6
+ * Hash of subsystems and their status
7
+ */
8
+ export declare type HubSystemStatus = {
9
+ [key in HubSubsystem]: SystemStatus;
10
+ };
11
+ declare const validSubsystems: readonly ["discussions", "events", "initiatives", "items", "metrics", "notifications", "pages", "projects", "search", "sites"];
12
+ /**
13
+ * Defines values for HubSubsystem
14
+ */
15
+ export declare type HubSubsystem = typeof validSubsystems[number];
16
+ /**
17
+ * Validate a Subsystem
18
+ * @param subsystem
19
+ * @returns
20
+ */
21
+ export declare function isSubsystem(maybeSubsystem: string): boolean;
22
+ export {};
@@ -1,3 +1,5 @@
1
+ export * from "./HubEntity";
2
+ export * from "./HubEntityType";
1
3
  export * from "./IHubContent";
2
4
  export * from "./IHubContentEnrichments";
3
5
  export * from "./IHubEntityBase";
@@ -13,6 +15,5 @@ export * from "./IHubSiteTheme";
13
15
  export * from "./IHubTimeline";
14
16
  export * from "./IItemEnrichments";
15
17
  export * from "./IServerEnrichments";
18
+ export * from "./ISystemStatus";
16
19
  export * from "./types";
17
- export * from "./IHubPermission";
18
- export * from "../traits/IWithViewSettings";
@@ -16,6 +16,7 @@ export * from "./models";
16
16
  export * from "./objects";
17
17
  export * from "./org";
18
18
  export * from "./pages";
19
+ export * from "./permissions";
19
20
  export * from "./projects";
20
21
  export * from "./request";
21
22
  export * from "./resources";
@@ -1,4 +1,4 @@
1
- import { IHubInitiative, IWithPermissionBehavior, IWithCatalogBehavior, PermissionManager, IWithStoreBehavior, IWithSharingBehavior } from "../core";
1
+ import { IHubInitiative, IWithPermissionBehavior, IWithCatalogBehavior, IWithStoreBehavior, IWithSharingBehavior } from "../core";
2
2
  import { Catalog } from "../search/Catalog";
3
3
  import { IArcGISContext } from "../ArcGISContext";
4
4
  import { HubItemEntity } from "../core/HubItemEntity";
@@ -7,7 +7,6 @@ import { HubItemEntity } from "../core/HubItemEntity";
7
7
  */
8
8
  export declare class HubInitiative extends HubItemEntity<IHubInitiative> implements IWithStoreBehavior<IHubInitiative>, IWithPermissionBehavior, IWithCatalogBehavior, IWithSharingBehavior {
9
9
  private _catalog;
10
- private _permissionManager;
11
10
  /**
12
11
  * Private constructor so we don't have `new` all over the place. Allows for
13
12
  * more flexibility in how we create the HubInitiativeManager over time.
@@ -19,11 +18,6 @@ export declare class HubInitiative extends HubItemEntity<IHubInitiative> impleme
19
18
  * @returns Catalog
20
19
  */
21
20
  get catalog(): Catalog;
22
- /**
23
- * PermissionManager instance for this Initiative. Note: Do not hold direct references to this object; always access it from the Initiative.
24
- * @returns PermissionManager
25
- */
26
- get permissions(): PermissionManager;
27
21
  /**
28
22
  * Create an instance from an IHubInitiative object
29
23
  * @param json - JSON object to create a HubInitiative from
@@ -0,0 +1,11 @@
1
+ import { IPermissionPolicy, Permission } from "./types";
2
+ /**
3
+ * All the permission policies for the Hub
4
+ */
5
+ export declare const HubPermissionsPolicies: IPermissionPolicy[];
6
+ /**
7
+ * Get the policies defined for a specific permission
8
+ * @param permission
9
+ * @returns
10
+ */
11
+ export declare function getPermissionPolicy(permission: Permission): IPermissionPolicy;
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPermissionPolicy, IPolicyCheck } from "../types";
3
+ /**
4
+ * Validate entityOwner policy
5
+ * @param policy
6
+ * @param context
7
+ * @param entity
8
+ * @returns
9
+ */
10
+ export declare function checkAlphaGating(policy: IPermissionPolicy, context: IArcGISContext, entity?: Record<string, any>): IPolicyCheck[];
@@ -0,0 +1,11 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPolicyAssertion, IPolicyCheck } from "../types";
3
+ /**
4
+ * Check a specific EntityAssertion
5
+ * Exported purely for testing. Not exported from the package.
6
+ * @param assertion
7
+ * @param entity
8
+ * @param context
9
+ * @returns
10
+ */
11
+ export declare function checkAssertion(assertion: IPolicyAssertion, entity: Record<string, any>, context: IArcGISContext): IPolicyCheck;
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPermissionPolicy, IPolicyCheck } from "../types";
3
+ /**
4
+ * Validate entityOwner policy
5
+ * @param policy
6
+ * @param context
7
+ * @param entity
8
+ * @returns
9
+ */
10
+ export declare function checkAssertions(policy: IPermissionPolicy, context: IArcGISContext, entity?: Record<string, any>): IPolicyCheck[];
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPermissionPolicy, IPolicyCheck } from "../types";
3
+ /**
4
+ * Validate authentication policy
5
+ * @param policy
6
+ * @param context
7
+ * @param entity
8
+ * @returns
9
+ */
10
+ export declare function checkAuthentication(policy: IPermissionPolicy, context: IArcGISContext, entity?: Record<string, any>): IPolicyCheck[];
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPermissionPolicy, IPolicyCheck } from "../types";
3
+ /**
4
+ * Validate entityEdit policy
5
+ * @param policy
6
+ * @param context
7
+ * @param entity
8
+ * @returns
9
+ */
10
+ export declare function checkEdit(policy: IPermissionPolicy, context: IArcGISContext, entity?: Record<string, any>): IPolicyCheck[];
@@ -0,0 +1,9 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPolicyCheck, IEntityPermissionPolicy } from "../types";
3
+ /**
4
+ * Validate user meets entity policy
5
+ * @param policy
6
+ * @param context
7
+ * @returns
8
+ */
9
+ export declare function checkEntityPolicy(policy: IEntityPermissionPolicy, context: IArcGISContext): IPolicyCheck;
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPermissionPolicy, IPolicyCheck } from "../types";
3
+ /**
4
+ * Validate license policy
5
+ * @param policy
6
+ * @param response
7
+ * @param context
8
+ * @returns
9
+ */
10
+ export declare function checkLicense(policy: IPermissionPolicy, context: IArcGISContext, entity?: Record<string, any>): IPolicyCheck[];
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPermissionPolicy, IPolicyCheck } from "../types";
3
+ /**
4
+ * Validate entityOwner policy
5
+ * @param policy
6
+ * @param context
7
+ * @param entity
8
+ * @returns
9
+ */
10
+ export declare function checkOwner(policy: IPermissionPolicy, context: IArcGISContext, entity?: Record<string, any>): IPolicyCheck[];
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IPermissionPolicy, IPolicyCheck } from "../types";
3
+ /**
4
+ * Validate privilege policy
5
+ * @param policy
6
+ * @param context
7
+ * @param entity
8
+ * @returns
9
+ */
10
+ export declare function checkPrivileges(policy: IPermissionPolicy, context: IArcGISContext, entity?: Record<string, any>): IPolicyCheck[];
@@ -0,0 +1,7 @@
1
+ import { PolicyResponse } from "../types";
2
+ /**
3
+ * Get a code that can be used for i18n or other purposes, based on the PolicyResponse
4
+ * @param response
5
+ * @returns
6
+ */
7
+ export declare function getPolicyResponseCode(response: PolicyResponse): string;
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../ArcGISContext";
2
+ import { IAccessResponse, Permission } from "./types";
3
+ /**
4
+ * Check a permission against the system policies, and possibly an entity policy
5
+ * @param permission
6
+ * @param context
7
+ * @param entity
8
+ * @returns
9
+ */
10
+ export declare function checkPermission(permission: Permission, context: IArcGISContext, entity?: Record<string, any>): IAccessResponse;
@@ -0,0 +1,4 @@
1
+ export * from "./HubPermissionPolicies";
2
+ export * from "./checkPermission";
3
+ export * from "./utils";
4
+ export * from "./types";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Defines the values for hub license types
3
+ */
4
+ export declare type HubLicense = "hub-basic" | "hub-premium" | "enterprise-sites";
@@ -0,0 +1,34 @@
1
+ import { Permission } from "./Permission";
2
+ import { IPolicyCheck } from "./IPolicyCheck";
3
+ import { PolicyResponse } from "./PolicyResponse";
4
+ /**
5
+ * Response from a permission check
6
+ */
7
+ export interface IAccessResponse {
8
+ /**
9
+ * Permission being checked
10
+ */
11
+ permission: Permission;
12
+ /**
13
+ * Is the user allowed to perform the action
14
+ */
15
+ access: boolean;
16
+ /**
17
+ * Code for the access response. Used for i18n and UX level messages
18
+ */
19
+ code: string;
20
+ /**
21
+ * Reason for the access response
22
+ */
23
+ response: PolicyResponse;
24
+ /**
25
+ * Message with details access response. Typically used to return additional
26
+ * information about assertion failures
27
+ */
28
+ message?: string;
29
+ /**
30
+ * List of all the policies that were checked, and their responses
31
+ * For debugging / observability
32
+ */
33
+ checks: IPolicyCheck[];
34
+ }
@@ -0,0 +1,22 @@
1
+ import { Permission } from "./Permission";
2
+ /**
3
+ * Association of a Permission with a set of collaborators
4
+ */
5
+ export interface IEntityPermissionPolicy {
6
+ /**
7
+ * Permission being granted
8
+ */
9
+ permission: Permission;
10
+ /**
11
+ * Type of the collaboration - org, group, group-admin or user
12
+ */
13
+ collaborationType: CollaborationType;
14
+ /**
15
+ * Id of the collaboration set
16
+ */
17
+ collaborationId: string;
18
+ }
19
+ /**
20
+ * Type of collaboration set. Used when associating a permission with a set of collaborators
21
+ */
22
+ export declare type CollaborationType = "user" | "group" | "group-admin" | "org" | "authenticated" | "anonymous";
@@ -0,0 +1,57 @@
1
+ import { HubLicense } from "./HubLicense";
2
+ import { HubSubsystem } from "../../core/types/ISystemStatus";
3
+ import { Permission } from "./Permission";
4
+ import { PlatformPrivilege } from "./PlatformPrivilege";
5
+ /**
6
+ * Defines a system level policy for a specific permission.
7
+ * All conditions must be met for the permission to be granted. Additinonal conditions may be added by an entity to further
8
+ * limit access when the permission is checed in the contex to the entity.
9
+ * e.g. "hub:project:create" in the context of an Initiative, may further restrict to members of a specfic group
10
+ */
11
+ export interface IPermissionPolicy {
12
+ /**
13
+ * Permission being defined
14
+ */
15
+ permission: Permission;
16
+ /**
17
+ * What subsystems are required to be online for this permission to be granted
18
+ */
19
+ subsystems: HubSubsystem[];
20
+ /**
21
+ * Must the user authenticated?
22
+ */
23
+ authenticated?: boolean;
24
+ /**
25
+ * What licenses are required for this permission to be granted.
26
+ * This is checking the licese of the current user's org. It is not transitive to the entity being accessed.
27
+ * e.g. If a user is in a Partner "hub-basic" org, they can not create "premium" entities (e.g. Projects)
28
+ */
29
+ licenses?: HubLicense[];
30
+ /**
31
+ * Any platform level privileges required for this permission to be granted
32
+ * e.g. "portal:user:createItem"
33
+ */
34
+ privileges?: PlatformPrivilege[];
35
+ /**
36
+ * Is the user an owner of the entity being accessed?
37
+ */
38
+ entityEdit?: boolean;
39
+ /**
40
+ * Must the user be the owner of the entity being accessed?
41
+ */
42
+ entityOwner?: boolean;
43
+ /**
44
+ * Is this gated to alpha orgs?
45
+ */
46
+ alpha?: boolean;
47
+ /**
48
+ * More complex policies can be defined with a set of assertions
49
+ */
50
+ assertions?: IPolicyAssertion[];
51
+ }
52
+ export interface IPolicyAssertion {
53
+ property: string;
54
+ type: AssertionType;
55
+ value: any;
56
+ }
57
+ export declare type AssertionType = "eq" | "neq" | "gt" | "lt" | "contains" | "contains-all" | "without" | "included-in" | "is-group-admin" | "is-group-member" | "is-group-owner";
@@ -0,0 +1,25 @@
1
+ import { PolicyResponse } from "./PolicyResponse";
2
+ /**
3
+ * Information about a specific policy check, and its response
4
+ * Used for debugging / observability
5
+ */
6
+ export interface IPolicyCheck {
7
+ /**
8
+ * Description of the policy being checked
9
+ * e.g. License Required: "hub-premium"
10
+ */
11
+ name: string;
12
+ /**
13
+ * Value determined for the current user
14
+ * e.g. "hub-basic"
15
+ */
16
+ value: string;
17
+ /**
18
+ * Policy Response code, for i18n
19
+ */
20
+ code: string;
21
+ /**
22
+ * Policy Response string
23
+ */
24
+ response: PolicyResponse;
25
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Defines the values for Permissions
3
+ * It's critical that the arrays defined in the modules use `as const`
4
+ * otherwise Permission devolves into just a string type
5
+ */
6
+ declare const validPermissions: readonly ["hub:site:create", "hub:site:delete", "hub:site:edit", "hub:site:view", "hub:project:create", "hub:project:delete", "hub:project:edit", "hub:project:view"];
7
+ /**
8
+ * Defines the possible values for Permissions
9
+ */
10
+ export declare type Permission = typeof validPermissions[number];
11
+ /**
12
+ * Validate a Permission
13
+ * @param permission
14
+ * @returns
15
+ */
16
+ export declare function isPermission(maybePermission: string): boolean;
17
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Type that defines Platform Privileges
3
+ * TODO: Ensure this is a complete list
4
+ */
5
+ export declare type PlatformPrivilege = "opendata:user:designateGroup" | "opendata:user:openDataAdmin" | "portal:admin:assignToGroups" | "portal:admin:categorizeItems" | "portal:admin:changeUserRoles" | "portal:admin:createGPWebhook" | "portal:admin:createUpdateCapableGroup" | "portal:admin:deleteGroups" | "portal:admin:deleteItems" | "portal:admin:deleteUsers" | "portal:admin:disableUsers" | "portal:admin:inviteUsers" | "portal:admin:manageCollaborations" | "portal:admin:manageCredits" | "portal:admin:manageEnterpriseGroups" | "portal:admin:manageLicenses" | "portal:admin:manageRoles" | "portal:admin:manageSecurity" | "portal:admin:manageServers" | "portal:admin:manageUtilityServices" | "portal:admin:manageWebhooks" | "portal:admin:manageWebsite" | "portal:admin:reassignGroups" | "portal:admin:reassignItems" | "portal:admin:reassignUsers" | "portal:admin:shareToGroup" | "portal:admin:shareToOrg" | "portal:admin:shareToPublic" | "portal:admin:updateGroups" | "portal:admin:updateItemCategorySchema" | "portal:admin:updateItems" | "portal:admin:updateMemberCategorySchema" | "portal:admin:updateUsers" | "portal:admin:viewGroups" | "portal:admin:viewItems" | "portal:admin:viewUsers" | "portal:publisher:bulkPublishFromDataStores" | "portal:publisher:createFeatureWebhook" | "portal:publisher:publishBigDataAnalytics" | "portal:publisher:publishDynamicImagery" | "portal:publisher:publishFeatures" | "portal:publisher:publishFeeds" | "portal:publisher:publishKnowledgeGraph" | "portal:publisher:publishRealTimeAnalytics" | "portal:publisher:publishScenes" | "portal:publisher:publishServerGPServices" | "portal:publisher:publishServerServices" | "portal:publisher:publishTiledImagery" | "portal:publisher:publishTiles" | "portal:publisher:registerDataStores" | "portal:user:addExternalMembersToGroup" | "portal:user:categorizeItems" | "portal:user:createGroup" | "portal:user:createItem" | "portal:user:invitePartneredCollaborationMembers" | "portal:user:joinGroup" | "portal:user:joinNonOrgGroup" | "portal:user:reassignItems" | "portal:user:receiveItems" | "portal:user:runWebTool" | "portal:user:shareGroupToOrg" | "portal:user:shareGroupToPublic" | "portal:user:shareToGroup" | "portal:user:shareToOrg" | "portal:user:shareToPublic" | "portal:user:viewHostedFeatureServices" | "portal:user:viewHostedTileServices" | "portal:user:viewOrgGroups" | "portal:user:viewOrgItems" | "portal:user:viewOrgUsers" | "portal:user:viewTracks";
@@ -0,0 +1,4 @@
1
+ /**`
2
+ * Human readable response from a policy check
3
+ */
4
+ export declare type PolicyResponse = "granted" | "org-member" | "not-org-member" | "group-member" | "not-group-member" | "not-group-admin" | "is-user" | "not-owner" | "not-licensed" | "not-licensed-available" | "not-available" | "not-granted" | "no-edit-access" | "edit-access" | "invalid-permission" | "privilege-required" | "system-offline" | "system-maintenance" | "entity-required" | "not-authenticated" | "not-alpha-org" | "property-missing" | "property-not-array" | "array-contains-invalid-value" | "array-missing-required-value" | "property-mismatch" | "user-not-group-member" | "user-not-group-manager" | "user-not-group-owner" | "assertion-property-not-found" | "assertion-failed" | "assertion-requires-numeric-values" | "property-match";
@@ -0,0 +1,8 @@
1
+ export * from "./HubLicense";
2
+ export * from "./IAccessResponse";
3
+ export * from "./IEntityPermissionPolicy";
4
+ export * from "./IPermissionPolicy";
5
+ export * from "./IPolicyCheck";
6
+ export * from "./Permission";
7
+ export * from "./PlatformPrivilege";
8
+ export * from "./PolicyResponse";
@@ -0,0 +1,18 @@
1
+ import { IEntityPermissionPolicy, Permission } from "./types";
2
+ /**
3
+ * Add a policy to an array of entity policies
4
+ * Returns a new array
5
+ * @param permissions
6
+ * @param policy
7
+ * @returns
8
+ */
9
+ export declare function addPermissionPolicy(permissions: IEntityPermissionPolicy[], policy: IEntityPermissionPolicy): IEntityPermissionPolicy[];
10
+ /**
11
+ * Remove a policy from an array of entity policies
12
+ * Returns a new array
13
+ * @param permissions
14
+ * @param permission
15
+ * @param id
16
+ * @returns
17
+ */
18
+ export declare function removePermissionPolicy(permissions: IEntityPermissionPolicy[], permission: Permission, id: string): IEntityPermissionPolicy[];
@@ -1,4 +1,4 @@
1
- import { IHubProject, IWithPermissionBehavior, IWithCatalogBehavior, PermissionManager, IWithStoreBehavior, IWithSharingBehavior, UiSchemaElementOptions } from "../core";
1
+ import { IHubProject, IWithPermissionBehavior, IWithCatalogBehavior, IWithStoreBehavior, IWithSharingBehavior, UiSchemaElementOptions } from "../core";
2
2
  import { Catalog } from "../search/Catalog";
3
3
  import { IArcGISContext } from "../ArcGISContext";
4
4
  import { HubItemEntity } from "../core/HubItemEntity";
@@ -8,7 +8,6 @@ import { EditorConfigType, IEditorConfig } from "../core/behaviors/IWithEditorBe
8
8
  */
9
9
  export declare class HubProject extends HubItemEntity<IHubProject> implements IWithStoreBehavior<IHubProject>, IWithPermissionBehavior, IWithCatalogBehavior, IWithSharingBehavior {
10
10
  private _catalog;
11
- private _permissionManager;
12
11
  /**
13
12
  * Private constructor so we don't have `new` all over the place. Allows for
14
13
  * more flexibility in how we create the HubProjectManager over time.
@@ -20,11 +19,6 @@ export declare class HubProject extends HubItemEntity<IHubProject> implements IW
20
19
  * @returns
21
20
  */
22
21
  get catalog(): Catalog;
23
- /**
24
- * PermissionManager instance for this project. Note: Do not hold direct references to this object; always access it from the project.
25
- * @returns
26
- */
27
- get permissions(): PermissionManager;
28
22
  /**
29
23
  * Create an instance from an IHubProject object
30
24
  * @param json - JSON object to create a HubProject from
@@ -0,0 +1,8 @@
1
+ import { IPermissionPolicy } from "../../permissions/types";
2
+ /**
3
+ * Project Permission Policies
4
+ * These define the requirements any user must meet to perform related actions
5
+ * @private
6
+ */
7
+ export declare const ProjectPermissions: readonly ["hub:project:create", "hub:project:delete", "hub:project:edit", "hub:project:view"];
8
+ export declare const ProjectPermissionPolicies: IPermissionPolicy[];
@@ -1,4 +1,4 @@
1
- import { IHubSite, IWithPermissionBehavior, IWithCatalogBehavior, PermissionManager, IWithStoreBehavior, IWithSharingBehavior } from "../core";
1
+ import { IHubSite, IWithPermissionBehavior, IWithCatalogBehavior, IWithStoreBehavior, IWithSharingBehavior } from "../core";
2
2
  import { Catalog } from "../search/Catalog";
3
3
  import { IArcGISContext } from "../ArcGISContext";
4
4
  import { HubItemEntity } from "../core/HubItemEntity";
@@ -9,7 +9,6 @@ import { IContainsResponse, IDeepCatalogInfo } from "../search";
9
9
  */
10
10
  export declare class HubSite extends HubItemEntity<IHubSite> implements IWithStoreBehavior<IHubSite>, IWithPermissionBehavior, IWithCatalogBehavior, IWithSharingBehavior {
11
11
  private _catalog;
12
- private _permissionManager;
13
12
  private _catalogCache;
14
13
  /**
15
14
  * Private constructor so we don't have `new` all over the place. Allows for
@@ -22,11 +21,6 @@ export declare class HubSite extends HubItemEntity<IHubSite> implements IWithSto
22
21
  * @returns
23
22
  */
24
23
  get catalog(): Catalog;
25
- /**
26
- * PermissionManager instance for this site. Note: Do not hold direct references to this object; always access it from the site.
27
- * @returns
28
- */
29
- get permissions(): PermissionManager;
30
24
  /**
31
25
  * Create an instance from an IHubSite object
32
26
  * @param json - JSON object to create a HubSite from
@@ -57,7 +57,7 @@ export declare function fetchSite(identifier: string, requestOptions: IHubReques
57
57
  * @param requestOptions
58
58
  * @returns
59
59
  */
60
- export declare function convertModelToSite(model: IModel, requestOptions: IHubRequestOptions): IHubSite;
60
+ export declare function convertModelToSite(model: IModel, requestOptions: IRequestOptions): IHubSite;
61
61
  /**
62
62
  * Convert a Hub Site Application item into a Hub Site, fetching any
63
63
  * additional information that may be required
@@ -0,0 +1,11 @@
1
+ import { IPermissionPolicy } from "../../permissions/types";
2
+ /**
3
+ * Site Permissions
4
+ * This feeds into the Permissions type
5
+ */
6
+ export declare const SitePermissions: readonly ["hub:site:create", "hub:site:delete", "hub:site:edit", "hub:site:view"];
7
+ /**
8
+ * Site permission policies
9
+ * @private
10
+ */
11
+ export declare const SitesPermissionPolicies: IPermissionPolicy[];
@@ -0,0 +1,7 @@
1
+ import { IModel } from "../../index";
2
+ /**
3
+ * Informal migration that creates default permission policies based on the
4
+ * Content and Collaboration Groups
5
+ * @param model
6
+ */
7
+ export declare function applyPermissionMigration(model: IModel): IModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/hub-common",
3
- "version": "11.23.3",
3
+ "version": "12.0.0-alpha.2",
4
4
  "description": "Common TypeScript types and utility functions for @esri/hub.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/esm/index.js",