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

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,89 +1,90 @@
1
1
  import { pipe as A } from "effect";
2
- import * as f from "effect/Option";
3
- import * as H from "jsonld";
4
- import { schemaProject as C } from "../../schema/projectLdSchema.js";
5
- import { getFirstItem as G, extractStringValue as t, extractLocalizedString as N } from "../useDpiSimpleLoader.js";
6
- import { isNonNullable as h } from "./encodeProject.js";
7
- import { PREFIXES as F, nonEmpty as I } from "./shared.js";
8
- function W(n) {
9
- const a = (n || "").trim();
10
- if (!a)
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)
11
12
  return "";
12
13
  try {
13
- const r = new URL(a).pathname.split("/").filter(Boolean);
14
- return r[r.length - 1] || "";
14
+ const a = new URL(r).pathname.split("/").filter(Boolean);
15
+ return a[a.length - 1] || "";
15
16
  } catch {
16
- return a;
17
+ return r;
17
18
  }
18
19
  }
19
- async function K(n) {
20
- const a = {
21
- "@context": F,
20
+ async function W(n) {
21
+ const r = {
22
+ "@context": q,
22
23
  "@type": "schema:Project"
23
- }, s = await H.frame(n, a, {
24
+ }, s = await F.frame(n, r, {
24
25
  embed: "@always",
25
26
  omitGraph: !0
26
- }), r = await H.compact(s, F, {
27
+ }), a = await F.compact(s, q, {
27
28
  compactArrays: !1,
28
29
  graph: !1
29
- }), l = C.safeParse(G(r == null ? void 0 : r["@graph"]));
30
- if (!l.success)
30
+ }), d = $.safeParse(E(a == null ? void 0 : a["@graph"]));
31
+ if (!d.success)
31
32
  throw new Error(`Failed to parse project
32
33
 
33
- ${l.error.message}`);
34
- return l.data;
34
+ ${d.error.message}`);
35
+ return d.data;
35
36
  }
36
- function U(n) {
37
- return I(G(n["@id"]));
37
+ function K(n) {
38
+ return S(E(n["@id"]));
38
39
  }
39
- function V(n, a) {
40
- var r, l;
41
- const { visibility: s } = a;
40
+ function C(n, r) {
41
+ var a, d;
42
+ const { visibility: s } = r;
42
43
  return {
43
44
  "Auffindbarkeit/Sichtbarkeit": {
44
45
  visibility: s
45
46
  },
46
47
  "Auffindbarkeit/Kategorien": {
47
- categories: ((r = n["dcat:theme"]) == null ? void 0 : r.map(U).filter(h)) || []
48
+ categories: ((a = n["dcat:theme"]) == null ? void 0 : a.map(K).filter(f)) || []
48
49
  },
49
50
  "Auffindbarkeit/Anwendungsbereiche": {
50
- applications: ((l = n["schema:application"]) == null ? void 0 : l.filter(h)) || []
51
+ applications: ((d = n["schema:application"]) == null ? void 0 : d.filter(f)) || []
51
52
  }
52
53
  };
53
54
  }
54
- function R(n) {
55
+ function X(n) {
55
56
  var s;
56
- const a = (s = n["dcat:contactPoint"]) == null ? void 0 : s.map((r) => ({
57
- name: I(t(r["vcard:fn"])),
58
- mail: I(t(r["vcard:hasEmail"])),
59
- phone: I(t(r["vcard:hasTelephone"]))
60
- })).filter(h);
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);
61
62
  return {
62
63
  "Grundlegende Informationen/Name": {
63
64
  projectName: A(
64
- f.fromNullable(N(n["dct:title"], "de")),
65
- f.flatMap((r) => I(r) ? f.some(r) : f.none()),
66
- f.getOrThrowWith(() => new Error("Project name is missing"))
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"))
67
68
  )
68
69
  },
69
70
  "Grundlegende Informationen/Beschreibung": {
70
71
  projectDescription: A(
71
- f.fromNullable(N(n["dct:description"], "de")),
72
+ p.fromNullable(z(n["dct:description"], "de")),
72
73
  // O.flatMap(s => nonEmpty(s) ? O.some(s) : O.none()),
73
74
  // O.getOrThrowWith(() => new Error('Project description is missing')),
74
- f.getOrElse(() => "")
75
+ p.getOrElse(() => "")
75
76
  )
76
77
  },
77
78
  "Grundlegende Informationen/Projektstatus": {
78
79
  projectName: A(
79
- f.fromNullable(n["schema:status"]),
80
+ p.fromNullable(n["schema:status"]),
80
81
  // O.flatMap(s => nonEmpty(s) ? O.some(s) : O.none()),
81
82
  // O.getOrThrowWith(() => new Error('Project status is missing')),
82
- f.getOrElse(() => "")
83
+ p.getOrElse(() => "")
83
84
  )
84
85
  },
85
86
  "Grundlegende Informationen/Organisation": {
86
- contact: G(a || []) || {
87
+ contact: E(r || []) || {
87
88
  name: "",
88
89
  mail: "",
89
90
  phone: ""
@@ -91,86 +92,66 @@ function R(n) {
91
92
  }
92
93
  };
93
94
  }
94
- function _(n) {
95
- var a, s, r, l, p, k, D, i;
95
+ function Y(n) {
96
+ var r, s, a, d, g, w, P, i;
96
97
  return {
97
98
  "Optionale Daten": {
98
- partners: ((a = n["dct:contributor"]) == null ? void 0 : a.map((c) => ({
99
+ partners: ((r = n["dct:contributor"]) == null ? void 0 : r.map((c) => ({
99
100
  name: t(c["foaf:name"]),
100
101
  url: t(c["foaf:homepage"])
101
- })).filter(h)) || [],
102
- requiredExpertise: ((s = n["schema:skills"]) == null ? void 0 : s.map(t).filter(h)) || [],
103
- references: ((l = (r = n["dct:references"]) == null ? void 0 : r.filter((c) => c["dct:type"] === "image")) == null ? void 0 : l.map((c) => ({
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) => ({
104
105
  homepage: t(c["schema:url"])
105
- })).filter(h)) || [],
106
+ })).filter(f)) || [],
106
107
  startDate: t(n["schema:startDate"] || ""),
107
108
  endDate: t(n["schema:endDate"] || ""),
108
- budget: t(((p = n["schema:amount"]) == null ? void 0 : p["schema:value"]) || ""),
109
- budgetDescription: t(((k = n["schema:amount"]) == null ? void 0 : k["schema:description"]) || ""),
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"]) || ""),
110
111
  // todo:
111
- links: ((i = (D = n["dct:references"]) == null ? void 0 : D.filter((c) => c["dct:type"] === "documentation")) == null ? void 0 : i.map((c) => ({
112
+ links: ((i = (P = n["dct:references"]) == null ? void 0 : P.filter((c) => c["dct:type"] === "documentation")) == null ? void 0 : i.map((c) => ({
112
113
  name: t(c["dct:title"]),
113
114
  url: t(c["schema:url"]),
114
115
  description: t(c["dct:description"])
115
- })).filter(h)) || []
116
+ })).filter(f)) || []
116
117
  }
117
118
  };
118
119
  }
119
- function $(n) {
120
- const a = n["schema:hasPart"] ?? [], s = (u) => a.find((m) => m["dct:type"] === u), r = (u) => {
121
- var g, w;
122
- const m = /* @__PURE__ */ new Map(), S = [...(u == null ? void 0 : u["schema:question"]) ?? []].sort((e, d) => {
123
- const y = Number.parseInt(t(e["schema:position"])), z = Number.parseInt(t(d["schema:position"]));
124
- return (Number.isNaN(y) ? 0 : y) - (Number.isNaN(z) ? 0 : z);
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);
125
126
  });
126
- for (const e of S) {
127
- const d = (g = e["schema:text"]) == null ? void 0 : g.trim(), y = (w = e["schema:acceptedAnswer"]) == null ? void 0 : w.trim();
128
- d && y && m.set(d, y);
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);
129
130
  }
130
- return m;
131
- }, l = {
132
- projectTriggers: "Was waren Ausloeser fuer das Projekt (z. B. rechtliche oder politische Vorgaben, intrinsische Motivation oder inspirierende Projekte aus anderen Kommunen)?",
133
- involvedStakeholders: "Welche relevanten Akteure innerhalb oder ausserhalb Ihrer Organisation haben Sie fruehzeitig involviert (z. B. um politische Rueckendeckung sicherzustellen)?",
134
- dataCollectionMethod: "Wie haben Sie den Bestand vorhandener Daten erhoben?",
135
- budgetPlanning: "Wie haben Sie das erste Budget berechnet und nachhaltig gesichert?"
136
- }, p = {
137
- requirementsGatherings: "Wie haben Sie die Anforderungen erhoben und dokumentiert (z. B. durch Markterkundung, externe Berater oder Workshops)?",
138
- tenderFormat: "Welche Ausschreibungsform haben Sie gewaehlt und warum? Gab es eine Vorlage oder Muster-Leistungsbeschreibung, die hilfreich war?",
139
- tenderTips: "Welche Tipps haben Sie fuer eine erfolgreiche Ausschreibung?",
140
- resourcePlanning: "Wie haben Sie die Ressourcenplanung fuer die Entwicklung und den Betrieb Ihres Digitalen Zwillings gestaltet und gesichert?"
141
- }, k = {
142
- projectTriggers: "Wie haben Sie die Zusammenarbeit mit den Dienstleistern organisiert und wie wurden relevante Stakeholder in Entscheidungsprozesse eingebunden?",
143
- involvedStakeholders: "Gab es Verzoegerungen und wenn ja, was waren die Gruende?",
144
- dataCollectionMethod: "Welche Schnittstellen wurden genutzt und traten technische Herausforderungen auf?",
145
- budgetPlanning: "Welche Ueberlegungen sind in Ihre Entscheidung fuer eine Open-Source-Loesung eingeflossen und welche Erfahrungen haben Sie gemacht?"
146
- }, D = {
147
- projectTriggers: "Was sind Ihre wichtigsten Learnings aus dem Projekt? Was wuerden Sie beim naechsten Use Case anders machen?",
148
- involvedStakeholders: "Wird die Wirksamkeit Ihres Projekts ueberwacht und wenn ja, wie? Ist der erwartete Nutzen eingetreten?",
149
- dataCollectionMethod: "Gibt es Plaene fuer eine Skalierung oder Weiterentwicklung? Wenn ja, wie sichern Sie die Finanzierung dafuer?",
150
- budgetPlanning: "Welche externen Unterstuetzungsangebote haben Ihnen geholfen oder auch gefehlt?"
151
- }, i = (u, m) => {
152
- const v = s(u), S = r(v), g = {};
153
- for (const [w, e] of Object.entries(m)) {
154
- const d = S.get(e);
155
- d && (g[w] = d);
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);
156
137
  }
157
- return g;
158
- }, c = i("Initiieren", l), b = i("Planen", p), j = i("Umsetzen", k), P = i("Weiterdenken", D);
138
+ return h;
139
+ }, c = i("Initiieren", d), y = i("Planen", g), N = i("Umsetzen", w), I = i("Weiterdenken", P);
159
140
  return {
160
141
  "Projektphasen (optional)": {},
161
142
  "Projektphasen (optional)/Initiieren": c,
162
- "Projektphasen (optional)/Planen": b,
163
- "Projektphasen (optional)/Umsetzen": j,
164
- "Projektphasen (optional)/Weiterdenken": P
143
+ "Projektphasen (optional)/Planen": y,
144
+ "Projektphasen (optional)/Umsetzen": N,
145
+ "Projektphasen (optional)/Weiterdenken": I
165
146
  };
166
147
  }
167
148
  function L(n) {
168
- const a = n["p-plan:hasStep"] ?? [], s = {
149
+ const r = n["p-plan:hasStep"] ?? [], s = {
169
150
  datenerfassung: "1. Datenerfassung",
170
151
  datenverarbeitung: "2. Datenverarbeitung",
171
152
  datensimulation: "3. Datensimulation",
172
153
  datenvisualisierung: "4. Datenvisualisierung"
173
- }, r = {
154
+ }, a = {
174
155
  "Technische Prozessschritte": {},
175
156
  "1. Datenerfassung/Grundlegende Informationen": {},
176
157
  "1. Datenerfassung/Software": {},
@@ -188,76 +169,76 @@ function L(n) {
188
169
  "4. Datenvisualisierung/Software": {},
189
170
  "4. Datenvisualisierung/Datensätze": {},
190
171
  "4. Datenvisualisierung/Hardware": {}
191
- }, l = (i) => `${i}/Grundlegende Informationen`, p = (i) => `${i}/Software`, k = (i) => `${i}/Datensätze`, D = (i) => `${i}/Hardware`;
192
- for (const i of a) {
193
- const c = (t(i["p-plan:Activity"] || "") || "").trim().toLowerCase(), b = s[c];
194
- if (!b)
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];
175
+ if (!y)
195
176
  continue;
196
- const j = N(i["dct:description"], "de") || "", P = j === "__EMPTY__" ? "" : j, u = (i["prov:used"] || []).map((e) => ({
177
+ const N = z(i["dct:description"], "de") || "", I = N === "__EMPTY__" ? "" : N, m = (i["prov:used"] || []).map((e) => ({
197
178
  name: t(e["dct:title"]) || ""
198
179
  // description: extractStringValue(m['dct:description']) || undefined,
199
- })).filter((e) => (e.name ?? "").length > 0), m = (i["dct:references"] || []).filter((e) => t(e["dct:type"]) === "documentation").map((e) => ({
180
+ })).filter((e) => (e.name ?? "").length > 0), u = (i["dct:references"] || []).filter((e) => t(e["dct:type"]) === "documentation").map((e) => ({
200
181
  name: t(e["dct:title"]) || "",
201
182
  url: t(e["schema:url"]) || "",
202
183
  description: t(e["dct:description"]) || void 0
203
184
  })).filter((e) => e.url.length > 0 && e.name.length > 0);
204
- (P || u.length > 0 || m.length > 0) && (r[l(b)] = {
205
- ...P ? { description: P } : {},
206
- ...u.length > 0 ? { methods: u } : {},
207
- ...m.length > 0 ? { links: m } : {}
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 } : {}
208
189
  });
209
- const v = i["p-plan:hasInputVar"] || [], S = v.filter((e) => t(e["@type"]) === "schema:SoftwareApplication").map((e) => ({
210
- id: W(t(e["dct:identifier"]) || ""),
211
- functionalities: (e["schema:featureList"] || []).map((d) => t(d)).filter(h)
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)
212
193
  })).filter((e) => e.id.length > 0);
213
- S.length > 0 && (r[p(b)] = {
214
- selected: S
194
+ k.length > 0 && (a[g(y)] = {
195
+ selected: k
215
196
  });
216
- const g = v.filter((e) => t(e["@type"]) === "dcat:Dataset").map((e) => ({ id: W(t(e["dct:identifier"]) || "") })).filter((e) => e.id.length > 0);
217
- g.length > 0 && (r[k(b)] = {
218
- selected: g
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
219
200
  });
220
- const w = v.filter((e) => t(e["@type"]) === "ssn:System").map((e) => {
221
- const d = e["ssn:deployedSystem"], y = W(t(e["dct:identifier"]) || ""), z = d && typeof d == "object" ? W(t(d["@id"]) || d["@id"]) : "", q = y || z, x = N(e["dct:description"], "de") || void 0, E = (e["ssn:forProperty"] || []).map((o) => t(o)).filter(h), 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), B = (e["foaf:depiction"] || []).map((o) => U(o)).filter(h), T = (e["dct:references"] || []).filter((o) => t(o["dct:type"]) === "documentation").map((o) => ({
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) => ({
222
203
  name: t(o["dct:title"]) || "",
223
204
  url: t(o["schema:url"]) || "",
224
205
  description: t(o["dct:description"]) || void 0
225
- })).filter((o) => o.url.length > 0), O = (e["ssn-system:hasSystemCapability"] || []).map((o) => t(o)).filter(h);
206
+ })).filter((o) => o.url.length > 0), B = (e["ssn-system:hasSystemCapability"] || []).map((o) => t(o)).filter(f);
226
207
  return {
227
- id: q,
228
- ...x ? { description: x } : {},
229
- ...E.length > 0 ? { forProperty: E } : {},
208
+ id: _,
209
+ ...G ? { description: G } : {},
210
+ ...H.length > 0 ? { forProperty: H } : {},
230
211
  ...M.length > 0 ? { locations: M } : {},
231
- ...B.length > 0 ? { depictions: B } : {},
212
+ ...O.length > 0 ? { depictions: O } : {},
232
213
  ...T.length > 0 ? { references: T } : {},
233
- ...O.length > 0 ? { functionalities: O } : {},
214
+ ...B.length > 0 ? { functionalities: B } : {},
234
215
  isHostedBy: e["sosa:isHostedBy"] || [],
235
216
  hosts: []
236
217
  };
237
218
  }).filter((e) => (e.id ?? "").length > 0);
238
- w.length > 0 && (r[D(b)] = {
239
- selected: w
219
+ D.length > 0 && (a[P(y)] = {
220
+ selected: D
240
221
  });
241
222
  }
242
- return r;
223
+ return a;
243
224
  }
244
- async function ee(n, a) {
245
- const s = await K(n);
225
+ async function re(n, r) {
226
+ const s = await W(n);
246
227
  return {
247
228
  Landing: {},
248
- ...V(s, { visibility: (a == null ? void 0 : a.visibility) || "public" }),
249
- ...R(s),
250
- ..._(s),
251
- ...$(s),
229
+ ...C(s, { visibility: (r == null ? void 0 : r.visibility) || "public" }),
230
+ ...X(s),
231
+ ...Y(s),
232
+ ...J(s),
252
233
  ...L(s),
253
234
  Vorschau: {}
254
235
  };
255
236
  }
256
237
  export {
257
- ee as decodeProject,
258
- V as toAuffindbarkeit,
259
- R as toGrundlegendeInformationen,
260
- _ as toOptionaleDaten,
261
- $ as toProjektphasen,
238
+ re as decodeProject,
239
+ C as toAuffindbarkeit,
240
+ X as toGrundlegendeInformationen,
241
+ Y as toOptionaleDaten,
242
+ J as toProjektphasen,
262
243
  L as toTechnicalProcessSteps
263
244
  };