glossarist 0.4.11 → 0.4.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glossarist",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "JavaScript SDK for Glossarist GCR packages — read, write, validate, and manage terminology concepts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -33,8 +33,8 @@ const RDFS = {
33
33
  seeAlso: `${RDFS_NS}seeAlso`,
34
34
  };
35
35
 
36
- const DEFAULT_AGENT_BASE = 'https://glossarist.org/agent';
37
- const DEFAULT_ORG_BASE = 'https://glossarist.org/org';
36
+ // No hardcoded default agent/org base URIs. Callers MUST pass agentBase
37
+ // explicitly so agent IRIs reflect the consumer's domain.
38
38
 
39
39
  /**
40
40
  * @typedef {Object} Contributor
@@ -64,7 +64,8 @@ export function slugify(input) {
64
64
  * Builds AgentInput records from raw contributor declarations.
65
65
  * Useful for callers that want to inspect the IRIs before emission.
66
66
  */
67
- export function agentsFromContributors(contributors, agentBase = DEFAULT_AGENT_BASE) {
67
+ export function agentsFromContributors(contributors, agentBase) {
68
+ if (!agentBase) throw new Error('agentsFromContributors requires agentBase — the deployment canonical URI root for agents (e.g. https://www.example.org/agent). glossarist-js does NOT default to glossarist.org.');
68
69
  return (contributors ?? []).map(c => {
69
70
  const slug = slugify(c.name);
70
71
  return {
@@ -92,7 +93,8 @@ export function agentsFromContributors(contributors, agentBase = DEFAULT_AGENT_B
92
93
  * @returns {Generator<Quad, void, unknown>}
93
94
  */
94
95
  export function* agentsToQuads(agents, options = {}) {
95
- const orgBase = options.orgBase ?? DEFAULT_ORG_BASE;
96
+ const orgBase = options.orgBase;
97
+ if (!orgBase) throw new Error('agentsToQuads requires options.orgBase — the deployment canonical URI root for organizations.');
96
98
  const emittedOrgs = new Set();
97
99
 
98
100
  for (const a of agents ?? []) {
@@ -28,7 +28,8 @@ const FOAF = {
28
28
  page: `${FOAF_NS}page`,
29
29
  };
30
30
 
31
- const DEFAULT_BASE_URI = 'https://glossarist.org';
31
+ // No hardcoded default base URI. Callers MUST pass baseUri explicitly
32
+ // so instance IRIs reflect the consumer's domain, not the library's.
32
33
 
33
34
  /**
34
35
  * @typedef {Object} BibliographyEntry
@@ -52,7 +53,8 @@ const DEFAULT_BASE_URI = 'https://glossarist.org';
52
53
  * @param {string} entryId
53
54
  * @param {string} [baseUri]
54
55
  */
55
- export function bibliographyEntryIri(registerId, entryId, baseUri = DEFAULT_BASE_URI) {
56
+ export function bibliographyEntryIri(registerId, entryId, baseUri) {
57
+ if (!baseUri) throw new Error('bibliographyEntryIri requires baseUri — the deployment canonical URI root. glossarist-js does NOT default to glossarist.org because instance data identity must reflect the consumer domain.');
56
58
  return `${baseUri}/${registerId}/bib/${entryId}`;
57
59
  }
58
60
 
@@ -64,7 +66,8 @@ export function bibliographyEntryIri(registerId, entryId, baseUri = DEFAULT_BASE
64
66
  * @returns {Generator<Quad, void, unknown>}
65
67
  */
66
68
  export function* bibliographyToQuads(input) {
67
- const baseUri = input.baseUri ?? DEFAULT_BASE_URI;
69
+ const baseUri = input.baseUri;
70
+ if (!baseUri) throw new Error('bibliographyToQuads requires input.baseUri — the deployment canonical URI root.');
68
71
  const parentIri = `${baseUri}/${input.registerId}/`;
69
72
 
70
73
  for (const entry of input.entries ?? []) {
@@ -76,7 +76,8 @@ export function buildActivityIri(input) {
76
76
  * @returns {Generator<Quad, void, unknown>}
77
77
  */
78
78
  export function* buildActivityToQuads(input) {
79
- const baseUri = input.baseUri ?? 'https://glossarist.org';
79
+ const baseUri = input.baseUri;
80
+ if (!baseUri) throw new Error('buildActivityToQuads requires input.baseUri — the deployment canonical URI root. glossarist-js does NOT default to glossarist.org because instance data identity must reflect the consumer domain.');
80
81
  const activityIri = `${baseUri}/${buildActivityIri(input)}`;
81
82
  const activity = namedNode(activityIri);
82
83
 
@@ -28,7 +28,7 @@ const DCAT = {
28
28
  };
29
29
  const XSD_INTEGER = `${XSD_NS}integer`;
30
30
 
31
- const DEFAULT_BASE_URI = 'https://glossarist.org';
31
+ // No hardcoded default base URI. Callers MUST pass baseUri explicitly.
32
32
 
33
33
  /**
34
34
  * @typedef {'svg' | 'png' | 'webp' | 'jpg' | 'gif'} ImageFormat
@@ -55,7 +55,8 @@ const MIME_BY_FORMAT = Object.freeze({
55
55
  * Returns the canonical IRI for an image variant. Includes the lang
56
56
  * segment when the variant is localized, otherwise omits it.
57
57
  */
58
- export function imageVariantIri(input, baseUri = DEFAULT_BASE_URI) {
58
+ export function imageVariantIri(input, baseUri) {
59
+ if (!baseUri) throw new Error('imageVariantIri requires baseUri — the deployment canonical URI root.');
59
60
  const langSuffix = input.lang ? `${input.lang}.` : '';
60
61
  return `${baseUri}/${input.registerId}/image/${input.figureId}/${langSuffix}${input.format}`;
61
62
  }
@@ -63,7 +64,8 @@ export function imageVariantIri(input, baseUri = DEFAULT_BASE_URI) {
63
64
  /**
64
65
  * Emits foaf:Image quads for one image variant.
65
66
  */
66
- export function* imageVariantToQuads(input, baseUri = DEFAULT_BASE_URI) {
67
+ export function* imageVariantToQuads(input, baseUri) {
68
+ if (!baseUri) throw new Error('imageVariantToQuads requires baseUri — the deployment canonical URI root.');
67
69
  const img = namedNode(imageVariantIri(input, baseUri));
68
70
  yield quad(img, namedNode(RDF_TYPE), namedNode(FOAF.Image));
69
71
  yield quad(img, namedNode(DCTERMS.format), literal(MIME_BY_FORMAT[input.format] ?? 'application/octet-stream'));
@@ -16,7 +16,8 @@ import {
16
16
  writeJsonld,
17
17
  } from '../rdf/document-writer.js';
18
18
 
19
- const DEFAULT_URI_BASE = 'https://glossarist.org';
19
+ // No hardcoded default URI base. Callers MUST pass options.uriBase so
20
+ // concept IRIs reflect the consumer's domain.
20
21
 
21
22
  // Writer registry. Each entry is `{ write: (quads, transform) => Promise<string> }`.
22
23
  // Adding a new output format is a single entry here, not six new methods.
@@ -29,7 +30,8 @@ const WRITERS = Object.freeze({
29
30
  export class ConceptToGlossTransform {
30
31
  constructor(options = {}) {
31
32
  this.registerId = options.registerId;
32
- this.uriBase = (options.uriBase ?? DEFAULT_URI_BASE).replace(/\/+$/, '');
33
+ this.uriBase = options.uriBase?.replace(/\/+$/, '');
34
+ if (!this.uriBase) throw new Error('ConceptToGlossTransform requires options.uriBase — the deployment canonical URI root.');
33
35
  this.jsonldContext = options.jsonldContext;
34
36
  }
35
37