@contentrain/wp-import 0.5.7 → 0.7.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/README.md CHANGED
@@ -37,6 +37,7 @@ const commentsExport = buildCommentsExport(raw, entry_source_map)
37
37
  - **UTC dates** — GMT columns preferred, stamped ISO 8601 `Z`.
38
38
  - **Pure conversion** — `rawToContentrain` returns a canonical-serialized file map (sorted keys, 2-space indent, trailing newline); writing to disk is the caller's one line.
39
39
  - **EntrySourceMap produced at the only place that can know it** — the WP-id → entry-address mapping the comments intake requires.
40
+ - **Only public discussion leaves the site** — `buildCommentsExport` carries comments on published, unprotected entries that are approved or pending (pending lands in the receiver's moderation queue). Comments on drafts, private, scheduled or password-protected entries, any other status (spam, trash, `post-trashed`, a plugin's) and entries the import does not hold, stay behind; `excluded` counts them.
40
41
 
41
42
  Streaming WXR parse (sax): a 100 MB export holds only its records in memory.
42
43
 
@@ -101,6 +102,36 @@ these before claiming a complete migration. ACF field/group records and their
101
102
  cross-model parents remain in the content store; route discovery decides which
102
103
  records become public pages. Importing configuration does not execute a plugin.
103
104
 
105
+ ### Site name over REST
106
+
107
+ `fetchRestRawIR` reads the `/wp-json/` index for the site's name and tagline
108
+ (`RawIR.site.title` / `description`, the store's `site` singleton) and its
109
+ install and public addresses (`base_site_url` / `base_blog_url`). An index that
110
+ does not answer leaves them out.
111
+
112
+ ### Menus over REST
113
+
114
+ With an Application Password, `fetchRestRawIR` reads the site's menus into
115
+ `RawIR.menus`: classic menus (`/wp/v2/menus` + `/wp/v2/menu-items`, with the
116
+ theme locations each is assigned to) and a block theme's published
117
+ `wp_navigation` posts (links, submenus, page lists, home links). A block menu's
118
+ `locations` are the template-part areas (`header`, `footer`) whose navigation
119
+ block refers to it; an empty navigation block without a `ref` shows the most
120
+ recent published one, as WordPress does. Block menu items have no WordPress id
121
+ and get negative ids; the store claims no `wp_id` for them.
122
+
123
+ A menu item that is itself a draft, or whose post target is not proven public
124
+ — a draft, pending, private, scheduled or password-protected post, or one this
125
+ import never read (a type outside REST, a listing past a page cap) — is left
126
+ out, fail-closed: its label is often that post's title. Its children move up to the
127
+ nearest kept ancestor; `warnings` gives only the count.
128
+
129
+ Both need `edit_theme_options`. Without a credential, with a rejected one, or
130
+ with a user who lacks that right, no menus are read and the result's `gaps`
131
+ contains `menus_require_auth` — an empty menu list is never presented as the
132
+ site having none. The `menus` model gains a `locations` field only when the
133
+ source named them.
134
+
104
135
 
105
136
  ### Publication and translation identity
106
137
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommentsExport, EntrySourceMap, HandoffComments, RawIR, SourceDeltaPlan } from "@contentrain/types";
1
+ import { CommentsExport, EntrySourceMap, HandoffComments, RawComment, RawIR, SourceDeltaPlan } from "@contentrain/types";
2
2
  import { Readable } from "node:stream";
3
3
 
4
4
  //#region src/wxr.d.ts
