@cogenta/import 0.1.0
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/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/wordpress/collections.d.ts +232 -0
- package/dist/wordpress/collections.d.ts.map +1 -0
- package/dist/wordpress/collections.js +133 -0
- package/dist/wordpress/collections.js.map +1 -0
- package/dist/wordpress/content-convert.d.ts +50 -0
- package/dist/wordpress/content-convert.d.ts.map +1 -0
- package/dist/wordpress/content-convert.js +222 -0
- package/dist/wordpress/content-convert.js.map +1 -0
- package/dist/wordpress/gutenberg.d.ts +27 -0
- package/dist/wordpress/gutenberg.d.ts.map +1 -0
- package/dist/wordpress/gutenberg.js +83 -0
- package/dist/wordpress/gutenberg.js.map +1 -0
- package/dist/wordpress/html-to-richtext.d.ts +23 -0
- package/dist/wordpress/html-to-richtext.d.ts.map +1 -0
- package/dist/wordpress/html-to-richtext.js +209 -0
- package/dist/wordpress/html-to-richtext.js.map +1 -0
- package/dist/wordpress/import.d.ts +19 -0
- package/dist/wordpress/import.d.ts.map +1 -0
- package/dist/wordpress/import.js +241 -0
- package/dist/wordpress/import.js.map +1 -0
- package/dist/wordpress/media.d.ts +27 -0
- package/dist/wordpress/media.d.ts.map +1 -0
- package/dist/wordpress/media.js +68 -0
- package/dist/wordpress/media.js.map +1 -0
- package/dist/wordpress/parse.d.ts +12 -0
- package/dist/wordpress/parse.d.ts.map +1 -0
- package/dist/wordpress/parse.js +95 -0
- package/dist/wordpress/parse.js.map +1 -0
- package/dist/wordpress/report.d.ts +45 -0
- package/dist/wordpress/report.d.ts.map +1 -0
- package/dist/wordpress/report.js +41 -0
- package/dist/wordpress/report.js.map +1 -0
- package/dist/wordpress/types.d.ts +66 -0
- package/dist/wordpress/types.d.ts.map +1 -0
- package/dist/wordpress/types.js +10 -0
- package/dist/wordpress/types.js.map +1 -0
- package/dist/wordpress/xml.d.ts +33 -0
- package/dist/wordpress/xml.d.ts.map +1 -0
- package/dist/wordpress/xml.js +262 -0
- package/dist/wordpress/xml.js.map +1 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { WORDPRESS_IMPORT_COLLECTIONS, wpCategory, wpComment, wpPage, wpPost, wpTag, } from './wordpress/collections.js';
|
|
2
|
+
export type { ContentConversionNote, ContentConversionResult, DraftBlock, } from './wordpress/content-convert.js';
|
|
3
|
+
export { convertContent, mediaUrlsOf, resolveMediaReferences } from './wordpress/content-convert.js';
|
|
4
|
+
export type { ImportWordPressOptions } from './wordpress/import.js';
|
|
5
|
+
export { importWordPress } from './wordpress/import.js';
|
|
6
|
+
export type { DownloadAndStoreMediaOptions, MediaDownloadFailure, MediaImportResult, } from './wordpress/media.js';
|
|
7
|
+
export { downloadAndStoreMedia } from './wordpress/media.js';
|
|
8
|
+
export { parseWxr } from './wordpress/parse.js';
|
|
9
|
+
export type { ConversionReport, UnconvertedItem } from './wordpress/report.js';
|
|
10
|
+
export { formatConversionReport } from './wordpress/report.js';
|
|
11
|
+
export type { ParsedWxr, WxrAuthor, WxrCategory, WxrComment, WxrItem, WxrPostMeta, WxrTag, WxrTermRef, } from './wordpress/types.js';
|
|
12
|
+
export type { XmlElement, XmlNode } from './wordpress/xml.js';
|
|
13
|
+
export { parseXmlDocument } from './wordpress/xml.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,UAAU,EACV,SAAS,EACT,MAAM,EACN,MAAM,EACN,KAAK,GACN,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,GACX,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACpG,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,YAAY,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,YAAY,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,MAAM,EACN,UAAU,GACX,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { WORDPRESS_IMPORT_COLLECTIONS, wpCategory, wpComment, wpPage, wpPost, wpTag, } from './wordpress/collections.js';
|
|
2
|
+
export { convertContent, mediaUrlsOf, resolveMediaReferences } from './wordpress/content-convert.js';
|
|
3
|
+
export { importWordPress } from './wordpress/import.js';
|
|
4
|
+
export { downloadAndStoreMedia } from './wordpress/media.js';
|
|
5
|
+
export { parseWxr } from './wordpress/parse.js';
|
|
6
|
+
export { formatConversionReport } from './wordpress/report.js';
|
|
7
|
+
export { parseXmlDocument } from './wordpress/xml.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,UAAU,EACV,SAAS,EACT,MAAM,EACN,MAAM,EACN,KAAK,GACN,MAAM,4BAA4B,CAAA;AAMnC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAEpG,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAMvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAY9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { type CollectionDefinition } from '@cogenta/schema';
|
|
2
|
+
/**
|
|
3
|
+
* The content model a WordPress import writes into.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately its own set, not a reuse of `create-cogenta`'s `blog`
|
|
6
|
+
* blueprint collections: this import needs two fields the blueprint's `post`
|
|
7
|
+
* does not declare — `publishedAt` (so the entry's real WordPress publish
|
|
8
|
+
* date survives, rather than being overwritten by the system `createdAt`,
|
|
9
|
+
* which is always "now") and `customFields` (`f.json()`, the only field kind
|
|
10
|
+
* contract A offers with no fixed shape, for WordPress postmeta that has
|
|
11
|
+
* nowhere semantic to go). Running this import against a site that already
|
|
12
|
+
* has its own `post`/`category`/`tag`/`page` collections under those exact
|
|
13
|
+
* names — e.g. one scaffolded from the `blog` blueprint — is out of scope for
|
|
14
|
+
* this task: `createSchemaTables` only creates a table that does not exist
|
|
15
|
+
* yet, so combining the two is not exercised or supported here.
|
|
16
|
+
*
|
|
17
|
+
* `body` is a block zone (`f.blocks()`), not a single `f.richText()` field
|
|
18
|
+
* like the blueprint's `post.body`: WordPress content commonly mixes
|
|
19
|
+
* paragraphs, images, quotes, galleries and embeds, and contract B already
|
|
20
|
+
* has a semantic block for each of those (`prose`, `mediaFigure`, `quote`,
|
|
21
|
+
* `gallery`, `embed`) — collapsing all of it into one rich-text field would
|
|
22
|
+
* either lose the image/quote/embed structure or smuggle it through as
|
|
23
|
+
* embedded HTML, which rule R3 forbids outright.
|
|
24
|
+
*/
|
|
25
|
+
export declare const wpCategory: {
|
|
26
|
+
readonly name: "category";
|
|
27
|
+
readonly labels: {
|
|
28
|
+
readonly singular: "Category";
|
|
29
|
+
readonly plural: "Categories";
|
|
30
|
+
};
|
|
31
|
+
readonly routing: {
|
|
32
|
+
readonly pattern: "/blog/category/:slug";
|
|
33
|
+
};
|
|
34
|
+
readonly fields: {
|
|
35
|
+
name: import("@cogenta/schema").FieldDefinition & {
|
|
36
|
+
readonly kind: "text";
|
|
37
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
38
|
+
};
|
|
39
|
+
slug: import("@cogenta/schema").FieldDefinition & {
|
|
40
|
+
readonly kind: "slug";
|
|
41
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
readonly indexes: readonly [readonly ["slug"]];
|
|
45
|
+
readonly permissions: {
|
|
46
|
+
readonly read: readonly ["public"];
|
|
47
|
+
readonly create: readonly ["editor", "admin"];
|
|
48
|
+
readonly update: readonly ["editor", "admin"];
|
|
49
|
+
readonly delete: readonly ["admin"];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const wpTag: {
|
|
53
|
+
readonly name: "tag";
|
|
54
|
+
readonly labels: {
|
|
55
|
+
readonly singular: "Tag";
|
|
56
|
+
readonly plural: "Tags";
|
|
57
|
+
};
|
|
58
|
+
readonly fields: {
|
|
59
|
+
name: import("@cogenta/schema").FieldDefinition & {
|
|
60
|
+
readonly kind: "text";
|
|
61
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
62
|
+
};
|
|
63
|
+
slug: import("@cogenta/schema").FieldDefinition & {
|
|
64
|
+
readonly kind: "slug";
|
|
65
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly indexes: readonly [readonly ["slug"]];
|
|
69
|
+
readonly permissions: {
|
|
70
|
+
readonly read: readonly ["public"];
|
|
71
|
+
readonly create: readonly ["editor", "admin"];
|
|
72
|
+
readonly update: readonly ["editor", "admin"];
|
|
73
|
+
readonly delete: readonly ["admin"];
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export declare const wpPost: {
|
|
77
|
+
readonly name: "post";
|
|
78
|
+
readonly labels: {
|
|
79
|
+
readonly singular: "Post";
|
|
80
|
+
readonly plural: "Posts";
|
|
81
|
+
};
|
|
82
|
+
readonly routing: {
|
|
83
|
+
readonly pattern: "/blog/:slug";
|
|
84
|
+
};
|
|
85
|
+
readonly versioning: {
|
|
86
|
+
readonly drafts: true;
|
|
87
|
+
readonly history: true;
|
|
88
|
+
};
|
|
89
|
+
readonly fields: {
|
|
90
|
+
title: import("@cogenta/schema").FieldDefinition & {
|
|
91
|
+
readonly kind: "text";
|
|
92
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
93
|
+
};
|
|
94
|
+
slug: import("@cogenta/schema").FieldDefinition & {
|
|
95
|
+
readonly kind: "slug";
|
|
96
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
97
|
+
};
|
|
98
|
+
excerpt: import("@cogenta/schema").FieldDefinition & {
|
|
99
|
+
readonly kind: "text";
|
|
100
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
101
|
+
};
|
|
102
|
+
body: import("@cogenta/schema").FieldDefinition & {
|
|
103
|
+
readonly kind: "blocks";
|
|
104
|
+
readonly options: {
|
|
105
|
+
allow: "*" | readonly string[];
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
publishedAt: import("@cogenta/schema").FieldDefinition & {
|
|
109
|
+
readonly kind: "datetime";
|
|
110
|
+
readonly options: {};
|
|
111
|
+
};
|
|
112
|
+
category: import("@cogenta/schema").FieldDefinition & {
|
|
113
|
+
readonly kind: "relation";
|
|
114
|
+
readonly options: {
|
|
115
|
+
to: string;
|
|
116
|
+
many: boolean;
|
|
117
|
+
onDelete: import("@cogenta/schema").OnDelete;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
tags: import("@cogenta/schema").FieldDefinition & {
|
|
121
|
+
readonly kind: "relation";
|
|
122
|
+
readonly options: {
|
|
123
|
+
to: string;
|
|
124
|
+
many: boolean;
|
|
125
|
+
onDelete: import("@cogenta/schema").OnDelete;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
/** Opaque WordPress postmeta — contract A has no free-form field kind, so this is the honest carrier for it. */
|
|
129
|
+
customFields: import("@cogenta/schema").FieldDefinition & {
|
|
130
|
+
readonly kind: "json";
|
|
131
|
+
readonly options: {};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
readonly indexes: readonly [readonly ["slug"]];
|
|
135
|
+
readonly permissions: {
|
|
136
|
+
readonly read: readonly ["public"];
|
|
137
|
+
readonly create: readonly ["editor", "admin"];
|
|
138
|
+
readonly update: readonly ["editor", "admin"];
|
|
139
|
+
readonly delete: readonly ["admin"];
|
|
140
|
+
readonly publish: readonly ["admin"];
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
export declare const wpPage: {
|
|
144
|
+
readonly name: "page";
|
|
145
|
+
readonly labels: {
|
|
146
|
+
readonly singular: "Page";
|
|
147
|
+
readonly plural: "Pages";
|
|
148
|
+
};
|
|
149
|
+
readonly routing: {
|
|
150
|
+
readonly pattern: "/:slug";
|
|
151
|
+
};
|
|
152
|
+
readonly fields: {
|
|
153
|
+
title: import("@cogenta/schema").FieldDefinition & {
|
|
154
|
+
readonly kind: "text";
|
|
155
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
156
|
+
};
|
|
157
|
+
slug: import("@cogenta/schema").FieldDefinition & {
|
|
158
|
+
readonly kind: "slug";
|
|
159
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
160
|
+
};
|
|
161
|
+
body: import("@cogenta/schema").FieldDefinition & {
|
|
162
|
+
readonly kind: "blocks";
|
|
163
|
+
readonly options: {
|
|
164
|
+
allow: "*" | readonly string[];
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
publishedAt: import("@cogenta/schema").FieldDefinition & {
|
|
168
|
+
readonly kind: "datetime";
|
|
169
|
+
readonly options: {};
|
|
170
|
+
};
|
|
171
|
+
customFields: import("@cogenta/schema").FieldDefinition & {
|
|
172
|
+
readonly kind: "json";
|
|
173
|
+
readonly options: {};
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
readonly indexes: readonly [readonly ["slug"]];
|
|
177
|
+
readonly permissions: {
|
|
178
|
+
readonly read: readonly ["public"];
|
|
179
|
+
readonly create: readonly ["editor", "admin"];
|
|
180
|
+
readonly update: readonly ["editor", "admin"];
|
|
181
|
+
readonly delete: readonly ["admin"];
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* A minimal, real comment model — not a stub. WordPress comments have no
|
|
186
|
+
* declared-user identity (a commenter is a name and an email, not an
|
|
187
|
+
* account), so `author`/`authorEmail` are plain fields rather than a
|
|
188
|
+
* `relation` to a user; `post` ties a comment back to the entry it belongs
|
|
189
|
+
* to. Only fields the frozen field vocabulary (contract A) already offers
|
|
190
|
+
* are used, the same discipline `create-cogenta`'s blueprints follow.
|
|
191
|
+
*/
|
|
192
|
+
export declare const wpComment: {
|
|
193
|
+
readonly name: "comment";
|
|
194
|
+
readonly labels: {
|
|
195
|
+
readonly singular: "Comment";
|
|
196
|
+
readonly plural: "Comments";
|
|
197
|
+
};
|
|
198
|
+
readonly fields: {
|
|
199
|
+
post: import("@cogenta/schema").FieldDefinition & {
|
|
200
|
+
readonly kind: "relation";
|
|
201
|
+
readonly options: {
|
|
202
|
+
to: string;
|
|
203
|
+
many: boolean;
|
|
204
|
+
onDelete: import("@cogenta/schema").OnDelete;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
author: import("@cogenta/schema").FieldDefinition & {
|
|
208
|
+
readonly kind: "text";
|
|
209
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
210
|
+
};
|
|
211
|
+
authorEmail: import("@cogenta/schema").FieldDefinition & {
|
|
212
|
+
readonly kind: "text";
|
|
213
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
214
|
+
};
|
|
215
|
+
body: import("@cogenta/schema").FieldDefinition & {
|
|
216
|
+
readonly kind: "text";
|
|
217
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
218
|
+
};
|
|
219
|
+
publishedAt: import("@cogenta/schema").FieldDefinition & {
|
|
220
|
+
readonly kind: "datetime";
|
|
221
|
+
readonly options: {};
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
readonly permissions: {
|
|
225
|
+
readonly read: readonly ["public"];
|
|
226
|
+
readonly create: readonly ["public"];
|
|
227
|
+
readonly update: readonly ["editor", "admin"];
|
|
228
|
+
readonly delete: readonly ["admin"];
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
export declare const WORDPRESS_IMPORT_COLLECTIONS: readonly CollectionDefinition[];
|
|
232
|
+
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/wordpress/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;QAKnB,IAAI;;;;QACJ,IAAI;;;;;;;;;;;;CASN,CAAA;AAEF,eAAO,MAAM,KAAK;;;;;;;QAId,IAAI;;;;QACJ,IAAI;;;;;;;;;;;;CASN,CAAA;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;QAMf,KAAK;;;;QACL,IAAI;;;;QACJ,OAAO;;;;QACP,IAAI;;;;;;QACJ,WAAW;;;;QACX,QAAQ;;;;;;;;QACR,IAAI;;;;;;;;QACJ,gHAAgH;QAChH,YAAY;;;;;;;;;;;;;CAUd,CAAA;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;QAKf,KAAK;;;;QACL,IAAI;;;;QACJ,IAAI;;;;;;QACJ,WAAW;;;;QACX,YAAY;;;;;;;;;;;;CASd,CAAA;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;;;;;;QAIlB,IAAI;;;;;;;;QACJ,MAAM;;;;QACN,WAAW;;;;QACX,IAAI;;;;QACJ,WAAW;;;;;;;;;;;CAQb,CAAA;AAEF,eAAO,MAAM,4BAA4B,EAAE,SAAS,oBAAoB,EAMvE,CAAA"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { defineCollection, f, validateCollectionSet, } from '@cogenta/schema';
|
|
2
|
+
/**
|
|
3
|
+
* The content model a WordPress import writes into.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately its own set, not a reuse of `create-cogenta`'s `blog`
|
|
6
|
+
* blueprint collections: this import needs two fields the blueprint's `post`
|
|
7
|
+
* does not declare — `publishedAt` (so the entry's real WordPress publish
|
|
8
|
+
* date survives, rather than being overwritten by the system `createdAt`,
|
|
9
|
+
* which is always "now") and `customFields` (`f.json()`, the only field kind
|
|
10
|
+
* contract A offers with no fixed shape, for WordPress postmeta that has
|
|
11
|
+
* nowhere semantic to go). Running this import against a site that already
|
|
12
|
+
* has its own `post`/`category`/`tag`/`page` collections under those exact
|
|
13
|
+
* names — e.g. one scaffolded from the `blog` blueprint — is out of scope for
|
|
14
|
+
* this task: `createSchemaTables` only creates a table that does not exist
|
|
15
|
+
* yet, so combining the two is not exercised or supported here.
|
|
16
|
+
*
|
|
17
|
+
* `body` is a block zone (`f.blocks()`), not a single `f.richText()` field
|
|
18
|
+
* like the blueprint's `post.body`: WordPress content commonly mixes
|
|
19
|
+
* paragraphs, images, quotes, galleries and embeds, and contract B already
|
|
20
|
+
* has a semantic block for each of those (`prose`, `mediaFigure`, `quote`,
|
|
21
|
+
* `gallery`, `embed`) — collapsing all of it into one rich-text field would
|
|
22
|
+
* either lose the image/quote/embed structure or smuggle it through as
|
|
23
|
+
* embedded HTML, which rule R3 forbids outright.
|
|
24
|
+
*/
|
|
25
|
+
export const wpCategory = defineCollection({
|
|
26
|
+
name: 'category',
|
|
27
|
+
labels: { singular: 'Category', plural: 'Categories' },
|
|
28
|
+
routing: { pattern: '/blog/category/:slug' },
|
|
29
|
+
fields: {
|
|
30
|
+
name: f.text({ required: true, max: 200 }),
|
|
31
|
+
slug: f.slug({ from: 'name', unique: true }),
|
|
32
|
+
},
|
|
33
|
+
indexes: [['slug']],
|
|
34
|
+
permissions: {
|
|
35
|
+
read: ['public'],
|
|
36
|
+
create: ['editor', 'admin'],
|
|
37
|
+
update: ['editor', 'admin'],
|
|
38
|
+
delete: ['admin'],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
export const wpTag = defineCollection({
|
|
42
|
+
name: 'tag',
|
|
43
|
+
labels: { singular: 'Tag', plural: 'Tags' },
|
|
44
|
+
fields: {
|
|
45
|
+
name: f.text({ required: true, max: 200 }),
|
|
46
|
+
slug: f.slug({ from: 'name', unique: true }),
|
|
47
|
+
},
|
|
48
|
+
indexes: [['slug']],
|
|
49
|
+
permissions: {
|
|
50
|
+
read: ['public'],
|
|
51
|
+
create: ['editor', 'admin'],
|
|
52
|
+
update: ['editor', 'admin'],
|
|
53
|
+
delete: ['admin'],
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export const wpPost = defineCollection({
|
|
57
|
+
name: 'post',
|
|
58
|
+
labels: { singular: 'Post', plural: 'Posts' },
|
|
59
|
+
routing: { pattern: '/blog/:slug' },
|
|
60
|
+
versioning: { drafts: true, history: true },
|
|
61
|
+
fields: {
|
|
62
|
+
title: f.text({ required: true, max: 300 }),
|
|
63
|
+
slug: f.slug({ from: 'title', unique: true }),
|
|
64
|
+
excerpt: f.text({ max: 2000, multiline: true }),
|
|
65
|
+
body: f.blocks({ allow: ['prose', 'mediaFigure', 'quote', 'gallery', 'embed'] }),
|
|
66
|
+
publishedAt: f.datetime(),
|
|
67
|
+
category: f.relation({ to: 'category', onDelete: 'setNull' }),
|
|
68
|
+
tags: f.relation({ to: 'tag', many: true, onDelete: 'cascade' }),
|
|
69
|
+
/** Opaque WordPress postmeta — contract A has no free-form field kind, so this is the honest carrier for it. */
|
|
70
|
+
customFields: f.json(),
|
|
71
|
+
},
|
|
72
|
+
indexes: [['slug']],
|
|
73
|
+
permissions: {
|
|
74
|
+
read: ['public'],
|
|
75
|
+
create: ['editor', 'admin'],
|
|
76
|
+
update: ['editor', 'admin'],
|
|
77
|
+
delete: ['admin'],
|
|
78
|
+
publish: ['admin'],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
export const wpPage = defineCollection({
|
|
82
|
+
name: 'page',
|
|
83
|
+
labels: { singular: 'Page', plural: 'Pages' },
|
|
84
|
+
routing: { pattern: '/:slug' },
|
|
85
|
+
fields: {
|
|
86
|
+
title: f.text({ required: true, max: 300 }),
|
|
87
|
+
slug: f.slug({ from: 'title', unique: true }),
|
|
88
|
+
body: f.blocks({ allow: ['prose', 'mediaFigure', 'quote', 'gallery', 'embed'] }),
|
|
89
|
+
publishedAt: f.datetime(),
|
|
90
|
+
customFields: f.json(),
|
|
91
|
+
},
|
|
92
|
+
indexes: [['slug']],
|
|
93
|
+
permissions: {
|
|
94
|
+
read: ['public'],
|
|
95
|
+
create: ['editor', 'admin'],
|
|
96
|
+
update: ['editor', 'admin'],
|
|
97
|
+
delete: ['admin'],
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* A minimal, real comment model — not a stub. WordPress comments have no
|
|
102
|
+
* declared-user identity (a commenter is a name and an email, not an
|
|
103
|
+
* account), so `author`/`authorEmail` are plain fields rather than a
|
|
104
|
+
* `relation` to a user; `post` ties a comment back to the entry it belongs
|
|
105
|
+
* to. Only fields the frozen field vocabulary (contract A) already offers
|
|
106
|
+
* are used, the same discipline `create-cogenta`'s blueprints follow.
|
|
107
|
+
*/
|
|
108
|
+
export const wpComment = defineCollection({
|
|
109
|
+
name: 'comment',
|
|
110
|
+
labels: { singular: 'Comment', plural: 'Comments' },
|
|
111
|
+
fields: {
|
|
112
|
+
post: f.relation({ to: 'post', onDelete: 'cascade', required: true }),
|
|
113
|
+
author: f.text({ required: true, max: 200 }),
|
|
114
|
+
authorEmail: f.text({ max: 320 }),
|
|
115
|
+
body: f.text({ required: true, multiline: true, max: 10000 }),
|
|
116
|
+
publishedAt: f.datetime(),
|
|
117
|
+
},
|
|
118
|
+
permissions: {
|
|
119
|
+
read: ['public'],
|
|
120
|
+
create: ['public'],
|
|
121
|
+
update: ['editor', 'admin'],
|
|
122
|
+
delete: ['admin'],
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
export const WORDPRESS_IMPORT_COLLECTIONS = [
|
|
126
|
+
wpPost,
|
|
127
|
+
wpPage,
|
|
128
|
+
wpCategory,
|
|
129
|
+
wpTag,
|
|
130
|
+
wpComment,
|
|
131
|
+
];
|
|
132
|
+
validateCollectionSet(WORDPRESS_IMPORT_COLLECTIONS);
|
|
133
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/wordpress/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,CAAC,EACD,qBAAqB,GACtB,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC;IACzC,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE;IACtD,OAAO,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE;IAC5C,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,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ACrE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QAC5C,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QACjC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAC7D,WAAW,EAAE,CAAC,CAAC,QAAQ,EAAE;KAC1B;IACD,WAAW,EAAE;QACX,IAAI,EAAE,CAAC,QAAQ,CAAC;QAChB,MAAM,EAAE,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC3B,MAAM,EAAE,CAAC,OAAO,CAAC;KAClB;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAoC;IAC3E,MAAM;IACN,MAAM;IACN,UAAU;IACV,KAAK;IACL,SAAS;CACV,CAAA;AAED,qBAAqB,CAAC,4BAA4B,CAAC,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { EmbedBlock, GalleryBlock, MediaFigureBlock, ProseBlock, QuoteBlock } from '@cogenta/blocks';
|
|
2
|
+
/**
|
|
3
|
+
* A block produced by this converter. Shaped exactly like the vocabulary
|
|
4
|
+
* (contract B) except that `media`/`gallery.items[].media` momentarily hold
|
|
5
|
+
* the *source URL* of the image rather than a `MediaAsset` id — `import.ts`
|
|
6
|
+
* downloads every referenced URL once, across the whole import, and
|
|
7
|
+
* `resolveMediaReferences` below substitutes the real ids afterwards. This
|
|
8
|
+
* keeps content conversion (pure, synchronous, heavily tested) separate from
|
|
9
|
+
* media download (network, best-effort, graceful on failure).
|
|
10
|
+
*/
|
|
11
|
+
export type DraftBlock = (Omit<ProseBlock, '_key' | '_version'> & {
|
|
12
|
+
readonly _key: string;
|
|
13
|
+
}) | (Omit<MediaFigureBlock, '_key' | '_version' | 'media'> & {
|
|
14
|
+
readonly _key: string;
|
|
15
|
+
readonly media: string;
|
|
16
|
+
}) | (Omit<QuoteBlock, '_key' | '_version'> & {
|
|
17
|
+
readonly _key: string;
|
|
18
|
+
}) | (Omit<GalleryBlock, '_key' | '_version' | 'items'> & {
|
|
19
|
+
readonly _key: string;
|
|
20
|
+
readonly items: readonly {
|
|
21
|
+
readonly _key: string;
|
|
22
|
+
readonly media: string;
|
|
23
|
+
}[];
|
|
24
|
+
}) | (Omit<EmbedBlock, '_key' | '_version'> & {
|
|
25
|
+
readonly _key: string;
|
|
26
|
+
});
|
|
27
|
+
export interface ContentConversionNote {
|
|
28
|
+
/** The Gutenberg block name, or an HTML tag name, that could not be represented. */
|
|
29
|
+
readonly source: string;
|
|
30
|
+
readonly reason: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ContentConversionResult {
|
|
33
|
+
readonly blocks: readonly DraftBlock[];
|
|
34
|
+
readonly notes: readonly ContentConversionNote[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Converts a post's `content:encoded` into the block vocabulary (contract B),
|
|
38
|
+
* best-effort. Everything that cannot be represented is named in `notes`
|
|
39
|
+
* rather than silently dropped or coerced into `prose` as raw HTML (rule R3).
|
|
40
|
+
*/
|
|
41
|
+
export declare function convertContent(content: string): ContentConversionResult;
|
|
42
|
+
/** Every source URL a draft's blocks reference, so the caller can download them once, up front. */
|
|
43
|
+
export declare function mediaUrlsOf(blocks: readonly DraftBlock[]): readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* Substitutes real media ids for the source URLs `convertContent` left in
|
|
46
|
+
* place. A block whose image never downloaded is dropped rather than written
|
|
47
|
+
* with a dangling reference; a gallery that loses every item is dropped too.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveMediaReferences(blocks: readonly DraftBlock[], urlToMediaId: ReadonlyMap<string, string>, notes: ContentConversionNote[]): readonly DraftBlock[];
|
|
50
|
+
//# sourceMappingURL=content-convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-convert.d.ts","sourceRoot":"","sources":["../../src/wordpress/content-convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,UAAU,EACX,MAAM,iBAAiB,CAAA;AAKxB;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAClB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACnE,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAC,GACF,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACnE,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,GAAG;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC7E,CAAC,GACF,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEvE,MAAM,WAAW,qBAAqB;IACpC,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,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