@underpeaks/generator-core 1.0.66 → 1.0.69
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.
|
@@ -8,14 +8,13 @@ export interface CardFieldSelection {
|
|
|
8
8
|
allFields?: ColumnDef[];
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Picks which fields a card/list preview should show
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* at all.
|
|
11
|
+
* Picks which fields a card/list preview should show. Always attempts a
|
|
12
|
+
* real curated layout (title/image/price/discount/meta) — project_type
|
|
13
|
+
* only chooses which keyword set to prefer, and falls back to a generic
|
|
14
|
+
* universal keyword set when unrecognized rather than giving up.
|
|
15
|
+
* allFields is reserved for the genuine edge case of a model with fewer
|
|
16
|
+
* than 2 visible columns, where no sensible card layout is possible at
|
|
17
|
+
* all.
|
|
19
18
|
*/
|
|
20
19
|
export declare function selectCardFields(model: Model, projectType: string): CardFieldSelection;
|
|
21
20
|
//# sourceMappingURL=card-field-selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-field-selection.d.ts","sourceRoot":"","sources":["../../src/schema/card-field-selection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAG/C,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAK,SAAS,CAAA;IACzB,UAAU,CAAC,EAAK,SAAS,CAAA;IACzB,UAAU,CAAC,EAAK,SAAS,CAAA;IACzB,aAAa,CAAC,EAAE,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"card-field-selection.d.ts","sourceRoot":"","sources":["../../src/schema/card-field-selection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAG/C,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAK,SAAS,CAAA;IACzB,UAAU,CAAC,EAAK,SAAS,CAAA;IACzB,UAAU,CAAC,EAAK,SAAS,CAAA;IACzB,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,UAAU,EAAM,SAAS,EAAE,CAAA;IAC3B,SAAS,CAAC,EAAM,SAAS,EAAE,CAAA;CAC5B;AAqFD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,kBAAkB,CAgDtF"}
|
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.selectCardFields = selectCardFields;
|
|
5
5
|
const parser_1 = require("./parser");
|
|
6
|
-
// Ordered keyword slots per project_type. First column whose name
|
|
7
|
-
// contains any keyword in a slot wins that slot — checked in the order
|
|
8
|
-
// listed, so e.g. 'title' is preferred over 'heading' for blog posts,
|
|
9
|
-
// without excluding 'heading' as a fallback.
|
|
10
6
|
const PROJECT_TYPE_SLOTS = {
|
|
11
7
|
blog: {
|
|
12
8
|
title: ['title', 'heading', 'headline'],
|
|
@@ -37,26 +33,34 @@ const PROJECT_TYPE_SLOTS = {
|
|
|
37
33
|
meta: [['content', 'body', 'text', 'caption'], ['likes', 'comments', 'reactions']],
|
|
38
34
|
},
|
|
39
35
|
};
|
|
40
|
-
// FIX: resolveProjectType previously
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
36
|
+
// FIX (final): resolveProjectType previously returned undefined for any
|
|
37
|
+
// project_type that didn't exact-match or fuzzy-match a known key,
|
|
38
|
+
// causing selectCardFields to bail to the raw allFields dump — every
|
|
39
|
+
// project whose project_type value wasn't literally one of the 5 known
|
|
40
|
+
// strings (or a substring of one) got a broken card, and there was no
|
|
41
|
+
// way to verify from here what this project's actual project_type value
|
|
42
|
+
// even is. Rather than depend on that string matching at all, this now
|
|
43
|
+
// ALWAYS returns usable slots: known project_type gets its tailored
|
|
44
|
+
// keyword set, anything else gets GENERIC_SLOTS — a universal keyword set
|
|
45
|
+
// that works for any reasonably-named schema. allFields is no longer
|
|
46
|
+
// reachable through project_type at all.
|
|
47
|
+
const GENERIC_SLOTS = {
|
|
48
|
+
title: ['name', 'title', 'heading', 'headline'],
|
|
49
|
+
image: ['image', 'thumbnail', 'photo', 'cover', 'avatar'],
|
|
50
|
+
price: ['price', 'cost', 'amount'],
|
|
51
|
+
discount: ['discount_percentage', 'discount_percent', 'discount'],
|
|
52
|
+
meta: [['description', 'summary', 'subtitle', 'excerpt']],
|
|
53
|
+
};
|
|
50
54
|
function resolveProjectType(projectType) {
|
|
51
|
-
const normalized = projectType.trim().toLowerCase();
|
|
55
|
+
const normalized = (projectType ?? '').trim().toLowerCase();
|
|
52
56
|
if (PROJECT_TYPE_SLOTS[normalized])
|
|
53
57
|
return PROJECT_TYPE_SLOTS[normalized];
|
|
54
58
|
for (const key of Object.keys(PROJECT_TYPE_SLOTS)) {
|
|
55
|
-
if (normalized.includes(key) || key.includes(normalized)) {
|
|
59
|
+
if (normalized && (normalized.includes(key) || key.includes(normalized))) {
|
|
56
60
|
return PROJECT_TYPE_SLOTS[key];
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
|
-
return
|
|
63
|
+
return GENERIC_SLOTS;
|
|
60
64
|
}
|
|
61
65
|
function findColumnMatching(columns, keywords, taken) {
|
|
62
66
|
for (const keyword of keywords) {
|
|
@@ -67,21 +71,20 @@ function findColumnMatching(columns, keywords, taken) {
|
|
|
67
71
|
return undefined;
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
|
-
* Picks which fields a card/list preview should show
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* at all.
|
|
74
|
+
* Picks which fields a card/list preview should show. Always attempts a
|
|
75
|
+
* real curated layout (title/image/price/discount/meta) — project_type
|
|
76
|
+
* only chooses which keyword set to prefer, and falls back to a generic
|
|
77
|
+
* universal keyword set when unrecognized rather than giving up.
|
|
78
|
+
* allFields is reserved for the genuine edge case of a model with fewer
|
|
79
|
+
* than 2 visible columns, where no sensible card layout is possible at
|
|
80
|
+
* all.
|
|
78
81
|
*/
|
|
79
82
|
function selectCardFields(model, projectType) {
|
|
80
83
|
const columns = (0, parser_1.getVisibleColumns)(model);
|
|
81
|
-
|
|
82
|
-
if (!slots) {
|
|
84
|
+
if (columns.length < 2) {
|
|
83
85
|
return { allFields: columns, metaFields: [] };
|
|
84
86
|
}
|
|
87
|
+
const slots = resolveProjectType(projectType);
|
|
85
88
|
const taken = new Set();
|
|
86
89
|
const titleField = slots.title
|
|
87
90
|
? findColumnMatching(columns, slots.title, taken)
|
|
@@ -111,8 +114,6 @@ function selectCardFields(model, projectType) {
|
|
|
111
114
|
taken.add(match.name);
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
|
-
// Never leave a card with no title at all — fall back to the first
|
|
115
|
-
// visible column (excluding the primary key) if no keyword matched.
|
|
116
117
|
const finalTitleField = titleField ?? columns.find((c) => c.name !== (0, parser_1.getPrimaryKey)(model)?.name);
|
|
117
118
|
return {
|
|
118
119
|
titleField: finalTitleField,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-field-selection.js","sourceRoot":"","sources":["../../src/schema/card-field-selection.ts"],"names":[],"mappings":";AAAA,sFAAsF;;
|
|
1
|
+
{"version":3,"file":"card-field-selection.js","sourceRoot":"","sources":["../../src/schema/card-field-selection.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AA0GtF,4CAgDC;AAvJD,qCAA2D;AAmB3D,MAAM,kBAAkB,GAA8B;IACpD,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CA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