@schemasentry/core 0.3.0 → 0.3.2
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 +50 -0
- package/dist/index.cjs +10 -0
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +8 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @schemasentry/core
|
|
2
|
+
|
|
3
|
+
Type-safe schema builders and validation primitives for Schema Sentry.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @schemasentry/core
|
|
9
|
+
npm install @schemasentry/core
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Type-safe builders** for 13+ schema types
|
|
15
|
+
- **Deterministic JSON-LD** output
|
|
16
|
+
- **Validation engine** with required/recommended field checks
|
|
17
|
+
- **Zero runtime dependencies**
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { Article, Organization, validateSchema } from "@schemasentry/core";
|
|
23
|
+
|
|
24
|
+
const article = Article({
|
|
25
|
+
headline: "My Article",
|
|
26
|
+
authorName: "John Doe",
|
|
27
|
+
datePublished: "2026-02-11",
|
|
28
|
+
url: "https://example.com/blog/my-article"
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const result = validateSchema([article]);
|
|
32
|
+
if (!result.ok) {
|
|
33
|
+
console.log(result.issues);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Supported Schema Types
|
|
38
|
+
|
|
39
|
+
- Organization, Person, Place, LocalBusiness
|
|
40
|
+
- WebSite, WebPage
|
|
41
|
+
- Article, BlogPosting
|
|
42
|
+
- Product
|
|
43
|
+
- FAQPage, HowTo
|
|
44
|
+
- BreadcrumbList
|
|
45
|
+
- Event, Review
|
|
46
|
+
- VideoObject, ImageObject
|
|
47
|
+
|
|
48
|
+
## Documentation
|
|
49
|
+
|
|
50
|
+
See [Schema Sentry Docs](https://github.com/arindamdawn/schema-sentry#readme)
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
Event: () => Event,
|
|
27
27
|
FAQPage: () => FAQPage,
|
|
28
28
|
HowTo: () => HowTo,
|
|
29
|
+
ImageObject: () => ImageObject,
|
|
29
30
|
LocalBusiness: () => LocalBusiness,
|
|
30
31
|
Location: () => Location,
|
|
31
32
|
Organization: () => Organization,
|
|
@@ -33,6 +34,7 @@ __export(index_exports, {
|
|
|
33
34
|
Product: () => Product,
|
|
34
35
|
Review: () => Review,
|
|
35
36
|
SCHEMA_CONTEXT: () => SCHEMA_CONTEXT,
|
|
37
|
+
VideoObject: () => VideoObject,
|
|
36
38
|
WebPage: () => WebPage,
|
|
37
39
|
WebSite: () => WebSite,
|
|
38
40
|
stableStringify: () => stableStringify,
|
|
@@ -91,6 +93,8 @@ var Product = (input) => {
|
|
|
91
93
|
} : {}
|
|
92
94
|
});
|
|
93
95
|
};
|
|
96
|
+
var ImageObject = (input) => withBase("ImageObject", input);
|
|
97
|
+
var VideoObject = (input) => withBase("VideoObject", input);
|
|
94
98
|
var Event = (input) => {
|
|
95
99
|
const {
|
|
96
100
|
locationName,
|
|
@@ -300,6 +304,8 @@ var REQUIRED_FIELDS = {
|
|
|
300
304
|
Article: ["headline", "author", "datePublished", "url"],
|
|
301
305
|
BlogPosting: ["headline", "author", "datePublished", "url"],
|
|
302
306
|
Product: ["name", "description", "url"],
|
|
307
|
+
VideoObject: ["name", "description", "thumbnailUrl", "uploadDate"],
|
|
308
|
+
ImageObject: ["contentUrl"],
|
|
303
309
|
Event: ["name", "startDate"],
|
|
304
310
|
Review: ["itemReviewed", "reviewRating", "author"],
|
|
305
311
|
FAQPage: ["mainEntity"],
|
|
@@ -316,6 +322,8 @@ var RECOMMENDED_FIELDS = {
|
|
|
316
322
|
Article: ["description", "image", "dateModified"],
|
|
317
323
|
BlogPosting: ["description", "image", "dateModified"],
|
|
318
324
|
Product: ["image", "brand", "sku"],
|
|
325
|
+
VideoObject: ["contentUrl", "embedUrl", "duration", "url"],
|
|
326
|
+
ImageObject: ["caption", "width", "height", "url"],
|
|
319
327
|
Event: ["description", "location", "organizer", "url"],
|
|
320
328
|
Review: ["reviewBody", "datePublished", "url"],
|
|
321
329
|
FAQPage: [],
|
|
@@ -438,6 +446,7 @@ var stableStringify = (value) => JSON.stringify(sortKeys(value));
|
|
|
438
446
|
Event,
|
|
439
447
|
FAQPage,
|
|
440
448
|
HowTo,
|
|
449
|
+
ImageObject,
|
|
441
450
|
LocalBusiness,
|
|
442
451
|
Location,
|
|
443
452
|
Organization,
|
|
@@ -445,6 +454,7 @@ var stableStringify = (value) => JSON.stringify(sortKeys(value));
|
|
|
445
454
|
Product,
|
|
446
455
|
Review,
|
|
447
456
|
SCHEMA_CONTEXT,
|
|
457
|
+
VideoObject,
|
|
448
458
|
WebPage,
|
|
449
459
|
WebSite,
|
|
450
460
|
stableStringify,
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ type JsonLdValue = string | number | boolean | null | JsonLdObject | JsonLdValue
|
|
|
3
3
|
type JsonLdObject = {
|
|
4
4
|
[key: string]: JsonLdValue;
|
|
5
5
|
};
|
|
6
|
-
type SchemaTypeName = "Organization" | "Person" | "Place" | "LocalBusiness" | "WebSite" | "WebPage" | "Article" | "BlogPosting" | "Product" | "Event" | "Review" | "FAQPage" | "HowTo" | "BreadcrumbList";
|
|
6
|
+
type SchemaTypeName = "Organization" | "Person" | "Place" | "LocalBusiness" | "WebSite" | "WebPage" | "Article" | "BlogPosting" | "Product" | "VideoObject" | "ImageObject" | "Event" | "Review" | "FAQPage" | "HowTo" | "BreadcrumbList";
|
|
7
7
|
type SchemaNode = JsonLdObject & {
|
|
8
8
|
"@context": typeof SCHEMA_CONTEXT;
|
|
9
9
|
"@type": SchemaTypeName;
|
|
@@ -78,6 +78,25 @@ type ProductInput = BaseInput & {
|
|
|
78
78
|
sku?: string;
|
|
79
79
|
};
|
|
80
80
|
declare const Product: (input: ProductInput) => SchemaNode;
|
|
81
|
+
type ImageObjectInput = BaseInput & {
|
|
82
|
+
contentUrl: string;
|
|
83
|
+
caption?: string;
|
|
84
|
+
width?: number;
|
|
85
|
+
height?: number;
|
|
86
|
+
url?: string;
|
|
87
|
+
};
|
|
88
|
+
declare const ImageObject: (input: ImageObjectInput) => SchemaNode;
|
|
89
|
+
type VideoObjectInput = BaseInput & {
|
|
90
|
+
name: string;
|
|
91
|
+
description: string;
|
|
92
|
+
thumbnailUrl: string;
|
|
93
|
+
uploadDate: string;
|
|
94
|
+
contentUrl?: string;
|
|
95
|
+
embedUrl?: string;
|
|
96
|
+
duration?: string;
|
|
97
|
+
url?: string;
|
|
98
|
+
};
|
|
99
|
+
declare const VideoObject: (input: VideoObjectInput) => SchemaNode;
|
|
81
100
|
type EventInput = BaseInput & {
|
|
82
101
|
name: string;
|
|
83
102
|
startDate: string;
|
|
@@ -148,4 +167,4 @@ type ValidationResult = {
|
|
|
148
167
|
declare const validateSchema: (nodes: SchemaNode[], options?: ValidationOptions) => ValidationResult;
|
|
149
168
|
declare const stableStringify: (value: JsonLdValue) => string;
|
|
150
169
|
|
|
151
|
-
export { Article, type ArticleInput, BlogPosting, type BlogPostingInput, type BreadcrumbItem, BreadcrumbList, type BreadcrumbListInput, Event, type EventInput, type FAQItem, FAQPage, type FAQPageInput, HowTo, type HowToInput, type HowToStep, type JsonLdObject, type JsonLdValue, LocalBusiness, type LocalBusinessInput, Location, type LocationInput, type Manifest, Organization, type OrganizationInput, Person, type PersonInput, Product, type ProductInput, Review, type ReviewInput, SCHEMA_CONTEXT, type SchemaNode, type SchemaTypeName, type ValidationIssue, type ValidationOptions, type ValidationResult, type ValidationSeverity, WebPage, type WebPageInput, WebSite, type WebSiteInput, stableStringify, validateSchema };
|
|
170
|
+
export { Article, type ArticleInput, BlogPosting, type BlogPostingInput, type BreadcrumbItem, BreadcrumbList, type BreadcrumbListInput, Event, type EventInput, type FAQItem, FAQPage, type FAQPageInput, HowTo, type HowToInput, type HowToStep, ImageObject, type ImageObjectInput, type JsonLdObject, type JsonLdValue, LocalBusiness, type LocalBusinessInput, Location, type LocationInput, type Manifest, Organization, type OrganizationInput, Person, type PersonInput, Product, type ProductInput, Review, type ReviewInput, SCHEMA_CONTEXT, type SchemaNode, type SchemaTypeName, type ValidationIssue, type ValidationOptions, type ValidationResult, type ValidationSeverity, VideoObject, type VideoObjectInput, WebPage, type WebPageInput, WebSite, type WebSiteInput, stableStringify, validateSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type JsonLdValue = string | number | boolean | null | JsonLdObject | JsonLdValue
|
|
|
3
3
|
type JsonLdObject = {
|
|
4
4
|
[key: string]: JsonLdValue;
|
|
5
5
|
};
|
|
6
|
-
type SchemaTypeName = "Organization" | "Person" | "Place" | "LocalBusiness" | "WebSite" | "WebPage" | "Article" | "BlogPosting" | "Product" | "Event" | "Review" | "FAQPage" | "HowTo" | "BreadcrumbList";
|
|
6
|
+
type SchemaTypeName = "Organization" | "Person" | "Place" | "LocalBusiness" | "WebSite" | "WebPage" | "Article" | "BlogPosting" | "Product" | "VideoObject" | "ImageObject" | "Event" | "Review" | "FAQPage" | "HowTo" | "BreadcrumbList";
|
|
7
7
|
type SchemaNode = JsonLdObject & {
|
|
8
8
|
"@context": typeof SCHEMA_CONTEXT;
|
|
9
9
|
"@type": SchemaTypeName;
|
|
@@ -78,6 +78,25 @@ type ProductInput = BaseInput & {
|
|
|
78
78
|
sku?: string;
|
|
79
79
|
};
|
|
80
80
|
declare const Product: (input: ProductInput) => SchemaNode;
|
|
81
|
+
type ImageObjectInput = BaseInput & {
|
|
82
|
+
contentUrl: string;
|
|
83
|
+
caption?: string;
|
|
84
|
+
width?: number;
|
|
85
|
+
height?: number;
|
|
86
|
+
url?: string;
|
|
87
|
+
};
|
|
88
|
+
declare const ImageObject: (input: ImageObjectInput) => SchemaNode;
|
|
89
|
+
type VideoObjectInput = BaseInput & {
|
|
90
|
+
name: string;
|
|
91
|
+
description: string;
|
|
92
|
+
thumbnailUrl: string;
|
|
93
|
+
uploadDate: string;
|
|
94
|
+
contentUrl?: string;
|
|
95
|
+
embedUrl?: string;
|
|
96
|
+
duration?: string;
|
|
97
|
+
url?: string;
|
|
98
|
+
};
|
|
99
|
+
declare const VideoObject: (input: VideoObjectInput) => SchemaNode;
|
|
81
100
|
type EventInput = BaseInput & {
|
|
82
101
|
name: string;
|
|
83
102
|
startDate: string;
|
|
@@ -148,4 +167,4 @@ type ValidationResult = {
|
|
|
148
167
|
declare const validateSchema: (nodes: SchemaNode[], options?: ValidationOptions) => ValidationResult;
|
|
149
168
|
declare const stableStringify: (value: JsonLdValue) => string;
|
|
150
169
|
|
|
151
|
-
export { Article, type ArticleInput, BlogPosting, type BlogPostingInput, type BreadcrumbItem, BreadcrumbList, type BreadcrumbListInput, Event, type EventInput, type FAQItem, FAQPage, type FAQPageInput, HowTo, type HowToInput, type HowToStep, type JsonLdObject, type JsonLdValue, LocalBusiness, type LocalBusinessInput, Location, type LocationInput, type Manifest, Organization, type OrganizationInput, Person, type PersonInput, Product, type ProductInput, Review, type ReviewInput, SCHEMA_CONTEXT, type SchemaNode, type SchemaTypeName, type ValidationIssue, type ValidationOptions, type ValidationResult, type ValidationSeverity, WebPage, type WebPageInput, WebSite, type WebSiteInput, stableStringify, validateSchema };
|
|
170
|
+
export { Article, type ArticleInput, BlogPosting, type BlogPostingInput, type BreadcrumbItem, BreadcrumbList, type BreadcrumbListInput, Event, type EventInput, type FAQItem, FAQPage, type FAQPageInput, HowTo, type HowToInput, type HowToStep, ImageObject, type ImageObjectInput, type JsonLdObject, type JsonLdValue, LocalBusiness, type LocalBusinessInput, Location, type LocationInput, type Manifest, Organization, type OrganizationInput, Person, type PersonInput, Product, type ProductInput, Review, type ReviewInput, SCHEMA_CONTEXT, type SchemaNode, type SchemaTypeName, type ValidationIssue, type ValidationOptions, type ValidationResult, type ValidationSeverity, VideoObject, type VideoObjectInput, WebPage, type WebPageInput, WebSite, type WebSiteInput, stableStringify, validateSchema };
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,8 @@ var Product = (input) => {
|
|
|
51
51
|
} : {}
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
|
+
var ImageObject = (input) => withBase("ImageObject", input);
|
|
55
|
+
var VideoObject = (input) => withBase("VideoObject", input);
|
|
54
56
|
var Event = (input) => {
|
|
55
57
|
const {
|
|
56
58
|
locationName,
|
|
@@ -260,6 +262,8 @@ var REQUIRED_FIELDS = {
|
|
|
260
262
|
Article: ["headline", "author", "datePublished", "url"],
|
|
261
263
|
BlogPosting: ["headline", "author", "datePublished", "url"],
|
|
262
264
|
Product: ["name", "description", "url"],
|
|
265
|
+
VideoObject: ["name", "description", "thumbnailUrl", "uploadDate"],
|
|
266
|
+
ImageObject: ["contentUrl"],
|
|
263
267
|
Event: ["name", "startDate"],
|
|
264
268
|
Review: ["itemReviewed", "reviewRating", "author"],
|
|
265
269
|
FAQPage: ["mainEntity"],
|
|
@@ -276,6 +280,8 @@ var RECOMMENDED_FIELDS = {
|
|
|
276
280
|
Article: ["description", "image", "dateModified"],
|
|
277
281
|
BlogPosting: ["description", "image", "dateModified"],
|
|
278
282
|
Product: ["image", "brand", "sku"],
|
|
283
|
+
VideoObject: ["contentUrl", "embedUrl", "duration", "url"],
|
|
284
|
+
ImageObject: ["caption", "width", "height", "url"],
|
|
279
285
|
Event: ["description", "location", "organizer", "url"],
|
|
280
286
|
Review: ["reviewBody", "datePublished", "url"],
|
|
281
287
|
FAQPage: [],
|
|
@@ -397,6 +403,7 @@ export {
|
|
|
397
403
|
Event,
|
|
398
404
|
FAQPage,
|
|
399
405
|
HowTo,
|
|
406
|
+
ImageObject,
|
|
400
407
|
LocalBusiness,
|
|
401
408
|
Location,
|
|
402
409
|
Organization,
|
|
@@ -404,6 +411,7 @@ export {
|
|
|
404
411
|
Product,
|
|
405
412
|
Review,
|
|
406
413
|
SCHEMA_CONTEXT,
|
|
414
|
+
VideoObject,
|
|
407
415
|
WebPage,
|
|
408
416
|
WebSite,
|
|
409
417
|
stableStringify,
|