@@ -55,6 +55,24 @@ interface RestImportOptions {
55
55
  interface RestImportResult {
56
56
  raw: RawIR;
57
57
  warnings: string[];
58
+ /**
59
+ * Whether the credential was honoured, for callers that must act on it
60
+ * without reading `warnings`. `none`: no `auth` given. `accepted`: every
61
+ * listing it unlocks was read with it. `rejected`: at least one was not —
62
+ * `fell_back` names each (`posts`, `pages`, a CPT's rest base, `comments`,
63
+ * `comments:hold`), and those came from the public listing instead, or not
64
+ * at all for `comments:hold`, which has none.
65
+ */
66
+ credential: {
67
+ status: 'none' | 'accepted' | 'rejected';
68
+ fell_back: string[];
69
+ };
70
+ /**
71
+ * What this rung could not read, as codes a caller can act on (the text is in `warnings`).
72
+ * `menus_require_auth`: menus and block navigation are only readable with an application password
73
+ * of a user who may edit theme options — none was given, the site rejected it, or it lacks that right.
74
+ */
75
+ gaps: string[];
58
76
  }
59
77
  declare function fetchRestRawIR(options: RestImportOptions): Promise<RestImportResult>;
60
78
  //#endregion
@@ -95,6 +113,16 @@ declare function rawToContentrain(raw: RawIR, opts?: {
95
113
  }): ContentrainResult;
96
114
  //#endregion
97
115
  //#region src/comments.d.ts
116
+ /**
117
+ * The comments that may leave the source site (see `CommentsExport.comments`). An allowlist, so it
118
+ * fails closed: a comment travels only when its entry is in this RawIR and public, and its status is
119
+ * approved (`'1'`, or none) or pending (`'0'`). Everything else is counted in `excluded`: spam, trash,
120
+ * WordPress's `post-trashed`, a plugin's own status, a post this RawIR does not hold.
121
+ */
122
+ declare function selectComments(raw: RawIR): {
123
+ comments: RawComment[];
124
+ excluded: NonNullable<CommentsExport['excluded']>;
125
+ };
98
126
  declare function buildCommentsExport(raw: RawIR, entries: EntrySourceMap, opts?: {
99
127
  generated_at?: string;
100
128
  }): CommentsExport;
@@ -178,5 +206,5 @@ declare function planSourceDelta(input: PlanSourceDeltaInput): SourceDeltaPlan;
178
206
  /** The plan as text, for a dry run: one line per record, then conflicts, unmapped records, redirects and warnings. */
179
207
  declare function formatSourceDeltaReport(plan: SourceDeltaPlan): string;
180
208
  //#endregion
181
- export { type ContentrainResult, DEFAULT_IMPORTERS, DEFAULT_TAXONOMIES, type DeltaStore, type ImportReport, PLUGIN_META, type PlanSourceDeltaInput, type RestImportOptions, type RestImportResult, SKIP_TYPES, type UnserializeResult, type WxrParseResult, type WxrStats, buildCommentsExport, canon, fetchRestRawIR, formatSourceDeltaReport, hexId, looksSerialized, parseWxr, phpUnserialize, planSourceDelta, rawToContentrain, slugify, strip, summarizeComments, taxModelId, tryUnserialize };
209
+ export { type ContentrainResult, DEFAULT_IMPORTERS, DEFAULT_TAXONOMIES, type DeltaStore, type ImportReport, PLUGIN_META, type PlanSourceDeltaInput, type RestImportOptions, type RestImportResult, SKIP_TYPES, type UnserializeResult, type WxrParseResult, type WxrStats, buildCommentsExport, canon, fetchRestRawIR, formatSourceDeltaReport, hexId, looksSerialized, parseWxr, phpUnserialize, planSourceDelta, rawToContentrain, selectComments, slugify, strip, summarizeComments, taxModelId, tryUnserialize };
182
210
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/wxr.ts","../src/rest.ts","../src/contentrain.ts","../src/comments.ts","../src/php-unserialize.ts","../src/core.ts","../src/delta.ts"],"mappings":";;;;UA2BiB,QAAA;EACf,UAAA;IAAc,QAAA;IAAkB,OAAA;IAAiB,MAAA;IAAgB,IAAA;EAAA;EACjE,UAAA;EACA,gBAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,UAGO,cAAA;EACf,GAAA,EAAK,KAAA;EACL,KAAA,EAAO,QAAA;AAAA;AAAA,iBAiBa,QAAA,CAAS,KAAA,WAAgB,QAAA,EAAU,IAAA;EAAS,IAAA;AAAA,IAAkB,OAAA,CAAQ,cAAA;;;UCtC3E,iBAAA;EACf,MAAA;;EAEA,SAAA,UAAmB,KAAA;EDSI;;;;;;;;ECAvB,IAAA;IAAS,IAAA;IAAc,WAAA;EAAA;EACvB,OAAA;EDGc;AAGhB;;;;ECAE,WAAA;EDCK;;;;ECIL,QAAA;EACA,IAAA;AAAA;AAAA,UAGe,gBAAA;EACf,GAAA,EAAK,KAAA;EACL,QAAA;AAAA;AAAA,iBA6CoB,cAAA,CAAe,OAAA,EAAS,iBAAA,GAAoB,OAAA,CAAQ,gBAAA;;;UC/DzD,YAAA;EACf,cAAA;EACA,aAAA;EACA,cAAA;EACA,WAAA,EAAa,MAAA;EACb,UAAA,EAAY,MAAA;EACZ,aAAA;EACA,iBAAA;EACA,MAAA,EAAQ,MAAA;IAAiB,IAAA;IAAc,MAAA;IAAgB,MAAA;IAAgB,OAAA;EAAA;EFJvE;EEMA,OAAA;EFNc;EEQd,kBAAA;EFLe;;;;;;EEYf,yBAAA;AAAA;AAAA,UAGe,iBAAA;EACf,KAAA,EAAO,MAAA;EACP,gBAAA,EAAkB,cAAA;EAClB,MAAA,EAAQ,YAAA;AAAA;AAAA,iBAoCM,gBAAA,CAAiB,GAAA,EAAK,KAAA,EAAO,IAAA;EAAS,SAAA;AAAA,IAAuB,iBAAA;;;iBChF7D,mBAAA,CAAoB,GAAA,EAAK,KAAA,EAAO,OAAA,EAAS,cAAA,EAAgB,IAAA;EAAS,YAAA;AAAA,IAA0B,cAAA;AHmB5G;AAAA,iBGJgB,iBAAA,CAAkB,GAAA,EAAK,cAAA,GAAiB,eAAA;;;UCnBvC,iBAAA;EACf,EAAA;EACA,UAAA;EACA,KAAA;EACA,KAAA;AAAA;AAAA,iBAGc,eAAA,CAAgB,CAAA,YAAa,CAAA;AAAA,iBAI7B,cAAA,CAAe,GAAA;;iBAyFf,cAAA,CAAe,CAAA,WAAY,iBAAA;;;cC9F9B,KAAA,GAAS,CAAA;;cAST,KAAA,GAAS,CAAA;;cAcT,KAAA,GAAS,CAAA;;;;;;;;;ALCtB;cK8Ba,UAAA,EAAU,MAAA;;cAIV,WAAA,EAAW,MAAA;;cAOX,UAAA,GAAc,CAAA;AAAA,cAGd,OAAA,GAAW,CAAA;;;;UC3DP,UAAA;EACf,KAAA,EAAO,MAAA;EACP,gBAAA,EAAkB,cAAA;AAAA;AAAA,UAGH,oBAAA;ENOD;EMLd,KAAA,EAAO,eAAA;ENEO;EMAd,KAAA,EAAO,UAAA;ENA0C;EMEjD,QAAA,GAAW,UAAA;ENDX;;;;;EMOA,UAAA;ENFe;;;;EMOf,SAAA;AAAA;AAAA,cAGW,kBAAA;AAAA,cACA,iBAAA;;;ANQb;;;;;;;;;;iBM8NgB,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAuB,eAAA;;iBAkC9C,uBAAA,CAAwB,IAAA,EAAM,eAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/wxr.ts","../src/rest.ts","../src/contentrain.ts","../src/comments.ts","../src/php-unserialize.ts","../src/core.ts","../src/delta.ts"],"mappings":";;;;UA2BiB,QAAA;EACf,UAAA;IAAc,QAAA;IAAkB,OAAA;IAAiB,MAAA;IAAgB,IAAA;EAAA;EACjE,UAAA;EACA,gBAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,UAGO,cAAA;EACf,GAAA,EAAK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