@piveau/dpi 0.1.0-beta.5 → 0.1.0-beta.6

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,24 +1,24 @@
1
- import { whenever as k } from "@vueuse/core";
2
- import { defineComponent as M, defineAsyncComponent as N, toRef as V, computed as i, toValue as q, provide as L, watchEffect as v, ref as u, nextTick as $ } from "vue";
3
- import { useRoute as P } from "vue-router";
4
- import { mapActions as D, mapGetters as _, useStore as B } from "vuex";
5
- import { useRuntimeEnv as O } from "../composables/useRuntimeEnv.js";
6
- import F from "./components/TheErrorDialog.vue.js";
7
- import { autocompleteKey as T, defaultAutocompleteAdapter as j } from "./composables/aucotomplete.js";
8
- import { setupDpiContext as z } from "./composables/useDpiContext.js";
9
- import { useDpiEditMode as J } from "./composables/useDpiEditMode.js";
10
- import { useFormValues as G } from "./composables/useDpiFormValues.js";
11
- import { useErrorDialog as K } from "./composables/useErrorDialog.js";
12
- import { config as H } from "./config/dpi-spec-config.js";
13
- import Q from "./HappyFlowComponents/ui/ButtonV3.vue.js";
14
- import U from "./HappyFlowComponents/ui/DpiModalBase.vue.js";
15
- const ue = M({
1
+ import { whenever as V } from "@vueuse/core";
2
+ import { defineComponent as q, defineAsyncComponent as P, toRef as _, computed as i, toValue as B, provide as O, watchEffect as v, ref as u, nextTick as D } from "vue";
3
+ import { useRoute as j } from "vue-router";
4
+ import { mapActions as w, mapGetters as z, useStore as F } from "vuex";
5
+ import { useRuntimeEnv as T } from "../composables/useRuntimeEnv.js";
6
+ import J from "./components/TheErrorDialog.vue.js";
7
+ import { autocompleteKey as G, defaultAutocompleteAdapter as K } from "./composables/aucotomplete.js";
8
+ import { setupDpiContext as H } from "./composables/useDpiContext.js";
9
+ import { useDpiEditMode as Q } from "./composables/useDpiEditMode.js";
10
+ import { useFormValues as U } from "./composables/useDpiFormValues.js";
11
+ import { useErrorDialog as W } from "./composables/useErrorDialog.js";
12
+ import { config as X } from "./config/dpi-spec-config.js";
13
+ import Y from "./HappyFlowComponents/ui/ButtonV3.vue.js";
14
+ import Z from "./HappyFlowComponents/ui/DpiModalBase.vue.js";
15
+ const fe = q({
16
16
  name: "DataProviderInterface",
17
17
  components: {
18
- ButtonV3: Q,
19
- InputPage: N(() => import("./views/InputPage.vue.js")),
20
- DpiModalBase: U,
21
- TheErrorDialog: F
18
+ ButtonV3: Y,
19
+ InputPage: P(() => import("./views/InputPage.vue.js")),
20
+ DpiModalBase: Z,
21
+ TheErrorDialog: J
22
22
  },
23
23
  props: {
24
24
  name: {
@@ -53,7 +53,7 @@ const ue = M({
53
53
  };
54
54
  },
55
55
  computed: {
56
- ..._("auth", [
56
+ ...z("auth", [
57
57
  "getIsEditMode"
58
58
  ]),
59
59
  mode() {
@@ -61,10 +61,10 @@ const ue = M({
61
61
  }
62
62
  },
63
63
  methods: {
64
- ...D("dpiStore", [
64
+ ...w("dpiStore", [
65
65
  "saveLocalstorageValues"
66
66
  ]),
67
- ...D("auth", [
67
+ ...w("auth", [
68
68
  "populateDraftAndEdit"
69
69
  ]),
70
70
  getClearPath() {
@@ -88,10 +88,10 @@ const ue = M({
88
88
  window.removeEventListener("scroll", this.handleScroll);
89
89
  },
90
90
  setup(o) {
91
- const e = P(), r = B(), c = O(), h = c.content.dataProviderInterface.specification, w = H[h], b = V(o, "dpiContext"), { formValues: g } = G(), { openErrorDialog: y } = K(), t = i(() => {
92
- const a = q(b);
91
+ const e = j(), r = F(), c = T(), h = c.content.dataProviderInterface.specification, S = X[h], b = _(o, "dpiContext"), { formValues: g } = U(), { openErrorDialog: y } = W(), t = i(() => {
92
+ const a = B(b);
93
93
  return {
94
- specification: w,
94
+ specification: S,
95
95
  specificationName: h,
96
96
  edit: {
97
97
  enabled: e.query.edit === "true",
@@ -101,26 +101,26 @@ const ue = M({
101
101
  },
102
102
  ...a
103
103
  };
104
- }), S = i(() => t.value.specification), E = i(() => t.value.specificationName);
105
- z(t);
106
- const A = j({
104
+ }), A = i(() => t.value.specification), E = i(() => t.value.specificationName);
105
+ H(t);
106
+ const C = K({
107
107
  envs: c,
108
108
  dpiContext: t
109
109
  });
110
- L(T, o.autocomplete || A.adapter), v(() => {
111
- r.dispatch("dpiStore/setSpecification", S.value), r.dispatch("dpiStore/setSpecificationname", E.value);
110
+ O(G, o.autocomplete || C.adapter), v(() => {
111
+ r.dispatch("dpiStore/setSpecification", A.value), r.dispatch("dpiStore/setSpecificationname", E.value);
112
112
  });
113
- const C = i(() => `${e.query.key}@${E.value}`), { isReady: p, result: m, inEditModeAndRptAvailable: I, parsingErrors: s, fetchError: n } = J(t), f = u(!1);
113
+ const I = i(() => `${e.query.key}@${E.value}`), { isReady: p, result: m, inEditModeAndRptAvailable: $, parsingErrors: s, fetchError: n, isSimpleLoaderReady: x, isMaterialized: R, isLoading: L, jsonld: M } = Q(t), f = u(!1);
114
114
  v(async () => {
115
- f.value || I.value && p.value && (await $(), await $(), g.value = m.value, console.log("resultus", m.value), f.value = !0);
115
+ f.value || $.value && p.value && (await D(), await D(), g.value = m.value, console.log("resultus", m.value), f.value = !0);
116
116
  });
117
- const x = i(() => {
117
+ const k = i(() => {
118
118
  var a;
119
119
  return (a = t.value.edit) != null && a.enabled ? p.value && f.value : p.value;
120
- }), d = u(!1), l = u(null), R = u(!0);
120
+ }), d = u(!1), l = u(null), N = u(!0);
121
121
  return v(() => {
122
122
  s.value && s.value.length > 0 ? (l.value = s.value[0], d.value = !0, y(new Error(s.value[0].message))) : (d.value = !1, l.value = null);
123
- }), k(n, () => {
123
+ }), V(n, () => {
124
124
  var a;
125
125
  l.value = {
126
126
  code: "fetch_failed",
@@ -129,16 +129,21 @@ const ue = M({
129
129
  }, { immediate: !0 }), {
130
130
  result: m,
131
131
  resolvedDpiContext: t,
132
- key: C,
133
- isReady: x,
132
+ key: I,
133
+ isReady: k,
134
134
  formValues: g,
135
135
  showErrorModal: d,
136
136
  currentError: l,
137
- isDevelopment: R,
138
- fetchError: n
137
+ isDevelopment: N,
138
+ fetchError: n,
139
+ isSimpleLoaderReady: x,
140
+ isMaterialized: R,
141
+ isLoading: L,
142
+ jsonld: M,
143
+ inEditModeAndRptAvailable: $
139
144
  };
140
145
  }
141
146
  });
142
147
  export {
143
- ue as default
148
+ fe as default
144
149
  };
@@ -1,13 +1,13 @@
1
- import { useRoute as y } from "vue-router";
1
+ import { useRoute as g } from "vue-router";
2
2
  import { useDpiContext as j } from "./useDpiContext.js";
3
3
  import { computed as o, toValue as n, watchEffect as R, watch as U } from "vue";
4
- import { useStore as g } from "vuex";
4
+ import { useStore as D } from "vuex";
5
5
  import { useRuntimeEnv as A } from "../../composables/useRuntimeEnv.js";
6
6
  import { useAsyncState as k } from "@vueuse/core";
7
7
  import L from "axios";
8
8
  import { useDpiSimpleLoader as Q } from "./useDpiSimpleLoader.js";
9
9
  function _(u) {
10
- const s = y(), a = g(), d = A(), m = o(() => {
10
+ const s = g(), a = D(), d = A(), m = o(() => {
11
11
  var e, i;
12
12
  return ((i = (e = n(u)) == null ? void 0 : e.edit) == null ? void 0 : i.enabled) ?? s.query.edit === "true";
13
13
  }), l = o(() => {
@@ -19,10 +19,10 @@ function _(u) {
19
19
  });
20
20
  m.value && (localStorage.setItem("dpi_editmode", "false"), a.dispatch("auth/setIsEditMode", !1));
21
21
  const t = o(() => {
22
- var v;
23
- const e = c.value, i = (v = a.getters["auth/getUserData"]) == null ? void 0 : v.rtpToken, $ = s.params.property, M = s.params.id;
22
+ var y;
23
+ const e = c.value, i = (y = a.getters["auth/getUserData"]) == null ? void 0 : y.rtpToken, $ = s.params.property, M = s.params.id;
24
24
  return { endpoint: e ? `${d.api.hubUrl}drafts/datasets/${l.value}.jsonld?catalogue=${s.query.catalog}` : s.params.property === "catalogues" ? `${d.api.hubUrl}catalogues/${s.query.catalog}.jsonld` : `${d.api.hubUrl}datasets/${l.value}.jsonld?useNormalizedId=true`, token: i, property: $, id: M };
25
- }), { state: r, execute: D, isLoading: b, error: E } = k(
25
+ }), { state: r, execute: b, isLoading: f, error: E } = k(
26
26
  async () => (await L.get(t.value.endpoint, {
27
27
  headers: {
28
28
  Accept: "application/ld+json",
@@ -41,28 +41,30 @@ function _(u) {
41
41
  U(p, () => {
42
42
  if (!p.value) return;
43
43
  const e = c.value;
44
- a.dispatch("auth/setIsEditMode", !0), a.dispatch("auth/setIsDraft", e), D();
44
+ a.dispatch("auth/setIsEditMode", !0), a.dispatch("auth/setIsDraft", e), b();
45
45
  }, { immediate: !0 });
46
- const { isReady: f, result: I, isMaterialized: h, errors: q } = Q(r, {
46
+ const { isReady: h, result: I, isMaterialized: v, errors: q } = Q(r, {
47
47
  enabled: p,
48
48
  hubSearchUrl: d.api.baseUrl
49
49
  }), S = o(() => {
50
50
  var e;
51
- return (e = n(u).edit) != null && e.enabled ? !!a.getters["dpiStore/getSpecificationName"] && !b.value && f.value && h.value : !0;
51
+ return (e = n(u).edit) != null && e.enabled ? !!a.getters["dpiStore/getSpecificationName"] && !f.value && h.value && v.value : !0;
52
52
  });
53
53
  return o(() => {
54
54
  }), {
55
55
  inEditModeAndRptAvailable: p,
56
56
  isReady: S,
57
57
  result: I,
58
- isSimpleLoaderReady: f,
59
- isMaterialized: h,
58
+ isSimpleLoaderReady: h,
59
+ isMaterialized: v,
60
60
  fetchError: E,
61
- parsingErrors: q
61
+ parsingErrors: q,
62
+ isLoading: f,
63
+ jsonld: r
62
64
  };
63
65
  }
64
66
  function G() {
65
- const u = y(), s = g(), a = j(), d = o(() => {
67
+ const u = g(), s = D(), a = j(), d = o(() => {
66
68
  var t, r;
67
69
  return ((r = (t = n(a)) == null ? void 0 : t.edit) == null ? void 0 : r.id) ?? u.query.id;
68
70
  }), m = o(() => {
@@ -1,4 +1,4 @@
1
- import { toRef as O, toValue as x, ref as E, computed as T, watch as F } from "vue";
1
+ import { toRef as O, ref as E, toValue as F, computed as T, watch as x } from "vue";
2
2
  import { useAsyncState as C } from "@vueuse/core";
3
3
  import { defineJsonldResolver as M, dcatDatasetTransformer as k, datasetResolvers as G } from "@piveau/jsonld";
4
4
  import { isEmpty as N } from "lodash-es";
@@ -16,7 +16,7 @@ function $(e) {
16
16
  return Object.fromEntries(Object.entries(e).filter(([i, t]) => t != null && !N(t)));
17
17
  }
18
18
  function ce(e, i) {
19
- const { enabled: t, hubSearchUrl: r } = i, n = O(x(t) ?? !1), { safeTransform: f } = M({
19
+ const { enabled: t, hubSearchUrl: r } = i, n = O(t), { safeTransform: f } = M({
20
20
  baseUrl: r,
21
21
  resolvers: G(),
22
22
  transformer: k
@@ -29,7 +29,7 @@ function ce(e, i) {
29
29
  } = C(
30
30
  async () => {
31
31
  var I;
32
- const c = await f(x(e));
32
+ const c = await f(F(e));
33
33
  if (c.error)
34
34
  return p.value.push({
35
35
  code: "transform_failed",
@@ -53,12 +53,12 @@ function ce(e, i) {
53
53
  var c;
54
54
  return (c = m.value) == null ? void 0 : c.data;
55
55
  });
56
- return F(
57
- () => x(e),
56
+ return x(
57
+ () => F(e),
58
58
  (c) => c && n.value ? R() : null
59
- ), F(A, (c) => {
59
+ ), x(A, (c) => {
60
60
  console.log("jsonld resolved result:", c);
61
- }), F(v, (c) => {
61
+ }), x(v, (c) => {
62
62
  console.log("jsonld error:", c);
63
63
  }), {
64
64
  processedInput: m,
@@ -0,0 +1,32 @@
1
+ import { createStore as o } from "vuex";
2
+ import r from "./modules/cataloguesStore.js";
3
+ import e from "./modules/catalogueDetailsStore.js";
4
+ import m from "./modules/datasetsStore.js";
5
+ import a from "./modules/datasetDetailsStore.js";
6
+ import s from "./modules/authStore.js";
7
+ import i from "./modules/snackbarStore.js";
8
+ import u from "./modules/dpiStore.js";
9
+ const l = {}, d = {}, c = {}, p = {
10
+ /**
11
+ * @description Returns the current route (name).
12
+ * @param state
13
+ */
14
+ getCurrentRoute: (t) => t.route
15
+ }, k = o({
16
+ state: l,
17
+ actions: d,
18
+ mutations: c,
19
+ getters: p,
20
+ modules: {
21
+ catalogs: r,
22
+ catalogDetails: e,
23
+ datasets: m,
24
+ datasetDetails: a,
25
+ dpiStore: u,
26
+ auth: s,
27
+ snackbar: i
28
+ }
29
+ });
30
+ export {
31
+ k as default
32
+ };
@@ -0,0 +1,301 @@
1
+ import o from "axios";
2
+ import { cloneDeep as u, get as T } from "lodash-es";
3
+ import i from "../../../utils/draftApi.js";
4
+ import f from "../../../utils/identifiersApi.js";
5
+ import { decode as R } from "../../../utils/jwt.js";
6
+ let _, A;
7
+ const d = {
8
+ authenticated: !1,
9
+ rtptoken: "",
10
+ keycloak: null,
11
+ userData: {
12
+ authToken: "",
13
+ rtpToken: "",
14
+ userName: "",
15
+ permissions: [],
16
+ drafts: [],
17
+ roles: []
18
+ },
19
+ isEditMode: !1,
20
+ isDraft: !1
21
+ }, U = {
22
+ securityAuth: (e) => e.authenticated,
23
+ getRTPToken: (e) => e.rtptoken,
24
+ getKeycloak: (e) => e.keycloak,
25
+ getUserData: (e) => e.userData,
26
+ getUserName: (e) => e.userData.userName,
27
+ /**
28
+ * @description Get all catalogs associated to the user where they have access to.
29
+ * @returns {Array} Array of catalogs
30
+ */
31
+ getUserCatalogs: (e) => e.userData.permissions.filter(
32
+ // User must have CRUD authorization
33
+ (t) => ["dataset:update", "dataset:delete", "dataset:create"].every(
34
+ (a) => t.scopes.includes(a)
35
+ )
36
+ ),
37
+ /**
38
+ * @description Get all catalog IDs associated to the user where they have access to.
39
+ */
40
+ getUserCatalogIds: (e, t) => t.getUserCatalogs.map((a) => a.rsname),
41
+ getUserDrafts: (e) => e.userData.drafts,
42
+ getUserDraftIds: (e) => e.userData.drafts.map((t) => t.id),
43
+ getIsEditMode: (e) => e.isEditMode,
44
+ getIsDraft: (e) => e.isDraft
45
+ }, l = {
46
+ authLogin({ commit: e }, t) {
47
+ e("SECURITY_AUTH", t);
48
+ },
49
+ authLogout({ commit: e }) {
50
+ e("SECURITY_AUTH", !1), e("RTP_TOKEN", "");
51
+ },
52
+ rtpToken({ commit: e }, t) {
53
+ e("RTP_TOKEN", t);
54
+ },
55
+ setKeycloak({ commit: e }, t) {
56
+ e("SET_KEYCLOAK", t);
57
+ },
58
+ /**
59
+ * Updates user data according to an authentication token and by supplying neccessary
60
+ * information to retrieve tFhe user's permissions as well as their drafts.
61
+ * @param {*} commit
62
+ * @param {Object} params
63
+ * @returns {Promise<Object>}
64
+ */
65
+ async updateUserData({ commit: e, dispatch: t }, { authToken: a, rtpToken: s, hubUrl: r }) {
66
+ if (!a || !s)
67
+ return console.error("Missing authToken or rtpToken"), e("UPDATE_USER_DATA_ERROR"), {};
68
+ e("UPDATE_USER_DATA_PENDING");
69
+ try {
70
+ if (!s) throw new Error("Failed to retrieve RTP token");
71
+ const E = R(s), D = T(E, "authorization.permissions", []), n = T(E, "realm_access.roles", []);
72
+ e("SET_USER_DATA", {
73
+ authToken: a,
74
+ rtpToken: s,
75
+ userName: E.preferred_username,
76
+ permissions: D,
77
+ drafts: [],
78
+ roles: n
79
+ }), _ = i({ baseURL: r, authToken: s }), A = f({
80
+ baseURL: r,
81
+ authToken: s
82
+ }), t("updateUserDrafts"), e("UPDATE_USER_DATA_SUCCESS");
83
+ } catch (E) {
84
+ console.error(E), e("UPDATE_USER_DATA_ERROR");
85
+ }
86
+ return {};
87
+ },
88
+ async updateUserDrafts({ commit: e, state: t }) {
89
+ if (!t.userData.rtpToken) throw new Error("Requires RTP token");
90
+ const s = await _.getAllDatasetDrafts(), r = s.status === 200 && s.data;
91
+ e("SET_USER_DATA", { drafts: r });
92
+ },
93
+ async createDataset({ commit: e }, t) {
94
+ const a = {
95
+ method: "PUT",
96
+ url: t.url,
97
+ headers: {
98
+ "Content-Type": "application/json",
99
+ Authorization: `Bearer ${t.token}`
100
+ },
101
+ data: t.body
102
+ };
103
+ console.log("############", a);
104
+ const s = await o.request(a);
105
+ (s.status === 201 || s.status === 204) && (e("CHANGE_IS_EDIT_MODE", !1), e("CHANGE_IS_DRAFT", !1));
106
+ },
107
+ /**
108
+ * Creates a draft dataset
109
+ * @param {*} commit
110
+ * @param {object} dataset - The dataset object
111
+ * @param {string} dataset.id - The ID of the dataset
112
+ * @param {string} dataset.catalog - The ID of the dataset
113
+ * @param {object} dataset.description - The description object of the dataset containing different locales
114
+ * @param {object} dataset.title - The title object of the dataset containing different locales
115
+ * @param {object} dataset.body - the JSON-LD representation of the dataset
116
+ * @returns {Promise<Object>}
117
+ */
118
+ async createUserDraft({ commit: e }, { id: t, catalog: a, description: s = { en: "" }, title: r = { en: "" }, body: E = {} }) {
119
+ if (!_) return {};
120
+ e("UPDATE_USER_DATA_PENDING");
121
+ let D;
122
+ try {
123
+ D = await _.createDatasetDraft({
124
+ id: t,
125
+ catalogue: a,
126
+ body: E
127
+ }), e("CREATE_USER_DRAFT", {
128
+ id: t,
129
+ catalog: a,
130
+ description: s,
131
+ title: r,
132
+ body: E
133
+ }), e("UPDATE_USER_DATA_SUCCESS");
134
+ } catch (n) {
135
+ throw e("UPDATE_USER_DATA_ERROR"), n;
136
+ }
137
+ return D;
138
+ },
139
+ async deleteUserDraftById({ commit: e, state: t }, { id: a, catalog: s }) {
140
+ if (console.log(a), !_) return {};
141
+ if (!t.userData.drafts.find((D) => D.id === a)) return {};
142
+ e("UPDATE_USER_DATA_PENDING");
143
+ let E;
144
+ try {
145
+ E = await _.deleteDatasetDraft({ id: a, catalogue: s }), e("DELETE_USER_DRAFT", a), e("UPDATE_USER_DATA_SUCCESS");
146
+ } catch (D) {
147
+ throw e("UPDATE_USER_DATA_ERROR"), D;
148
+ }
149
+ return E;
150
+ },
151
+ async publishUserDraftById({ commit: e, state: t }, { id: a, catalog: s, body: r = {} }) {
152
+ if (!_) return {};
153
+ if (!t.userData.drafts.find((n) => n.id === a)) return {};
154
+ e("UPDATE_USER_DATA_PENDING");
155
+ let D;
156
+ try {
157
+ D = await _.publishDatasetDraft({
158
+ id: a,
159
+ catalogue: s,
160
+ body: r
161
+ }), e("DELETE_USER_DRAFT", a), e("UPDATE_USER_DATA_SUCCESS"), e("CHANGE_IS_DRAFT", !1), e("CHANGE_IS_EDIT_MODE", !1);
162
+ } catch (n) {
163
+ throw e("UPDATE_USER_DATA_ERROR"), n;
164
+ }
165
+ return D;
166
+ },
167
+ async duplicateDataset({ commit: e, state: t }, { id: a, newId: s, catalog: r, url: E }) {
168
+ console.log(a, r, E);
169
+ const D = {
170
+ method: "GET",
171
+ url: E + "drafts/datasets/" + a + ".nt?catalogue=" + r
172
+ };
173
+ await o.request(D);
174
+ },
175
+ async publishUserDraft({ dispatch: e }, { id: t, catalog: a, body: s }) {
176
+ return e("publishUserDraftById", { id: t, catalog: a, body: s });
177
+ },
178
+ async putDatasetToDraft({ commit: e }, { id: t, catalog: a, title: s, description: r }) {
179
+ if (!_) return {};
180
+ e("UPDATE_USER_DATA_PENDING");
181
+ let E;
182
+ try {
183
+ console.log(t, a, s, r), E = await _.putDatasetToDraft({ id: t, catalogue: a }), e("PUT_DATASET_TO_DRAFT", {
184
+ id: t,
185
+ catalog: a,
186
+ title: s,
187
+ description: r
188
+ }), e("UPDATE_USER_DATA_SUCCESS");
189
+ } catch (D) {
190
+ throw e("UPDATE_USER_DATA_ERROR"), D;
191
+ }
192
+ return E;
193
+ },
194
+ setIsEditMode({ commit: e }, t) {
195
+ e("CHANGE_IS_EDIT_MODE", t);
196
+ },
197
+ setIsDraft({ commit: e }, t) {
198
+ e("CHANGE_IS_DRAFT", t);
199
+ },
200
+ async createPersistentIdentifier({ commit: e }, { id: t, catalog: a, type: s = "mock" }) {
201
+ if (!A) return {};
202
+ e("UPDATE_USER_DATA_PENDING");
203
+ let r;
204
+ try {
205
+ r = await A.createPersistentIdentifier({
206
+ id: t,
207
+ catalogue: a,
208
+ type: s
209
+ }), e("UPDATE_USER_DATA_SUCCESS");
210
+ } catch (E) {
211
+ throw e("UPDATE_USER_DATA_ERROR"), E;
212
+ }
213
+ return r;
214
+ },
215
+ populateDraftAndEdit({ commit: e }) {
216
+ e("PREDEFINE_DRAFT_AND_EDIT");
217
+ },
218
+ async createCatalogue({ commit: e }, t) {
219
+ const a = {
220
+ method: "PUT",
221
+ url: t.url,
222
+ headers: {
223
+ "Content-Type": "text/turtle",
224
+ Authorization: `Bearer ${t.token}`
225
+ },
226
+ data: t.data
227
+ }, s = await o.request(a);
228
+ if (s.status === 201 | s.status === 204) {
229
+ e("CHANGE_IS_EDIT_MODE", !1), e("CHANGE_IS_DRAFT", !1);
230
+ const r = u(d.userData), E = {
231
+ rsid: "",
232
+ rsname: t.id,
233
+ scopes: ["dataset:update", "dataset:delete", "dataset:create"]
234
+ };
235
+ r.permissions.push(E), e("SET_USER_DATA", r);
236
+ }
237
+ }
238
+ }, S = {
239
+ SECURITY_AUTH(e, t) {
240
+ e.authenticated = t;
241
+ },
242
+ RTP_TOKEN(e, t) {
243
+ e.rtptoken = t;
244
+ },
245
+ SET_KEYCLOAK(e, t) {
246
+ e.keycloak = t;
247
+ },
248
+ SET_USER_DATA(e, t) {
249
+ e.userData = { ...e.userData, ...t };
250
+ },
251
+ UPDATE_USER_DATA_PENDING(e) {
252
+ e.userData.pending = !0;
253
+ },
254
+ UPDATE_USER_DATA_SUCCESS(e) {
255
+ e.userData.pending = !1;
256
+ },
257
+ UPDATE_USER_DATA_ERROR(e) {
258
+ e.userData.pending = !1;
259
+ },
260
+ CREATE_USER_DRAFT(e, { id: t, catalog: a, title: s, description: r }) {
261
+ e.userData.drafts.push({
262
+ id: t,
263
+ catalog: a,
264
+ title: s,
265
+ description: r
266
+ });
267
+ },
268
+ PUT_DATASET_TO_DRAFT(e, { id: t, catalog: a, title: s, description: r }) {
269
+ e.userData.drafts.push({
270
+ id: t,
271
+ catalog: a,
272
+ title: s,
273
+ description: r
274
+ });
275
+ },
276
+ DELETE_USER_DRAFT(e, t) {
277
+ const a = e.userData.drafts.findIndex(
278
+ (s) => s.id === t
279
+ );
280
+ a > -1 && e.userData.drafts.splice(a, 1);
281
+ },
282
+ CHANGE_IS_EDIT_MODE(e, t) {
283
+ e.isEditMode = t, localStorage.setItem("dpi_editmode", t);
284
+ },
285
+ CHANGE_IS_DRAFT(e, t) {
286
+ e.isDraft = t, localStorage.setItem("dpi_draftmode", t);
287
+ },
288
+ PREDEFINE_DRAFT_AND_EDIT(e) {
289
+ const t = Object.keys(localStorage);
290
+ t.includes("dpi_editmode") && (e.isEditMode = JSON.parse(localStorage.getItem("dpi_editmode"))), t.includes("dpi_draftmode") && (e.isDraft = JSON.parse(localStorage.getItem("dpi_draftmode")));
291
+ }
292
+ }, C = {
293
+ namespaced: !0,
294
+ state: d,
295
+ actions: l,
296
+ mutations: S,
297
+ getters: U
298
+ };
299
+ export {
300
+ C as default
301
+ };
@@ -0,0 +1,34 @@
1
+ const l = {
2
+ catalog: {}
3
+ }, g = {
4
+ getCatalog: (a) => a.catalog
5
+ }, n = {
6
+ /**
7
+ * @description Loads details for the dataset with the given ID.
8
+ * @param commit
9
+ * @param state
10
+ * @param id {String} The dataset ID.
11
+ */
12
+ loadCatalog({ state: a, commit: o }, e) {
13
+ return new Promise((c, s) => {
14
+ this.$catalogService.getSingle(e).then((t) => {
15
+ o("SET_catalog", t), c(t);
16
+ }).catch((t) => {
17
+ console.error(t), s(t);
18
+ });
19
+ });
20
+ }
21
+ }, r = {
22
+ SET_catalog(a, o) {
23
+ a.catalog = o;
24
+ }
25
+ }, i = {
26
+ namespaced: !0,
27
+ state: l,
28
+ actions: n,
29
+ mutations: r,
30
+ getters: g
31
+ };
32
+ export {
33
+ i as default
34
+ };