open-agreements
Version:
Open-source legal template filling CLI and library
537 lines • 21.7 kB
TypeScript
import { z } from 'zod';
import { type ConditionalRequirement } from './conditional-predicates.js';
import { type InputValueFormat } from './input-value-formats.js';
/**
* License values accepted by template metadata.
*
* CC-BY-4.0 and CC0-1.0 templates may be redistributed as OpenAgreements
* content. CC-BY-ND-4.0 templates are vendored only when unmodified and must
* declare `allow_derivatives: false`.
*/
export declare const LicenseEnum: z.ZodEnum<{
"CC-BY-4.0": "CC-BY-4.0";
"CC0-1.0": "CC0-1.0";
"CC-BY-ND-4.0": "CC-BY-ND-4.0";
}>;
export type License = z.infer<typeof LicenseEnum>;
/**
* How a managed artifact ships (S3 source/rights restructure, #1249):
* `bundled` = the DOCX is committed in-repo; `linked` = only transformation
* instructions ship and the source is fetched from its upstream URL.
*/
export declare const DistributionEnum: z.ZodEnum<{
bundled: "bundled";
linked: "linked";
}>;
export type Distribution = z.infer<typeof DistributionEnum>;
/** Whether a directory holds a fillable template or a field-selector. */
export declare const ArtifactTypeEnum: z.ZodEnum<{
template: "template";
"field-selector": "field-selector";
}>;
export type ArtifactType = z.infer<typeof ArtifactTypeEnum>;
/**
* Maturity / support expectation for a first-party template (open-agreements#243).
*
* Distinct from the SemVer `version`, which signals the *past* (was a release a
* breaking change?). `stability` signals the *future* support expectation:
* - `experimental` — legal logic still settling; expect change.
* - `beta` — schema and structure stable; legal text still hardening.
* - `stable` — graduated (== SemVer 1.0): DTSA parity holds where applicable,
* high-risk cover-term drafting notes are complete, and two consecutive
* minor releases have shipped without legal-text rework.
*
* First-party (`openagreements-*`) templates declare this explicitly; it is
* optional so vendored third-party templates (whose maturity is upstream-derived)
* and any pre-existing metadata still validate.
*/
export declare const StabilityEnum: z.ZodEnum<{
experimental: "experimental";
beta: "beta";
stable: "stable";
}>;
export type Stability = z.infer<typeof StabilityEnum>;
/** Field kinds supported by template, external-template, and fieldSelector metadata. */
declare const FieldTypeEnum: z.ZodEnum<{
string: "string";
number: "number";
boolean: "boolean";
date: "date";
array: "array";
enum: "enum";
multiselect: "multiselect";
}>;
export type FieldType = z.infer<typeof FieldTypeEnum>;
/**
* Metadata definition for a fillable field.
*
* `name`, `type`, and `description` are required. `enum` and `multiselect`
* fields must declare non-empty `options`; `array` fields may declare nested
* `items`; `display_label` is a presentation hint and never replaces `name`.
*/
export interface FieldDefinition {
name: string;
type: FieldType;
description: string;
display_label?: string;
default?: string;
default_value_rationale?: string;
options?: string[];
derive_booleans?: boolean;
section?: string;
items?: FieldDefinition[];
/** Require an explicit, nonblank input when a top-level scalar field matches. */
required_when?: ConditionalRequirement;
/** Explicit caller value shape; does not depend on field names or prose. */
value_format?: InputValueFormat;
/**
* Marks this boolean field as a *statutory compliance representation*: its
* `true` value asserts a past real-world fact that is a statutory precondition
* to the agreement's enforceability/validity (e.g. a required advance notice
* or written advisal that must actually have been given before signing).
*
* Deliberately NARROW — opt-in per field and reserved for the few reps that
* gate enforceability, NOT general representations (a purchase agreement may
* carry dozens of ordinary reps that should not all demand per-rep
* confirmation). When set, the field MUST be boolean with `default: 'false'`
* and MUST declare `authority_url`. A template clause references it via the
* renderer's `confirm=` directive, which renders the recital clean when the
* field is true and as a highlighted `[CONFIRM …]` bracket when it is false
* (never silently dropped). The broad confirmation warning rides in
* `description`; the short reason shown inside the rendered bracket rides in
* `confirm_note`.
*/
statutory_compliance_representation?: boolean;
/**
* Statute / practice-note link used as the learn-more reference for a
* `statutory_compliance_representation` field (surfaced in the field
* description and the rendered `[CONFIRM …; see <authority_url>]` bracket).
* Only valid on a `statutory_compliance_representation` field.
*/
authority_url?: string;
/**
* Short, human-readable reason rendered inside the
* `[CONFIRM before signing: <confirm_note>; see <authority_url>]` bracket of a
* `statutory_compliance_representation` field. This is the single source of
* truth for the bracket note — a `confirm=<field>` clause directive resolves
* it from here rather than restating it. Only valid on (and required for) a
* `statutory_compliance_representation` field.
*/
confirm_note?: string;
}
export declare const FieldDefinitionSchema: z.ZodType<FieldDefinition>;
/** Optional template provenance entry surfaced by CLI discovery output. */
declare const TemplateCreditSchema: z.ZodObject<{
name: z.ZodString;
role: z.ZodEnum<{
drafter: "drafter";
drafting_editor: "drafting_editor";
reviewer: "reviewer";
maintainer: "maintainer";
}>;
profile_url: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
/** Structured credit entry (name/role, optional profile_url) — shared with the
* template-listing projection so MCP/API output preserves the structure (#533). */
export type TemplateCredit = z.infer<typeof TemplateCreditSchema>;
export declare const TemplateCapabilityManifestSchema: z.ZodObject<{
artifact_kind: z.ZodDefault<z.ZodEnum<{
agreement: "agreement";
consent: "consent";
notice: "notice";
letter: "letter";
checklist: "checklist";
policy: "policy";
other: "other";
}>>;
capabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<{
create: "create";
review: "review";
render: "render";
}>>>;
party_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
signature_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
mutation_policy: z.ZodDefault<z.ZodEnum<{
terms: "terms";
fields_only: "fields_only";
immutable: "immutable";
}>>;
maturity: z.ZodDefault<z.ZodEnum<{
experimental: "experimental";
beta: "beta";
stable: "stable";
}>>;
}, z.core.$strip>;
export type TemplateCapabilityManifest = z.infer<typeof TemplateCapabilityManifestSchema>;
export declare const TemplateMetadataSchema: z.ZodObject<{
artifact_kind: z.ZodDefault<z.ZodEnum<{
agreement: "agreement";
consent: "consent";
notice: "notice";
letter: "letter";
checklist: "checklist";
policy: "policy";
other: "other";
}>>;
capabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<{
create: "create";
review: "review";
render: "render";
}>>>;
party_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
signature_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
mutation_policy: z.ZodDefault<z.ZodEnum<{
terms: "terms";
fields_only: "fields_only";
immutable: "immutable";
}>>;
maturity: z.ZodDefault<z.ZodEnum<{
experimental: "experimental";
beta: "beta";
stable: "stable";
}>>;
name: z.ZodString;
description: z.ZodOptional<z.ZodString>;
category: z.ZodOptional<z.ZodString>;
source_url: z.ZodString;
version: z.ZodString;
license: z.ZodEnum<{
"CC-BY-4.0": "CC-BY-4.0";
"CC0-1.0": "CC0-1.0";
"CC-BY-ND-4.0": "CC-BY-ND-4.0";
}>;
allow_derivatives: z.ZodBoolean;
attribution_text: z.ZodString;
distribution: z.ZodOptional<z.ZodEnum<{
bundled: "bundled";
linked: "linked";
}>>;
artifact_type: z.ZodOptional<z.ZodEnum<{
template: "template";
"field-selector": "field-selector";
}>>;
stability: z.ZodOptional<z.ZodEnum<{
experimental: "experimental";
beta: "beta";
stable: "stable";
}>>;
fields: z.ZodArray<z.ZodType<FieldDefinition, unknown, z.core.$ZodTypeInternals<FieldDefinition, unknown>>>;
priority_fields: z.ZodDefault<z.ZodArray<z.ZodString>>;
credits: z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
role: z.ZodEnum<{
drafter: "drafter";
drafting_editor: "drafting_editor";
reviewer: "reviewer";
maintainer: "maintainer";
}>;
profile_url: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>>;
derived_from: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export type TemplateMetadata = z.infer<typeof TemplateMetadataSchema>;
/**
* Metadata for vendored external templates.
*
* `source_sha256` records the checksum of the unmodified upstream document so
* validation can verify provenance for no-derivatives templates before local
* transient fills or CI license checks rely on that source.
*/
export declare const ExternalMetadataSchema: z.ZodObject<{
artifact_kind: z.ZodDefault<z.ZodEnum<{
agreement: "agreement";
consent: "consent";
notice: "notice";
letter: "letter";
checklist: "checklist";
policy: "policy";
other: "other";
}>>;
capabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<{
create: "create";
review: "review";
render: "render";
}>>>;
party_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
signature_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
mutation_policy: z.ZodDefault<z.ZodEnum<{
terms: "terms";
fields_only: "fields_only";
immutable: "immutable";
}>>;
maturity: z.ZodDefault<z.ZodEnum<{
experimental: "experimental";
beta: "beta";
stable: "stable";
}>>;
name: z.ZodString;
description: z.ZodOptional<z.ZodString>;
category: z.ZodOptional<z.ZodString>;
source_url: z.ZodString;
version: z.ZodString;
license: z.ZodEnum<{
"CC-BY-4.0": "CC-BY-4.0";
"CC0-1.0": "CC0-1.0";
"CC-BY-ND-4.0": "CC-BY-ND-4.0";
}>;
allow_derivatives: z.ZodBoolean;
attribution_text: z.ZodString;
distribution: z.ZodOptional<z.ZodEnum<{
bundled: "bundled";
linked: "linked";
}>>;
artifact_type: z.ZodOptional<z.ZodEnum<{
template: "template";
"field-selector": "field-selector";
}>>;
stability: z.ZodOptional<z.ZodEnum<{
experimental: "experimental";
beta: "beta";
stable: "stable";
}>>;
fields: z.ZodArray<z.ZodType<FieldDefinition, unknown, z.core.$ZodTypeInternals<FieldDefinition, unknown>>>;
priority_fields: z.ZodDefault<z.ZodArray<z.ZodString>>;
credits: z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
role: z.ZodEnum<{
drafter: "drafter";
drafting_editor: "drafting_editor";
reviewer: "reviewer";
maintainer: "maintainer";
}>;
profile_url: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>>;
derived_from: z.ZodOptional<z.ZodString>;
source_sha256: z.ZodString;
}, z.core.$strip>;
export type ExternalMetadata = z.infer<typeof ExternalMetadataSchema>;
/** Declarative cleaner configuration for fieldSelector DOCX preprocessing. */
export declare const CleanConfigSchema: z.ZodObject<{
removeFootnotes: z.ZodDefault<z.ZodBoolean>;
removeBeforePattern: z.ZodOptional<z.ZodString>;
removeParagraphPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
removeRanges: z.ZodDefault<z.ZodArray<z.ZodObject<{
start: z.ZodString;
end: z.ZodString;
}, z.core.$strip>>>;
clearParts: z.ZodDefault<z.ZodArray<z.ZodString>>;
removeStoryParagraphs: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodString;
part: z.ZodString;
pattern: z.ZodString;
expected_matches: z.ZodNumber;
}, z.core.$strip>>>;
removeHeaderFooterDrawings: z.ZodOptional<z.ZodBoolean>;
headerFooterDrawingMinBytes: z.ZodOptional<z.ZodNumber>;
removeEmptyLeadingParagraphs: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
export type CleanConfig = z.infer<typeof CleanConfigSchema>;
/**
* Whether a clean config performs any operation capable of removing (or
* exposing) body content — and can therefore strand a textless first body
* paragraph (blank first page/section). Used to gate the verifier's
* first-body-paragraph guard so cleaner capabilities and verifier coverage
* cannot silently diverge.
*
* `removeFootnotes` is deliberately excluded: it removes footnote-reference
* runs and footnote bodies, not body paragraphs; a first body paragraph whose
* only content is a footnote reference marker does not occur in practice.
* `clearParts` is excluded because it targets whole header/footer parts, not
* the document body.
*/
export declare function cleanConfigRemovesBodyContent(config: CleanConfig): boolean;
export declare const DeclarativeParagraphNormalizeRuleSchema: z.ZodObject<{
id: z.ZodString;
section_heading: z.ZodString;
section_heading_any: z.ZodOptional<z.ZodArray<z.ZodString>>;
ignore_heading: z.ZodOptional<z.ZodBoolean>;
paragraph_contains: z.ZodString;
paragraph_end_contains: z.ZodOptional<z.ZodString>;
replacements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
trim_unmatched_trailing_bracket: z.ZodOptional<z.ZodBoolean>;
expected_min_matches: z.ZodOptional<z.ZodNumber>;
expected_max_matches: z.ZodOptional<z.ZodNumber>;
source_drift: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
stage: z.ZodLiteral<"raw_source">;
}, z.core.$strict>, z.ZodObject<{
stage: z.ZodLiteral<"post_transform">;
prerequisites: z.ZodArray<z.ZodString>;
}, z.core.$strict>], "stage">>;
}, z.core.$strict>;
export type DeclarativeParagraphNormalizeRule = z.infer<typeof DeclarativeParagraphNormalizeRuleSchema>;
export declare const NumberingContinuationsSchema: z.ZodObject<{
source_sha256: z.ZodString;
source_num_id: z.ZodString;
headings: z.ZodArray<z.ZodObject<{
anchor: z.ZodString;
num_id: z.ZodString;
expected_abstract_num_id: z.ZodString;
ilvl: z.ZodNumber;
expected_starts: z.ZodRecord<z.ZodString, z.ZodNumber>;
}, z.core.$strict>>;
}, z.core.$strict>;
export type NumberingContinuations = z.infer<typeof NumberingContinuationsSchema>;
export declare const NormalizeConfigSchema: z.ZodObject<{
paragraph_rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
id: z.ZodString;
section_heading: z.ZodString;
section_heading_any: z.ZodOptional<z.ZodArray<z.ZodString>>;
ignore_heading: z.ZodOptional<z.ZodBoolean>;
paragraph_contains: z.ZodString;
paragraph_end_contains: z.ZodOptional<z.ZodString>;
replacements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
trim_unmatched_trailing_bracket: z.ZodOptional<z.ZodBoolean>;
expected_min_matches: z.ZodOptional<z.ZodNumber>;
expected_max_matches: z.ZodOptional<z.ZodNumber>;
source_drift: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
stage: z.ZodLiteral<"raw_source">;
}, z.core.$strict>, z.ZodObject<{
stage: z.ZodLiteral<"post_transform">;
prerequisites: z.ZodArray<z.ZodString>;
}, z.core.$strict>], "stage">>;
}, z.core.$strict>>>;
numbering_continuations: z.ZodOptional<z.ZodObject<{
source_sha256: z.ZodString;
source_num_id: z.ZodString;
headings: z.ZodArray<z.ZodObject<{
anchor: z.ZodString;
num_id: z.ZodString;
expected_abstract_num_id: z.ZodString;
ilvl: z.ZodNumber;
expected_starts: z.ZodRecord<z.ZodString, z.ZodNumber>;
}, z.core.$strict>>;
}, z.core.$strict>>;
}, z.core.$strict>;
export type NormalizeConfig = z.infer<typeof NormalizeConfigSchema>;
export declare const GuidanceEntrySchema: z.ZodObject<{
source: z.ZodEnum<{
pattern: "pattern";
footnote: "footnote";
range: "range";
}>;
part: z.ZodString;
index: z.ZodNumber;
text: z.ZodString;
groupId: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
export type GuidanceEntry = z.infer<typeof GuidanceEntrySchema>;
/** Machine-readable guidance artifact produced from fieldSelector cleaning inputs. */
export declare const GuidanceOutputSchema: z.ZodObject<{
extractedFrom: z.ZodObject<{
sourceHash: z.ZodString;
configHash: z.ZodString;
}, z.core.$strip>;
entries: z.ZodArray<z.ZodObject<{
source: z.ZodEnum<{
pattern: "pattern";
footnote: "footnote";
range: "range";
}>;
part: z.ZodString;
index: z.ZodNumber;
text: z.ZodString;
groupId: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
}, z.core.$strip>;
export type GuidanceOutput = z.infer<typeof GuidanceOutputSchema>;
/**
* Metadata required for field-selector-based templates.
*
* FieldSelectors point at non-redistributable upstream source DOCX files and ship only
* transformation instructions. Required fields are `name`, `source_url`,
* `source_version`, and `license_note`; `fields` and `priority_fields` reuse
* the same field-definition semantics as template metadata and default to
* empty arrays. `optional` defaults to `false`. `source_sha256` verifies
* provenance for upstream sources when present. `market_data_citations`
* records optional external citation metadata used by fieldSelector guidance.
*/
export declare const StyleSeparatorSpacingProfileSchema: z.ZodObject<{
boundaries: z.ZodArray<z.ZodObject<{
heading_para_id: z.ZodString;
continuation_para_id: z.ZodString;
before_twips: z.ZodNumber;
expected_layout_sha256: z.ZodString;
}, z.core.$strict>>;
}, z.core.$strict>;
export type StyleSeparatorSpacingProfile = z.infer<typeof StyleSeparatorSpacingProfileSchema>;
export declare const FieldSelectorMetadataSchema: z.ZodObject<{
artifact_kind: z.ZodDefault<z.ZodEnum<{
agreement: "agreement";
consent: "consent";
notice: "notice";
letter: "letter";
checklist: "checklist";
policy: "policy";
other: "other";
}>>;
capabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<{
create: "create";
review: "review";
render: "render";
}>>>;
party_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
signature_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
mutation_policy: z.ZodDefault<z.ZodEnum<{
terms: "terms";
fields_only: "fields_only";
immutable: "immutable";
}>>;
maturity: z.ZodDefault<z.ZodEnum<{
experimental: "experimental";
beta: "beta";
stable: "stable";
}>>;
name: z.ZodString;
category: z.ZodOptional<z.ZodString>;
description: z.ZodOptional<z.ZodString>;
source_url: z.ZodString;
source_version: z.ZodString;
license_note: z.ZodString;
optional: z.ZodDefault<z.ZodBoolean>;
distribution: z.ZodOptional<z.ZodEnum<{
bundled: "bundled";
linked: "linked";
}>>;
artifact_type: z.ZodOptional<z.ZodEnum<{
template: "template";
"field-selector": "field-selector";
}>>;
source_sha256: z.ZodOptional<z.ZodString>;
rendering: z.ZodOptional<z.ZodObject<{
style_separator_spacing: z.ZodObject<{
boundaries: z.ZodArray<z.ZodObject<{
heading_para_id: z.ZodString;
continuation_para_id: z.ZodString;
before_twips: z.ZodNumber;
expected_layout_sha256: z.ZodString;
}, z.core.$strict>>;
}, z.core.$strict>;
}, z.core.$strict>>;
fields: z.ZodDefault<z.ZodArray<z.ZodType<FieldDefinition, unknown, z.core.$ZodTypeInternals<FieldDefinition, unknown>>>>;
priority_fields: z.ZodDefault<z.ZodArray<z.ZodString>>;
market_data_citations: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodString;
label: z.ZodString;
url: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>>;
}, z.core.$strip>;
export type FieldSelectorMetadata = z.infer<typeof FieldSelectorMetadataSchema>;
export declare function loadMetadata(templateDir: string): TemplateMetadata;
export declare function validateMetadata(templateDir: string): {
valid: boolean;
errors: string[];
};
export declare function loadExternalMetadata(externalDir: string): ExternalMetadata;
export declare function validateExternalMetadata(externalDir: string): {
valid: boolean;
errors: string[];
};
export declare function loadFieldSelectorMetadata(fieldSelectorDir: string): FieldSelectorMetadata;
export declare function loadCleanConfig(fieldSelectorDir: string): CleanConfig;
export declare function loadNormalizeConfig(fieldSelectorDir: string): NormalizeConfig;
export declare function validateFieldSelectorMetadata(fieldSelectorDir: string): {
valid: boolean;
errors: string[];
};
export {};
//# sourceMappingURL=metadata.d.ts.map