@broberg/legal 0.8.0 → 0.8.1
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/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -161,6 +161,7 @@ declare function createLibrary(sources: DocumentSource[], products: ProductFacts
|
|
|
161
161
|
doc: DocId;
|
|
162
162
|
locale: Locale;
|
|
163
163
|
product: string;
|
|
164
|
+
stale?: boolean;
|
|
164
165
|
}) => LegalDocument;
|
|
165
166
|
products: () => string[];
|
|
166
167
|
sources: () => DocumentSource[];
|
|
@@ -316,6 +317,6 @@ declare function getDocument(opts: {
|
|
|
316
317
|
facts: ProductFacts;
|
|
317
318
|
}): LegalDocument;
|
|
318
319
|
/** A finished document from a template you fetched from the API + your own facts. */
|
|
319
|
-
declare function resolveTemplate(template: DocumentSource, facts: ProductFacts): LegalDocument;
|
|
320
|
+
declare function resolveTemplate(template: DocumentSource | LegalTemplate, facts: ProductFacts): LegalDocument;
|
|
320
321
|
|
|
321
322
|
export { type AcceptanceRecord, type AcceptedDoc, BID_URL, type BidCallOptions, BidConsentError, type Block, type ConsentRecord, DEFAULT_REFRESH_MS, DOC_IDS, type DocId, type DocumentSource, EXAMPLE_FACTS, type FactKey, LEGAL_API_URL, type LegalCacheOptions, type LegalDocument, type LegalTemplate, type Locale, MASTER_LOCALE, type ModuleTermsFacts, PLACEHOLDERS, type Placeholder, type ProductFacts, type ResolvedBlock, type ResolvedSection, SOURCES, type Section, canonicalJson, createLegalCache, createLibrary, getAcceptance, getConsent, getDocument, getTemplate, listDocuments, needsReaccept, parityProblems, placeholdersIn, recordAcceptance, recordConsent, renderHtml, resolveTemplate, sha256Hex, sourceHash, templateHash, toBidHash, verifyTemplate };
|
package/dist/index.d.ts
CHANGED
|
@@ -161,6 +161,7 @@ declare function createLibrary(sources: DocumentSource[], products: ProductFacts
|
|
|
161
161
|
doc: DocId;
|
|
162
162
|
locale: Locale;
|
|
163
163
|
product: string;
|
|
164
|
+
stale?: boolean;
|
|
164
165
|
}) => LegalDocument;
|
|
165
166
|
products: () => string[];
|
|
166
167
|
sources: () => DocumentSource[];
|
|
@@ -316,6 +317,6 @@ declare function getDocument(opts: {
|
|
|
316
317
|
facts: ProductFacts;
|
|
317
318
|
}): LegalDocument;
|
|
318
319
|
/** A finished document from a template you fetched from the API + your own facts. */
|
|
319
|
-
declare function resolveTemplate(template: DocumentSource, facts: ProductFacts): LegalDocument;
|
|
320
|
+
declare function resolveTemplate(template: DocumentSource | LegalTemplate, facts: ProductFacts): LegalDocument;
|
|
320
321
|
|
|
321
322
|
export { type AcceptanceRecord, type AcceptedDoc, BID_URL, type BidCallOptions, BidConsentError, type Block, type ConsentRecord, DEFAULT_REFRESH_MS, DOC_IDS, type DocId, type DocumentSource, EXAMPLE_FACTS, type FactKey, LEGAL_API_URL, type LegalCacheOptions, type LegalDocument, type LegalTemplate, type Locale, MASTER_LOCALE, type ModuleTermsFacts, PLACEHOLDERS, type Placeholder, type ProductFacts, type ResolvedBlock, type ResolvedSection, SOURCES, type Section, canonicalJson, createLegalCache, createLibrary, getAcceptance, getConsent, getDocument, getTemplate, listDocuments, needsReaccept, parityProblems, placeholdersIn, recordAcceptance, recordConsent, renderHtml, resolveTemplate, sha256Hex, sourceHash, templateHash, toBidHash, verifyTemplate };
|
package/dist/index.js
CHANGED
|
@@ -293,7 +293,7 @@ function createLibrary(sources, products) {
|
|
|
293
293
|
const src = byKey.get(`${opts.doc}:${opts.locale}`) ?? byKey.get(`${opts.doc}:${MASTER_LOCALE}`);
|
|
294
294
|
if (!src) throw new Error(`no document "${opts.doc}"`);
|
|
295
295
|
const master = byKey.get(`${opts.doc}:${MASTER_LOCALE}`);
|
|
296
|
-
const stale = src.locale !== MASTER_LOCALE && (!src.translationOf || !master || src.translationOf.sourceHash !== sourceHash(master));
|
|
296
|
+
const stale = opts.stale ?? (src.locale !== MASTER_LOCALE && (!src.translationOf || !master || src.translationOf.sourceHash !== sourceHash(master)));
|
|
297
297
|
const sections = src.sections.map((s) => ({
|
|
298
298
|
id: s.id,
|
|
299
299
|
heading: s.heading,
|
|
@@ -1721,7 +1721,9 @@ function getDocument(opts) {
|
|
|
1721
1721
|
}
|
|
1722
1722
|
function resolveTemplate(template, facts) {
|
|
1723
1723
|
const { doc, locale, title, version, effectiveFrom, material, draft, translationOf, sections } = template;
|
|
1724
|
-
|
|
1724
|
+
const master = SOURCES.find((s) => s.doc === doc && s.locale === MASTER_LOCALE);
|
|
1725
|
+
const stale = "stale" in template && typeof template.stale === "boolean" ? template.stale : locale !== MASTER_LOCALE && (!master || translationOf?.sourceHash !== sourceHash(master));
|
|
1726
|
+
return createLibrary([{ doc, locale, title, version, effectiveFrom, material, draft, translationOf, sections }], [facts]).getDocument({ doc, locale, product: facts.id, stale });
|
|
1725
1727
|
}
|
|
1726
1728
|
|
|
1727
1729
|
export { BID_URL, BidConsentError, DEFAULT_REFRESH_MS, DOC_IDS, EXAMPLE_FACTS, LEGAL_API_URL, MASTER_LOCALE, PLACEHOLDERS, SOURCES, canonicalJson, createLegalCache, createLibrary, getAcceptance, getConsent, getDocument, getTemplate, listDocuments, needsReaccept, parityProblems, placeholdersIn, recordAcceptance, recordConsent, renderHtml, resolveTemplate, sha256Hex, sourceHash, templateHash, toBidHash, verifyTemplate };
|