Skip to content

Commit

Permalink
Merge branch 'f/10007-notices' of github.com:Esri/hub.js into f/10007…
Browse files Browse the repository at this point in the history
…-notices
  • Loading branch information
jordantsanz committed May 13, 2024
2 parents 575595a + f1c6f2b commit 520aa34
Show file tree
Hide file tree
Showing 122 changed files with 5,610 additions and 478 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,108 @@
## @esri/hub-common [14.127.1](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-09)


### Bug Fixes

* add content to site propertyMap, allow more props on ICapabilityConfig ([#1508](https://github.com/Esri/hub.js/issues/1508)) ([c947301](https://github.com/Esri/hub.js/commit/c947301d2090e9e3a8a520e92a2026544cf18e15))

# @esri/hub-common [14.127.0](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-09)


### Features

* **hub-common:** add attendees settings pane ([#1475](https://github.com/Esri/hub.js/issues/1475)) ([0c49423](https://github.com/Esri/hub.js/commit/0c49423ff09d9d540f3598c2daddae00ed805c1a))

## @esri/hub-common [14.126.4](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-08)


### Bug Fixes

* **hub-common:** get-events dto enum array types ([#1507](https://github.com/Esri/hub.js/issues/1507)) ([fb2e67a](https://github.com/Esri/hub.js/commit/fb2e67a5eff93773412e3019e5c674e78c93f008))

## @esri/hub-common [14.126.3](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-08)


### Bug Fixes

* **hub-common:** fix undefined token when getting schedule ([#1506](https://github.com/Esri/hub.js/issues/1506)) ([7f8c782](https://github.com/Esri/hub.js/commit/7f8c78214f99401979bcc9c31507f85c2002fff5))

## @esri/hub-common [14.126.2](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-08)


### Bug Fixes

* **hub-common:** fix undefined token when getSchedule is called ([#1505](https://github.com/Esri/hub.js/issues/1505)) ([9be1d5f](https://github.com/Esri/hub.js/commit/9be1d5fa13471e3715ea3106f75df042e0e6b1c0))

## @esri/hub-common [14.126.1](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-08)


### Bug Fixes

* updates well known types to fix gallery query ([#1492](https://github.com/Esri/hub.js/issues/1492)) ([24f0f97](https://github.com/Esri/hub.js/commit/24f0f9710f1392c8942d6ef664cfb7877c39c5d8))

# @esri/hub-common [14.126.0](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-07)


### Features

* **hub-common:** add token to schedule api endpoints ([#1502](https://github.com/Esri/hub.js/issues/1502)) ([3206757](https://github.com/Esri/hub.js/commit/32067577788c1142f9f01e611e0abd6e469d5d27))

## @esri/hub-common [14.125.2](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-07)


### Bug Fixes

* **hub-common:** add IAssociation, update IEvent with associations, a… ([#1498](https://github.com/Esri/hub.js/issues/1498)) ([2562bd2](https://github.com/Esri/hub.js/commit/2562bd275740b49307375c6013e590fb5e9c28f9))

## @esri/hub-common [14.125.1](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-06)


### Bug Fixes

* **hub-common:** fix unified list feature flag, format order, and additional resource calculation ([#1501](https://github.com/Esri/hub.js/issues/1501)) ([46d4715](https://github.com/Esri/hub.js/commit/46d4715bc5f330dc15fda57ee12601a62d80d782))

# @esri/hub-common [14.125.0](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-06)


### Features

* scheduler force update ([#1494](https://github.com/Esri/hub.js/issues/1494)) ([5a8c47b](https://github.com/Esri/hub.js/commit/5a8c47b5499bab2da494003082c38bd8b95aafdf))

# @esri/hub-common [14.124.0](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-06)


### Features

* remove default groups ([#1483](https://github.com/Esri/hub.js/issues/1483)) ([61a48f4](https://github.com/Esri/hub.js/commit/61a48f4b6082e93862d1e751e482190dfa577044))

## @esri/hub-common [14.123.1](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-03)


### Bug Fixes

* **hub-common:** fix createHubEvent method and property mappings ([#1496](https://github.com/Esri/hub.js/issues/1496)) ([944dcb8](https://github.com/Esri/hub.js/commit/944dcb8de601368e914e2fa1b077ba265f4820c9))

# @esri/hub-common [14.123.0](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-02)


### Features

* **hub-common:** add support for searching for Events3 events from h… ([#1476](https://github.com/Esri/hub.js/issues/1476)) ([4afe9a4](https://github.com/Esri/hub.js/commit/4afe9a4e2bf366ebbca39923818cc29ec4121c0f))

## @esri/hub-common [14.122.1](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-02)


### Bug Fixes

* **hub-common:** restrict temp:hub:content:downloads:unifiedList to be behind a feature flag ([#1495](https://github.com/Esri/hub.js/issues/1495)) ([d53f50f](https://github.com/Esri/hub.js/commit/d53f50fef63edbb63ba3e74a8ccd068799288e54))

# @esri/hub-common [14.122.0](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-05-01)


### Features

* **hub-common:** add new utils for a unified download flow ([#1482](https://github.com/Esri/hub.js/issues/1482)) ([7f45d61](https://github.com/Esri/hub.js/commit/7f45d61bec8c8b79227834df6ac02ea4ae7f4328))

## @esri/hub-common [14.121.2](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2024-04-30)


Expand Down
4 changes: 2 additions & 2 deletions packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@esri/hub-common",
"version": "14.121.2",
"version": "14.127.1",
"description": "Common TypeScript types and utility functions for @esri/hub.js.",
"main": "dist/node/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/ArcGISContextManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ const HUB_SERVICE_STATUS: HubServiceStatus = {
notifications: "online",
"hub-search": "online",
domains: "online",
"hub-downloads": "online",
};

const ENTERPRISE_SITES_SERVICE_STATUS: HubServiceStatus = {
Expand All @@ -749,6 +750,7 @@ const ENTERPRISE_SITES_SERVICE_STATUS: HubServiceStatus = {
notifications: "not-available",
"hub-search": "not-available",
domains: "not-available",
"hub-downloads": "not-available",
};

const DEV_ALPHA_ORGS = [
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/content/_internal/ContentBusinessRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const ContentPermissions = [
"hub:content:manage",
"hub:content:canRecordDownloadErrors",
"hub:content:downloads:displayErrors",
"temp:hub:content:downloads:unifiedList",
] as const;

/**
Expand Down Expand Up @@ -134,4 +135,8 @@ export const ContentPermissionPolicies: IPermissionPolicy[] = [
availability: ["alpha"],
environments: ["qaext", "devext"],
},
{
permission: "temp:hub:content:downloads:unifiedList",
availability: ["flag"],
},
];
7 changes: 7 additions & 0 deletions packages/common/src/content/_internal/ContentSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,12 @@ export const ContentSchema: IConfigurationSchema = {
schedule: {
type: "object",
},
_forceUpdate: {
type: "array",
items: {
type: "boolean",
enum: [true],
},
},
},
} as IConfigurationSchema;
29 changes: 21 additions & 8 deletions packages/common/src/content/_internal/ContentUiSchemaSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { checkPermission } from "../..";
import { IArcGISContext } from "../../ArcGISContext";
import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions";
import { IUiSchema } from "../../core/schemas/types";
import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types";
import { IHubEditableContent } from "../../core/types/IHubEditableContent";
import { isHostedFeatureServiceEntity } from "../hostedServiceUtils";

Expand Down Expand Up @@ -45,13 +45,26 @@ export const buildUiSchema = async (
{ type: "weekly" },
{ type: "monthly" },
{ type: "yearly" },
// uncomment this when the manual option is available
// {
// label: `option.manual.label`,
// type: "manual",
// helperActionIcon: "information-f",
// helperActionText: "option.manual.helperActionText",
// },
{
type: "manual",
helperActionIcon: "information-f",
helperActionText: `{{${i18nScope}.fields.schedule.manual.helperActionText:translate}}`,
},
],
},
},
// force update checkbox -- TODO: replace with button once available
{
type: "Control",
scope: "/properties/_forceUpdate",
options: {
control: "hub-field-input-tile-select",
type: "checkbox",
labels: [
`{{${i18nScope}.fields.schedule.forceUpdateButton.label:translate}}`,
],
descriptions: [
`{{${i18nScope}.fields.schedule.forceUpdateButton.description:translate}}`,
],
},
},
Expand Down
23 changes: 21 additions & 2 deletions packages/common/src/content/_internal/computeProps.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { IRequestOptions } from "@esri/arcgis-rest-request";
import { UserSession } from "@esri/arcgis-rest-auth";
import { getItemThumbnailUrl } from "../../resources";
import { IModel } from "../../types";
import { IHubRequestOptions, IModel } from "../../types";
import { getItemHomeUrl } from "../../urls/get-item-home-url";
import { getContentEditUrl, getHubRelativeUrl } from "./internalContentUtils";
import {
getAdditionalResources,
getContentEditUrl,
getHubRelativeUrl,
} from "./internalContentUtils";
import { IHubEditableContent } from "../../core/types/IHubEditableContent";
import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl";
import { isDiscussable } from "../../discussions";
Expand All @@ -12,6 +16,7 @@ import {
ServiceCapabilities,
} from "../hostedServiceUtils";
import { computeBaseProps } from "../../core/_internal/computeBaseProps";
import { getProp } from "../../objects";
import { IHubEditableContentEnrichments } from "../../items/_enrichments";

export function computeProps(
Expand Down Expand Up @@ -58,6 +63,20 @@ export function computeProps(
ServiceCapabilities.EXTRACT,
enrichments.server
);
const extractFormatsList: string = getProp(
enrichments,
"server.supportedExportFormats"
);
content.serverExtractFormats =
extractFormatsList && extractFormatsList.split(",");
}

if (enrichments.metadata) {
content.additionalResources = getAdditionalResources(
model.item,
enrichments.metadata,
requestOptions as IHubRequestOptions
);
}

return content as IHubEditableContent;
Expand Down
12 changes: 0 additions & 12 deletions packages/common/src/content/_internal/getSchedulerApiUrl.ts

This file was deleted.

35 changes: 35 additions & 0 deletions packages/common/src/content/_internal/internalContentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import { _getHubUrlFromPortalHostname } from "../../urls/_get-hub-url-from-porta
import { IRequestOptions } from "@esri/arcgis-rest-request";
import { geojsonToArcGIS } from "@terraformer/arcgis";
import { Polygon } from "geojson";
import { getHubApiUrl } from "../../api";
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";

/**
* Hashmap of Hub environment and application url surfix
Expand Down Expand Up @@ -247,6 +249,7 @@ export const getHubRelativeUrl = (
"project",
"initiative",
"discussion",
"event",
];
// default to the catchall content route
let path = "/content";
Expand Down Expand Up @@ -965,3 +968,35 @@ const getUrbanModelEditUrl = (item: IItem, requestOptions: IRequestOptions) => {
const isPortalFromUrl = (portalUrl: string): boolean => {
return portalUrl.indexOf("arcgis.com") === -1;
};

export function getSchedulerApiUrl(
itemId: string,
requestOptions: IUserRequestOptions
): string {
const hubApiUrlRoot = getHubApiUrlRoot(requestOptions);
return `${hubApiUrlRoot}/api/download/v1/items/${itemId}/schedule?token=${requestOptions.authentication.token}`;
}

export function getHubApiUrlRoot(requestOptions: IRequestOptions): string {
// sometimes the url has /api/v3 at the end, so we need to remove it
const hubApiUrlWithVersion = getHubApiUrl(requestOptions);
return hubApiUrlWithVersion.replace(/\/api\/v3$/, "");
}

export const forceUpdateContent = async (
itemId: string,
requestOptions: IUserRequestOptions
) => {
const hubApiUrlRoot = getHubApiUrl(requestOptions);
const url = `${hubApiUrlRoot}/api/v3/jobs/item/${itemId}/harvest`;
const options = {
method: "POST",
headers: {
"content-type": "application/json",
authorization: requestOptions.authentication.token,
},
};

const response = await fetch(url, options);
return response.ok;
};
10 changes: 10 additions & 0 deletions packages/common/src/content/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
isDownloadSchedulingAvailable,
maybeUpdateSchedule,
} from "./manageSchedule";
import { forceUpdateContent } from "./_internal/internalContentUtils";
import { deepEqual } from "../objects";

// TODO: move this to defaults?
const DEFAULT_CONTENT_MODEL: IModel = {
Expand Down Expand Up @@ -174,6 +176,14 @@ export async function updateContent(
}

if (isDownloadSchedulingAvailable(requestOptions, content.access)) {
// if schedule has "Force Update" checked and clicked save, initiate an update
if (deepEqual(content._forceUpdate, [true])) {
// [true]
await forceUpdateContent(item.id, requestOptions);
}

delete content._forceUpdate;

await maybeUpdateSchedule(content, requestOptions);
}

Expand Down
Loading

0 comments on commit 520aa34

Please sign in to comment.