@react-pakistan/util-functions 1.25.11 → 1.25.13
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/constants/cache-time.d.ts +2 -0
- package/constants/cache-time.js +3 -1
- package/general/generate-article-schema.d.ts +49 -0
- package/general/generate-article-schema.js +100 -0
- package/general/generate-blog-schema.d.ts +7 -5
- package/general/generate-blog-schema.js +7 -5
- package/general/generate-book-schema.d.ts +57 -0
- package/general/generate-book-schema.js +109 -0
- package/general/generate-breadcrumb-schema.d.ts +22 -6
- package/general/generate-breadcrumb-schema.js +15 -4
- package/general/generate-carousel-schema.d.ts +51 -0
- package/general/generate-carousel-schema.js +172 -0
- package/general/generate-course-schema.d.ts +52 -0
- package/general/generate-course-schema.js +124 -0
- package/general/generate-dataset-schema.d.ts +64 -0
- package/general/generate-dataset-schema.js +156 -0
- package/general/generate-discussion-forum-schema.d.ts +38 -0
- package/general/generate-discussion-forum-schema.js +67 -0
- package/general/generate-education-schema.d.ts +67 -0
- package/general/generate-education-schema.js +137 -0
- package/general/generate-employer-aggregate-rating-schema.d.ts +28 -0
- package/general/generate-employer-aggregate-rating-schema.js +64 -0
- package/general/generate-event-schema.d.ts +62 -0
- package/general/generate-event-schema.js +214 -0
- package/general/generate-faq-schema.d.ts +15 -11
- package/general/generate-faq-schema.js +18 -6
- package/general/generate-image-metadata-schema.d.ts +35 -0
- package/general/generate-image-metadata-schema.js +73 -0
- package/general/generate-job-posting-schema.d.ts +48 -0
- package/general/generate-job-posting-schema.js +120 -0
- package/general/generate-local-business-schema.d.ts +41 -0
- package/general/generate-local-business-schema.js +75 -0
- package/general/generate-math-solver-schema.d.ts +44 -0
- package/general/generate-math-solver-schema.js +83 -0
- package/general/generate-movie-carousel-schema.d.ts +50 -0
- package/general/generate-movie-carousel-schema.js +160 -0
- package/general/generate-organization-schema.d.ts +9 -5
- package/general/generate-organization-schema.js +9 -5
- package/general/generate-profile-page-schema.d.ts +36 -0
- package/general/generate-profile-page-schema.js +82 -0
- package/general/generate-qa-page-schema.d.ts +33 -0
- package/general/generate-qa-page-schema.js +67 -0
- package/general/generate-recipe-schema.d.ts +48 -0
- package/general/generate-recipe-schema.js +104 -0
- package/general/generate-review-snippet-schema.d.ts +51 -0
- package/general/generate-review-snippet-schema.js +137 -0
- package/general/generate-shopping-loyalty-program-schema.d.ts +37 -0
- package/general/generate-shopping-loyalty-program-schema.js +59 -0
- package/general/generate-shopping-merchant-listing-schema.d.ts +52 -0
- package/general/generate-shopping-merchant-listing-schema.js +153 -0
- package/general/generate-shopping-merchant-return-policy-schema.d.ts +31 -0
- package/general/generate-shopping-merchant-return-policy-schema.js +68 -0
- package/general/generate-shopping-merchant-shipping-policy-schema.d.ts +35 -0
- package/general/generate-shopping-merchant-shipping-policy-schema.js +74 -0
- package/general/generate-shopping-overview-schema.d.ts +51 -0
- package/general/generate-shopping-overview-schema.js +157 -0
- package/general/generate-shopping-product-snippet-schema.d.ts +56 -0
- package/general/generate-shopping-product-snippet-schema.js +167 -0
- package/general/generate-shopping-variants-schema.d.ts +45 -0
- package/general/generate-shopping-variants-schema.js +143 -0
- package/general/generate-software-app-schema.d.ts +61 -0
- package/general/generate-software-app-schema.js +143 -0
- package/general/generate-speakable-schema.d.ts +63 -0
- package/general/generate-speakable-schema.js +139 -0
- package/general/generate-subscription-schema.d.ts +59 -0
- package/general/generate-subscription-schema.js +133 -0
- package/general/generate-vacation-rental-schema.d.ts +66 -0
- package/general/generate-vacation-rental-schema.js +135 -0
- package/general/generate-video-schema.d.ts +74 -0
- package/general/generate-video-schema.js +163 -0
- package/general/index.d.ts +30 -0
- package/general/index.js +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `JobPosting` JSON-LD.
|
|
3
|
+
*
|
|
4
|
+
* Supports structured `hiringOrganization`, `jobLocation`, and `baseSalary`
|
|
5
|
+
* representations. Currency validation is available via
|
|
6
|
+
* `skipInvalidCurrency` to catch malformed currency codes.
|
|
7
|
+
*
|
|
8
|
+
* See `JobPostingOptions` for the supported inputs.
|
|
9
|
+
* @returns A JSON-LD compatible `JobPosting` object
|
|
10
|
+
*/
|
|
11
|
+
interface SimpleOrganization {
|
|
12
|
+
name: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
logo?: string;
|
|
15
|
+
}
|
|
16
|
+
interface SimpleAddress {
|
|
17
|
+
streetAddress?: string;
|
|
18
|
+
addressLocality?: string;
|
|
19
|
+
postalCode?: string;
|
|
20
|
+
addressRegion?: string;
|
|
21
|
+
addressCountry?: string;
|
|
22
|
+
}
|
|
23
|
+
interface JobLocation {
|
|
24
|
+
name?: string;
|
|
25
|
+
address?: string | SimpleAddress;
|
|
26
|
+
}
|
|
27
|
+
interface BaseSalary {
|
|
28
|
+
value?: string | number;
|
|
29
|
+
currency?: string;
|
|
30
|
+
unitText?: string;
|
|
31
|
+
}
|
|
32
|
+
interface JobPostingOptions {
|
|
33
|
+
title: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
datePosted: string;
|
|
36
|
+
validThrough?: string;
|
|
37
|
+
employmentType?: string | string[];
|
|
38
|
+
hiringOrganization?: string | SimpleOrganization;
|
|
39
|
+
jobLocation?: JobLocation | string;
|
|
40
|
+
baseSalary?: number | string | BaseSalary;
|
|
41
|
+
qualifications?: string;
|
|
42
|
+
skills?: string[];
|
|
43
|
+
identifier?: string;
|
|
44
|
+
url?: string;
|
|
45
|
+
skipInvalidCurrency?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare const generateJobPostingSchema: ({ title, description, datePosted, validThrough, employmentType, hiringOrganization, jobLocation, baseSalary, qualifications, skills, identifier, url, skipInvalidCurrency, }: JobPostingOptions) => any;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate schema.org `JobPosting` JSON-LD.
|
|
4
|
+
*
|
|
5
|
+
* Supports structured `hiringOrganization`, `jobLocation`, and `baseSalary`
|
|
6
|
+
* representations. Currency validation is available via
|
|
7
|
+
* `skipInvalidCurrency` to catch malformed currency codes.
|
|
8
|
+
*
|
|
9
|
+
* See `JobPostingOptions` for the supported inputs.
|
|
10
|
+
* @returns A JSON-LD compatible `JobPosting` object
|
|
11
|
+
*/
|
|
12
|
+
var __assign = (this && this.__assign) || function () {
|
|
13
|
+
__assign = Object.assign || function(t) {
|
|
14
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
s = arguments[i];
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
return __assign.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.generateJobPostingSchema = void 0;
|
|
25
|
+
var formatOrganization = function (org) {
|
|
26
|
+
if (!org)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (typeof org === 'string')
|
|
29
|
+
return { '@type': 'Organization', name: org };
|
|
30
|
+
var out = { '@type': 'Organization', name: org.name };
|
|
31
|
+
if (org.url)
|
|
32
|
+
out.url = org.url;
|
|
33
|
+
if (org.logo)
|
|
34
|
+
out.logo = { '@type': 'ImageObject', url: org.logo };
|
|
35
|
+
return out;
|
|
36
|
+
};
|
|
37
|
+
var formatJobLocation = function (loc) {
|
|
38
|
+
if (!loc)
|
|
39
|
+
return undefined;
|
|
40
|
+
if (typeof loc === 'string')
|
|
41
|
+
return loc;
|
|
42
|
+
var out = { '@type': 'Place' };
|
|
43
|
+
if (loc.name)
|
|
44
|
+
out.name = loc.name;
|
|
45
|
+
if (loc.address) {
|
|
46
|
+
if (typeof loc.address === 'string')
|
|
47
|
+
out.address = loc.address;
|
|
48
|
+
else
|
|
49
|
+
out.address = __assign(__assign(__assign(__assign(__assign({ '@type': 'PostalAddress' }, (loc.address.streetAddress && {
|
|
50
|
+
streetAddress: loc.address.streetAddress,
|
|
51
|
+
})), (loc.address.addressLocality && {
|
|
52
|
+
addressLocality: loc.address.addressLocality,
|
|
53
|
+
})), (loc.address.postalCode && { postalCode: loc.address.postalCode })), (loc.address.addressRegion && {
|
|
54
|
+
addressRegion: loc.address.addressRegion,
|
|
55
|
+
})), (loc.address.addressCountry && {
|
|
56
|
+
addressCountry: loc.address.addressCountry,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
};
|
|
61
|
+
var isValidCurrency = function (code) {
|
|
62
|
+
if (!code)
|
|
63
|
+
return false;
|
|
64
|
+
return /^[A-Z]{3}$/.test(code);
|
|
65
|
+
};
|
|
66
|
+
var generateJobPostingSchema = function (_a) {
|
|
67
|
+
var title = _a.title, description = _a.description, datePosted = _a.datePosted, validThrough = _a.validThrough, employmentType = _a.employmentType, hiringOrganization = _a.hiringOrganization, jobLocation = _a.jobLocation, baseSalary = _a.baseSalary, qualifications = _a.qualifications, skills = _a.skills, identifier = _a.identifier, url = _a.url, _b = _a.skipInvalidCurrency, skipInvalidCurrency = _b === void 0 ? false : _b;
|
|
68
|
+
var schema = {
|
|
69
|
+
'@context': 'https://schema.org',
|
|
70
|
+
'@type': 'JobPosting',
|
|
71
|
+
title: title,
|
|
72
|
+
datePosted: datePosted,
|
|
73
|
+
};
|
|
74
|
+
if (description)
|
|
75
|
+
schema.description = description;
|
|
76
|
+
if (validThrough)
|
|
77
|
+
schema.validThrough = validThrough;
|
|
78
|
+
if (employmentType)
|
|
79
|
+
schema.employmentType = employmentType;
|
|
80
|
+
var org = formatOrganization(hiringOrganization);
|
|
81
|
+
if (org)
|
|
82
|
+
schema.hiringOrganization = org;
|
|
83
|
+
var loc = formatJobLocation(jobLocation);
|
|
84
|
+
if (loc)
|
|
85
|
+
schema.jobLocation = loc;
|
|
86
|
+
if (baseSalary != null) {
|
|
87
|
+
// support simple number/string or detailed object
|
|
88
|
+
if (typeof baseSalary === 'number' || typeof baseSalary === 'string') {
|
|
89
|
+
schema.baseSalary = {
|
|
90
|
+
'@type': 'MonetaryAmount',
|
|
91
|
+
value: baseSalary,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
var bs = baseSalary;
|
|
96
|
+
if (bs.currency && !isValidCurrency(bs.currency)) {
|
|
97
|
+
if (!skipInvalidCurrency)
|
|
98
|
+
throw new Error("Invalid currency code: ".concat(bs.currency));
|
|
99
|
+
}
|
|
100
|
+
var ma = { '@type': 'MonetaryAmount' };
|
|
101
|
+
if (bs.value != null)
|
|
102
|
+
ma.value = bs.value;
|
|
103
|
+
if (bs.currency && isValidCurrency(bs.currency))
|
|
104
|
+
ma.currency = bs.currency;
|
|
105
|
+
if (bs.unitText)
|
|
106
|
+
ma.unitText = bs.unitText;
|
|
107
|
+
schema.baseSalary = ma;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (qualifications)
|
|
111
|
+
schema.qualifications = qualifications;
|
|
112
|
+
if (skills && skills.length > 0)
|
|
113
|
+
schema.skills = skills.join(', ');
|
|
114
|
+
if (identifier)
|
|
115
|
+
schema.identifier = identifier;
|
|
116
|
+
if (url)
|
|
117
|
+
schema.jobLocation = schema.jobLocation || { '@type': 'Place', name: url };
|
|
118
|
+
return schema;
|
|
119
|
+
};
|
|
120
|
+
exports.generateJobPostingSchema = generateJobPostingSchema;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `LocalBusiness` JSON-LD.
|
|
3
|
+
*
|
|
4
|
+
* Accepts common local business metadata (address, telephone, opening
|
|
5
|
+
* hours, geo coordinates, aggregateRating, etc.) and returns an object
|
|
6
|
+
* formatted for JSON-LD. Address may be provided as a simple string or a
|
|
7
|
+
* structured `SimpleAddress` object.
|
|
8
|
+
*
|
|
9
|
+
* See `LocalBusinessOptions` below for supported fields.
|
|
10
|
+
* @returns A JSON-LD compatible `LocalBusiness` object
|
|
11
|
+
*/
|
|
12
|
+
interface SimpleAddress {
|
|
13
|
+
streetAddress?: string;
|
|
14
|
+
addressLocality?: string;
|
|
15
|
+
postalCode?: string;
|
|
16
|
+
addressRegion?: string;
|
|
17
|
+
addressCountry?: string;
|
|
18
|
+
}
|
|
19
|
+
interface LocalBusinessOptions {
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
url?: string;
|
|
23
|
+
telephone?: string;
|
|
24
|
+
email?: string;
|
|
25
|
+
address?: string | SimpleAddress;
|
|
26
|
+
openingHours?: string[];
|
|
27
|
+
geo?: {
|
|
28
|
+
latitude: string | number;
|
|
29
|
+
longitude: string | number;
|
|
30
|
+
};
|
|
31
|
+
priceRange?: string;
|
|
32
|
+
image?: string;
|
|
33
|
+
logo?: string;
|
|
34
|
+
aggregateRating?: {
|
|
35
|
+
ratingValue: number | string;
|
|
36
|
+
reviewCount?: number;
|
|
37
|
+
};
|
|
38
|
+
sameAs?: string[];
|
|
39
|
+
}
|
|
40
|
+
export declare const generateLocalBusinessSchema: ({ name, description, url, telephone, email, address, openingHours, geo, priceRange, image, logo, aggregateRating, sameAs, }: LocalBusinessOptions) => any;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate schema.org `LocalBusiness` JSON-LD.
|
|
4
|
+
*
|
|
5
|
+
* Accepts common local business metadata (address, telephone, opening
|
|
6
|
+
* hours, geo coordinates, aggregateRating, etc.) and returns an object
|
|
7
|
+
* formatted for JSON-LD. Address may be provided as a simple string or a
|
|
8
|
+
* structured `SimpleAddress` object.
|
|
9
|
+
*
|
|
10
|
+
* See `LocalBusinessOptions` below for supported fields.
|
|
11
|
+
* @returns A JSON-LD compatible `LocalBusiness` object
|
|
12
|
+
*/
|
|
13
|
+
var __assign = (this && this.__assign) || function () {
|
|
14
|
+
__assign = Object.assign || function(t) {
|
|
15
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
16
|
+
s = arguments[i];
|
|
17
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
18
|
+
t[p] = s[p];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
return __assign.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.generateLocalBusinessSchema = void 0;
|
|
26
|
+
var formatAddress = function (a) {
|
|
27
|
+
if (!a)
|
|
28
|
+
return undefined;
|
|
29
|
+
if (typeof a === 'string')
|
|
30
|
+
return a;
|
|
31
|
+
return __assign(__assign(__assign(__assign(__assign({ '@type': 'PostalAddress' }, (a.streetAddress && { streetAddress: a.streetAddress })), (a.addressLocality && { addressLocality: a.addressLocality })), (a.postalCode && { postalCode: a.postalCode })), (a.addressRegion && { addressRegion: a.addressRegion })), (a.addressCountry && { addressCountry: a.addressCountry }));
|
|
32
|
+
};
|
|
33
|
+
var generateLocalBusinessSchema = function (_a) {
|
|
34
|
+
var name = _a.name, description = _a.description, url = _a.url, telephone = _a.telephone, email = _a.email, address = _a.address, openingHours = _a.openingHours, geo = _a.geo, priceRange = _a.priceRange, image = _a.image, logo = _a.logo, aggregateRating = _a.aggregateRating, sameAs = _a.sameAs;
|
|
35
|
+
var schema = {
|
|
36
|
+
'@context': 'https://schema.org',
|
|
37
|
+
'@type': 'LocalBusiness',
|
|
38
|
+
name: name,
|
|
39
|
+
};
|
|
40
|
+
if (description)
|
|
41
|
+
schema.description = description;
|
|
42
|
+
if (url)
|
|
43
|
+
schema.url = url;
|
|
44
|
+
if (telephone)
|
|
45
|
+
schema.telephone = telephone;
|
|
46
|
+
if (email)
|
|
47
|
+
schema.email = email;
|
|
48
|
+
var addr = formatAddress(address);
|
|
49
|
+
if (addr)
|
|
50
|
+
schema.address = addr;
|
|
51
|
+
if (openingHours && openingHours.length > 0)
|
|
52
|
+
schema.openingHours = openingHours;
|
|
53
|
+
if (geo) {
|
|
54
|
+
schema.geo = {
|
|
55
|
+
'@type': 'GeoCoordinates',
|
|
56
|
+
latitude: String(geo.latitude),
|
|
57
|
+
longitude: String(geo.longitude),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (priceRange)
|
|
61
|
+
schema.priceRange = priceRange;
|
|
62
|
+
if (image)
|
|
63
|
+
schema.image = image;
|
|
64
|
+
if (logo)
|
|
65
|
+
schema.logo = { '@type': 'ImageObject', url: logo };
|
|
66
|
+
if (aggregateRating) {
|
|
67
|
+
schema.aggregateRating = __assign({ '@type': 'AggregateRating', ratingValue: aggregateRating.ratingValue }, (aggregateRating.reviewCount != null && {
|
|
68
|
+
reviewCount: aggregateRating.reviewCount,
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
if (sameAs && sameAs.length > 0)
|
|
72
|
+
schema.sameAs = sameAs;
|
|
73
|
+
return schema;
|
|
74
|
+
};
|
|
75
|
+
exports.generateLocalBusinessSchema = generateLocalBusinessSchema;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org JSON-LD for a `MathSolver` application.
|
|
3
|
+
*
|
|
4
|
+
* Accepts application metadata (author, provider, softwareVersion, offers,
|
|
5
|
+
* etc.) and formats optional fields into a minimal `MathSolver` object
|
|
6
|
+
* suitable for embedding as JSON-LD. Only provided fields are included.
|
|
7
|
+
*
|
|
8
|
+
* See `MathSolverOptions` below for the accepted input shape.
|
|
9
|
+
* @returns A JSON-LD compatible `MathSolver` object
|
|
10
|
+
*/
|
|
11
|
+
interface PersonSimple {
|
|
12
|
+
name: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
}
|
|
15
|
+
interface OrganizationSimple {
|
|
16
|
+
name: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
}
|
|
19
|
+
interface ImageSimple {
|
|
20
|
+
url: string;
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
}
|
|
24
|
+
interface OfferSimple {
|
|
25
|
+
price?: string | number;
|
|
26
|
+
priceCurrency?: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
}
|
|
29
|
+
interface MathSolverOptions {
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
image?: string | ImageSimple;
|
|
34
|
+
author?: string | PersonSimple;
|
|
35
|
+
provider?: string | OrganizationSimple;
|
|
36
|
+
softwareVersion?: string;
|
|
37
|
+
applicationCategory?: string;
|
|
38
|
+
operatingSystem?: string | string[];
|
|
39
|
+
programmingLanguage?: string | string[];
|
|
40
|
+
license?: string;
|
|
41
|
+
offers?: OfferSimple | OfferSimple[];
|
|
42
|
+
}
|
|
43
|
+
export declare const generateMathSolverSchema: ({ name, description, url, image, author, provider, softwareVersion, applicationCategory, operatingSystem, programmingLanguage, license, offers, }: MathSolverOptions) => any;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate schema.org JSON-LD for a `MathSolver` application.
|
|
4
|
+
*
|
|
5
|
+
* Accepts application metadata (author, provider, softwareVersion, offers,
|
|
6
|
+
* etc.) and formats optional fields into a minimal `MathSolver` object
|
|
7
|
+
* suitable for embedding as JSON-LD. Only provided fields are included.
|
|
8
|
+
*
|
|
9
|
+
* See `MathSolverOptions` below for the accepted input shape.
|
|
10
|
+
* @returns A JSON-LD compatible `MathSolver` object
|
|
11
|
+
*/
|
|
12
|
+
var __assign = (this && this.__assign) || function () {
|
|
13
|
+
__assign = Object.assign || function(t) {
|
|
14
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
s = arguments[i];
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
return __assign.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.generateMathSolverSchema = void 0;
|
|
25
|
+
var formatPerson = function (p) {
|
|
26
|
+
if (!p)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (typeof p === 'string')
|
|
29
|
+
return { '@type': 'Person', name: p };
|
|
30
|
+
return __assign({ '@type': 'Person', name: p.name }, (p.url && { url: p.url }));
|
|
31
|
+
};
|
|
32
|
+
var formatOrganization = function (o) {
|
|
33
|
+
if (!o)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (typeof o === 'string')
|
|
36
|
+
return { '@type': 'Organization', name: o };
|
|
37
|
+
return __assign({ '@type': 'Organization', name: o.name }, (o.url && { url: o.url }));
|
|
38
|
+
};
|
|
39
|
+
var formatImage = function (i) {
|
|
40
|
+
if (!i)
|
|
41
|
+
return undefined;
|
|
42
|
+
if (typeof i === 'string')
|
|
43
|
+
return i;
|
|
44
|
+
return __assign(__assign({ '@type': 'ImageObject', url: i.url }, (i.width && { width: i.width })), (i.height && { height: i.height }));
|
|
45
|
+
};
|
|
46
|
+
var generateMathSolverSchema = function (_a) {
|
|
47
|
+
var name = _a.name, description = _a.description, url = _a.url, image = _a.image, author = _a.author, provider = _a.provider, softwareVersion = _a.softwareVersion, applicationCategory = _a.applicationCategory, operatingSystem = _a.operatingSystem, programmingLanguage = _a.programmingLanguage, license = _a.license, offers = _a.offers;
|
|
48
|
+
var schema = {
|
|
49
|
+
'@context': 'https://schema.org',
|
|
50
|
+
'@type': 'MathSolver',
|
|
51
|
+
name: name,
|
|
52
|
+
};
|
|
53
|
+
if (description)
|
|
54
|
+
schema.description = description;
|
|
55
|
+
if (url)
|
|
56
|
+
schema.url = url;
|
|
57
|
+
var img = formatImage(image);
|
|
58
|
+
if (img)
|
|
59
|
+
schema.image = img;
|
|
60
|
+
var a = formatPerson(author);
|
|
61
|
+
if (a)
|
|
62
|
+
schema.author = a;
|
|
63
|
+
var prov = formatOrganization(provider);
|
|
64
|
+
if (prov)
|
|
65
|
+
schema.provider = prov;
|
|
66
|
+
if (softwareVersion)
|
|
67
|
+
schema.softwareVersion = softwareVersion;
|
|
68
|
+
if (applicationCategory)
|
|
69
|
+
schema.applicationCategory = applicationCategory;
|
|
70
|
+
if (operatingSystem)
|
|
71
|
+
schema.operatingSystem = operatingSystem;
|
|
72
|
+
if (programmingLanguage)
|
|
73
|
+
schema.programmingLanguage = programmingLanguage;
|
|
74
|
+
if (license)
|
|
75
|
+
schema.license = license;
|
|
76
|
+
if (offers) {
|
|
77
|
+
var arr = Array.isArray(offers) ? offers : [offers];
|
|
78
|
+
var mapped = arr.map(function (o) { return (__assign(__assign(__assign({ '@type': 'Offer' }, (o.price != null && { price: o.price })), (o.priceCurrency && { priceCurrency: o.priceCurrency })), (o.url && { url: o.url }))); });
|
|
79
|
+
schema.offers = mapped.length === 1 ? mapped[0] : mapped;
|
|
80
|
+
}
|
|
81
|
+
return schema;
|
|
82
|
+
};
|
|
83
|
+
exports.generateMathSolverSchema = generateMathSolverSchema;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `ItemList` JSON-LD for a movie carousel (list of
|
|
3
|
+
* `Movie` entries).
|
|
4
|
+
*
|
|
5
|
+
* Each movie item can include director/actor references, offers,
|
|
6
|
+
* aggregate ratings and genre metadata. Images are normalized to
|
|
7
|
+
* `ImageObject` entries.
|
|
8
|
+
*
|
|
9
|
+
* See `MovieCarouselOptions` and `MovieItem` for input details.
|
|
10
|
+
* @returns A JSON-LD compatible `ItemList` of `Movie` objects
|
|
11
|
+
*/
|
|
12
|
+
interface PersonRef {
|
|
13
|
+
name: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}
|
|
16
|
+
interface MovieOffer {
|
|
17
|
+
price?: string | number;
|
|
18
|
+
priceCurrency?: string;
|
|
19
|
+
availability?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
}
|
|
22
|
+
interface MovieItem {
|
|
23
|
+
id?: string;
|
|
24
|
+
name: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
image?: string | {
|
|
27
|
+
url: string;
|
|
28
|
+
width?: number;
|
|
29
|
+
height?: number;
|
|
30
|
+
};
|
|
31
|
+
description?: string;
|
|
32
|
+
director?: string | PersonRef | Array<string | PersonRef>;
|
|
33
|
+
actor?: string | PersonRef | Array<string | PersonRef>;
|
|
34
|
+
datePublished?: string;
|
|
35
|
+
duration?: string;
|
|
36
|
+
genre?: string | string[];
|
|
37
|
+
aggregateRating?: {
|
|
38
|
+
ratingValue: number | string;
|
|
39
|
+
reviewCount?: number;
|
|
40
|
+
};
|
|
41
|
+
offers?: MovieOffer | MovieOffer[];
|
|
42
|
+
}
|
|
43
|
+
interface MovieCarouselOptions {
|
|
44
|
+
name?: string;
|
|
45
|
+
url?: string;
|
|
46
|
+
items: MovieItem[];
|
|
47
|
+
skipInvalidCurrency?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare const generateMovieCarouselSchema: ({ name, url, items, skipInvalidCurrency, }: MovieCarouselOptions) => any;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate schema.org `ItemList` JSON-LD for a movie carousel (list of
|
|
4
|
+
* `Movie` entries).
|
|
5
|
+
*
|
|
6
|
+
* Each movie item can include director/actor references, offers,
|
|
7
|
+
* aggregate ratings and genre metadata. Images are normalized to
|
|
8
|
+
* `ImageObject` entries.
|
|
9
|
+
*
|
|
10
|
+
* See `MovieCarouselOptions` and `MovieItem` for input details.
|
|
11
|
+
* @returns A JSON-LD compatible `ItemList` of `Movie` objects
|
|
12
|
+
*/
|
|
13
|
+
var __assign = (this && this.__assign) || function () {
|
|
14
|
+
__assign = Object.assign || function(t) {
|
|
15
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
16
|
+
s = arguments[i];
|
|
17
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
18
|
+
t[p] = s[p];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
return __assign.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.generateMovieCarouselSchema = void 0;
|
|
26
|
+
var formatPerson = function (p) {
|
|
27
|
+
if (typeof p === 'string')
|
|
28
|
+
return { '@type': 'Person', name: p };
|
|
29
|
+
return __assign({ '@type': 'Person', name: p.name }, (p.url && { url: p.url }));
|
|
30
|
+
};
|
|
31
|
+
var formatImage = function (image) {
|
|
32
|
+
if (!image)
|
|
33
|
+
return undefined;
|
|
34
|
+
if (typeof image === 'string')
|
|
35
|
+
return image;
|
|
36
|
+
return __assign(__assign({ '@type': 'ImageObject', url: image.url }, (image.width && { width: image.width })), (image.height && { height: image.height }));
|
|
37
|
+
};
|
|
38
|
+
var isValidCurrency = function (code) {
|
|
39
|
+
if (!code)
|
|
40
|
+
return false;
|
|
41
|
+
return /^[A-Z]{3}$/.test(code);
|
|
42
|
+
};
|
|
43
|
+
var AVAILABILITIES = [
|
|
44
|
+
'InStock',
|
|
45
|
+
'OutOfStock',
|
|
46
|
+
'PreOrder',
|
|
47
|
+
'PreSale',
|
|
48
|
+
'Discontinued',
|
|
49
|
+
'OnlineOnly',
|
|
50
|
+
'InStoreOnly',
|
|
51
|
+
'LimitedAvailability',
|
|
52
|
+
'BackOrder',
|
|
53
|
+
];
|
|
54
|
+
var normalizeAvailability = function (val) {
|
|
55
|
+
if (!val)
|
|
56
|
+
return undefined;
|
|
57
|
+
try {
|
|
58
|
+
var asUrl = String(val);
|
|
59
|
+
if (asUrl.startsWith('http')) {
|
|
60
|
+
var token = asUrl.replace(/https?:\/\/schema\.org\//i, '');
|
|
61
|
+
if (AVAILABILITIES.includes(token))
|
|
62
|
+
return "https://schema.org/".concat(token);
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
if (AVAILABILITIES.includes(asUrl))
|
|
66
|
+
return "https://schema.org/".concat(asUrl);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
catch (_a) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var generateMovieCarouselSchema = function (_a) {
|
|
74
|
+
var name = _a.name, url = _a.url, items = _a.items, _b = _a.skipInvalidCurrency, skipInvalidCurrency = _b === void 0 ? false : _b;
|
|
75
|
+
var itemList = items.map(function (it, idx) {
|
|
76
|
+
var movie = {
|
|
77
|
+
'@type': 'Movie',
|
|
78
|
+
name: it.name,
|
|
79
|
+
};
|
|
80
|
+
if (it.url)
|
|
81
|
+
movie.url = it.url;
|
|
82
|
+
if (it.id)
|
|
83
|
+
movie['@id'] = it.id;
|
|
84
|
+
var img = formatImage(it.image);
|
|
85
|
+
if (img)
|
|
86
|
+
movie.image = img;
|
|
87
|
+
if (it.description)
|
|
88
|
+
movie.description = it.description;
|
|
89
|
+
if (it.datePublished)
|
|
90
|
+
movie.datePublished = it.datePublished;
|
|
91
|
+
if (it.duration)
|
|
92
|
+
movie.duration = it.duration;
|
|
93
|
+
if (it.genre)
|
|
94
|
+
movie.genre = Array.isArray(it.genre) ? it.genre.join(', ') : it.genre;
|
|
95
|
+
if (it.director) {
|
|
96
|
+
if (Array.isArray(it.director))
|
|
97
|
+
movie.director = it.director.map(function (d) { return formatPerson(d); });
|
|
98
|
+
else
|
|
99
|
+
movie.director = formatPerson(it.director);
|
|
100
|
+
}
|
|
101
|
+
if (it.actor) {
|
|
102
|
+
if (Array.isArray(it.actor))
|
|
103
|
+
movie.actor = it.actor.map(function (a) { return formatPerson(a); });
|
|
104
|
+
else
|
|
105
|
+
movie.actor = formatPerson(it.actor);
|
|
106
|
+
}
|
|
107
|
+
if (it.aggregateRating) {
|
|
108
|
+
movie.aggregateRating = __assign({ '@type': 'AggregateRating', ratingValue: it.aggregateRating.ratingValue }, (it.aggregateRating.reviewCount != null && {
|
|
109
|
+
reviewCount: it.aggregateRating.reviewCount,
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
if (it.offers) {
|
|
113
|
+
var offs = Array.isArray(it.offers) ? it.offers : [it.offers];
|
|
114
|
+
var mapped = offs
|
|
115
|
+
.map(function (o) {
|
|
116
|
+
if (o.priceCurrency && !isValidCurrency(o.priceCurrency))
|
|
117
|
+
return { __invalidCurrency: o.priceCurrency };
|
|
118
|
+
var of = { '@type': 'Offer' };
|
|
119
|
+
if (o.price != null)
|
|
120
|
+
of.price = o.price;
|
|
121
|
+
if (o.priceCurrency)
|
|
122
|
+
of.priceCurrency = o.priceCurrency;
|
|
123
|
+
if (o.availability) {
|
|
124
|
+
var n = normalizeAvailability(o.availability);
|
|
125
|
+
if (n)
|
|
126
|
+
of.availability = n;
|
|
127
|
+
}
|
|
128
|
+
if (o.url)
|
|
129
|
+
of.url = o.url;
|
|
130
|
+
return of;
|
|
131
|
+
})
|
|
132
|
+
.filter(function (x) { return x && !('__invalidCurrency' in x); });
|
|
133
|
+
var hadInvalid = offs.some(function (o) { return o.priceCurrency && !isValidCurrency(o.priceCurrency); });
|
|
134
|
+
if (hadInvalid && !skipInvalidCurrency) {
|
|
135
|
+
var bad = offs.find(function (o) { return o.priceCurrency && !isValidCurrency(o.priceCurrency); });
|
|
136
|
+
throw new Error("Invalid currency code: ".concat(bad === null || bad === void 0 ? void 0 : bad.priceCurrency));
|
|
137
|
+
}
|
|
138
|
+
if (mapped.length === 1)
|
|
139
|
+
movie.offers = mapped[0];
|
|
140
|
+
else if (mapped.length > 1)
|
|
141
|
+
movie.offers = mapped;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
'@type': 'ListItem',
|
|
145
|
+
position: idx + 1,
|
|
146
|
+
item: movie,
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
var schema = {
|
|
150
|
+
'@context': 'https://schema.org',
|
|
151
|
+
'@type': 'ItemList',
|
|
152
|
+
itemListElement: itemList,
|
|
153
|
+
};
|
|
154
|
+
if (name)
|
|
155
|
+
schema.name = name;
|
|
156
|
+
if (url)
|
|
157
|
+
schema.mainEntityOfPage = { '@type': 'WebPage', '@id': url };
|
|
158
|
+
return schema;
|
|
159
|
+
};
|
|
160
|
+
exports.generateMovieCarouselSchema = generateMovieCarouselSchema;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Generate schema.org `Organization` JSON-LD.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* This helper builds a minimal `Organization` object including `address`,
|
|
5
|
+
* `logo`, `image`, `email`, and `telephone`. The input shape is an
|
|
6
|
+
* application-specific `Organization` interface defined below — the
|
|
7
|
+
* function emits only the provided properties to keep the result
|
|
8
|
+
* compact.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Organization properties (see interface below)
|
|
11
|
+
* @returns A JSON-LD compatible `Organization` object
|
|
7
12
|
*/
|
|
8
|
-
/** End file docs */
|
|
9
13
|
interface Organization {
|
|
10
14
|
addressCountry: string;
|
|
11
15
|
addressLocality: string;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Generate schema.org `Organization` JSON-LD.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This helper builds a minimal `Organization` object including `address`,
|
|
6
|
+
* `logo`, `image`, `email`, and `telephone`. The input shape is an
|
|
7
|
+
* application-specific `Organization` interface defined below — the
|
|
8
|
+
* function emits only the provided properties to keep the result
|
|
9
|
+
* compact.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Organization properties (see interface below)
|
|
12
|
+
* @returns A JSON-LD compatible `Organization` object
|
|
8
13
|
*/
|
|
9
|
-
/** End file docs */
|
|
10
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
15
|
exports.generateOrganizationSchema = void 0;
|
|
12
16
|
var generateOrganizationSchema = function (_a) {
|