@piveau/dpi 0.2.0-alpha.64 → 0.2.0-alpha.65

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.
@@ -1,90 +1,89 @@
1
- import { pipe as A } from "effect";
2
- import * as p from "effect/Option";
3
- import * as F from "jsonld";
4
- import { schemaProject as $ } from "../../schema/projectLdSchema.js";
5
- import { getFirstItem as E, extractStringValue as t, extractLocalizedString as z } from "../useDpiSimpleLoader.js";
6
- import { isNonNullable as f } from "./encodeProject.js";
7
- import { weiterdenkenQuestions as Q, umsetzenQuestions as U, planenQuestions as R, initiierenQuestions as V } from "./questions.js";
8
- import { PREFIXES as q, nonEmpty as S } from "./shared.js";
9
- function j(n) {
10
- const r = (n || "").trim();
11
- if (!r)
1
+ import { pipe as N } from "effect";
2
+ import * as u from "effect/Option";
3
+ import * as H from "jsonld";
4
+ import { schemaProject as _ } from "../../schema/projectLdSchema.js";
5
+ import { getFirstItem as z, extractStringValue as t, extractLocalizedString as G } from "../useDpiSimpleLoader.js";
6
+ import { isNonNullable as m } from "./encodeProject.js";
7
+ import { PREFIXES as M, nonEmpty as S } from "./shared.js";
8
+ function E(n) {
9
+ const i = (n || "").trim();
10
+ if (!i)
12
11
  return "";
13
12
  try {
14
- const a = new URL(r).pathname.split("/").filter(Boolean);
15
- return a[a.length - 1] || "";
13
+ const r = new URL(i).pathname.split("/").filter(Boolean);
14
+ return r[r.length - 1] || "";
16
15
  } catch {
17
- return r;
16
+ return i;
18
17
  }
19
18
  }
20
- async function W(n) {
21
- const r = {
22
- "@context": q,
19
+ async function $(n) {
20
+ const i = {
21
+ "@context": M,
23
22
  "@type": "schema:Project"
24
- }, s = await F.frame(n, r, {
23
+ }, a = await H.frame(n, i, {
25
24
  embed: "@always",
26
25
  omitGraph: !0
27
- }), a = await F.compact(s, q, {
26
+ }), r = await H.compact(a, M, {
28
27
  compactArrays: !1,
29
28
  graph: !1
30
- }), d = $.safeParse(E(a == null ? void 0 : a["@graph"]));
31
- if (!d.success)
29
+ }), c = _.safeParse(z(r == null ? void 0 : r["@graph"]));
30
+ if (!c.success)
32
31
  throw new Error(`Failed to parse project
33
32
 
34
- ${d.error.message}`);
35
- return d.data;
33
+ ${c.error.message}`);
34
+ return c.data;
36
35
  }
37
- function K(n) {
38
- return S(E(n["@id"]));
36
+ function q(n) {
37
+ return S(z(n["@id"]));
39
38
  }
40
- function C(n, r) {
41
- var a, d;
42
- const { visibility: s } = r;
39
+ function U(n, i) {
40
+ var r, c;
41
+ const { visibility: a } = i;
43
42
  return {
44
43
  "Auffindbarkeit/Sichtbarkeit": {
45
- visibility: s
44
+ visibility: a
46
45
  },
47
46
  "Auffindbarkeit/Kategorien": {
48
- categories: ((a = n["dcat:theme"]) == null ? void 0 : a.map(K).filter(f)) || []
47
+ categories: ((r = n["dcat:theme"]) == null ? void 0 : r.map(q).filter(m)) || []
49
48
  },
50
49
  "Auffindbarkeit/Anwendungsbereiche": {
51
- applications: ((d = n["schema:application"]) == null ? void 0 : d.filter(f)) || []
50
+ applications: ((c = n["schema:application"]) == null ? void 0 : c.filter(m)) || []
52
51
  }
53
52
  };
54
53
  }
55
- function X(n) {
56
- var s;
57
- const r = (s = n["dcat:contactPoint"]) == null ? void 0 : s.map((a) => ({
58
- name: S(t(a["vcard:fn"])),
59
- mail: S(t(a["vcard:hasEmail"])),
60
- phone: S(t(a["vcard:hasTelephone"]))
61
- })).filter(f);
54
+ function R(n) {
55
+ var a;
56
+ const i = (a = n["dcat:contactPoint"]) == null ? void 0 : a.map((r) => ({
57
+ name: S(t(r["vcard:fn"])),
58
+ mail: S(t(r["vcard:hasEmail"])),
59
+ phone: S(t(r["vcard:hasTelephone"]))
60
+ })).filter(m);
62
61
  return {
63
62
  "Grundlegende Informationen/Name": {
64
- projectName: A(
65
- p.fromNullable(z(n["dct:title"], "de")),
66
- p.flatMap((a) => S(a) ? p.some(a) : p.none()),
67
- p.getOrThrowWith(() => new Error("Project name is missing"))
63
+ projectName: N(
64
+ u.fromNullable(G(n["dct:title"], "de")),
65
+ u.flatMap((r) => S(r) ? u.some(r) : u.none()),
66
+ u.getOrThrowWith(() => new Error("Project name is missing"))
68
67
  )
69
68
  },
70
69
  "Grundlegende Informationen/Beschreibung": {
71
- projectDescription: A(
72
- p.fromNullable(z(n["dct:description"], "de")),
70
+ projectDescription: N(
71
+ u.fromNullable(G(n["dct:description"], "de")),
73
72
  // O.flatMap(s => nonEmpty(s) ? O.some(s) : O.none()),
74
73
  // O.getOrThrowWith(() => new Error('Project description is missing')),
75
- p.getOrElse(() => "")
74
+ u.getOrElse(() => "")
76
75
  )
77
76
  },
78
77
  "Grundlegende Informationen/Projektstatus": {
79
- projectName: A(
80
- p.fromNullable(n["schema:status"]),
78
+ projectName: N(
79
+ u.fromNullable(n["schema:status"]),
81
80
  // O.flatMap(s => nonEmpty(s) ? O.some(s) : O.none()),
82
81
  // O.getOrThrowWith(() => new Error('Project status is missing')),
83
- p.getOrElse(() => "")
82
+ u.getOrElse(() => "")
84
83
  )
85
84
  },
86
85
  "Grundlegende Informationen/Organisation": {
87
- contact: E(r || []) || {
86
+ contact: z(i || []) || {
88
87
  name: "",
89
88
  mail: "",
90
89
  phone: ""
@@ -92,66 +91,62 @@ function X(n) {
92
91
  }
93
92
  };
94
93
  }
95
- function Y(n) {
96
- var r, s, a, d, g, w, P, i;
94
+ function V(n) {
95
+ var i, a, r, c, h, P, v, o;
97
96
  return {
98
97
  "Optionale Daten": {
99
- partners: ((r = n["dct:contributor"]) == null ? void 0 : r.map((c) => ({
100
- name: t(c["foaf:name"]),
101
- url: t(c["foaf:homepage"])
102
- })).filter(f)) || [],
103
- requiredExpertise: ((s = n["schema:skills"]) == null ? void 0 : s.map(t).filter(f)) || [],
104
- references: ((d = (a = n["dct:references"]) == null ? void 0 : a.filter((c) => c["dct:type"] === "image")) == null ? void 0 : d.map((c) => ({
105
- homepage: t(c["schema:url"])
106
- })).filter(f)) || [],
98
+ partners: ((i = n["dct:contributor"]) == null ? void 0 : i.map((l) => ({
99
+ name: t(l["foaf:name"]),
100
+ url: t(l["foaf:homepage"])
101
+ })).filter(m)) || [],
102
+ requiredExpertise: ((a = n["schema:skills"]) == null ? void 0 : a.map(t).filter(m)) || [],
103
+ references: ((c = (r = n["dct:references"]) == null ? void 0 : r.filter((l) => l["dct:type"] === "image")) == null ? void 0 : c.map((l) => ({
104
+ homepage: t(l["schema:url"])
105
+ })).filter(m)) || [],
107
106
  startDate: t(n["schema:startDate"] || ""),
108
107
  endDate: t(n["schema:endDate"] || ""),
109
- budget: t(((g = n["schema:amount"]) == null ? void 0 : g["schema:value"]) || ""),
110
- budgetDescription: t(((w = n["schema:amount"]) == null ? void 0 : w["schema:description"]) || ""),
108
+ budget: t(((h = n["schema:amount"]) == null ? void 0 : h["schema:value"]) || ""),
109
+ budgetDescription: t(((P = n["schema:amount"]) == null ? void 0 : P["schema:description"]) || ""),
111
110
  // todo:
112
- links: ((i = (P = n["dct:references"]) == null ? void 0 : P.filter((c) => c["dct:type"] === "documentation")) == null ? void 0 : i.map((c) => ({
113
- name: t(c["dct:title"]),
114
- url: t(c["schema:url"]),
115
- description: t(c["dct:description"])
116
- })).filter(f)) || []
111
+ links: ((o = (v = n["dct:references"]) == null ? void 0 : v.filter((l) => l["dct:type"] === "documentation")) == null ? void 0 : o.map((l) => ({
112
+ name: t(l["dct:title"]),
113
+ url: t(l["schema:url"]),
114
+ description: t(l["dct:description"])
115
+ })).filter(m)) || []
117
116
  }
118
117
  };
119
118
  }
120
- function J(n) {
121
- const r = n["schema:hasPart"] ?? [], s = (m) => r.find((u) => u["dct:type"] === m), a = (m) => {
122
- var h, D;
123
- const u = /* @__PURE__ */ new Map(), k = [...(m == null ? void 0 : m["schema:question"]) ?? []].sort((e, l) => {
124
- const b = Number.parseInt(t(e["schema:position"])), x = Number.parseInt(t(l["schema:position"]));
125
- return (Number.isNaN(b) ? 0 : b) - (Number.isNaN(x) ? 0 : x);
126
- });
127
- for (const e of k) {
128
- const l = (h = e["schema:text"]) == null ? void 0 : h.trim(), b = (D = e["schema:acceptedAnswer"]) == null ? void 0 : D.trim();
129
- l && b && u.set(l, b);
119
+ function W(n) {
120
+ const i = n["schema:hasPart"] ?? [], a = (d) => i.find((f) => f["dct:type"] === d), r = (d) => {
121
+ var b;
122
+ const f = /* @__PURE__ */ new Map(), D = (d == null ? void 0 : d["schema:question"]) ?? [];
123
+ for (const p of D) {
124
+ const w = Number.parseInt(t(p["schema:position"])), e = (b = p["schema:acceptedAnswer"]) == null ? void 0 : b.trim();
125
+ !Number.isNaN(w) && e && f.set(w, e);
130
126
  }
131
- return u;
132
- }, d = V, g = R, w = U, P = Q, i = (m, u) => {
133
- const v = s(m), k = a(v), h = {};
134
- for (const [D, e] of Object.entries(u)) {
135
- const l = k.get(e);
136
- l && (h[D] = l);
137
- }
138
- return h;
139
- }, c = i("Initiieren", d), y = i("Planen", g), N = i("Umsetzen", w), I = i("Weiterdenken", P);
127
+ return f;
128
+ }, c = (d, f) => {
129
+ const D = a(d), b = r(D), p = {};
130
+ return f.forEach((w, e) => {
131
+ const g = e + 1, j = b.get(g);
132
+ j && (p[w] = j);
133
+ }), p;
134
+ }, h = ["projectTriggers", "involvedStakeholders", "dataCollectionMethod", "budgetPlanning"], P = ["requirementsGatherings", "tenderFormat", "tenderTips", "resourcePlanning"], v = ["projectTriggers", "involvedStakeholders", "dataCollectionMethod", "budgetPlanning"], o = ["projectTriggers", "involvedStakeholders", "dataCollectionMethod", "budgetPlanning"], l = c("Initiieren", h), y = c("Planen", P), I = c("Umsetzen", v), k = c("Weiterdenken", o);
140
135
  return {
141
136
  "Projektphasen (optional)": {},
142
- "Projektphasen (optional)/Initiieren": c,
137
+ "Projektphasen (optional)/Initiieren": l,
143
138
  "Projektphasen (optional)/Planen": y,
144
- "Projektphasen (optional)/Umsetzen": N,
145
- "Projektphasen (optional)/Weiterdenken": I
139
+ "Projektphasen (optional)/Umsetzen": I,
140
+ "Projektphasen (optional)/Weiterdenken": k
146
141
  };
147
142
  }
148
- function L(n) {
149
- const r = n["p-plan:hasStep"] ?? [], s = {
143
+ function X(n) {
144
+ const i = n["p-plan:hasStep"] ?? [], a = {
150
145
  datenerfassung: "1. Datenerfassung",
151
146
  datenverarbeitung: "2. Datenverarbeitung",
152
147
  datensimulation: "3. Datensimulation",
153
148
  datenvisualisierung: "4. Datenvisualisierung"
154
- }, a = {
149
+ }, r = {
155
150
  "Technische Prozessschritte": {},
156
151
  "1. Datenerfassung/Grundlegende Informationen": {},
157
152
  "1. Datenerfassung/Software": {},
@@ -169,76 +164,76 @@ function L(n) {
169
164
  "4. Datenvisualisierung/Software": {},
170
165
  "4. Datenvisualisierung/Datensätze": {},
171
166
  "4. Datenvisualisierung/Hardware": {}
172
- }, d = (i) => `${i}/Grundlegende Informationen`, g = (i) => `${i}/Software`, w = (i) => `${i}/Datensätze`, P = (i) => `${i}/Hardware`;
173
- for (const i of r) {
174
- const c = (t(i["p-plan:Activity"] || "") || "").trim().toLowerCase(), y = s[c];
167
+ }, c = (o) => `${o}/Grundlegende Informationen`, h = (o) => `${o}/Software`, P = (o) => `${o}/Datensätze`, v = (o) => `${o}/Hardware`;
168
+ for (const o of i) {
169
+ const l = (t(o["p-plan:Activity"] || "") || "").trim().toLowerCase(), y = a[l];
175
170
  if (!y)
176
171
  continue;
177
- const N = z(i["dct:description"], "de") || "", I = N === "__EMPTY__" ? "" : N, m = (i["prov:used"] || []).map((e) => ({
172
+ const I = G(o["dct:description"], "de") || "", k = I === "__EMPTY__" ? "" : I, d = (o["prov:used"] || []).map((e) => ({
178
173
  name: t(e["dct:title"]) || ""
179
174
  // description: extractStringValue(m['dct:description']) || undefined,
180
- })).filter((e) => (e.name ?? "").length > 0), u = (i["dct:references"] || []).filter((e) => t(e["dct:type"]) === "documentation").map((e) => ({
175
+ })).filter((e) => (e.name ?? "").length > 0), f = (o["dct:references"] || []).filter((e) => t(e["dct:type"]) === "documentation").map((e) => ({
181
176
  name: t(e["dct:title"]) || "",
182
177
  url: t(e["schema:url"]) || "",
183
178
  description: t(e["dct:description"]) || void 0
184
179
  })).filter((e) => e.url.length > 0 && e.name.length > 0);
185
- (I || m.length > 0 || u.length > 0) && (a[d(y)] = {
186
- ...I ? { description: I } : {},
187
- ...m.length > 0 ? { methods: m } : {},
188
- ...u.length > 0 ? { links: u } : {}
180
+ (k || d.length > 0 || f.length > 0) && (r[c(y)] = {
181
+ ...k ? { description: k } : {},
182
+ ...d.length > 0 ? { methods: d } : {},
183
+ ...f.length > 0 ? { links: f } : {}
189
184
  });
190
- const v = i["p-plan:hasInputVar"] || [], k = v.filter((e) => t(e["@type"]) === "schema:SoftwareApplication").map((e) => ({
191
- id: j(t(e["dct:identifier"]) || ""),
192
- functionalities: (e["schema:featureList"] || []).map((l) => t(l)).filter(f)
185
+ const D = o["p-plan:hasInputVar"] || [], b = D.filter((e) => t(e["@type"]) === "schema:SoftwareApplication").map((e) => ({
186
+ id: E(t(e["dct:identifier"]) || ""),
187
+ functionalities: (e["schema:featureList"] || []).map((g) => t(g)).filter(m)
193
188
  })).filter((e) => e.id.length > 0);
194
- k.length > 0 && (a[g(y)] = {
195
- selected: k
189
+ b.length > 0 && (r[h(y)] = {
190
+ selected: b
196
191
  });
197
- const h = v.filter((e) => t(e["@type"]) === "dcat:Dataset").map((e) => ({ id: j(t(e["dct:identifier"]) || "") })).filter((e) => e.id.length > 0);
198
- h.length > 0 && (a[w(y)] = {
199
- selected: h
192
+ const p = D.filter((e) => t(e["@type"]) === "dcat:Dataset").map((e) => ({ id: E(t(e["dct:identifier"]) || "") })).filter((e) => e.id.length > 0);
193
+ p.length > 0 && (r[P(y)] = {
194
+ selected: p
200
195
  });
201
- const D = v.filter((e) => t(e["@type"]) === "ssn:System").map((e) => {
202
- const l = e["ssn:deployedSystem"], b = j(t(e["dct:identifier"]) || ""), x = l && typeof l == "object" ? j(t(l["@id"]) || l["@id"]) : "", _ = b || x, G = z(e["dct:description"], "de") || void 0, H = (e["ssn:forProperty"] || []).map((o) => t(o)).filter(f), M = (e["sosa:hasLocation"] || []).map((o) => ({ lat: t(o["geo:lat"]) || "", lng: t(o["geo:long"]) || "" })).filter((o) => o.lat.length > 0 && o.lng.length > 0), O = (e["foaf:depiction"] || []).map((o) => K(o)).filter(f), T = (e["dct:references"] || []).filter((o) => t(o["dct:type"]) === "documentation").map((o) => ({
203
- name: t(o["dct:title"]) || "",
204
- url: t(o["schema:url"]) || "",
205
- description: t(o["dct:description"]) || void 0
206
- })).filter((o) => o.url.length > 0), B = (e["ssn-system:hasSystemCapability"] || []).map((o) => t(o)).filter(f);
196
+ const w = D.filter((e) => t(e["@type"]) === "ssn:System").map((e) => {
197
+ const g = e["ssn:deployedSystem"], j = E(t(e["dct:identifier"]) || ""), C = g && typeof g == "object" ? E(t(g["@id"]) || g["@id"]) : "", K = j || C, A = G(e["dct:description"], "de") || void 0, F = (e["ssn:forProperty"] || []).map((s) => t(s)).filter(m), O = (e["sosa:hasLocation"] || []).map((s) => ({ lat: t(s["geo:lat"]) || "", lng: t(s["geo:long"]) || "" })).filter((s) => s.lat.length > 0 && s.lng.length > 0), T = (e["foaf:depiction"] || []).map((s) => q(s)).filter(m), B = (e["dct:references"] || []).filter((s) => t(s["dct:type"]) === "documentation").map((s) => ({
198
+ name: t(s["dct:title"]) || "",
199
+ url: t(s["schema:url"]) || "",
200
+ description: t(s["dct:description"]) || void 0
201
+ })).filter((s) => s.url.length > 0), x = (e["ssn-system:hasSystemCapability"] || []).map((s) => t(s)).filter(m);
207
202
  return {
208
- id: _,
209
- ...G ? { description: G } : {},
210
- ...H.length > 0 ? { forProperty: H } : {},
211
- ...M.length > 0 ? { locations: M } : {},
212
- ...O.length > 0 ? { depictions: O } : {},
213
- ...T.length > 0 ? { references: T } : {},
214
- ...B.length > 0 ? { functionalities: B } : {},
203
+ id: K,
204
+ ...A ? { description: A } : {},
205
+ ...F.length > 0 ? { forProperty: F } : {},
206
+ ...O.length > 0 ? { locations: O } : {},
207
+ ...T.length > 0 ? { depictions: T } : {},
208
+ ...B.length > 0 ? { references: B } : {},
209
+ ...x.length > 0 ? { functionalities: x } : {},
215
210
  isHostedBy: e["sosa:isHostedBy"] || [],
216
211
  hosts: []
217
212
  };
218
213
  }).filter((e) => (e.id ?? "").length > 0);
219
- D.length > 0 && (a[P(y)] = {
220
- selected: D
214
+ w.length > 0 && (r[v(y)] = {
215
+ selected: w
221
216
  });
222
217
  }
223
- return a;
218
+ return r;
224
219
  }
225
- async function re(n, r) {
226
- const s = await W(n);
220
+ async function ee(n, i) {
221
+ const a = await $(n);
227
222
  return {
228
223
  Landing: {},
229
- ...C(s, { visibility: (r == null ? void 0 : r.visibility) || "public" }),
230
- ...X(s),
231
- ...Y(s),
232
- ...J(s),
233
- ...L(s),
224
+ ...U(a, { visibility: (i == null ? void 0 : i.visibility) || "public" }),
225
+ ...R(a),
226
+ ...V(a),
227
+ ...W(a),
228
+ ...X(a),
234
229
  Vorschau: {}
235
230
  };
236
231
  }
237
232
  export {
238
- re as decodeProject,
239
- C as toAuffindbarkeit,
240
- X as toGrundlegendeInformationen,
241
- Y as toOptionaleDaten,
242
- J as toProjektphasen,
243
- L as toTechnicalProcessSteps
233
+ ee as decodeProject,
234
+ U as toAuffindbarkeit,
235
+ R as toGrundlegendeInformationen,
236
+ V as toOptionaleDaten,
237
+ W as toProjektphasen,
238
+ X as toTechnicalProcessSteps
244
239
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@piveau/dpi",
3
3
  "type": "module",
4
- "version": "0.2.0-alpha.64",
4
+ "version": "0.2.0-alpha.65",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "*.css",