Skip to content

Commit 2b4db8e

Browse files
committed
Revert
1 parent de5145f commit 2b4db8e

11 files changed

Lines changed: 106 additions & 207 deletions

File tree

packages/core-json-ld/src/orgSchema/Action.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, string, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { actionStatusSchema, type ActionStatusInput, type ActionStatusOutput } from './ActionStatus';
44
import { projectSchema, type ProjectInput, type ProjectOutput } from './Project';
@@ -75,24 +75,15 @@ type ActionOutput = ThingOutput & {
7575
readonly result: readonly (ThingOutput | UserReviewOutput)[];
7676
};
7777

78-
const actionSchema: GenericSchema<ActionInput, ActionOutput> = pipe(
79-
intersect([
80-
pipe(
81-
lazy(() => thingSchema),
82-
// TODO: `intersect()` seems doesn't like frozen objects.
83-
// Related to https://github.com/open-circle/valibot/pull/1463.
84-
transform(value => ({ ...value }))
85-
),
86-
object({
87-
actionOption: jsonLinkedDataProperty(string()),
88-
actionStatus: jsonLinkedDataProperty(actionStatusSchema),
89-
provider: jsonLinkedDataProperty(lazy(() => projectSchema)),
90-
result: jsonLinkedDataProperty(userReviewSchema)
91-
})
92-
]),
93-
readonly(),
94-
transform(value => Object.freeze({ ...value }))
95-
);
78+
const actionSchema: GenericSchema<ActionInput, ActionOutput> = intersect([
79+
lazy(() => thingSchema),
80+
object({
81+
actionOption: jsonLinkedDataProperty(string()),
82+
actionStatus: jsonLinkedDataProperty(actionStatusSchema),
83+
provider: jsonLinkedDataProperty(lazy(() => projectSchema)),
84+
result: jsonLinkedDataProperty(userReviewSchema)
85+
})
86+
]);
9687

9788
/** @deprecated Use Valibot.parse(actionSchema) instead. Will be removed on or after 2028-04-23. */
9889
const parseAction: (action: ActionInput) => ActionOutput = parser(actionSchema);

packages/core-json-ld/src/orgSchema/Claim.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { creativeWorkSchema, type CreativeWorkInput, type CreativeWorkOutput } from './CreativeWork';
44
import { projectSchema, type ProjectInput, type ProjectOutput } from './Project';
@@ -53,22 +53,13 @@ type ClaimOutput = CreativeWorkOutput & {
5353
readonly claimInterpreter: readonly ProjectOutput[];
5454
};
5555

56-
const claimSchema: GenericSchema<ClaimInput, ClaimOutput> = pipe(
57-
intersect([
58-
pipe(
59-
lazy(() => creativeWorkSchema),
60-
// TODO: `intersect()` seems doesn't like frozen objects.
61-
// Related to https://github.com/open-circle/valibot/pull/1463.
62-
transform(value => ({ ...value }))
63-
),
64-
object({
65-
appearance: jsonLinkedDataProperty(lazy(() => creativeWorkSchema)),
66-
claimInterpreter: jsonLinkedDataProperty(lazy(() => projectSchema))
67-
})
68-
]),
69-
readonly(),
70-
transform(value => Object.freeze({ ...value }))
71-
);
56+
const claimSchema: GenericSchema<ClaimInput, ClaimOutput> = intersect([
57+
lazy(() => creativeWorkSchema),
58+
object({
59+
appearance: jsonLinkedDataProperty(lazy(() => creativeWorkSchema)),
60+
claimInterpreter: jsonLinkedDataProperty(lazy(() => projectSchema))
61+
})
62+
]);
7263

7364
/** @deprecated Use Valibot.parse(claimSchema) instead. Will be removed on or after 2028-04-23. */
7465
const parseClaim: (claim: ClaimInput) => ClaimOutput = parser(claimSchema);

