@contentful/optimization-api-schemas 0.1.0-alpha
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/LICENSE +21 -0
- package/README.md +127 -0
- package/dist/contentful/AudienceEntry.d.ts +73 -0
- package/dist/contentful/AudienceEntry.d.ts.map +1 -0
- package/dist/contentful/AudienceEntry.js +41 -0
- package/dist/contentful/AudienceEntry.js.map +1 -0
- package/dist/contentful/CtflEntry.d.ts +206 -0
- package/dist/contentful/CtflEntry.d.ts.map +1 -0
- package/dist/contentful/CtflEntry.js +122 -0
- package/dist/contentful/CtflEntry.js.map +1 -0
- package/dist/contentful/MergeTagEntry.d.ts +68 -0
- package/dist/contentful/MergeTagEntry.d.ts.map +1 -0
- package/dist/contentful/MergeTagEntry.js +38 -0
- package/dist/contentful/MergeTagEntry.js.map +1 -0
- package/dist/contentful/PersonalizationConfig.d.ts +437 -0
- package/dist/contentful/PersonalizationConfig.d.ts.map +1 -0
- package/dist/contentful/PersonalizationConfig.js +164 -0
- package/dist/contentful/PersonalizationConfig.js.map +1 -0
- package/dist/contentful/PersonalizationEntry.d.ts +541 -0
- package/dist/contentful/PersonalizationEntry.d.ts.map +1 -0
- package/dist/contentful/PersonalizationEntry.js +95 -0
- package/dist/contentful/PersonalizationEntry.js.map +1 -0
- package/dist/contentful/PersonalizedEntry.d.ts +244 -0
- package/dist/contentful/PersonalizedEntry.d.ts.map +1 -0
- package/dist/contentful/PersonalizedEntry.js +27 -0
- package/dist/contentful/PersonalizedEntry.js.map +1 -0
- package/dist/contentful/index.d.ts +7 -0
- package/dist/contentful/index.d.ts.map +1 -0
- package/dist/contentful/index.js +7 -0
- package/dist/contentful/index.js.map +1 -0
- package/dist/experience/BatchExperienceResponse.d.ts +110 -0
- package/dist/experience/BatchExperienceResponse.d.ts.map +1 -0
- package/dist/experience/BatchExperienceResponse.js +25 -0
- package/dist/experience/BatchExperienceResponse.js.map +1 -0
- package/dist/experience/ExperienceRequest.d.ts +440 -0
- package/dist/experience/ExperienceRequest.d.ts.map +1 -0
- package/dist/experience/ExperienceRequest.js +36 -0
- package/dist/experience/ExperienceRequest.js.map +1 -0
- package/dist/experience/ExperienceResponse.d.ts +173 -0
- package/dist/experience/ExperienceResponse.d.ts.map +1 -0
- package/dist/experience/ExperienceResponse.js +38 -0
- package/dist/experience/ExperienceResponse.js.map +1 -0
- package/dist/experience/ResponseEnvelope.d.ts +35 -0
- package/dist/experience/ResponseEnvelope.d.ts.map +1 -0
- package/dist/experience/ResponseEnvelope.js +31 -0
- package/dist/experience/ResponseEnvelope.js.map +1 -0
- package/dist/experience/change/Change.d.ts +138 -0
- package/dist/experience/change/Change.d.ts.map +1 -0
- package/dist/experience/change/Change.js +102 -0
- package/dist/experience/change/Change.js.map +1 -0
- package/dist/experience/change/index.d.ts +2 -0
- package/dist/experience/change/index.d.ts.map +1 -0
- package/dist/experience/change/index.js +2 -0
- package/dist/experience/change/index.js.map +1 -0
- package/dist/experience/event/AliasEvent.d.ts +73 -0
- package/dist/experience/event/AliasEvent.d.ts.map +1 -0
- package/dist/experience/event/AliasEvent.js +20 -0
- package/dist/experience/event/AliasEvent.js.map +1 -0
- package/dist/experience/event/BatchExperienceEvent.d.ts +820 -0
- package/dist/experience/event/BatchExperienceEvent.d.ts.map +1 -0
- package/dist/experience/event/BatchExperienceEvent.js +37 -0
- package/dist/experience/event/BatchExperienceEvent.js.map +1 -0
- package/dist/experience/event/ComponentViewEvent.d.ts +75 -0
- package/dist/experience/event/ComponentViewEvent.d.ts.map +1 -0
- package/dist/experience/event/ComponentViewEvent.js +43 -0
- package/dist/experience/event/ComponentViewEvent.js.map +1 -0
- package/dist/experience/event/ExperienceEvent.d.ts +810 -0
- package/dist/experience/event/ExperienceEvent.d.ts.map +1 -0
- package/dist/experience/event/ExperienceEvent.js +29 -0
- package/dist/experience/event/ExperienceEvent.js.map +1 -0
- package/dist/experience/event/GroupEvent.d.ts +73 -0
- package/dist/experience/event/GroupEvent.d.ts.map +1 -0
- package/dist/experience/event/GroupEvent.js +20 -0
- package/dist/experience/event/GroupEvent.js.map +1 -0
- package/dist/experience/event/IdentifyEvent.d.ts +71 -0
- package/dist/experience/event/IdentifyEvent.d.ts.map +1 -0
- package/dist/experience/event/IdentifyEvent.js +24 -0
- package/dist/experience/event/IdentifyEvent.js.map +1 -0
- package/dist/experience/event/PageViewEvent.d.ts +128 -0
- package/dist/experience/event/PageViewEvent.d.ts.map +1 -0
- package/dist/experience/event/PageViewEvent.js +44 -0
- package/dist/experience/event/PageViewEvent.js.map +1 -0
- package/dist/experience/event/ScreenViewEvent.d.ts +111 -0
- package/dist/experience/event/ScreenViewEvent.d.ts.map +1 -0
- package/dist/experience/event/ScreenViewEvent.js +43 -0
- package/dist/experience/event/ScreenViewEvent.js.map +1 -0
- package/dist/experience/event/TrackEvent.d.ts +73 -0
- package/dist/experience/event/TrackEvent.d.ts.map +1 -0
- package/dist/experience/event/TrackEvent.js +27 -0
- package/dist/experience/event/TrackEvent.js.map +1 -0
- package/dist/experience/event/UniversalEventProperties.d.ts +175 -0
- package/dist/experience/event/UniversalEventProperties.d.ts.map +1 -0
- package/dist/experience/event/UniversalEventProperties.js +100 -0
- package/dist/experience/event/UniversalEventProperties.js.map +1 -0
- package/dist/experience/event/index.d.ts +12 -0
- package/dist/experience/event/index.d.ts.map +1 -0
- package/dist/experience/event/index.js +12 -0
- package/dist/experience/event/index.js.map +1 -0
- package/dist/experience/event/properties/App.d.ts +25 -0
- package/dist/experience/event/properties/App.d.ts.map +1 -0
- package/dist/experience/event/properties/App.js +21 -0
- package/dist/experience/event/properties/App.js.map +1 -0
- package/dist/experience/event/properties/Campaign.d.ts +34 -0
- package/dist/experience/event/properties/Campaign.d.ts.map +1 -0
- package/dist/experience/event/properties/Campaign.js +30 -0
- package/dist/experience/event/properties/Campaign.js.map +1 -0
- package/dist/experience/event/properties/Channel.d.ts +17 -0
- package/dist/experience/event/properties/Channel.d.ts.map +1 -0
- package/dist/experience/event/properties/Channel.js +13 -0
- package/dist/experience/event/properties/Channel.js.map +1 -0
- package/dist/experience/event/properties/Dictionary.d.ts +13 -0
- package/dist/experience/event/properties/Dictionary.d.ts.map +1 -0
- package/dist/experience/event/properties/Dictionary.js +9 -0
- package/dist/experience/event/properties/Dictionary.js.map +1 -0
- package/dist/experience/event/properties/GeoLocation.d.ts +66 -0
- package/dist/experience/event/properties/GeoLocation.d.ts.map +1 -0
- package/dist/experience/event/properties/GeoLocation.js +76 -0
- package/dist/experience/event/properties/GeoLocation.js.map +1 -0
- package/dist/experience/event/properties/Library.d.ts +22 -0
- package/dist/experience/event/properties/Library.d.ts.map +1 -0
- package/dist/experience/event/properties/Library.js +18 -0
- package/dist/experience/event/properties/Library.js.map +1 -0
- package/dist/experience/event/properties/Page.d.ts +39 -0
- package/dist/experience/event/properties/Page.d.ts.map +1 -0
- package/dist/experience/event/properties/Page.js +36 -0
- package/dist/experience/event/properties/Page.js.map +1 -0
- package/dist/experience/event/properties/Properties.d.ts +13 -0
- package/dist/experience/event/properties/Properties.d.ts.map +1 -0
- package/dist/experience/event/properties/Properties.js +9 -0
- package/dist/experience/event/properties/Properties.js.map +1 -0
- package/dist/experience/event/properties/Screen.d.ts +19 -0
- package/dist/experience/event/properties/Screen.d.ts.map +1 -0
- package/dist/experience/event/properties/Screen.js +15 -0
- package/dist/experience/event/properties/Screen.js.map +1 -0
- package/dist/experience/event/properties/Traits.d.ts +14 -0
- package/dist/experience/event/properties/Traits.d.ts.map +1 -0
- package/dist/experience/event/properties/Traits.js +10 -0
- package/dist/experience/event/properties/Traits.js.map +1 -0
- package/dist/experience/event/properties/index.d.ts +11 -0
- package/dist/experience/event/properties/index.d.ts.map +1 -0
- package/dist/experience/event/properties/index.js +11 -0
- package/dist/experience/event/properties/index.js.map +1 -0
- package/dist/experience/index.d.ts +8 -0
- package/dist/experience/index.d.ts.map +1 -0
- package/dist/experience/index.js +8 -0
- package/dist/experience/index.js.map +1 -0
- package/dist/experience/personalization/SelectedPersonalization.d.ts +86 -0
- package/dist/experience/personalization/SelectedPersonalization.d.ts.map +1 -0
- package/dist/experience/personalization/SelectedPersonalization.js +48 -0
- package/dist/experience/personalization/SelectedPersonalization.js.map +1 -0
- package/dist/experience/personalization/index.d.ts +2 -0
- package/dist/experience/personalization/index.d.ts.map +1 -0
- package/dist/experience/personalization/index.js +2 -0
- package/dist/experience/personalization/index.js.map +1 -0
- package/dist/experience/profile/Profile.d.ts +104 -0
- package/dist/experience/profile/Profile.d.ts.map +1 -0
- package/dist/experience/profile/Profile.js +72 -0
- package/dist/experience/profile/Profile.js.map +1 -0
- package/dist/experience/profile/index.d.ts +3 -0
- package/dist/experience/profile/index.d.ts.map +1 -0
- package/dist/experience/profile/index.js +3 -0
- package/dist/experience/profile/index.js.map +1 -0
- package/dist/experience/profile/properties/SessionStatistics.d.ts +60 -0
- package/dist/experience/profile/properties/SessionStatistics.d.ts.map +1 -0
- package/dist/experience/profile/properties/SessionStatistics.js +50 -0
- package/dist/experience/profile/properties/SessionStatistics.js.map +1 -0
- package/dist/experience/profile/properties/index.d.ts +2 -0
- package/dist/experience/profile/properties/index.d.ts.map +1 -0
- package/dist/experience/profile/properties/index.js +2 -0
- package/dist/experience/profile/properties/index.js.map +1 -0
- package/dist/index.cjs +684 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +425 -0
- package/dist/index.mjs.map +1 -0
- package/dist/insights/event/BatchInsightsEvent.d.ts +173 -0
- package/dist/insights/event/BatchInsightsEvent.d.ts.map +1 -0
- package/dist/insights/event/BatchInsightsEvent.js +32 -0
- package/dist/insights/event/BatchInsightsEvent.js.map +1 -0
- package/dist/insights/event/InsightsEvent.d.ts +145 -0
- package/dist/insights/event/InsightsEvent.d.ts.map +1 -0
- package/dist/insights/event/InsightsEvent.js +16 -0
- package/dist/insights/event/InsightsEvent.js.map +1 -0
- package/dist/insights/event/index.d.ts +3 -0
- package/dist/insights/event/index.d.ts.map +1 -0
- package/dist/insights/event/index.js +3 -0
- package/dist/insights/event/index.js.map +1 -0
- package/dist/insights/index.d.ts +2 -0
- package/dist/insights/index.d.ts.map +1 -0
- package/dist/insights/index.js +2 -0
- package/dist/insights/index.js.map +1 -0
- package/package.json +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2026 Contentful Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://www.contentful.com/developers/docs/personalization/">
|
|
3
|
+
<img alt="Contentful Logo" title="Contentful" src="../../contentful-icon.png" width="150">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Contentful Personalization & Analytics</h1>
|
|
8
|
+
|
|
9
|
+
<h3 align="center">API Schema Library</h3>
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
|
|
13
|
+
[Readme](./README.md) · [Reference](https://contentful.github.io/optimization) ·
|
|
14
|
+
[Contributing](/CONTRIBUTING.md)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
> [!WARNING]
|
|
19
|
+
>
|
|
20
|
+
> The Optimization SDK Suite is currently ALPHA! Breaking changes may be published at any time.
|
|
21
|
+
|
|
22
|
+
The Contentful Optimization API Schema Library is a collection of Zod Mini schemas and their
|
|
23
|
+
inferred TypeScript types. These schemas help provide run-time validation when working with requests
|
|
24
|
+
and responses for the APIs referenced within Optimization SDKs.
|
|
25
|
+
|
|
26
|
+
<details>
|
|
27
|
+
<summary>Table of Contents</summary>
|
|
28
|
+
<!-- mtoc-start -->
|
|
29
|
+
|
|
30
|
+
- [Getting Started](#getting-started)
|
|
31
|
+
- [Contentful CDA Schemas](#contentful-cda-schemas)
|
|
32
|
+
- [Essential Schemas](#essential-schemas)
|
|
33
|
+
- [Essential Functions](#essential-functions)
|
|
34
|
+
- [Experience API Schemas](#experience-api-schemas)
|
|
35
|
+
- [Essential Experience API Request Schemas](#essential-experience-api-request-schemas)
|
|
36
|
+
- [Essential Experience API Response Schemas](#essential-experience-api-response-schemas)
|
|
37
|
+
- [Insights API Schemas](#insights-api-schemas)
|
|
38
|
+
- [Essential Insights API Response Schemas](#essential-insights-api-response-schemas)
|
|
39
|
+
|
|
40
|
+
<!-- mtoc-end -->
|
|
41
|
+
</details>
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
Install using an NPM-compatible package manager, pnpm for example:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pnpm install @contentful/optimization-api-schemas
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Consult [Zod's documentation](https://zod.dev/basics) for more information on working with
|
|
52
|
+
[Zod Mini](https://zod.dev/packages/mini) schemas.
|
|
53
|
+
|
|
54
|
+
## Contentful CDA Schemas
|
|
55
|
+
|
|
56
|
+
These schemas assist in determining whether Contentful content entries provided by the CDA and its
|
|
57
|
+
SDK are valid for personalization. These schemas do not encapsulate all features and functionality
|
|
58
|
+
specified in the CDA SDK's exported TypeScript type system, but strive to remain compatible enough
|
|
59
|
+
for the purposes of personalization.
|
|
60
|
+
|
|
61
|
+
### Essential Schemas
|
|
62
|
+
|
|
63
|
+
- `CtflEntry`: Zod schema describing a generic Contentful entry; the `fields` member is loosely
|
|
64
|
+
typed as any valid JSON
|
|
65
|
+
- `PersonalizedEntry`: Zod schema describing a `CtflEntry` that has associated personalization
|
|
66
|
+
entries
|
|
67
|
+
- `PersonalizationEntry`: Zod schema describing a personalization entry, which is associated with a
|
|
68
|
+
`PersonalizedEntry` via its `fields.nt_experiences` property
|
|
69
|
+
- `PersonalizationConfig`: Zod schema describing the configuration of a `PersonalizationEntry` via
|
|
70
|
+
its `fields.nt_config` property
|
|
71
|
+
|
|
72
|
+
### Essential Functions
|
|
73
|
+
|
|
74
|
+
- `isEntry<S extends SkeletonType, M extends ChainModifiers, L extends string>`: Type guard that
|
|
75
|
+
checks whether the given value is a Contentful Entry, passing through the specified skeleton,
|
|
76
|
+
chain modifiers, and locale
|
|
77
|
+
- `isPersonalizedEntry`: Type guard for `PersonalizedEntry`
|
|
78
|
+
- `isPersonalizationEntry`: Type guard for `PersonalizationEntry`
|
|
79
|
+
|
|
80
|
+
## Experience API Schemas
|
|
81
|
+
|
|
82
|
+
These schemas help validate at run-time that both the request and response data for Experience API
|
|
83
|
+
requests conform to current API specifications.
|
|
84
|
+
|
|
85
|
+
### Essential Experience API Request Schemas
|
|
86
|
+
|
|
87
|
+
- `ExperienceRequestData`: Zod schema describing the data payload for an experience request
|
|
88
|
+
- `ExperienceEvent`: Zod schema union of supported experience/personalization events
|
|
89
|
+
- `BatchExperienceEvent`: Zod schema describing each valid experience/personalization event within a
|
|
90
|
+
batch; Similar to `ExperienceEvent`, but with an additional `anonymousId` member on each event
|
|
91
|
+
schema
|
|
92
|
+
|
|
93
|
+
Experience/personalization event schemas:
|
|
94
|
+
|
|
95
|
+
- `AliasEvent`: Zod schema describing an `alias` event
|
|
96
|
+
- `ComponentViewEvent`: Zod schema describing a `component` view event (may be a Contentful entry or
|
|
97
|
+
a Custom Flag)
|
|
98
|
+
- `IdentifyEvent`: Zod schema describing an `identify` event
|
|
99
|
+
- `PageViewEvent`: Zod schema describing a `page` view event
|
|
100
|
+
- `ScreenViewEvent`: Zod schema describing a `screen` view event
|
|
101
|
+
- `TrackEvent`: Zod schema describing a custom `track` event
|
|
102
|
+
|
|
103
|
+
### Essential Experience API Response Schemas
|
|
104
|
+
|
|
105
|
+
- `ExperienceResponse`: Zod schema describing a full Experience API response; includes a `data`
|
|
106
|
+
object with `changes`, `experiences`, and `profile` properties
|
|
107
|
+
- `BatchExperienceResponse`: Zod schema describing a batch experience response from the Experience
|
|
108
|
+
API; includes a `profiles` collection
|
|
109
|
+
- `Change`: Union of supported change types, which currently only includes `VariableChange`; this
|
|
110
|
+
change type is used for Custom Flags
|
|
111
|
+
- `SelectedPersonalization`: Zod schema describing a selected personalization outcome for a user
|
|
112
|
+
- `Profile`: Zod schema describing a full user profile as received from the Experience API
|
|
113
|
+
|
|
114
|
+
## Insights API Schemas
|
|
115
|
+
|
|
116
|
+
Insights API endpoints currently do not return response data.
|
|
117
|
+
|
|
118
|
+
### Essential Insights API Response Schemas
|
|
119
|
+
|
|
120
|
+
- `InsightsEvent`: Zod schema union of supported insights/analytics events
|
|
121
|
+
- `BatchInsightsEvent`: Zod schema describing a batched Insights event payload; expects a `profile`
|
|
122
|
+
property alongside a collection of `events`
|
|
123
|
+
|
|
124
|
+
Insights/analytics event schemas:
|
|
125
|
+
|
|
126
|
+
- `ComponentViewEvent`: Zod schema describing a `component` view event (may be a Contentful entry or
|
|
127
|
+
a Custom Flag)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema describing the fields of an Audience entry.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Extends the base {@link EntryFields} with audience-specific properties.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AudienceEntryFields: z.ZodMiniObject<{
|
|
9
|
+
nt_audience_id: z.ZodMiniString<string>;
|
|
10
|
+
nt_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
11
|
+
nt_description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
12
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>;
|
|
13
|
+
/**
|
|
14
|
+
* TypeScript type inferred from {@link AudienceEntryFields}.
|
|
15
|
+
*/
|
|
16
|
+
export type AudienceEntryFields = z.infer<typeof AudienceEntryFields>;
|
|
17
|
+
/**
|
|
18
|
+
* Zod schema for a Contentful Audience entry, including system metadata.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Extends the generic {@link CtflEntry} with {@link AudienceEntryFields} as the `fields` payload.
|
|
22
|
+
*/
|
|
23
|
+
export declare const AudienceEntry: z.ZodMiniObject<{
|
|
24
|
+
metadata: z.ZodMiniObject<{
|
|
25
|
+
tags: z.ZodMiniArray<z.ZodMiniObject<{
|
|
26
|
+
sys: z.ZodMiniObject<{
|
|
27
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
28
|
+
linkType: z.ZodMiniLiteral<"Tag">;
|
|
29
|
+
id: z.ZodMiniString<string>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>;
|
|
33
|
+
sys: z.ZodMiniObject<{
|
|
34
|
+
type: z.ZodMiniLiteral<"Entry">;
|
|
35
|
+
contentType: z.ZodMiniObject<{
|
|
36
|
+
sys: z.ZodMiniObject<{
|
|
37
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
38
|
+
linkType: z.ZodMiniLiteral<"ContentType">;
|
|
39
|
+
id: z.ZodMiniString<string>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
publishedVersion: z.ZodMiniNumber<number>;
|
|
43
|
+
id: z.ZodMiniString<string>;
|
|
44
|
+
createdAt: z.ZodMiniAny;
|
|
45
|
+
updatedAt: z.ZodMiniAny;
|
|
46
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
47
|
+
revision: z.ZodMiniNumber<number>;
|
|
48
|
+
space: z.ZodMiniObject<{
|
|
49
|
+
sys: z.ZodMiniObject<{
|
|
50
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
51
|
+
linkType: z.ZodMiniLiteral<"Space">;
|
|
52
|
+
id: z.ZodMiniString<string>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
environment: z.ZodMiniObject<{
|
|
56
|
+
sys: z.ZodMiniObject<{
|
|
57
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
58
|
+
linkType: z.ZodMiniLiteral<"Environment">;
|
|
59
|
+
id: z.ZodMiniString<string>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
fields: z.ZodMiniObject<{
|
|
64
|
+
nt_audience_id: z.ZodMiniString<string>;
|
|
65
|
+
nt_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
66
|
+
nt_description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
67
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
/**
|
|
70
|
+
* TypeScript type inferred from {@link AudienceEntry}.
|
|
71
|
+
*/
|
|
72
|
+
export type AudienceEntry = z.infer<typeof AudienceEntry>;
|
|
73
|
+
//# sourceMappingURL=AudienceEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudienceEntry.d.ts","sourceRoot":"","sources":["../../src/contentful/AudienceEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAG7B;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;yCAwB9B,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAErE;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAExB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
import { CtflEntry, EntryFields } from './CtflEntry';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema describing the fields of an Audience entry.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Extends the base {@link EntryFields} with audience-specific properties.
|
|
8
|
+
*/
|
|
9
|
+
export const AudienceEntryFields = z.extend(EntryFields, {
|
|
10
|
+
/**
|
|
11
|
+
* The internal id of the audience (Short Text).
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This usually corresponds to a stable identifier used by the personalization system.
|
|
15
|
+
*/
|
|
16
|
+
nt_audience_id: z.string(),
|
|
17
|
+
/**
|
|
18
|
+
* The name of the audience (Short Text).
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Optional field used for display purposes in tools and UI.
|
|
22
|
+
*/
|
|
23
|
+
nt_name: z.optional(z.string()),
|
|
24
|
+
/**
|
|
25
|
+
* The description of the audience (Short Text).
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Optional field intended for internal documentation and operator context.
|
|
29
|
+
*/
|
|
30
|
+
nt_description: z.optional(z.string()),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Zod schema for a Contentful Audience entry, including system metadata.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Extends the generic {@link CtflEntry} with {@link AudienceEntryFields} as the `fields` payload.
|
|
37
|
+
*/
|
|
38
|
+
export const AudienceEntry = z.extend(CtflEntry, {
|
|
39
|
+
fields: AudienceEntryFields,
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=AudienceEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudienceEntry.js","sourceRoot":"","sources":["../../src/contentful/AudienceEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE;IACvD;;;;;OAKG;IACH,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAE1B;;;;;OAKG;IACH,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAE/B;;;;;OAKG;IACH,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACvC,CAAC,CAAA;AAOF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE;IAC/C,MAAM,EAAE,mBAAmB;CAC5B,CAAC,CAAA"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { ChainModifiers, Entry, EntrySkeletonType, LocaleCode } from 'contentful';
|
|
2
|
+
import * as z from 'zod/mini';
|
|
3
|
+
/**
|
|
4
|
+
* Base Zod schema for entry fields.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This is modeled as a catch-all map from string keys to JSON-compatible values.
|
|
8
|
+
* The strong typing ot consumer-specified Contentful Entry fields is not
|
|
9
|
+
* validated by these schemas.
|
|
10
|
+
*/
|
|
11
|
+
export declare const EntryFields: z.ZodMiniObject<{}, z.core.$catchall<z.ZodMiniJSONSchema>>;
|
|
12
|
+
/**
|
|
13
|
+
* TypeScript type inferred from {@link EntryFields}.
|
|
14
|
+
*/
|
|
15
|
+
export type EntryFields = z.infer<typeof EntryFields>;
|
|
16
|
+
/**
|
|
17
|
+
* Zod schema representing a generic Contentful Link object.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This is used for references to other Contentful resources where `linkType` is not constrained.
|
|
21
|
+
*/
|
|
22
|
+
export declare const Link: z.ZodMiniObject<{
|
|
23
|
+
sys: z.ZodMiniObject<{
|
|
24
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
25
|
+
linkType: z.ZodMiniString<string>;
|
|
26
|
+
id: z.ZodMiniString<string>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/**
|
|
30
|
+
* TypeScript type inferred from {@link Link}.
|
|
31
|
+
*/
|
|
32
|
+
export type Link = z.infer<typeof Link>;
|
|
33
|
+
/**
|
|
34
|
+
* Zod schema representing a Contentful ContentType link.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ContentTypeLink: z.ZodMiniObject<{
|
|
37
|
+
sys: z.ZodMiniObject<{
|
|
38
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
39
|
+
linkType: z.ZodMiniLiteral<"ContentType">;
|
|
40
|
+
id: z.ZodMiniString<string>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
/**
|
|
44
|
+
* TypeScript type inferred from {@link ContentTypeLink}.
|
|
45
|
+
*/
|
|
46
|
+
export type ContentTypeLink = z.infer<typeof ContentTypeLink>;
|
|
47
|
+
/**
|
|
48
|
+
* Zod schema representing a Contentful Environment link.
|
|
49
|
+
*/
|
|
50
|
+
export declare const EnvironmentLink: z.ZodMiniObject<{
|
|
51
|
+
sys: z.ZodMiniObject<{
|
|
52
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
53
|
+
linkType: z.ZodMiniLiteral<"Environment">;
|
|
54
|
+
id: z.ZodMiniString<string>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
/**
|
|
58
|
+
* TypeScript type inferred from {@link EnvironmentLink}.
|
|
59
|
+
*/
|
|
60
|
+
export type EnvironmentLink = z.infer<typeof EnvironmentLink>;
|
|
61
|
+
/**
|
|
62
|
+
* Zod schema representing a Contentful Space link.
|
|
63
|
+
*/
|
|
64
|
+
export declare const SpaceLink: z.ZodMiniObject<{
|
|
65
|
+
sys: z.ZodMiniObject<{
|
|
66
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
67
|
+
linkType: z.ZodMiniLiteral<"Space">;
|
|
68
|
+
id: z.ZodMiniString<string>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
/**
|
|
72
|
+
* TypeScript type inferred from {@link SpaceLink}.
|
|
73
|
+
*/
|
|
74
|
+
export type SpaceLink = z.infer<typeof SpaceLink>;
|
|
75
|
+
/**
|
|
76
|
+
* Zod schema representing a Contentful Tag link.
|
|
77
|
+
*/
|
|
78
|
+
export declare const TagLink: z.ZodMiniObject<{
|
|
79
|
+
sys: z.ZodMiniObject<{
|
|
80
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
81
|
+
linkType: z.ZodMiniLiteral<"Tag">;
|
|
82
|
+
id: z.ZodMiniString<string>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
/**
|
|
86
|
+
* TypeScript type inferred from {@link TagLink}.
|
|
87
|
+
*/
|
|
88
|
+
export type TagLink = z.infer<typeof TagLink>;
|
|
89
|
+
/**
|
|
90
|
+
* Zod schema describing the `sys` block for a Contentful entry.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* This mirrors the structure of `Entry['sys']` from the Contentful SDK with
|
|
94
|
+
* a subset of fields used by this library.
|
|
95
|
+
*/
|
|
96
|
+
export declare const EntrySys: z.ZodMiniObject<{
|
|
97
|
+
type: z.ZodMiniLiteral<"Entry">;
|
|
98
|
+
contentType: z.ZodMiniObject<{
|
|
99
|
+
sys: z.ZodMiniObject<{
|
|
100
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
101
|
+
linkType: z.ZodMiniLiteral<"ContentType">;
|
|
102
|
+
id: z.ZodMiniString<string>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
publishedVersion: z.ZodMiniNumber<number>;
|
|
106
|
+
id: z.ZodMiniString<string>;
|
|
107
|
+
createdAt: z.ZodMiniAny;
|
|
108
|
+
updatedAt: z.ZodMiniAny;
|
|
109
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
110
|
+
revision: z.ZodMiniNumber<number>;
|
|
111
|
+
space: z.ZodMiniObject<{
|
|
112
|
+
sys: z.ZodMiniObject<{
|
|
113
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
114
|
+
linkType: z.ZodMiniLiteral<"Space">;
|
|
115
|
+
id: z.ZodMiniString<string>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
environment: z.ZodMiniObject<{
|
|
119
|
+
sys: z.ZodMiniObject<{
|
|
120
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
121
|
+
linkType: z.ZodMiniLiteral<"Environment">;
|
|
122
|
+
id: z.ZodMiniString<string>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
/**
|
|
127
|
+
* TypeScript type inferred from {@link EntrySys}.
|
|
128
|
+
*/
|
|
129
|
+
export type EntrySys = z.infer<typeof EntrySys>;
|
|
130
|
+
/**
|
|
131
|
+
* Zod schema describing a generic Contentful entry.
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* This model is intentionally loose: `fields` is any JSON-compliant object and
|
|
135
|
+
* `metadata` is modeled as a catch-all object that must contain an array of
|
|
136
|
+
* {@link TagLink} tags.
|
|
137
|
+
*/
|
|
138
|
+
export declare const CtflEntry: z.ZodMiniObject<{
|
|
139
|
+
/**
|
|
140
|
+
* The entry fields payload.
|
|
141
|
+
*/
|
|
142
|
+
fields: z.ZodMiniObject<{}, z.core.$catchall<z.ZodMiniJSONSchema>>;
|
|
143
|
+
/**
|
|
144
|
+
* Contentful metadata, including tags.
|
|
145
|
+
*/
|
|
146
|
+
metadata: z.ZodMiniObject<{
|
|
147
|
+
tags: z.ZodMiniArray<z.ZodMiniObject<{
|
|
148
|
+
sys: z.ZodMiniObject<{
|
|
149
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
150
|
+
linkType: z.ZodMiniLiteral<"Tag">;
|
|
151
|
+
id: z.ZodMiniString<string>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>;
|
|
155
|
+
/**
|
|
156
|
+
* System-managed properties describing the entry.
|
|
157
|
+
*/
|
|
158
|
+
sys: z.ZodMiniObject<{
|
|
159
|
+
type: z.ZodMiniLiteral<"Entry">;
|
|
160
|
+
contentType: z.ZodMiniObject<{
|
|
161
|
+
sys: z.ZodMiniObject<{
|
|
162
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
163
|
+
linkType: z.ZodMiniLiteral<"ContentType">;
|
|
164
|
+
id: z.ZodMiniString<string>;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
publishedVersion: z.ZodMiniNumber<number>;
|
|
168
|
+
id: z.ZodMiniString<string>;
|
|
169
|
+
createdAt: z.ZodMiniAny;
|
|
170
|
+
updatedAt: z.ZodMiniAny;
|
|
171
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
172
|
+
revision: z.ZodMiniNumber<number>;
|
|
173
|
+
space: z.ZodMiniObject<{
|
|
174
|
+
sys: z.ZodMiniObject<{
|
|
175
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
176
|
+
linkType: z.ZodMiniLiteral<"Space">;
|
|
177
|
+
id: z.ZodMiniString<string>;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
}, z.core.$strip>;
|
|
180
|
+
environment: z.ZodMiniObject<{
|
|
181
|
+
sys: z.ZodMiniObject<{
|
|
182
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
183
|
+
linkType: z.ZodMiniLiteral<"Environment">;
|
|
184
|
+
id: z.ZodMiniString<string>;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
/**
|
|
190
|
+
* TypeScript type inferred from {@link CtflEntry}.
|
|
191
|
+
*/
|
|
192
|
+
export type CtflEntry = z.infer<typeof CtflEntry>;
|
|
193
|
+
/**
|
|
194
|
+
* Type guard that checks whether the given value is a Contentful {@link Entry},
|
|
195
|
+
* passing through the specified skeleton, chain modifiers, and locale.
|
|
196
|
+
*
|
|
197
|
+
* @typeParam S - The entry skeleton type.
|
|
198
|
+
* @typeParam M - The chain modifiers type. Defaults to {@link ChainModifiers}.
|
|
199
|
+
* @typeParam L - The locale code type. Defaults to {@link LocaleCode}.
|
|
200
|
+
*
|
|
201
|
+
* @param entry - The value to test.
|
|
202
|
+
* @returns `true` if the object conforms to {@link CtflEntry} and can be treated
|
|
203
|
+
* as a typed {@link Entry}, otherwise `false`.
|
|
204
|
+
*/
|
|
205
|
+
export declare function isEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry | undefined): entry is Entry<S, M, L>;
|
|
206
|
+
//# sourceMappingURL=CtflEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CtflEntry.d.ts","sourceRoot":"","sources":["../../src/contentful/CtflEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACtF,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,4DAAqC,CAAA;AAE7D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,IAAI;;;;;;iBAMf,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;iBAM1B,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;iBAM1B,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;iBAMpB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;iBAMlB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAWnB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;IACpB;;OAEG;;IAGH;;OAEG;;;;;;;;;;IAQH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEH,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAEjD;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CACrB,CAAC,SAAS,iBAAiB,EAC3B,CAAC,SAAS,cAAc,GAAG,cAAc,EACzC,CAAC,SAAS,UAAU,GAAG,UAAU,EACjC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAEnD"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
/**
|
|
3
|
+
* Base Zod schema for entry fields.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This is modeled as a catch-all map from string keys to JSON-compatible values.
|
|
7
|
+
* The strong typing ot consumer-specified Contentful Entry fields is not
|
|
8
|
+
* validated by these schemas.
|
|
9
|
+
*/
|
|
10
|
+
export const EntryFields = z.catchall(z.object({}), z.json());
|
|
11
|
+
/**
|
|
12
|
+
* Zod schema representing a generic Contentful Link object.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This is used for references to other Contentful resources where `linkType` is not constrained.
|
|
16
|
+
*/
|
|
17
|
+
export const Link = z.object({
|
|
18
|
+
sys: z.object({
|
|
19
|
+
type: z.literal('Link'),
|
|
20
|
+
linkType: z.string(),
|
|
21
|
+
id: z.string(),
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Zod schema representing a Contentful ContentType link.
|
|
26
|
+
*/
|
|
27
|
+
export const ContentTypeLink = z.object({
|
|
28
|
+
sys: z.object({
|
|
29
|
+
type: z.literal('Link'),
|
|
30
|
+
linkType: z.literal('ContentType'),
|
|
31
|
+
id: z.string(),
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Zod schema representing a Contentful Environment link.
|
|
36
|
+
*/
|
|
37
|
+
export const EnvironmentLink = z.object({
|
|
38
|
+
sys: z.object({
|
|
39
|
+
type: z.literal('Link'),
|
|
40
|
+
linkType: z.literal('Environment'),
|
|
41
|
+
id: z.string(),
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Zod schema representing a Contentful Space link.
|
|
46
|
+
*/
|
|
47
|
+
export const SpaceLink = z.object({
|
|
48
|
+
sys: z.object({
|
|
49
|
+
type: z.literal('Link'),
|
|
50
|
+
linkType: z.literal('Space'),
|
|
51
|
+
id: z.string(),
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Zod schema representing a Contentful Tag link.
|
|
56
|
+
*/
|
|
57
|
+
export const TagLink = z.object({
|
|
58
|
+
sys: z.object({
|
|
59
|
+
type: z.literal('Link'),
|
|
60
|
+
linkType: z.literal('Tag'),
|
|
61
|
+
id: z.string(),
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Zod schema describing the `sys` block for a Contentful entry.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* This mirrors the structure of `Entry['sys']` from the Contentful SDK with
|
|
69
|
+
* a subset of fields used by this library.
|
|
70
|
+
*/
|
|
71
|
+
export const EntrySys = z.object({
|
|
72
|
+
type: z.literal('Entry'),
|
|
73
|
+
contentType: ContentTypeLink,
|
|
74
|
+
publishedVersion: z.number(),
|
|
75
|
+
id: z.string(),
|
|
76
|
+
createdAt: z.any(),
|
|
77
|
+
updatedAt: z.any(),
|
|
78
|
+
locale: z.optional(z.string()),
|
|
79
|
+
revision: z.number(),
|
|
80
|
+
space: SpaceLink,
|
|
81
|
+
environment: EnvironmentLink,
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Zod schema describing a generic Contentful entry.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* This model is intentionally loose: `fields` is any JSON-compliant object and
|
|
88
|
+
* `metadata` is modeled as a catch-all object that must contain an array of
|
|
89
|
+
* {@link TagLink} tags.
|
|
90
|
+
*/
|
|
91
|
+
export const CtflEntry = z.object({
|
|
92
|
+
/**
|
|
93
|
+
* The entry fields payload.
|
|
94
|
+
*/
|
|
95
|
+
fields: EntryFields,
|
|
96
|
+
/**
|
|
97
|
+
* Contentful metadata, including tags.
|
|
98
|
+
*/
|
|
99
|
+
metadata: z.catchall(z.object({
|
|
100
|
+
tags: z.array(TagLink),
|
|
101
|
+
}), z.json()),
|
|
102
|
+
/**
|
|
103
|
+
* System-managed properties describing the entry.
|
|
104
|
+
*/
|
|
105
|
+
sys: EntrySys,
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Type guard that checks whether the given value is a Contentful {@link Entry},
|
|
109
|
+
* passing through the specified skeleton, chain modifiers, and locale.
|
|
110
|
+
*
|
|
111
|
+
* @typeParam S - The entry skeleton type.
|
|
112
|
+
* @typeParam M - The chain modifiers type. Defaults to {@link ChainModifiers}.
|
|
113
|
+
* @typeParam L - The locale code type. Defaults to {@link LocaleCode}.
|
|
114
|
+
*
|
|
115
|
+
* @param entry - The value to test.
|
|
116
|
+
* @returns `true` if the object conforms to {@link CtflEntry} and can be treated
|
|
117
|
+
* as a typed {@link Entry}, otherwise `false`.
|
|
118
|
+
*/
|
|
119
|
+
export function isEntry(entry) {
|
|
120
|
+
return CtflEntry.safeParse(entry).success;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=CtflEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CtflEntry.js","sourceRoot":"","sources":["../../src/contentful/CtflEntry.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for a Merge Tag Contentful entry.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Extends {@link CtflEntry} with merge-tag-specific fields and constrains the
|
|
7
|
+
* `contentType` to the `nt_mergetag` content type.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MergeTagEntry: z.ZodMiniObject<{
|
|
10
|
+
metadata: z.ZodMiniObject<{
|
|
11
|
+
tags: z.ZodMiniArray<z.ZodMiniObject<{
|
|
12
|
+
sys: z.ZodMiniObject<{
|
|
13
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
14
|
+
linkType: z.ZodMiniLiteral<"Tag">;
|
|
15
|
+
id: z.ZodMiniString<string>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>;
|
|
19
|
+
fields: z.ZodMiniObject<{
|
|
20
|
+
/**
|
|
21
|
+
* Human-readable name of the merge tag.
|
|
22
|
+
*/
|
|
23
|
+
nt_name: z.ZodMiniString<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Fallback value to use when the merge tag cannot be resolved.
|
|
26
|
+
*/
|
|
27
|
+
nt_fallback: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
28
|
+
/**
|
|
29
|
+
* Internal identifier of the merge tag.
|
|
30
|
+
*/
|
|
31
|
+
nt_mergetag_id: z.ZodMiniString<string>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
sys: z.ZodMiniObject<{
|
|
34
|
+
type: z.ZodMiniLiteral<"Entry">;
|
|
35
|
+
publishedVersion: z.ZodMiniNumber<number>;
|
|
36
|
+
id: z.ZodMiniString<string>;
|
|
37
|
+
createdAt: z.ZodMiniAny;
|
|
38
|
+
updatedAt: z.ZodMiniAny;
|
|
39
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
40
|
+
revision: z.ZodMiniNumber<number>;
|
|
41
|
+
space: z.ZodMiniObject<{
|
|
42
|
+
sys: z.ZodMiniObject<{
|
|
43
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
44
|
+
linkType: z.ZodMiniLiteral<"Space">;
|
|
45
|
+
id: z.ZodMiniString<string>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
environment: z.ZodMiniObject<{
|
|
49
|
+
sys: z.ZodMiniObject<{
|
|
50
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
51
|
+
linkType: z.ZodMiniLiteral<"Environment">;
|
|
52
|
+
id: z.ZodMiniString<string>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
contentType: z.ZodMiniObject<{
|
|
56
|
+
sys: z.ZodMiniObject<{
|
|
57
|
+
type: z.ZodMiniLiteral<"Link">;
|
|
58
|
+
linkType: z.ZodMiniLiteral<"ContentType">;
|
|
59
|
+
id: z.ZodMiniLiteral<"nt_mergetag">;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
/**
|
|
65
|
+
* TypeScript type inferred from {@link MergeTagEntry}.
|
|
66
|
+
*/
|
|
67
|
+
export type MergeTagEntry = z.infer<typeof MergeTagEntry>;
|
|
68
|
+
//# sourceMappingURL=MergeTagEntry.d.ts.map
|