From 592f722bbd53ededaac83a50508014a97183aa8c Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart Date: Mon, 29 Aug 2022 10:24:08 +0200 Subject: [PATCH] First packaging --- README.md | 2 +- src/lib/index.ts | 53 ++++++++++++++++++++++++++++++++++++++++++++ src/lib/legal.ts | 2 +- src/lib/summaries.ts | 8 +++---- svelte.config.js | 9 ++++++++ 5 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 src/lib/index.ts diff --git a/README.md b/README.md index ecdd5e6..ebc51e8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tricoteuses Legal Explorer -## _Web API & site to browse legal open data from French Direction de l'information légale et administrative (Dila)_ +## _Web API, site & library to browse legal open data from French Direction de l'information légale et administrative (Dila)_ _Tricoteuses Legal Explorer_ is free and open source software. diff --git a/src/lib/index.ts b/src/lib/index.ts new file mode 100644 index 0000000..ea9b235 --- /dev/null +++ b/src/lib/index.ts @@ -0,0 +1,53 @@ +export { + type Aggregate, + allFollows, + allFollowsMutable, + type Follow, + type GetArticleResult, + type GetRechercheResult, + type GetTexteResult, + type ListTextesResult, +} from "$lib/aggregates" + +export { default as ArticleView } from "$lib/components/ArticleView.svelte" + +export { default as LienView } from "$lib/components/LienView.svelte" + +export { default as SectionTaView } from "$lib/components/SectionTaView.svelte" + +export { default as TextelrView } from "$lib/components/TextelrView.svelte" + +export { default as TexteVersionView } from "$lib/components/TexteVersionView.svelte" + +export { + type Article, + type ArticleVersion, + bestItemForDate, + type Contexte, + type DossierLegislatif, + type Etat, + type Idcc, + type Jo, + type LegalObject, + type LegalObjectType, + type Lien, + type LienArt, + type LienSectionTa, + type MetaCommun, + type MetaTexteChronicle, + pathnameFromLegalId, + pathnameFromLegalObject, + pathnameFromLegalObjectTypeAndId, + rootTypeFromLegalId, + type SectionTa, + type Textekali, + type Textelr, + type TextelrVersion, + type TextelrVersionLienTxt, + type TexteVersion, + type TitreTm, + type TitreTxt, + type Tm, + type TmLienTxt, + type Versions, +} from "$lib/legal" diff --git a/src/lib/legal.ts b/src/lib/legal.ts index 7c502b2..4cd3645 100644 --- a/src/lib/legal.ts +++ b/src/lib/legal.ts @@ -440,7 +440,7 @@ export function pathnameFromLegalObject( } } -export function pathnameFromLegalObjectId( +export function pathnameFromLegalObjectTypeAndId( type: LegalObjectType, id: string, ): string { diff --git a/src/lib/summaries.ts b/src/lib/summaries.ts index 9433b49..f88d7ec 100644 --- a/src/lib/summaries.ts +++ b/src/lib/summaries.ts @@ -17,7 +17,7 @@ import { type LienSectionTa, pathnameFromLegalId, pathnameFromLegalObject, - pathnameFromLegalObjectId, + pathnameFromLegalObjectTypeAndId, type SectionTa, type Textekali, type Textelr, @@ -126,7 +126,7 @@ export const summarizeArticleProperties: Summarizer = (access, value) => { ], type: "concatenation", }, - href: pathnameFromLegalObjectId("article", lienArt["@id"]), + href: pathnameFromLegalObjectTypeAndId("article", lienArt["@id"]), type: "link", } } @@ -375,7 +375,7 @@ export const summarizeLienArt: Summarizer = (access, value) => { } return { content: `Article ${lienArt["@num"]}`, - href: pathnameFromLegalObjectId("article", lienArt["@id"]), + href: pathnameFromLegalObjectTypeAndId("article", lienArt["@id"]), type: "link", } } @@ -431,7 +431,7 @@ export const summarizeLienSectionTa: Summarizer = (access, value) => { } return { content: lienSectionTa["#text"], - href: pathnameFromLegalObjectId("section_ta", lienSectionTa["@id"]), + href: pathnameFromLegalObjectTypeAndId("section_ta", lienSectionTa["@id"]), type: "link", } } diff --git a/svelte.config.js b/svelte.config.js index 8cfa22a..6e13ffb 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -3,6 +3,15 @@ import preprocess from "svelte-preprocess" /** @type {import('@sveltejs/kit').Config} */ const config = { + package: { + exports: (filePath) => { + return !filePath.startsWith("scripts/") && !filePath.startsWith("server/") + }, + files: (filePath) => { + return !filePath.startsWith("scripts/") && !filePath.startsWith("server/") + }, + }, + // Consult https://github.com/sveltejs/svelte-preprocess // for more information about preprocessors preprocess: [