packages/core-json-ld/src/orgSchema/CreativeWork.ts

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
import {
2-
intersect,
3-
lazy,
4-
number,
5-
object,
6-
parser,
7-
pipe,
8-
readonly,
9-
string,
10-
transform,
11-
union,
12-
type GenericSchema
13-
} from 'valibot';
1+
import { intersect, lazy, number, object, parser, string, union, type GenericSchema } from 'valibot';
142
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
153
import { claimSchema } from './Claim';
164
import {
@@ -199,31 +187,22 @@ let creativeWorkSchema_: GenericSchema<CreativeWorkInput, CreativeWorkOutput>;
199187

200188
// This is for cyclic dependency.
201189
// eslint-disable-next-line prefer-const
202-
creativeWorkSchema_ = pipe(
203-
intersect([
204-
pipe(
205-
lazy(() => thingSchema),
206-
// TODO: `intersect()` seems doesn't like frozen objects.
207-
// Related to https://github.com/open-circle/valibot/pull/1463.
208-
transform(value => ({ ...value }))
209-
),
210-
object({
211-
abstract: jsonLinkedDataProperty(string()),
212-
author: jsonLinkedDataProperty(union([lazy(() => personSchema), string()])),
213-
citation: jsonLinkedDataProperty(lazy(() => claimSchema)),
214-
creativeWorkStatus: jsonLinkedDataProperty(creativeWorkStatusSchema),
215-
isBasedOn: jsonLinkedDataProperty(lazy(() => softwareSourceCodeSchema)),
216-
isPartOf: jsonLinkedDataProperty(lazy(() => creativeWorkSchema_)),
217-
keywords: jsonLinkedDataProperty(union([lazy(() => definedTermSchema), string()])),
218-
pattern: jsonLinkedDataProperty(lazy(() => definedTermSchema)),
219-
position: jsonLinkedDataProperty(union([number(), string()])),
220-
text: jsonLinkedDataProperty(string()),
221-
usageInfo: jsonLinkedDataProperty(lazy(() => creativeWorkSchema_))
222-
})
223-
]),
224-
readonly(),
225-
transform(value => Object.freeze({ ...value }))
226-
);
190+
creativeWorkSchema_ = intersect([
191+
lazy(() => thingSchema),
192+
object({
193+
abstract: jsonLinkedDataProperty(string()),
194+
author: jsonLinkedDataProperty(union([lazy(() => personSchema), string()])),
195+
citation: jsonLinkedDataProperty(lazy(() => claimSchema)),
196+
creativeWorkStatus: jsonLinkedDataProperty(creativeWorkStatusSchema),
197+
isBasedOn: jsonLinkedDataProperty(lazy(() => softwareSourceCodeSchema)),
198+
isPartOf: jsonLinkedDataProperty(lazy(() => creativeWorkSchema_)),
199+
keywords: jsonLinkedDataProperty(union([lazy(() => definedTermSchema), string()])),
200+
pattern: jsonLinkedDataProperty(lazy(() => definedTermSchema)),
201+
position: jsonLinkedDataProperty(union([number(), string()])),
202+
text: jsonLinkedDataProperty(string()),
203+
usageInfo: jsonLinkedDataProperty(lazy(() => creativeWorkSchema_))
204+
})
205+
]);
227206

228207
// Constantize here, so we are exporting a const than a let.
229208
const creativeWorkSchema = creativeWorkSchema_;

packages/core-json-ld/src/orgSchema/DefinedTerm.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, string, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { thingSchema, type ThingInput, type ThingOutput } from './Thing';
44

@@ -48,22 +48,13 @@ type DefinedTermOutput = ThingOutput & {
4848
readonly termCode: readonly string[];
4949
};
5050

51-
const definedTermSchema: GenericSchema<DefinedTermInput, DefinedTermOutput> = pipe(
52-
intersect([
53-
pipe(
54-
lazy(() => thingSchema),
55-
// TODO: `intersect()` seems doesn't like frozen objects.
56-
// Related to https://github.com/open-circle/valibot/pull/1463.
57-
transform(value => ({ ...value }))
58-
),
59-
object({
60-
inDefinedTermSet: jsonLinkedDataProperty(string()),
61-
termCode: jsonLinkedDataProperty(string())
62-
})
63-
]),
64-
readonly(),
65-
transform(value => Object.freeze({ ...value }))
66-
);
51+
const definedTermSchema: GenericSchema<DefinedTermInput, DefinedTermOutput> = intersect([
52+
lazy(() => thingSchema),
53+
object({
54+
inDefinedTermSet: jsonLinkedDataProperty(string()),
55+
termCode: jsonLinkedDataProperty(string())
56+
})
57+
]);
6758

6859
/** @deprecated Use Valibot.parse(definedTermSchema) instead. Will be removed on or after 2028-04-23. */
6960
const parseDefinedTerm: (definedTerm: DefinedTermInput) => DefinedTermOutput = parser(definedTermSchema);

packages/core-json-ld/src/orgSchema/Person.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, string, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { thingSchema, type ThingInput, type ThingOutput } from './Thing';
44

@@ -38,23 +38,14 @@ type PersonOutput = ThingOutput & {
3838
readonly image: readonly string[];
3939
};
4040

41-
const personSchema: GenericSchema<PersonInput, PersonOutput> = pipe(
42-
intersect([
43-
pipe(
44-
lazy(() => thingSchema),
45-
// TODO: `intersect()` seems doesn't like frozen objects.
46-
// Related to https://github.com/open-circle/valibot/pull/1463.
47-
transform(value => ({ ...value }))
48-
),
49-
object({
50-
description: jsonLinkedDataProperty(string()),
51-
image: jsonLinkedDataProperty(string()),
52-
name: jsonLinkedDataProperty(string())
53-
})
54-
]),
55-
readonly(),
56-
transform(value => Object.freeze({ ...value }))
57-
);
41+
const personSchema: GenericSchema<PersonInput, PersonOutput> = intersect([
42+
lazy(() => thingSchema),
43+
object({
44+
description: jsonLinkedDataProperty(string()),
45+
image: jsonLinkedDataProperty(string()),
46+
name: jsonLinkedDataProperty(string())
47+
})
48+
]);
5849

5950
/** @deprecated Use Valibot.parse(personSchema) instead. Will be removed on or after 2028-04-23. */
6051
const parsePerson: (person: PersonInput) => PersonOutput = parser(personSchema);

packages/core-json-ld/src/orgSchema/Project.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, string, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { thingSchema, type ThingInput, type ThingOutput } from './Thing';
44

@@ -34,21 +34,12 @@ type ProjectOutput = ThingOutput & {
3434
readonly slogan: readonly string[];
3535
};
3636

37-
const projectSchema: GenericSchema<ProjectInput, ProjectOutput> = pipe(
38-
intersect([
39-
pipe(
40-
lazy(() => thingSchema),
41-
// TODO: `intersect()` seems doesn't like frozen objects.
42-
// Related to https://github.com/open-circle/valibot/pull/1463.
43-
transform(value => ({ ...value }))
44-
),
45-
object({
46-
slogan: jsonLinkedDataProperty(string())
47-
})
48-
]),
49-
readonly(),
50-
transform(value => Object.freeze({ ...value }))
51-
);
37+
const projectSchema: GenericSchema<ProjectInput, ProjectOutput> = intersect([
38+
lazy(() => thingSchema),
39+
object({
40+
slogan: jsonLinkedDataProperty(string())
41+
})
42+
]);
5243

5344
/** @deprecated Use Valibot.parse(projectSchema) instead. Will be removed on or after 2028-04-23. */
5445
const parseProject: (project: ProjectInput) => ProjectOutput = parser(projectSchema);

packages/core-json-ld/src/orgSchema/SoftwareSourceCode.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, string, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { creativeWorkSchema, type CreativeWorkInput, type CreativeWorkOutput } from './CreativeWork';
44

@@ -34,20 +34,11 @@ type SoftwareSourceCodeOutput = CreativeWorkOutput & {
3434
readonly programmingLanguage: readonly string[];
3535
};
3636

37-
const softwareSourceCodeSchema: GenericSchema<SoftwareSourceCodeInput, SoftwareSourceCodeOutput> = pipe(
38-
intersect([
39-
pipe(
40-
lazy(() => creativeWorkSchema),
41-
// TODO: `intersect()` seems doesn't like frozen objects.
42-
// Related to https://github.com/open-circle/valibot/pull/1463.
43-
transform(value => ({ ...value }))
44-
),
45-
object({
46-
programmingLanguage: jsonLinkedDataProperty(string())
47-
})
48-
]),
49-
readonly(),
50-
transform(value => Object.freeze({ ...value }))
51-
);
37+
const softwareSourceCodeSchema: GenericSchema<SoftwareSourceCodeInput, SoftwareSourceCodeOutput> = intersect([
38+
lazy(() => creativeWorkSchema),
39+
object({
40+
programmingLanguage: jsonLinkedDataProperty(string())
41+
})
42+
]);
5243

5344
export { softwareSourceCodeSchema, type SoftwareSourceCodeInput, type SoftwareSourceCodeOutput };

packages/core-json-ld/src/orgSchema/Thing.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, string, type GenericSchema } from 'valibot';
22
import { jsonLinkedDataSchema, type JSONLinkedDataInput, type JSONLinkedDataOutput } from '../JSONLinkedData';
33
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
44
import { actionSchema, type ActionInput, type ActionOutput } from './Action';
@@ -105,26 +105,17 @@ type ThingOutput = JSONLinkedDataOutput & {
105105
readonly url: readonly string[];
106106
};
107107

