@manta-eu/client 0.9.0 → 0.10.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.
@@ -1497,8 +1497,10 @@ export type GQLManualActionChangeAssigneesPayload = {
1497
1497
 
1498
1498
  export type GQLManualActionProgressResult = {
1499
1499
  __typename?: "ManualActionProgressResult";
1500
+ ended: Scalars["Boolean"]["output"];
1500
1501
  manualAction?: Maybe<GQLManualActionResult>;
1501
1502
  state: Array<Scalars["String"]["output"]>;
1503
+ workflowStatus?: Maybe<Scalars["String"]["output"]>;
1502
1504
  };
1503
1505
 
1504
1506
  export type GQLManualActionResolvePayload = {
@@ -5803,6 +5805,8 @@ export type GQLManualActionProgressQuery = {
5803
5805
  manualActionProgress?: {
5804
5806
  __typename?: "ManualActionProgressResult";
5805
5807
  state: Array<string>;
5808
+ ended: boolean;
5809
+ workflowStatus?: string | null;
5806
5810
  manualAction?: {
5807
5811
  __typename?: "ManualActionResult";
5808
5812
  status?: string | null;
@@ -11852,6 +11856,8 @@ export const ManualActionProgressDocument = `
11852
11856
  query ManualActionProgress($namedGraphIri: String!, $subjectIri: String!) {
11853
11857
  manualActionProgress(namedGraphIri: $namedGraphIri, subjectIri: $subjectIri) {
11854
11858
  state
11859
+ ended
11860
+ workflowStatus
11855
11861
  manualAction {
11856
11862
  status
11857
11863
  assignees
@@ -8,6 +8,8 @@ export const datastoreQueryParam = "datastore";
8
8
 
9
9
  export const redirectRoutePath = "/redirect";
10
10
 
11
+ export const imageRoutePath = "/image";
12
+
11
13
  export type DatastoreLocation = { datastoreId: string | undefined; path: string };
12
14
 
13
15
  const datastorePathPattern = new RegExp(`^${datastoreRoutePrefix}/([^/]+)(/.*)?$`);
@@ -0,0 +1,47 @@
1
+ import { datastoreRoutePrefix, imageRoutePath } from "./datastore-path";
2
+
3
+ export const imageWidths = [160, 320, 480, 640, 960, 1280, 1920] as const;
4
+
5
+ export type ImageWidth = (typeof imageWidths)[number];
6
+
7
+ const resizableImageTypes: ReadonlySet<string> = new Set([
8
+ "image/png",
9
+ "image/jpeg",
10
+ "image/pjpeg",
11
+ "image/gif",
12
+ "image/webp",
13
+ ]);
14
+
15
+ const smallestImageWidth: ImageWidth = 160;
16
+ const largestImageWidth: ImageWidth = 1920;
17
+
18
+ export function isImageWidth(value: unknown): value is ImageWidth {
19
+ return typeof value === "number" && (imageWidths as readonly number[]).includes(value);
20
+ }
21
+
22
+ export function isResizableImageType(mediaType: string): boolean {
23
+ return resizableImageTypes.has(mediaType.split(";")[0]!.trim().toLowerCase());
24
+ }
25
+
26
+ export function imageWidthFor(cssWidth: number, devicePixelRatio = 1): ImageWidth {
27
+ const needed = Math.ceil(cssWidth * Math.min(Math.max(devicePixelRatio, 1), 3));
28
+ if (!Number.isFinite(needed)) return smallestImageWidth;
29
+
30
+ return imageWidths.find((width) => width >= needed) ?? largestImageWidth;
31
+ }
32
+
33
+ // Name the datastore when the file may sit outside the session's own, since an <img> sends no datastore header.
34
+ // `datastorePrefix` is where the app mounts datastore-scoped routes: "/d" on the platform's own origin.
35
+ export type ImageScope = { datastoreId?: string | null; datastorePrefix?: string };
36
+
37
+ export function imagePath(iri: string, width: ImageWidth, scope: ImageScope = {}): string {
38
+ const { datastoreId, datastorePrefix = datastoreRoutePrefix } = scope;
39
+ const route = datastoreId ? `${datastorePrefix}/${encodeURIComponent(datastoreId)}${imageRoutePath}` : imageRoutePath;
40
+
41
+ return `${route}?iri=${encodeURIComponent(iri)}&width=${width}`;
42
+ }
43
+
44
+ // Every ladder width as `srcset` candidates; pair it with `sizes` so the browser picks the width itself.
45
+ export function imageSrcSet(iri: string, scope: ImageScope = {}): string {
46
+ return imageWidths.map((width) => `${imagePath(iri, width, scope)} ${width}w`).join(", ");
47
+ }