@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.cjs
CHANGED
|
@@ -295,7 +295,7 @@ function createLibrary(sources, products) {
|
|
|
295
295
|
const src = byKey.get(`${opts.doc}:${opts.locale}`) ?? byKey.get(`${opts.doc}:${MASTER_LOCALE}`);
|
|
296
296
|
if (!src) throw new Error(`no document "${opts.doc}"`);
|
|
297
297
|
const master = byKey.get(`${opts.doc}:${MASTER_LOCALE}`);
|
|
298
|
-
const stale = src.locale !== MASTER_LOCALE && (!src.translationOf || !master || src.translationOf.sourceHash !== sourceHash(master));
|
|
298
|
+
const stale = opts.stale ?? (src.locale !== MASTER_LOCALE && (!src.translationOf || !master || src.translationOf.sourceHash !== sourceHash(master)));
|
|
299
299
|
const sections = src.sections.map((s) => ({
|
|
300
300
|
id: s.id,
|
|
301
301
|
heading: s.heading,
|
|
@@ -1723,7 +1723,9 @@ function getDocument(opts) {
|
|
|
1723
1723
|
}
|
|
1724
1724
|
function resolveTemplate(template, facts) {
|
|
1725
1725
|
const { doc, locale, title, version, effectiveFrom, material, draft, translationOf, sections } = template;
|
|
1726
|
-
|
|
1726
|
+
const master = SOURCES.find((s) => s.doc === doc && s.locale === MASTER_LOCALE);
|
|
1727
|
+
const stale = "stale" in template && typeof template.stale === "boolean" ? template.stale : locale !== MASTER_LOCALE && (!master || translationOf?.sourceHash !== sourceHash(master));
|
|
1728
|
+
return createLibrary([{ doc, locale, title, version, effectiveFrom, material, draft, translationOf, sections }], [facts]).getDocument({ doc, locale, product: facts.id, stale });
|
|
1727
1729
|
}
|
|
1728
1730
|
|
|
1729
1731
|
exports.BID_URL = BID_URL;
|