108-
const thingSchema: GenericSchema<ThingInput, ThingOutput> = pipe(
109-
intersect([
110-
pipe(
111-
lazy(() => jsonLinkedDataSchema),
112-
// TODO: `intersect()` seems doesn't like frozen objects.
113-
// Related to https://github.com/open-circle/valibot/pull/1463.
114-
transform(value => ({ ...value }))
115-
),
116-
object({
117-
additionalType: jsonLinkedDataProperty(string()),
118-
alternateName: jsonLinkedDataProperty(string()),
119-
description: jsonLinkedDataProperty(string()),
120-
name: jsonLinkedDataProperty(string()),
121-
potentialAction: jsonLinkedDataProperty(lazy(() => actionSchema)),
122-
url: jsonLinkedDataProperty(string())
123-
})
124-
]),
125-
readonly(),
126-
transform(value => Object.freeze({ ...value }))
127-
);
108+
const thingSchema: GenericSchema<ThingInput, ThingOutput> = intersect([
109+
lazy(() => jsonLinkedDataSchema),
110+
object({
111+
additionalType: jsonLinkedDataProperty(string()),
112+
alternateName: jsonLinkedDataProperty(string()),
113+
description: jsonLinkedDataProperty(string()),
114+
name: jsonLinkedDataProperty(string()),
115+
potentialAction: jsonLinkedDataProperty(lazy(() => actionSchema)),
116+
url: jsonLinkedDataProperty(string())
117+
})
118+
]);
128119

