@se-studio/core-data-types 1.1.2 → 1.2.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/CHANGELOG.md +29 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/redirect.d.ts +44 -0
- package/dist/types/redirect.d.ts.map +1 -0
- package/dist/types/redirect.js +4 -0
- package/dist/types/redirect.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @se-studio/core-data-types
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 31b2200: Add first-class support for managing redirects from Contentful.
|
|
8
|
+
|
|
9
|
+
Editors can now create `redirect` entries (via new content type) using reference pickers for existing Pages/Articles/etc. (for "from" and "to") or raw paths/URLs, plus a status code dropdown (301/302/etc.), active flag, and notes. This makes redirects easy for non-technical users without requiring them to know or type exact slugs.
|
|
10
|
+
|
|
11
|
+
Redirects use the simple rebuild pattern (already proven by A/B tests):
|
|
12
|
+
|
|
13
|
+
- Publish in Contentful → webhook triggers a Vercel Deploy Hook.
|
|
14
|
+
- Build fetches current published redirects (via `getRedirectsWithErrors` / `getRedirectMap` on the helpers from `createAppHelpers`) and bakes a static map (using the new pure `buildRedirectMap`).
|
|
15
|
+
- Middleware performs exact (or lightly normalized) lookups against the baked data with zero runtime cost or external calls.
|
|
16
|
+
|
|
17
|
+
Key additions:
|
|
18
|
+
|
|
19
|
+
- `IRedirect` type + `isRedirect` guard.
|
|
20
|
+
- `BaseRedirectSkeleton`, `baseRedirectConverter` (resolves reference links to concrete `fromPath`/`to` using existing `resolveLink` + project `urlCalculators`).
|
|
21
|
+
- `contentfulRedirectsRest`, revalidation `RedirectTag`, and `buildRedirectMap` / `RedirectMap` types (exported from `@se-studio/contentful-rest-api`).
|
|
22
|
+
- `getRedirectsWithErrors` and `getRedirectMap` (convenience) exposed additively via `createAppHelpers` (like banners).
|
|
23
|
+
- Two Contentful migration scripts: `18-create-redirect-content-type.js` (full CT with rich help text for the picker UX) and `19-remove-redirectTo-fields.js` (cleans up legacy per-page `redirectTo` fields on page/pageVariant).
|
|
24
|
+
- New `@se-studio/skills` entry `se-marketing-sites-redirects` (the canonical guide, including CT spec, migration instructions, generate script example, static middleware example + A/B composition, deploy hook webhook setup, testing, and preview notes).
|
|
25
|
+
- Minimal demo in `example-empty` (middleware + `/api/redirects` route exercising the new helpers at runtime for easy local verification; production apps follow the baked recipe in the skill).
|
|
26
|
+
- Light updates to CLAUDE.md, vercel-setup skill, CONTENT_MODEL.md, and related docs.
|
|
27
|
+
|
|
28
|
+
The model and helpers are forward-compatible if a faster (e.g. Edge Config) path is added later. Legacy `redirectTo` fields are left untouched for now (removal is optional via the migration).
|
|
29
|
+
|
|
30
|
+
This is a new feature (minor bumps).
|
|
31
|
+
|
|
3
32
|
## 1.1.2
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export type { IBaseCustomType } from './types/customType';
|
|
|
38
38
|
export { isCustomType } from './types/customType';
|
|
39
39
|
export type { IBasePage } from './types/page';
|
|
40
40
|
export { isPage } from './types/page';
|
|
41
|
+
export type { IRedirect, RedirectStatusCode } from './types/redirect';
|
|
42
|
+
export { isRedirect } from './types/redirect';
|
|
41
43
|
export type { ISchema } from './types/schema';
|
|
42
44
|
export type { IBaseTag, IBaseTags, IBaseTagType } from './types/tag';
|
|
43
45
|
export { isTag, isTags, } from './types/tag';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,YAAY,EAA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,EACN,aAAa,EACb,WAAW,EACX,OAAO,EACP,aAAa,EACb,YAAY,EACZ,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,WAAW,EACX,OAAO,EACP,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,+BAA+B,GAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export { isArticleLink, isArticleTypeLink, isBlankLink, isCollection, isComponen
|
|
|
34
34
|
export { isCustomType } from './types/customType';
|
|
35
35
|
// Export type guard functions
|
|
36
36
|
export { isPage } from './types/page';
|
|
37
|
+
export { isRedirect } from './types/redirect';
|
|
37
38
|
export { isTag, isTags, } from './types/tag';
|
|
38
39
|
export { getVisualHorizontalPosition, getVisualWidthPercent, isAnimation, isExternalVideo, isFullVideo, isImage, isLocalVideo, isPicture, isResponsiveVisual, isSvgData, isSvgImage, isVideo, isVisual, isVisualAnimation, isVisualImage, isVisualVideo, processSizes, } from './types/visual';
|
|
39
40
|
export { formatArticleAuthorNames, getArticleAuthors, getPrimaryArticleAuthor, normalizeResolvedArticleAuthors, } from './utils/articleAuthors';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,+BAA+B,GAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IInternalLink, ITyped } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* Status codes supported for redirects.
|
|
4
|
+
*/
|
|
5
|
+
export type RedirectStatusCode = 301 | 302 | 307 | 308;
|
|
6
|
+
/**
|
|
7
|
+
* Base interface for Redirect entries managed in Contentful.
|
|
8
|
+
*
|
|
9
|
+
* "From" and "to" are always the final concrete path/URL strings (resolved
|
|
10
|
+
* from references at fetch time if the editor used a picker). Optional
|
|
11
|
+
* provenance links are included so future admin UIs or reports can show
|
|
12
|
+
* what the editor originally selected.
|
|
13
|
+
*
|
|
14
|
+
* This type is intentionally small for the common case (middleware map
|
|
15
|
+
* only needs fromPath + to + status).
|
|
16
|
+
*/
|
|
17
|
+
export interface IRedirect extends ITyped {
|
|
18
|
+
type: 'Redirect';
|
|
19
|
+
id: string;
|
|
20
|
+
/** The effective source path (always starts with /, normalized with trailing slash where appropriate). */
|
|
21
|
+
fromPath: string;
|
|
22
|
+
/** The effective target (path or full external URL). */
|
|
23
|
+
to: string;
|
|
24
|
+
/** HTTP status for the redirect. Defaults to 301 in the map builder if omitted. */
|
|
25
|
+
statusCode?: RedirectStatusCode | null;
|
|
26
|
+
/** Whether this redirect is active (map builders should filter inactive ones). */
|
|
27
|
+
active?: boolean | null;
|
|
28
|
+
/** Optional internal note for editors (not used at runtime). */
|
|
29
|
+
note?: string | null;
|
|
30
|
+
fromPage?: IInternalLink;
|
|
31
|
+
fromArticle?: IInternalLink;
|
|
32
|
+
fromArticleType?: IInternalLink;
|
|
33
|
+
fromPerson?: IInternalLink;
|
|
34
|
+
fromTag?: IInternalLink;
|
|
35
|
+
fromCustomType?: IInternalLink;
|
|
36
|
+
toPage?: IInternalLink;
|
|
37
|
+
toArticle?: IInternalLink;
|
|
38
|
+
toArticleType?: IInternalLink;
|
|
39
|
+
toPerson?: IInternalLink;
|
|
40
|
+
toTag?: IInternalLink;
|
|
41
|
+
toCustomType?: IInternalLink;
|
|
42
|
+
}
|
|
43
|
+
export declare function isRedirect(content: ITyped): content is IRedirect;
|
|
44
|
+
//# sourceMappingURL=redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../src/types/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAU,SAAQ,MAAM;IACvC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IAEX,0GAA0G;IAC1G,QAAQ,EAAE,MAAM,CAAC;IAEjB,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAC;IAEX,mFAAmF;IACnF,UAAU,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEvC,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAExB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,U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