marc-ts 0.2.0 → 0.4.2

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.
@@ -0,0 +1,3 @@
1
+ function u(e,n,r,t){return{type:e,message:n,position:r,tag:t}}Object.defineProperty(exports,"createWarning",{enumerable:!0,get:function(){return u}});
2
+
3
+ //# sourceMappingURL=warnings-6yoB06xI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warnings-6yoB06xI.cjs","names":[],"sources":["../src/warnings.ts"],"sourcesContent":["/**\n * Warning system for MARC parsing.\n * Re-exports types and provides utility functions.\n */\n\nimport type { MarcWarning, MarcWarningType } from './types';\n\n/**\n * Create a warning object.\n *\n * @param type - The warning type\n * @param message - The warning message\n * @param position - Optional byte position in the record\n * @param tag - Optional field tag associated with the warning\n * @returns A MarcWarning object\n *\n * @example\n * ```typescript\n * const warning = createWarning(\n * 'invalid_leader',\n * 'Leader length is invalid',\n * 0,\n * undefined\n * );\n * ```\n */\nexport function createWarning(\n type: MarcWarningType,\n message: string,\n position?: number,\n tag?: string\n): MarcWarning {\n return { type, message, position, tag };\n}\n"],"mappings":"AA0BA,SAAgB,EACd,EACA,EACA,EACA,EACa,CACb,MAAO,CAAE,KAAA,EAAM,QAAA,EAAS,SAAA,EAAU,IAAA,CAAI,CACxC"}
@@ -0,0 +1,13 @@
1
+ function a(n, r, t, e) {
2
+ return {
3
+ type: n,
4
+ message: r,
5
+ position: t,
6
+ tag: e
7
+ };
8
+ }
9
+ export {
10
+ a as t
11
+ };
12
+
13
+ //# sourceMappingURL=warnings-Bt6wvWFe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warnings-Bt6wvWFe.js","names":[],"sources":["../src/warnings.ts"],"sourcesContent":["/**\n * Warning system for MARC parsing.\n * Re-exports types and provides utility functions.\n */\n\nimport type { MarcWarning, MarcWarningType } from './types';\n\n/**\n * Create a warning object.\n *\n * @param type - The warning type\n * @param message - The warning message\n * @param position - Optional byte position in the record\n * @param tag - Optional field tag associated with the warning\n * @returns A MarcWarning object\n *\n * @example\n * ```typescript\n * const warning = createWarning(\n * 'invalid_leader',\n * 'Leader length is invalid',\n * 0,\n * undefined\n * );\n * ```\n */\nexport function createWarning(\n type: MarcWarningType,\n message: string,\n position?: number,\n tag?: string\n): MarcWarning {\n return { type, message, position, tag };\n}\n"],"mappings":"AA0BA,SAAgB,EACd,GACA,GACA,GACA,GACa;AACb,SAAO;AAAA,IAAE,MAAA;AAAA,IAAM,SAAA;AAAA,IAAS,UAAA;AAAA,IAAU,KAAA;AAAA,EAAI;AACxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marc-ts",
3
- "version": "0.2.0",
3
+ "version": "0.4.2",
4
4
  "description": "TypeScript MARC21 library for Node.js and browsers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "homepage": "https://github.com/jamesrf/marc-ts#readme",
71
71
  "engines": {
72
- "node": ">=20.19.0"
72
+ "node": ">=24"
73
73
  },
