| 1 | import { mkdir, writeFile } from 'node:fs/promises';
|
| 2 | import { z } from 'zod';
|
| 3 | import {
|
| 4 | AgentIdentitySchema,
|
| 5 | DelegationCredentialSchema,
|
| 6 | ExpectationManifestSchema,
|
| 7 | FactCheckResultSchema,
|
| 8 | FeedbackSchema,
|
| 9 | InteractionContractSchema,
|
| 10 | InteractionEventSchema,
|
| 11 | ReceiptSchema,
|
| 12 | RiskDecisionSchema,
|
| 13 | TrustEnvelopeSchema,
|
| 14 | } from '@openclasp/protocol';
|
| 15 |
|
| 16 | const schemas = {
|
| 17 | agent_identity: AgentIdentitySchema,
|
| 18 | delegation_credential: DelegationCredentialSchema,
|
| 19 | expectation_manifest: ExpectationManifestSchema,
|
| 20 | interaction_contract: InteractionContractSchema,
|
| 21 | trust_envelope: TrustEnvelopeSchema,
|
| 22 | interaction_event: InteractionEventSchema,
|
| 23 | fact_check_result: FactCheckResultSchema,
|
| 24 | receipt: ReceiptSchema,
|
| 25 | feedback: FeedbackSchema,
|
| 26 | risk_decision: RiskDecisionSchema,
|
| 27 | };
|
| 28 | await mkdir('schemas/v0.1', { recursive: true });
|
| 29 | await Promise.all(
|
| 30 | Object.entries(schemas).map(([name, schema]) =>
|
| 31 | writeFile(
|
| 32 | `schemas/v0.1/${name}.schema.json`,
|
| 33 | `${JSON.stringify(z.toJSONSchema(schema, { target: 'draft-2020-12' }), null, 2)}\n`,
|
| 34 | ),
|
| 35 | ),
|
| 36 | );
|