@seedprotocol/mapping 0.6.2 → 0.6.3
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.
- package/CHANGELOG.md +11 -0
- package/README.md +22 -3
- package/dist/applyMapping.d.ts +4 -2
- package/dist/applyMapping.d.ts.map +1 -1
- package/dist/autoMap-Dh9SiWhT.js +631 -0
- package/dist/autoMap-Dh9SiWhT.js.map +1 -0
- package/dist/edgeMapping.d.ts +21 -0
- package/dist/edgeMapping.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -34
- package/dist/react/FieldMapper.d.ts +12 -2
- package/dist/react/FieldMapper.d.ts.map +1 -1
- package/dist/react/FieldMapperWires.d.ts.map +1 -1
- package/dist/react/PropertyRows.d.ts +4 -2
- package/dist/react/PropertyRows.d.ts.map +1 -1
- package/dist/react/SourceRows.d.ts +4 -2
- package/dist/react/SourceRows.d.ts.map +1 -1
- package/dist/react/fieldMapperCore.d.ts +3 -1
- package/dist/react/fieldMapperCore.d.ts.map +1 -1
- package/dist/react/fieldMapperSlots.d.ts +1 -1
- package/dist/react/fieldMapperSlots.d.ts.map +1 -1
- package/dist/react/fieldMapperTheme.d.ts +1 -1
- package/dist/react/fieldMapperTheme.d.ts.map +1 -1
- package/dist/react/fieldMapperTransforms.d.ts +7 -0
- package/dist/react/fieldMapperTransforms.d.ts.map +1 -0
- package/dist/react/fieldMapperTypes.d.ts +11 -1
- package/dist/react/fieldMapperTypes.d.ts.map +1 -1
- package/dist/react/useFieldMapper.d.ts.map +1 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +741 -658
- package/dist/react.js.map +1 -1
- package/dist/resolvedSources.d.ts.map +1 -1
- package/dist/types.d.ts +20 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
//#region src/relationLookup.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e.dataType === "Relation" ? !0 : e.dataType === "List" ? e.refValueType === "Relation" || !!e.ref : !1;
|
|
4
|
+
}
|
|
5
|
+
function t(e) {
|
|
6
|
+
return e.replace(/\s+/g, " ").trim();
|
|
7
|
+
}
|
|
8
|
+
function n(e) {
|
|
9
|
+
return e ? t(e.value || e.label) : "";
|
|
10
|
+
}
|
|
11
|
+
function r(e, t) {
|
|
12
|
+
if (t.dataType === "List") {
|
|
13
|
+
if (Array.isArray(e)) return e.map((e) => String(e).trim()).filter(Boolean);
|
|
14
|
+
let t = String(e).trim();
|
|
15
|
+
return t ? [t] : [];
|
|
16
|
+
}
|
|
17
|
+
return Array.isArray(e) ? String(e[0] ?? "").trim() : String(e).trim();
|
|
18
|
+
}
|
|
19
|
+
function i(e) {
|
|
20
|
+
return e?.lookup?.entries ?? [];
|
|
21
|
+
}
|
|
22
|
+
function a(e, n) {
|
|
23
|
+
let r = t(n);
|
|
24
|
+
if (r && e?.length) for (let n of e) {
|
|
25
|
+
if (t(n.value) !== r) continue;
|
|
26
|
+
let e = String(n.ref ?? "").trim();
|
|
27
|
+
if (e) return e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function o(e, t, n) {
|
|
31
|
+
if (!e) return;
|
|
32
|
+
let r = e[t];
|
|
33
|
+
if (r && Object.prototype.hasOwnProperty.call(r, n)) return r[n];
|
|
34
|
+
}
|
|
35
|
+
function s(e, n, r) {
|
|
36
|
+
let i = t(n), s = a(e.lookup?.entries, i);
|
|
37
|
+
return s === void 0 ? o(r, e.propertyName, i) : s;
|
|
38
|
+
}
|
|
39
|
+
function c(e, t) {
|
|
40
|
+
if (t.length === 0) {
|
|
41
|
+
if (!e.lookup) return e;
|
|
42
|
+
let { lookup: t, ...n } = e;
|
|
43
|
+
return n;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
...e,
|
|
47
|
+
lookup: { entries: t }
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function l(e) {
|
|
51
|
+
if (!e.lookup) return e;
|
|
52
|
+
let { lookup: t, ...n } = e;
|
|
53
|
+
return n;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/classifyUrl.ts
|
|
57
|
+
function u(e) {
|
|
58
|
+
return e.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
59
|
+
}
|
|
60
|
+
function d(e) {
|
|
61
|
+
return e ? e.startsWith("image/") ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : e === "text/html" || e === "application/xhtml+xml" || e === "application/xhtml" ? "html" : null : null;
|
|
62
|
+
}
|
|
63
|
+
function ee(e) {
|
|
64
|
+
let t = e.trim();
|
|
65
|
+
try {
|
|
66
|
+
return new URL(t).pathname.toLowerCase();
|
|
67
|
+
} catch {
|
|
68
|
+
return (t.split("?")[0]?.split("#")[0] ?? t).toLowerCase();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function f(e) {
|
|
72
|
+
return /\.(html?|xhtml|php|asp|aspx|jsp)$/i.test(e) ? "html" : /\.(jpe?g|png|gif|webp|avif|svg|bmp|ico|tiff?)$/i.test(e) ? "image" : /\.(mp3|m4a|aac|ogg|oga|opus|wav|flac|aiff?)$/i.test(e) ? "audio" : /\.(mp4|m4v|webm|ogv|mov|avi|mkv)$/i.test(e) ? "video" : "unknown";
|
|
73
|
+
}
|
|
74
|
+
function p(e) {
|
|
75
|
+
let t = typeof e.url == "string" ? e.url.trim() : "";
|
|
76
|
+
if (!t) return "unknown";
|
|
77
|
+
if (e.contentType) {
|
|
78
|
+
let t = d(u(String(e.contentType)));
|
|
79
|
+
if (t) return t;
|
|
80
|
+
}
|
|
81
|
+
return f(ee(t));
|
|
82
|
+
}
|
|
83
|
+
function m(e) {
|
|
84
|
+
let t = e.trim().toLowerCase();
|
|
85
|
+
return t.startsWith("http://") || t.startsWith("https://") || t.startsWith("blob:") || t.startsWith("data:");
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/resolvedSources.ts
|
|
89
|
+
var h = "@extract", g = "@file";
|
|
90
|
+
function _(e) {
|
|
91
|
+
if (!e) return;
|
|
92
|
+
let t = e.contentType ?? e.type;
|
|
93
|
+
return typeof t == "string" && t.trim() ? t.trim() : void 0;
|
|
94
|
+
}
|
|
95
|
+
function v(e) {
|
|
96
|
+
let t = e.meta?.class;
|
|
97
|
+
return t === "html" || t === "image" || t === "audio" || t === "video" || t === "unknown" ? t : p({
|
|
98
|
+
url: typeof e.meta?.url == "string" && e.meta.url.trim() ? e.meta.url.trim() : e.value,
|
|
99
|
+
contentType: _(e.meta)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function y(e) {
|
|
103
|
+
return e.kind === "resolved" || e.kind === "full" || e.kind === "section" ? !1 : m(typeof e.meta?.url == "string" && e.meta.url.trim() ? e.meta.url.trim() : e.value);
|
|
104
|
+
}
|
|
105
|
+
function b(e) {
|
|
106
|
+
return e.endsWith("@extract") ? {
|
|
107
|
+
originId: e.slice(0, -8),
|
|
108
|
+
resolve: "extract"
|
|
109
|
+
} : e.endsWith("@file") ? {
|
|
110
|
+
originId: e.slice(0, -5),
|
|
111
|
+
resolve: "file"
|
|
112
|
+
} : null;
|
|
113
|
+
}
|
|
114
|
+
function te(e, t) {
|
|
115
|
+
let n = b(e);
|
|
116
|
+
return n ? {
|
|
117
|
+
sourceId: n.originId,
|
|
118
|
+
propertyName: t,
|
|
119
|
+
resolve: n.resolve
|
|
120
|
+
} : {
|
|
121
|
+
sourceId: e,
|
|
122
|
+
propertyName: t
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function x(e, t) {
|
|
126
|
+
return t === "extract" ? `${e}${h}` : t === "file" ? `${e}${g}` : e;
|
|
127
|
+
}
|
|
128
|
+
function ne(e) {
|
|
129
|
+
let t = [...e], n = new Set(e.map((e) => e.id));
|
|
130
|
+
for (let r of e) {
|
|
131
|
+
if (!y(r)) continue;
|
|
132
|
+
let e = typeof r.meta?.url == "string" && r.meta.url.trim() ? r.meta.url.trim() : r.value.trim(), i = _(r.meta), a = v(r), o = x(r.id, "extract");
|
|
133
|
+
n.has(o) || (t.push({
|
|
134
|
+
id: o,
|
|
135
|
+
label: `${r.label} → extract HTML`,
|
|
136
|
+
kind: "resolved",
|
|
137
|
+
value: e,
|
|
138
|
+
meta: {
|
|
139
|
+
originId: r.id,
|
|
140
|
+
resolve: "extract",
|
|
141
|
+
class: "html",
|
|
142
|
+
contentType: i,
|
|
143
|
+
url: e
|
|
144
|
+
}
|
|
145
|
+
}), n.add(o));
|
|
146
|
+
let s = x(r.id, "file");
|
|
147
|
+
n.has(s) || (t.push({
|
|
148
|
+
id: s,
|
|
149
|
+
label: `${r.label} → file`,
|
|
150
|
+
kind: "resolved",
|
|
151
|
+
value: e,
|
|
152
|
+
meta: {
|
|
153
|
+
originId: r.id,
|
|
154
|
+
resolve: "file",
|
|
155
|
+
class: a,
|
|
156
|
+
contentType: i,
|
|
157
|
+
url: e
|
|
158
|
+
}
|
|
159
|
+
}), n.add(s));
|
|
160
|
+
}
|
|
161
|
+
return t;
|
|
162
|
+
}
|
|
163
|
+
function S(e, t) {
|
|
164
|
+
let n = new Map(e.map((e) => [e.id, e]));
|
|
165
|
+
if (!t.sourceId) return;
|
|
166
|
+
let r = n.get(t.sourceId);
|
|
167
|
+
if (r) return r;
|
|
168
|
+
if (t.resolve) {
|
|
169
|
+
let e = n.get(x(t.sourceId, t.resolve));
|
|
170
|
+
if (e) return e;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/applyMapping.ts
|
|
175
|
+
function C(e, t) {
|
|
176
|
+
if (t === "Number") return parseFloat(String(e)) || 0;
|
|
177
|
+
if (t === "Boolean") return e === "true" || e === "1" || String(e).toLowerCase() === "yes";
|
|
178
|
+
if (t === "Json") try {
|
|
179
|
+
return JSON.parse(e);
|
|
180
|
+
} catch {
|
|
181
|
+
return e;
|
|
182
|
+
}
|
|
183
|
+
if (t === "Date") {
|
|
184
|
+
let t = new Date(String(e));
|
|
185
|
+
return Number.isNaN(t.getTime()) ? e : t.getTime();
|
|
186
|
+
}
|
|
187
|
+
return String(e ?? "");
|
|
188
|
+
}
|
|
189
|
+
function w(e, t) {
|
|
190
|
+
return typeof e == "string" ? C(e, t) : e == null ? C("", t) : t === "Image" || t === "File" || t === "Relation" || t === "List" || t === "Json" ? e : C(String(e), t);
|
|
191
|
+
}
|
|
192
|
+
function T(e) {
|
|
193
|
+
return typeof e.meta?.url == "string" && e.meta.url.trim() ? e.meta.url.trim() : (e.value || e.label).trim();
|
|
194
|
+
}
|
|
195
|
+
function E(e) {
|
|
196
|
+
let t = e.meta?.contentType ?? e.meta?.type;
|
|
197
|
+
return typeof t == "string" && t.trim() ? t.trim() : void 0;
|
|
198
|
+
}
|
|
199
|
+
function D(e) {
|
|
200
|
+
let t = e.meta?.class;
|
|
201
|
+
if (t === "html" || t === "image" || t === "audio" || t === "video" || t === "unknown") return t;
|
|
202
|
+
}
|
|
203
|
+
function O(e, n, i, a) {
|
|
204
|
+
let o = t(n.value || n.label), c = s(e, o, a);
|
|
205
|
+
return c === void 0 ? { unmatched: o } : { value: r(c, i) };
|
|
206
|
+
}
|
|
207
|
+
function k(t, n, r, i) {
|
|
208
|
+
let a = new Map(t.map((e) => [e.id, e])), o = new Map(r.map((e) => [e.name, e])), s = {};
|
|
209
|
+
for (let t of n) {
|
|
210
|
+
if (t.resolve && t.resolve !== "lookup") continue;
|
|
211
|
+
let n = t.sourceId ? a.get(t.sourceId) : void 0, r = o.get(t.propertyName);
|
|
212
|
+
if (!n || !r) continue;
|
|
213
|
+
if (t.resolve === "lookup") {
|
|
214
|
+
let e = O(t, n, r, i?.lookups);
|
|
215
|
+
"value" in e && (s[t.propertyName] = e.value);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (e(r)) continue;
|
|
219
|
+
let c = n.value || n.label;
|
|
220
|
+
s[t.propertyName] = C(c, r.dataType);
|
|
221
|
+
}
|
|
222
|
+
return s;
|
|
223
|
+
}
|
|
224
|
+
async function A(t, n, r, i = {}) {
|
|
225
|
+
let a = new Map(r.map((e) => [e.name, e])), o = {}, s = [];
|
|
226
|
+
for (let r of n) {
|
|
227
|
+
let n = a.get(r.propertyName);
|
|
228
|
+
if (!n || r.resolve === "derive" || r.resolve === "assemble") continue;
|
|
229
|
+
if (!r.resolve) {
|
|
230
|
+
let i = r.sourceId ? t.find((e) => e.id === r.sourceId) : void 0;
|
|
231
|
+
if (!i || e(n)) continue;
|
|
232
|
+
let a = i.value || i.label;
|
|
233
|
+
o[r.propertyName] = C(a, n.dataType);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (r.resolve === "lookup") {
|
|
237
|
+
let e = r.sourceId ? t.find((e) => e.id === r.sourceId) : void 0;
|
|
238
|
+
if (!e) {
|
|
239
|
+
s.push({
|
|
240
|
+
sourceId: r.sourceId,
|
|
241
|
+
propertyName: r.propertyName,
|
|
242
|
+
resolve: "lookup",
|
|
243
|
+
message: `Source not found: ${r.sourceId}`
|
|
244
|
+
});
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
let a = O(r, e, n, i.lookups);
|
|
248
|
+
"value" in a ? o[r.propertyName] = a.value : s.push({
|
|
249
|
+
sourceId: r.sourceId,
|
|
250
|
+
propertyName: r.propertyName,
|
|
251
|
+
resolve: "lookup",
|
|
252
|
+
message: `No lookup entry for "${a.unmatched}"`
|
|
253
|
+
});
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
let c = S(t, r);
|
|
257
|
+
if (!c) {
|
|
258
|
+
s.push({
|
|
259
|
+
sourceId: r.sourceId,
|
|
260
|
+
propertyName: r.propertyName,
|
|
261
|
+
resolve: r.resolve,
|
|
262
|
+
message: `Source not found: ${r.sourceId}`
|
|
263
|
+
});
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (!i.resolve) {
|
|
267
|
+
s.push({
|
|
268
|
+
sourceId: r.sourceId,
|
|
269
|
+
propertyName: r.propertyName,
|
|
270
|
+
resolve: r.resolve,
|
|
271
|
+
message: `No resolve callback for ${r.resolve}`
|
|
272
|
+
});
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
let l = {
|
|
276
|
+
job: r.resolve,
|
|
277
|
+
url: T(c),
|
|
278
|
+
source: c,
|
|
279
|
+
target: n,
|
|
280
|
+
contentType: E(c),
|
|
281
|
+
class: D(c)
|
|
282
|
+
};
|
|
283
|
+
try {
|
|
284
|
+
let e = await i.resolve(l);
|
|
285
|
+
o[r.propertyName] = w(e, n.dataType);
|
|
286
|
+
} catch (e) {
|
|
287
|
+
s.push({
|
|
288
|
+
sourceId: r.sourceId,
|
|
289
|
+
propertyName: r.propertyName,
|
|
290
|
+
resolve: r.resolve,
|
|
291
|
+
message: e instanceof Error ? e.message : String(e)
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
properties: o,
|
|
297
|
+
errors: s
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/edgeMapping.ts
|
|
302
|
+
function j(e) {
|
|
303
|
+
return e.propertyName ? e.sourceId ? !0 : e.resolve === "derive" : !1;
|
|
304
|
+
}
|
|
305
|
+
function M(e) {
|
|
306
|
+
if (e.sourceId) return e;
|
|
307
|
+
let { sourceId: t, ...n } = e;
|
|
308
|
+
return n;
|
|
309
|
+
}
|
|
310
|
+
function N(e) {
|
|
311
|
+
return e.resolve === "derive" || !!e.derive;
|
|
312
|
+
}
|
|
313
|
+
function P(e) {
|
|
314
|
+
return M({
|
|
315
|
+
propertyName: e.propertyName,
|
|
316
|
+
resolve: "derive",
|
|
317
|
+
...e.derive ? { derive: e.derive } : {}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function re(e, t) {
|
|
321
|
+
if (!t) {
|
|
322
|
+
if (!e.derive) return M(e);
|
|
323
|
+
let { derive: t, ...n } = e;
|
|
324
|
+
return M(n);
|
|
325
|
+
}
|
|
326
|
+
return M({
|
|
327
|
+
...e,
|
|
328
|
+
derive: t
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
function ie(e, t) {
|
|
332
|
+
return M({
|
|
333
|
+
...e,
|
|
334
|
+
assemble: { blocks: t }
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function F(e, t) {
|
|
338
|
+
let n = {
|
|
339
|
+
propertyName: e.propertyName,
|
|
340
|
+
...e.sourceId ? { sourceId: e.sourceId } : {}
|
|
341
|
+
};
|
|
342
|
+
return t ? M(t === "derive" ? {
|
|
343
|
+
...n,
|
|
344
|
+
resolve: "derive",
|
|
345
|
+
...e.derive ? { derive: e.derive } : {}
|
|
346
|
+
} : t === "assemble" ? {
|
|
347
|
+
...n,
|
|
348
|
+
resolve: "assemble",
|
|
349
|
+
...e.assemble ? { assemble: e.assemble } : {}
|
|
350
|
+
} : t === "lookup" ? {
|
|
351
|
+
...n,
|
|
352
|
+
resolve: "lookup",
|
|
353
|
+
...e.lookup ? { lookup: e.lookup } : {}
|
|
354
|
+
} : {
|
|
355
|
+
...n,
|
|
356
|
+
resolve: t
|
|
357
|
+
}) : !e.sourceId && N(e) ? P(e) : (e.derive && (n.derive = e.derive), M(n));
|
|
358
|
+
}
|
|
359
|
+
function I(e, t) {
|
|
360
|
+
if (!t) return M(L(e));
|
|
361
|
+
let n = { ...e };
|
|
362
|
+
return n.resolve || (t.resolve === "assemble" ? n = {
|
|
363
|
+
...n,
|
|
364
|
+
resolve: "assemble",
|
|
365
|
+
...t.assemble ? { assemble: t.assemble } : {}
|
|
366
|
+
} : t.resolve === "derive" && (n = {
|
|
367
|
+
...n,
|
|
368
|
+
resolve: "derive"
|
|
369
|
+
})), t.derive && (!n.resolve || n.resolve === "derive") && (n = {
|
|
370
|
+
...n,
|
|
371
|
+
derive: n.derive ?? t.derive
|
|
372
|
+
}), n.resolve === "assemble" && t.assemble && !n.assemble && (n = {
|
|
373
|
+
...n,
|
|
374
|
+
assemble: t.assemble
|
|
375
|
+
}), M(L(n));
|
|
376
|
+
}
|
|
377
|
+
function L(e) {
|
|
378
|
+
return e.resolve === "lookup" ? e : l(e);
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/autoMap.ts
|
|
382
|
+
var R = [
|
|
383
|
+
"text",
|
|
384
|
+
"content",
|
|
385
|
+
"body",
|
|
386
|
+
"fulltext",
|
|
387
|
+
"markdown"
|
|
388
|
+
], z = [
|
|
389
|
+
"html",
|
|
390
|
+
"content",
|
|
391
|
+
"body",
|
|
392
|
+
"text"
|
|
393
|
+
], B = [
|
|
394
|
+
"featureimage",
|
|
395
|
+
"feature_image",
|
|
396
|
+
"image",
|
|
397
|
+
"cover",
|
|
398
|
+
"coverimage"
|
|
399
|
+
], V = [
|
|
400
|
+
"file",
|
|
401
|
+
"audio",
|
|
402
|
+
"video",
|
|
403
|
+
"enclosure",
|
|
404
|
+
"attachment",
|
|
405
|
+
"media"
|
|
406
|
+
], H = [
|
|
407
|
+
"importurl",
|
|
408
|
+
"canonicalurl",
|
|
409
|
+
"url",
|
|
410
|
+
"link",
|
|
411
|
+
"permalink"
|
|
412
|
+
];
|
|
413
|
+
function U(e) {
|
|
414
|
+
return e.toLowerCase().replace(/\s+/g, "").replace(/[:_-]/g, "");
|
|
415
|
+
}
|
|
416
|
+
function W(e, t) {
|
|
417
|
+
let n = U(e), r = U(t);
|
|
418
|
+
return n === r || n.includes(r) || r.includes(n);
|
|
419
|
+
}
|
|
420
|
+
var G = {
|
|
421
|
+
link: H,
|
|
422
|
+
url: H
|
|
423
|
+
};
|
|
424
|
+
function K(e) {
|
|
425
|
+
if (e.kind === "resolved") return;
|
|
426
|
+
let t = U(e.label), n = U(e.id.replace(/^rss-/, "").replace(/^fm-/, ""));
|
|
427
|
+
return G[t] ?? G[n];
|
|
428
|
+
}
|
|
429
|
+
function q(e) {
|
|
430
|
+
if (!e) return;
|
|
431
|
+
let t = e.contentType ?? e.type;
|
|
432
|
+
return typeof t == "string" && t.trim() ? t.trim() : void 0;
|
|
433
|
+
}
|
|
434
|
+
function J(e) {
|
|
435
|
+
let t = e.meta?.class;
|
|
436
|
+
return t === "html" || t === "image" || t === "audio" || t === "video" || t === "unknown" ? t : p({
|
|
437
|
+
url: typeof e.meta?.url == "string" && e.meta.url.trim() ? e.meta.url.trim() : e.value,
|
|
438
|
+
contentType: q(e.meta)
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function Y(e) {
|
|
442
|
+
if (e.kind === "resolved" || e.kind === "full" || e.kind === "section") return !1;
|
|
443
|
+
let t = U(e.label);
|
|
444
|
+
if (t === "contentencoded" || t === "content" || t === "description" || t === "summary" || t === "title") return !1;
|
|
445
|
+
let n = typeof e.meta?.url == "string" && e.meta.url.trim() ? e.meta.url.trim() : e.value;
|
|
446
|
+
return m(n) && !n.trim().includes("<");
|
|
447
|
+
}
|
|
448
|
+
function X(e) {
|
|
449
|
+
let t = U(e.name);
|
|
450
|
+
return z.some((e) => W(t, e)) || e.dataType === "Html" || e.dataType === "Text";
|
|
451
|
+
}
|
|
452
|
+
function Z(e) {
|
|
453
|
+
let t = U(e.name);
|
|
454
|
+
return e.dataType === "Image" || e.dataType === "File" || e.dataType === "Relation" ? B.some((e) => W(t, e)) || V.some((e) => W(t, e)) || e.dataType === "Image" || e.dataType === "File" : B.some((e) => W(t, e)) || V.some((e) => W(t, e));
|
|
455
|
+
}
|
|
456
|
+
function Q(e) {
|
|
457
|
+
let t = U(e.name);
|
|
458
|
+
return H.some((e) => W(t, e));
|
|
459
|
+
}
|
|
460
|
+
function ae(e, t) {
|
|
461
|
+
return e.find((e) => {
|
|
462
|
+
if (t.has(e.name)) return !1;
|
|
463
|
+
let n = U(e.name);
|
|
464
|
+
return e.dataType === "Image" || B.some((e) => W(n, e));
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function oe(e, t, n) {
|
|
468
|
+
return e.find((e) => {
|
|
469
|
+
if (t.has(e.name)) return !1;
|
|
470
|
+
let r = U(e.name);
|
|
471
|
+
return n === "audio" && W(r, "audio") || n === "video" && W(r, "video") ? !0 : e.dataType === "File" || V.some((e) => W(r, e));
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
function $(e, t) {
|
|
475
|
+
return e.find((e) => {
|
|
476
|
+
if (t.has(e.name)) return !1;
|
|
477
|
+
let n = U(e.name);
|
|
478
|
+
return e.dataType === "Html" || z.some((e) => W(n, e));
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function se(t, n) {
|
|
482
|
+
let r = [], i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = t.filter((e) => e.kind !== "resolved"), s = o.find((e) => e.kind === "full");
|
|
483
|
+
if (s) {
|
|
484
|
+
let e = n.find((e) => R.includes(e.name.toLowerCase()));
|
|
485
|
+
e && (r.push({
|
|
486
|
+
sourceId: s.id,
|
|
487
|
+
propertyName: e.name
|
|
488
|
+
}), i.add(e.name), a.add(s.id));
|
|
489
|
+
}
|
|
490
|
+
let c = {
|
|
491
|
+
title: [
|
|
492
|
+
"title",
|
|
493
|
+
"name",
|
|
494
|
+
"headline"
|
|
495
|
+
],
|
|
496
|
+
"content:encoded": [
|
|
497
|
+
"html",
|
|
498
|
+
"content",
|
|
499
|
+
"body",
|
|
500
|
+
"text"
|
|
501
|
+
],
|
|
502
|
+
content: [
|
|
503
|
+
"html",
|
|
504
|
+
"content",
|
|
505
|
+
"body",
|
|
506
|
+
"text"
|
|
507
|
+
],
|
|
508
|
+
description: [
|
|
509
|
+
"summary",
|
|
510
|
+
"description",
|
|
511
|
+
"excerpt"
|
|
512
|
+
],
|
|
513
|
+
summary: [
|
|
514
|
+
"summary",
|
|
515
|
+
"description",
|
|
516
|
+
"excerpt"
|
|
517
|
+
],
|
|
518
|
+
featureimage: [
|
|
519
|
+
"featureimage",
|
|
520
|
+
"feature_image",
|
|
521
|
+
"image",
|
|
522
|
+
"cover"
|
|
523
|
+
],
|
|
524
|
+
feature_image: [
|
|
525
|
+
"featureimage",
|
|
526
|
+
"feature_image",
|
|
527
|
+
"image",
|
|
528
|
+
"cover"
|
|
529
|
+
],
|
|
530
|
+
link: [
|
|
531
|
+
"url",
|
|
532
|
+
"link",
|
|
533
|
+
"permalink"
|
|
534
|
+
],
|
|
535
|
+
creator: [
|
|
536
|
+
"author",
|
|
537
|
+
"authors",
|
|
538
|
+
"creator",
|
|
539
|
+
"byline"
|
|
540
|
+
],
|
|
541
|
+
author: [
|
|
542
|
+
"author",
|
|
543
|
+
"authors",
|
|
544
|
+
"creator",
|
|
545
|
+
"byline"
|
|
546
|
+
]
|
|
547
|
+
};
|
|
548
|
+
for (let e of o) {
|
|
549
|
+
if (a.has(e.id)) continue;
|
|
550
|
+
let t = U(e.label), o = e.id.replace(/^rss-/, "").replace(/^fm-/, "");
|
|
551
|
+
if (t === "contentencoded" || U(o) === "contentencoded" || t === "content" && e.value.includes("<")) {
|
|
552
|
+
let t = $(n, i);
|
|
553
|
+
t && (r.push({
|
|
554
|
+
sourceId: e.id,
|
|
555
|
+
propertyName: t.name
|
|
556
|
+
}), i.add(t.name), a.add(e.id));
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
for (let t of o) {
|
|
560
|
+
if (a.has(t.id)) continue;
|
|
561
|
+
let o = K(t);
|
|
562
|
+
if (o) {
|
|
563
|
+
for (let e of n) i.has(e.name) || (!Z(e) || Q(e)) && (!X(e) || Q(e) || U(e.name) !== "html" && e.dataType !== "Html") && o.some((t) => W(e.name, t)) && (r.push({
|
|
564
|
+
sourceId: t.id,
|
|
565
|
+
propertyName: e.name
|
|
566
|
+
}), i.add(e.name));
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
if (Y(t)) {
|
|
570
|
+
let e = J(t);
|
|
571
|
+
if (e === "image") {
|
|
572
|
+
let e = ae(n, i);
|
|
573
|
+
if (e) {
|
|
574
|
+
r.push({
|
|
575
|
+
sourceId: t.id,
|
|
576
|
+
propertyName: e.name,
|
|
577
|
+
resolve: "file"
|
|
578
|
+
}), i.add(e.name), a.add(t.id);
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (e === "audio" || e === "video") {
|
|
583
|
+
let o = oe(n, i, e);
|
|
584
|
+
if (o) {
|
|
585
|
+
r.push({
|
|
586
|
+
sourceId: t.id,
|
|
587
|
+
propertyName: o.name,
|
|
588
|
+
resolve: "file"
|
|
589
|
+
}), i.add(o.name), a.add(t.id);
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
let s = U(t.label), l = t.id.replace(/^rss-/, "").replace(/^fm-/, ""), u = [
|
|
595
|
+
...c[t.label] ?? [],
|
|
596
|
+
...c[l] ?? [],
|
|
597
|
+
...c[s] ?? []
|
|
598
|
+
], d;
|
|
599
|
+
for (let e of u) if (d = n.find((t) => !i.has(t.name) && W(t.name, e)), d) break;
|
|
600
|
+
d ||= n.find((e) => !i.has(e.name) && (W(e.name, t.label) || W(e.name, l))), d && (Y(t) && (X(d) || Z(d)) && !Q(d) || (Y(t) && J(t) === "image" && Z(d) ? (r.push({
|
|
601
|
+
sourceId: t.id,
|
|
602
|
+
propertyName: d.name,
|
|
603
|
+
resolve: "file"
|
|
604
|
+
}), i.add(d.name), a.add(t.id)) : e(d) ? (r.push({
|
|
605
|
+
sourceId: t.id,
|
|
606
|
+
propertyName: d.name,
|
|
607
|
+
resolve: "lookup"
|
|
608
|
+
}), i.add(d.name), a.add(t.id)) : (r.push({
|
|
609
|
+
sourceId: t.id,
|
|
610
|
+
propertyName: d.name
|
|
611
|
+
}), i.add(d.name), a.add(t.id))));
|
|
612
|
+
}
|
|
613
|
+
let l = $(n, i);
|
|
614
|
+
if (l) {
|
|
615
|
+
let e = o.find((e) => {
|
|
616
|
+
if (a.has(e.id) && !K(e)) return !1;
|
|
617
|
+
let t = U(e.label), n = U(e.id.replace(/^rss-/, "").replace(/^fm-/, ""));
|
|
618
|
+
return (t === "link" || t === "url" || n === "link" || n === "url" || t === "permalink") && m(e.value);
|
|
619
|
+
});
|
|
620
|
+
e && (r.push({
|
|
621
|
+
sourceId: e.id,
|
|
622
|
+
propertyName: l.name,
|
|
623
|
+
resolve: "extract"
|
|
624
|
+
}), i.add(l.name));
|
|
625
|
+
}
|
|
626
|
+
return r;
|
|
627
|
+
}
|
|
628
|
+
//#endregion
|
|
629
|
+
export { c as A, i as C, n as D, s as E, r as O, e as S, t as T, b as _, j as a, p as b, re as c, A as d, C as f, te as g, ne as h, N as i, l as k, I as l, g as m, F as n, M as o, h as p, P as r, ie as s, se as t, k as u, S as v, a as w, m as x, x as y };
|
|
630
|
+
|
|
631
|
+
//# sourceMappingURL=autoMap-Dh9SiWhT.js.map
|