Initial commit
This commit is contained in:
commit
c534d5ce80
163 files changed
+11500
No files matched your search
@@ -0,0 +1,45 @@
|
||||
// ==========================================
|
||||
// APPLICATION: СБОРКА ДОКУМЕНТА
|
||||
// ==========================================
|
||||
#import "../domain/document.typ": document-context, render-options, validate-profile-contract
|
||||
#import "../domain/company.typ": validate-company
|
||||
#import "../domain/parties.typ": validate-parties
|
||||
#import "../domain/attachments.typ": attachment-set, validate-attachment-set
|
||||
#import "../domain/references.typ": validate-bibliographies
|
||||
#import "../infrastructure/company-assets.typ": load-company
|
||||
|
||||
#let resolve-company(value) = {
|
||||
if type(value) == str {
|
||||
validate-company(load-company(value))
|
||||
} else {
|
||||
validate-company(value)
|
||||
}
|
||||
}
|
||||
|
||||
#let render-document(
|
||||
body,
|
||||
company,
|
||||
profile,
|
||||
options: (:),
|
||||
) = {
|
||||
let company = resolve-company(company)
|
||||
let profile = validate-profile-contract(profile)
|
||||
let normalized = (profile.normalize)(profile.metadata)
|
||||
let validated = (profile.validate)(normalized)
|
||||
let metadata = if validated == none { normalized } else { validated }
|
||||
let parties = validate-parties(metadata.at("parties", default: ()))
|
||||
let attachments = validate-attachment-set(
|
||||
metadata.at("attachments", default: attachment-set()),
|
||||
)
|
||||
let bibliographies = validate-bibliographies(metadata.at("bibliographies", default: ()))
|
||||
let ctx = document-context(
|
||||
company,
|
||||
profile,
|
||||
metadata,
|
||||
render-options(options: options),
|
||||
parties: parties,
|
||||
attachments: attachments,
|
||||
bibliographies: bibliographies,
|
||||
)
|
||||
(profile.render)(body, ctx)
|
||||
}
|
||||
Reference in new issue
Block a user