129120
/** @deprecated Use Valibot.parse(thingSchema) instead. Will be removed on or after 2028-04-23. */
130121
const parseThing: (thing: ThingInput) => ThingOutput = parser(thingSchema);

packages/core-json-ld/src/orgSchema/UserReview.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, string, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { thingSchema, type ThingInput, type ThingOutput } from './Thing';
44

@@ -30,21 +30,12 @@ type UserReviewOutput = ThingOutput & {
3030
readonly reviewAspect: readonly string[];
3131
};
3232

33-
const userReviewSchema: GenericSchema<UserReviewInput, UserReviewOutput> = pipe(
34-
intersect([
35-
pipe(
36-
lazy(() => thingSchema),
37-
// TODO: `intersect()` seems doesn't like frozen objects.
38-
// Related to https://github.com/open-circle/valibot/pull/1463.
39-
transform(value => ({ ...value }))
40-
),
41-
object({
42-
reviewAspect: jsonLinkedDataProperty(string())
43-
})
44-
]),
45-
readonly(),
46-
transform(value => Object.freeze({ ...value }))
47-
);
33+
const userReviewSchema: GenericSchema<UserReviewInput, UserReviewOutput> = intersect([
34+
lazy(() => thingSchema),
35+
object({
36+
reviewAspect: jsonLinkedDataProperty(string())
37+
})
38+
]);
4839

4940
/** @deprecated Use Valibot.parse(userReviewSchema) instead. Will be removed on or after 2028-04-23. */
5041
const parseUserReview: (userReview: UserReviewInput) => UserReviewOutput = parser(userReviewSchema);

packages/core-json-ld/src/orgSchema/VoteAction.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { intersect, lazy, object, parser, pipe, readonly, string, transform, type GenericSchema } from 'valibot';
1+
import { intersect, lazy, object, parser, string, type GenericSchema } from 'valibot';
22
import jsonLinkedDataProperty from '../private/jsonLinkedDataProperty';
33
import { actionSchema, type ActionInput, type ActionOutput } from './Action';
44

@@ -38,21 +38,12 @@ type VoteActionOutput = ActionOutput & {
3838
readonly actionOption: readonly string[];
3939
};
4040

41-
const voteActionSchema: GenericSchema<VoteActionInput, VoteActionOutput> = pipe(
42-
intersect([
43-
pipe(
44-
lazy(() => actionSchema),
45-
// TODO: `intersect()` seems doesn't like frozen objects.
46-
// Related to https://github.com/open-circle/valibot/pull/1463.
47-
transform(value => ({ ...value }))
48-
),
49-
object({
50-
actionOption: jsonLinkedDataProperty(string())
51-
})
52-
]),
53-
readonly(),
54-
transform(value => Object.freeze({ ...value }))
55-
);
41+
const voteActionSchema: GenericSchema<VoteActionInput, VoteActionOutput> = intersect([
42+
lazy(() => actionSchema),
43+
object({
44+
actionOption: jsonLinkedDataProperty(string())
45+
})
46+
]);
5647

5748
/** @deprecated Use Valibot.parse(voteActionSchema) instead. Will be removed on or after 2028-04-23. */
5849
const parseVoteAction: (voteAction: VoteActionInput) => VoteActionOutput = parser(voteActionSchema);

0 commit comments

Comments
 (0)