74
74
  "browser": {
75
75
  "buffer": false
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-CJcxHJff.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Core type definitions for MARC21 records.\n * All types use readonly modifiers to enforce immutability.\n */\n\n/**\n * A subfield within a MARC data field.\n * Contains a single-character code and its associated value.\n *\n * @example\n * ```typescript\n * const subfield: Subfield = { code: 'a', value: 'The Catcher in the Rye' };\n * ```\n */\nexport interface Subfield {\n readonly code: string;\n readonly value: string;\n}\n\n/**\n * A MARC control field (tag 00X).\n * Control fields have no indicators or subfields, only a tag and data.\n *\n * @example\n * ```typescript\n * const controlField: ControlField = { tag: '001', data: 'ocm12345678' };\n * ```\n */\nexport interface ControlField {\n readonly tag: string;\n readonly data: string;\n}\n\n/**\n * A MARC data field (tag 01X-9XX).\n * Data fields have a tag, two indicators, and one or more subfields.\n *\n * @example\n * ```typescript\n * const dataField: DataField = {\n * tag: '245',\n * indicator1: '1',\n * indicator2: '0',\n * subfields: [\n * { code: 'a', value: 'The Catcher in the Rye /' },\n * { code: 'c', value: 'J.D. Salinger.' },\n * ],\n * };\n * ```\n */\nexport interface DataField {\n readonly tag: string;\n readonly indicator1: string; // Use ' ' for blank indicator\n readonly indicator2: string; // Use ' ' for blank indicator\n readonly subfields: readonly Subfield[];\n}\n\n/**\n * A complete MARC21 record.\n * Contains a 24-character leader and an array of fields (control or data fields).\n *\n * @example\n * ```typescript\n * const record: MarcRecord = {\n * leader: '00000nam 2200000 4500',\n * fields: [\n * { tag: '001', data: 'ocm12345678' },\n * {\n * tag: '245',\n * indicator1: '1',\n * indicator2: '0',\n * subfields: [{ code: 'a', value: 'Title' }],\n * },\n * ],\n * };\n * ```\n */\nexport interface MarcRecord {\n readonly leader: string; // Always 24 characters\n readonly fields: readonly (ControlField | DataField)[];\n}\n\n/**\n * Warning type categories for MARC parsing errors.\n */\nexport type MarcWarningType =\n | 'invalid_leader'\n | 'invalid_directory'\n | 'invalid_field'\n | 'truncated_record'\n | 'encoding_error';\n\n/**\n * A warning generated during MARC record parsing.\n * Warnings indicate non-fatal issues that were encountered and recovered from.\n */\nexport interface MarcWarning {\n readonly type: MarcWarningType;\n readonly message: string;\n readonly position?: number; // Byte position in the record\n readonly tag?: string; // Field tag associated with the warning\n}\n\n/**\n * Options for parsing MARC records.\n */\nexport interface ParseOptions {\n /**\n * If true, throw errors instead of collecting warnings.\n * Default: false\n */\n readonly strict?: boolean;\n\n /**\n * Maximum number of warnings to collect before stopping.\n * Prevents memory issues with severely malformed records.\n * Default: 100\n */\n readonly maxWarnings?: number;\n}\n\n/**\n * Result of parsing a MARC record.\n * Contains the parsed record (if successful) and any warnings encountered.\n */\nexport interface ParseResult {\n readonly record: MarcRecord | null;\n readonly warnings: readonly MarcWarning[];\n}\n\n/**\n * Type guard to check if a field is a control field.\n *\n * @param field - The field to check\n * @returns True if the field is a control field\n *\n * @example\n * ```typescript\n * if (isControlField(field)) {\n * console.log(field.data); // TypeScript knows field is ControlField\n * }\n * ```\n */\nexport function isControlField(field: ControlField | DataField): field is ControlField {\n return 'data' in field;\n}\n\n/**\n * Type guard to check if a field is a data field.\n *\n * @param field - The field to check\n * @returns True if the field is a data field\n *\n * @example\n * ```typescript\n * if (isDataField(field)) {\n * console.log(field.subfields); // TypeScript knows field is DataField\n * }\n * ```\n */\nexport function isDataField(field: ControlField | DataField): field is DataField {\n return 'subfields' in field;\n}\n"],"mappings":"AA+IA,SAAgB,EAAe,EAAwD,CACrF,MAAO,SAAU,CACnB,CAeA,SAAgB,EAAY,EAAqD,CAC/E,MAAO,cAAe,CACxB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-c4Mo9m9u.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Core type definitions for MARC21 records.\n * All types use readonly modifiers to enforce immutability.\n */\n\n/**\n * A subfield within a MARC data field.\n * Contains a single-character code and its associated value.\n *\n * @example\n * ```typescript\n * const subfield: Subfield = { code: 'a', value: 'The Catcher in the Rye' };\n * ```\n */\nexport interface Subfield {\n readonly code: string;\n readonly value: string;\n}\n\n/**\n * A MARC control field (tag 00X).\n * Control fields have no indicators or subfields, only a tag and data.\n *\n * @example\n * ```typescript\n * const controlField: ControlField = { tag: '001', data: 'ocm12345678' };\n * ```\n */\nexport interface ControlField {\n readonly tag: string;\n readonly data: string;\n}\n\n/**\n * A MARC data field (tag 01X-9XX).\n * Data fields have a tag, two indicators, and one or more subfields.\n *\n * @example\n * ```typescript\n * const dataField: DataField = {\n * tag: '245',\n * indicator1: '1',\n * indicator2: '0',\n * subfields: [\n * { code: 'a', value: 'The Catcher in the Rye /' },\n * { code: 'c', value: 'J.D. Salinger.' },\n * ],\n * };\n * ```\n */\nexport interface DataField {\n readonly tag: string;\n readonly indicator1: string; // Use ' ' for blank indicator\n readonly indicator2: string; // Use ' ' for blank indicator\n readonly subfields: readonly Subfield[];\n}\n\n/**\n * A complete MARC21 record.\n * Contains a 24-character leader and an array of fields (control or data fields).\n *\n * @example\n * ```typescript\n * const record: MarcRecord = {\n * leader: '00000nam 2200000 4500',\n * fields: [\n * { tag: '001', data: 'ocm12345678' },\n * {\n * tag: '245',\n * indicator1: '1',\n * indicator2: '0',\n * subfields: [{ code: 'a', value: 'Title' }],\n * },\n * ],\n * };\n * ```\n */\nexport interface MarcRecord {\n readonly leader: string; // Always 24 characters\n readonly fields: readonly (ControlField | DataField)[];\n}\n\n/**\n * Warning type categories for MARC parsing errors.\n */\nexport type MarcWarningType =\n | 'invalid_leader'\n | 'invalid_directory'\n | 'invalid_field'\n | 'truncated_record'\n | 'encoding_error';\n\n/**\n * A warning generated during MARC record parsing.\n * Warnings indicate non-fatal issues that were encountered and recovered from.\n */\nexport interface MarcWarning {\n readonly type: MarcWarningType;\n readonly message: string;\n readonly position?: number; // Byte position in the record\n readonly tag?: string; // Field tag associated with the warning\n}\n\n/**\n * Options for parsing MARC records.\n */\nexport interface ParseOptions {\n /**\n * If true, throw errors instead of collecting warnings.\n * Default: false\n */\n readonly strict?: boolean;\n\n /**\n * Maximum number of warnings to collect before stopping.\n * Prevents memory issues with severely malformed records.\n * Default: 100\n */\n readonly maxWarnings?: number;\n}\n\n/**\n * Result of parsing a MARC record.\n * Contains the parsed record (if successful) and any warnings encountered.\n */\nexport interface ParseResult {\n readonly record: MarcRecord | null;\n readonly warnings: readonly MarcWarning[];\n}\n\n/**\n * Type guard to check if a field is a control field.\n *\n * @param field - The field to check\n * @returns True if the field is a control field\n *\n * @example\n * ```typescript\n * if (isControlField(field)) {\n * console.log(field.data); // TypeScript knows field is ControlField\n * }\n * ```\n */\nexport function isControlField(field: ControlField | DataField): field is ControlField {\n return 'data' in field;\n}\n\n/**\n * Type guard to check if a field is a data field.\n *\n * @param field - The field to check\n * @returns True if the field is a data field\n *\n * @example\n * ```typescript\n * if (isDataField(field)) {\n * console.log(field.subfields); // TypeScript knows field is DataField\n * }\n * ```\n */\nexport function isDataField(field: ControlField | DataField): field is DataField {\n return 'subfields' in field;\n}\n"],"mappings":"AA+IA,SAAgB,EAAe,GAAwD;AACrF,SAAO,UAAU;AACnB;AAeA,SAAgB,EAAY,GAAqD;AAC/E,SAAO,eAAe;AACxB"}