glost 0.4.0 → 0.5.0

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.
Files changed (67) hide show
  1. package/README.md +253 -114
  2. package/dist/index.d.ts +29 -8
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +38 -24
  5. package/dist/index.js.map +1 -1
  6. package/dist/presets.d.ts +7 -0
  7. package/dist/presets.d.ts.map +1 -0
  8. package/dist/presets.js +7 -0
  9. package/dist/presets.js.map +1 -0
  10. package/dist/processor.d.ts +8 -0
  11. package/dist/processor.d.ts.map +1 -0
  12. package/dist/processor.js +7 -0
  13. package/dist/processor.js.map +1 -0
  14. package/dist/registry.d.ts +8 -0
  15. package/dist/registry.d.ts.map +1 -0
  16. package/dist/registry.js +7 -0
  17. package/dist/registry.js.map +1 -0
  18. package/package.json +27 -40
  19. package/src/index.ts +126 -69
  20. package/src/presets.ts +18 -0
  21. package/src/processor.ts +24 -0
  22. package/src/registry.ts +23 -0
  23. package/tsconfig.json +6 -3
  24. package/CHANGELOG.md +0 -296
  25. package/dist/cli/migrate.d.ts +0 -8
  26. package/dist/cli/migrate.d.ts.map +0 -1
  27. package/dist/cli/migrate.js +0 -229
  28. package/dist/cli/migrate.js.map +0 -1
  29. package/dist/errors.d.ts +0 -168
  30. package/dist/errors.d.ts.map +0 -1
  31. package/dist/errors.js +0 -300
  32. package/dist/errors.js.map +0 -1
  33. package/dist/example.d.ts +0 -10
  34. package/dist/example.d.ts.map +0 -1
  35. package/dist/example.js +0 -138
  36. package/dist/example.js.map +0 -1
  37. package/dist/guards.d.ts +0 -103
  38. package/dist/guards.d.ts.map +0 -1
  39. package/dist/guards.js +0 -264
  40. package/dist/guards.js.map +0 -1
  41. package/dist/nodes.d.ts +0 -163
  42. package/dist/nodes.d.ts.map +0 -1
  43. package/dist/nodes.js +0 -185
  44. package/dist/nodes.js.map +0 -1
  45. package/dist/types.d.ts +0 -395
  46. package/dist/types.d.ts.map +0 -1
  47. package/dist/types.js +0 -6
  48. package/dist/types.js.map +0 -1
  49. package/dist/utils.d.ts +0 -203
  50. package/dist/utils.d.ts.map +0 -1
  51. package/dist/utils.js +0 -497
  52. package/dist/utils.js.map +0 -1
  53. package/dist/validators.d.ts +0 -1876
  54. package/dist/validators.d.ts.map +0 -1
  55. package/dist/validators.js +0 -302
  56. package/dist/validators.js.map +0 -1
  57. package/src/__tests__/README.md +0 -20
  58. package/src/__tests__/example.test.ts +0 -43
  59. package/src/__tests__/example.ts +0 -186
  60. package/src/__tests__/mock-data.ts +0 -624
  61. package/src/cli/migrate.ts +0 -294
  62. package/src/errors.ts +0 -394
  63. package/src/guards.ts +0 -341
  64. package/src/nodes.ts +0 -326
  65. package/src/types.ts +0 -581
  66. package/src/utils.ts +0 -652
  67. package/src/validators.ts +0 -336
package/dist/errors.js DELETED
@@ -1,300 +0,0 @@
1
- /**
2
- * GLOST Error Classes
3
- *
4
- * Comprehensive error handling with context, suggestions, and helpful messages
5
- *
6
- * @packageDocumentation
7
- */
8
- /**
9
- * Base class for all GLOST errors
10
- */
11
- export class GLOSTError extends Error {
12
- context;
13
- constructor(message, context = {}) {
14
- super(message);
15
- this.name = 'GLOSTError';
16
- this.context = context;
17
- // Maintain proper stack trace
18
- if (Error.captureStackTrace) {
19
- Error.captureStackTrace(this, this.constructor);
20
- }
21
- }
22
- /**
23
- * Format error message with context
24
- */
25
- toString() {
26
- const parts = [];
27
- // Header
28
- parts.push(`${this.name}: ${this.message}`);
29
- parts.push('');
30
- // Location information
31
- if (this.context.path) {
32
- parts.push(` Location: ${this.context.path.join('.')}`);
33
- }
34
- if (this.context.file) {
35
- parts.push(` File: ${this.context.file}`);
36
- }
37
- if (this.context.node) {
38
- parts.push(` Node type: ${this.context.node.type || 'unknown'}`);
39
- }
40
- // Suggestion
41
- if (this.context.suggestion) {
42
- parts.push('');
43
- parts.push(` Suggestion: ${this.context.suggestion}`);
44
- }
45
- // Documentation link
46
- if (this.context.docsUrl) {
47
- parts.push('');
48
- parts.push(` Documentation: ${this.context.docsUrl}`);
49
- }
50
- // Stack trace
51
- if (this.stack) {
52
- parts.push('');
53
- parts.push(' Stack trace:');
54
- const stackLines = this.stack.split('\n').slice(1); // Skip first line (message)
55
- parts.push(...stackLines.map(line => ` ${line}`));
56
- }
57
- return parts.join('\n');
58
- }
59
- /**
60
- * Get a concise error summary
61
- */
62
- toSummary() {
63
- let summary = `${this.name}: ${this.message}`;
64
- if (this.context.path) {
65
- summary += ` (at ${this.context.path.join('.')})`;
66
- }
67
- return summary;
68
- }
69
- }
70
- /**
71
- * Validation error for schema violations
72
- */
73
- export class GLOSTValidationError extends GLOSTError {
74
- constructor(message, context = {}) {
75
- super(message, context);
76
- this.name = 'GLOSTValidationError';
77
- }
78
- toString() {
79
- const parts = [];
80
- parts.push(`${this.name}: ${this.message}`);
81
- parts.push('');
82
- // Location
83
- if (this.context.path) {
84
- const location = this.context.path.length > 0
85
- ? this.context.path.join('.')
86
- : 'root';
87
- parts.push(` Location: ${location}`);
88
- }
89
- if (this.context.node) {
90
- const node = this.context.node;
91
- parts.push(` Node type: ${node.type || 'unknown'}`);
92
- }
93
- if (this.context.file) {
94
- parts.push(` File: ${this.context.file}`);
95
- }
96
- // Expected vs Received
97
- if (this.context.expected) {
98
- parts.push('');
99
- parts.push(` Expected: ${JSON.stringify(this.context.expected, null, 2)}`);
100
- }
101
- if (this.context.received) {
102
- parts.push(` Received: ${JSON.stringify(this.context.received, null, 2)}`);
103
- }
104
- // Problem explanation
105
- if (this.context.problem) {
106
- parts.push('');
107
- parts.push(` Problem: ${this.context.problem}`);
108
- }
109
- // Suggestion
110
- if (this.context.suggestion) {
111
- parts.push('');
112
- parts.push(` Suggestion: ${this.context.suggestion}`);
113
- }
114
- // Documentation
115
- if (this.context.docsUrl) {
116
- parts.push('');
117
- parts.push(` Documentation: ${this.context.docsUrl}`);
118
- }
119
- return parts.join('\n');
120
- }
121
- }
122
- /**
123
- * Error for missing required fields
124
- */
125
- export class GLOSTMissingFieldError extends GLOSTValidationError {
126
- constructor(fieldName, nodeType, context = {}) {
127
- const message = `Missing required field '${fieldName}' on ${nodeType}`;
128
- super(message, {
129
- ...context,
130
- problem: `${nodeType} must have a '${fieldName}' field.`,
131
- docsUrl: context.docsUrl || `https://glost.dev/docs/node-types#${nodeType.toLowerCase()}`,
132
- });
133
- this.name = 'GLOSTMissingFieldError';
134
- }
135
- }
136
- /**
137
- * Error for invalid field types
138
- */
139
- export class GLOSTInvalidTypeError extends GLOSTValidationError {
140
- constructor(fieldName, expectedType, receivedType, context = {}) {
141
- const message = `Invalid type for field '${fieldName}': expected ${expectedType}, got ${receivedType}`;
142
- super(message, {
143
- ...context,
144
- problem: `Field '${fieldName}' must be of type ${expectedType}.`,
145
- suggestion: `Convert the value to ${expectedType} or check your data source.`,
146
- });
147
- this.name = 'GLOSTInvalidTypeError';
148
- }
149
- }
150
- /**
151
- * Error for invalid language codes
152
- */
153
- export class GLOSTInvalidLanguageCodeError extends GLOSTValidationError {
154
- constructor(code, context = {}) {
155
- const message = `Invalid language code: "${code}"`;
156
- super(message, {
157
- ...context,
158
- problem: `Language codes must follow BCP-47 format (e.g., "en-US", "th-TH").`,
159
- suggestion: `Use normalizeLanguageCode() from glost-common to convert "${code}" to a valid format.`,
160
- docsUrl: context.docsUrl || 'https://glost.dev/docs/languages#bcp-47',
161
- });
162
- this.name = 'GLOSTInvalidLanguageCodeError';
163
- }
164
- }
165
- /**
166
- * Error for extension processing
167
- */
168
- export class GLOSTExtensionError extends GLOSTError {
169
- constructor(extensionName, message, context = {}) {
170
- super(`[${extensionName}] ${message}`, context);
171
- this.name = 'GLOSTExtensionError';
172
- }
173
- }
174
- /**
175
- * Error for provider issues
176
- */
177
- export class GLOSTProviderError extends GLOSTError {
178
- constructor(providerName, message, context = {}) {
179
- super(`[${providerName} Provider] ${message}`, context);
180
- this.name = 'GLOSTProviderError';
181
- }
182
- }
183
- /**
184
- * Error for document parsing
185
- */
186
- export class GLOSTParseError extends GLOSTError {
187
- constructor(message, context = {}) {
188
- super(message, context);
189
- this.name = 'GLOSTParseError';
190
- }
191
- }
192
- /**
193
- * Error for serialization issues
194
- */
195
- export class GLOSTSerializationError extends GLOSTError {
196
- constructor(message, context = {}) {
197
- super(message, context);
198
- this.name = 'GLOSTSerializationError';
199
- }
200
- }
201
- /**
202
- * Create a validation error with helpful context
203
- *
204
- * @param message - Error message
205
- * @param options - Error options
206
- * @returns GLOSTValidationError instance
207
- *
208
- * @example
209
- * ```typescript
210
- * throw createValidationError('Invalid word node', {
211
- * node: wordNode,
212
- * path: ['document', 'children', '0'],
213
- * suggestion: 'Add a "text" field to the word node',
214
- * docsUrl: 'https://glost.dev/docs/node-types#word'
215
- * });
216
- * ```
217
- */
218
- export function createValidationError(message, options = {}) {
219
- return new GLOSTValidationError(message, options);
220
- }
221
- /**
222
- * Format a path array as a readable string
223
- *
224
- * @param path - Path array
225
- * @returns Formatted path string
226
- *
227
- * @example
228
- * ```typescript
229
- * formatPath(['document', 'children', '0', 'text'])
230
- * // Returns: "document.children[0].text"
231
- * ```
232
- */
233
- export function formatPath(path) {
234
- if (path.length === 0)
235
- return 'root';
236
- return path.reduce((acc, segment, index) => {
237
- if (index === 0)
238
- return String(segment);
239
- if (typeof segment === 'number' || !isNaN(Number(segment))) {
240
- return `${acc}[${segment}]`;
241
- }
242
- return `${acc}.${segment}`;
243
- }, '');
244
- }
245
- /**
246
- * Assert that a condition is true, throw validation error if not
247
- *
248
- * @param condition - Condition to check
249
- * @param message - Error message if condition is false
250
- * @param context - Error context
251
- *
252
- * @example
253
- * ```typescript
254
- * glostAssert(
255
- * node.type === 'word',
256
- * 'Node must be a word node',
257
- * { node, path: ['document', 'children', '0'] }
258
- * );
259
- * ```
260
- */
261
- export function glostAssert(condition, message, context) {
262
- if (!condition) {
263
- throw new GLOSTValidationError(message, context);
264
- }
265
- }
266
- /**
267
- * Wrap an error with additional GLOST context
268
- *
269
- * @param error - Original error
270
- * @param context - Additional context
271
- * @returns GLOST error
272
- *
273
- * @example
274
- * ```typescript
275
- * try {
276
- * await processNode(node);
277
- * } catch (error) {
278
- * throw wrapError(error, {
279
- * node,
280
- * path: ['document', 'children', '0'],
281
- * suggestion: 'Check that the node has all required fields'
282
- * });
283
- * }
284
- * ```
285
- */
286
- export function wrapError(error, context) {
287
- if (error instanceof GLOSTError) {
288
- // Merge contexts - create new error with merged context
289
- return new GLOSTError(error.message, {
290
- ...error.context,
291
- ...context,
292
- });
293
- }
294
- // Create new GLOST error
295
- return new GLOSTError(error.message, {
296
- ...context,
297
- originalError: error,
298
- });
299
- }
300
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnB,OAAO,CAAoB;IAE3C,YAAY,OAAe,EAAE,UAA6B,EAAE;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,8BAA8B;QAC9B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,SAAS;QACT,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEf,uBAAuB;QACvB,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACtB,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,IAAI,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IACrD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAErC,OAAO,IAAI,CAAC,MAAM,CAAS,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACjD,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;QAExC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;YAC3D,OAAO,GAAG,GAAG,IAAI,OAAO,GAAG,CAAC;QAC9B,CAAC;QAED,OAAO,GAAG,GAAG,IAAI,OAAO,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CACzB,SAAc,EACd,OAAe,EACf,OAA2B;IAE3B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,SAAS,CACvB,KAAY,EACZ,OAA0B;IAE1B,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,wDAAwD;QACxD,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE;YACnC,GAAG,KAAK,CAAC,OAAO;YAChB,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED,yBAAyB;IACzB,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE;QACnC,GAAG,OAAO;QACV,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC"}
package/dist/example.d.ts DELETED
@@ -1,10 +0,0 @@
1
- declare const thaiWords: import("../types").GLOSTWord[];
2
- declare const thaiSentence: import("../types").GLOSTSentence;
3
- declare const japaneseWords: import("../types").GLOSTWord[];
4
- declare const japaneseSentence: import("../types").GLOSTSentence;
5
- declare const thaiParagraph: import("../types").GLOSTParagraph;
6
- declare const japaneseParagraph: import("../types").GLOSTParagraph;
7
- declare const document: import("../types").GLOSTRoot;
8
- export declare function demonstrateUtilities(): void;
9
- export { thaiWords, japaneseWords, thaiSentence, japaneseSentence, thaiParagraph, japaneseParagraph, document };
10
- //# sourceMappingURL=example.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAiBA,QAAA,MAAM,SAAS,+BAoCd,CAAC;AAEF,QAAA,MAAM,YAAY,iCAKjB,CAAC;AAMF,QAAA,MAAM,aAAa,+BAkClB,CAAC;AAEF,QAAA,MAAM,gBAAgB,iCAKrB,CAAC;AAMF,QAAA,MAAM,aAAa,kCAA+C,CAAC;AACnE,QAAA,MAAM,iBAAiB,kCAAmD,CAAC;AAE3E,QAAA,MAAM,QAAQ,6BAQb,CAAC;AAMF,wBAAgB,oBAAoB,SA4CnC;AAGD,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACT,CAAC"}
package/dist/example.js DELETED
@@ -1,138 +0,0 @@
1
- // Example usage of the GLOST package
2
- import { createThaiWord, createJapaneseWord, createSentenceFromWords, createParagraphFromSentences, createDocumentFromParagraphs, getAllWords, getWordTranscription, validateGLOSTTree, getWordText } from './index';
3
- // ============================================================================
4
- // Thai Example: "สวัสดีครับ ผมชื่อสมชาย" (Hello, my name is Somchai)
5
- // ============================================================================
6
- const thaiWords = [
7
- createThaiWord({
8
- text: 'สวัสดี',
9
- rtgs: 'sà-wàt-dii',
10
- partOfSpeech: 'interjection',
11
- tone: 2,
12
- syllables: ['sa', 'wat', 'dii']
13
- }),
14
- createThaiWord({
15
- text: 'ครับ',
16
- rtgs: 'khráp',
17
- partOfSpeech: 'particle',
18
- tone: 2,
19
- syllables: ['khrap']
20
- }),
21
- createThaiWord({
22
- text: 'ผม',
23
- rtgs: 'phǒm',
24
- partOfSpeech: 'pronoun',
25
- tone: 3,
26
- syllables: ['phom']
27
- }),
28
- createThaiWord({
29
- text: 'ชื่อ',
30
- rtgs: 'chûue',
31
- partOfSpeech: 'noun',
32
- tone: 3,
33
- syllables: ['chue']
34
- }),
35
- createThaiWord({
36
- text: 'สมชาย',
37
- rtgs: 'sǒm-chaai',
38
- partOfSpeech: 'proper noun',
39
- tone: 3,
40
- syllables: ['som', 'chaai']
41
- })
42
- ];
43
- const thaiSentence = createSentenceFromWords(thaiWords, 'th', 'thai', 'สวัสดีครับ ผมชื่อสมชาย');
44
- // ============================================================================
45
- // Japanese Example: "私の名前は田中です。" (My name is Tanaka)
46
- // ============================================================================
47
- const japaneseWords = [
48
- createJapaneseWord({
49
- text: '私',
50
- romaji: 'watashi',
51
- partOfSpeech: 'pronoun',
52
- furigana: 'わたし'
53
- }),
54
- createJapaneseWord({
55
- text: 'の',
56
- romaji: 'no',
57
- partOfSpeech: 'particle'
58
- }),
59
- createJapaneseWord({
60
- text: '名前',
61
- romaji: 'namae',
62
- partOfSpeech: 'noun',
63
- furigana: 'なまえ'
64
- }),
65
- createJapaneseWord({
66
- text: 'は',
67
- romaji: 'wa',
68
- partOfSpeech: 'particle'
69
- }),
70
- createJapaneseWord({
71
- text: '田中',
72
- romaji: 'tanaka',
73
- partOfSpeech: 'proper noun',
74
- furigana: 'たなか'
75
- }),
76
- createJapaneseWord({
77
- text: 'です',
78
- romaji: 'desu',
79
- partOfSpeech: 'copula'
80
- })
81
- ];
82
- const japaneseSentence = createSentenceFromWords(japaneseWords, 'ja', 'mixed', '私の名前は田中です。');
83
- // ============================================================================
84
- // Create Document Structure
85
- // ============================================================================
86
- const thaiParagraph = createParagraphFromSentences([thaiSentence]);
87
- const japaneseParagraph = createParagraphFromSentences([japaneseSentence]);
88
- const document = createDocumentFromParagraphs([thaiParagraph, japaneseParagraph], 'mixed', 'mixed', {
89
- title: 'Multilingual Greeting Examples',
90
- description: 'Examples of greetings in Thai and Japanese with transcriptions'
91
- });
92
- // ============================================================================
93
- // Demonstrate Utilities
94
- // ============================================================================
95
- export function demonstrateUtilities() {
96
- console.log('=== GLOST Package Demo ===\n');
97
- // Get all words from the document
98
- const allWords = getAllWords(document);
99
- console.log(`Total words: ${allWords.length}`);
100
- // Show Thai words with RTGS transcriptions
101
- const thaiWordsOnly = allWords.filter(word => word.lang === 'th');
102
- console.log('\n=== Thai Words ===');
103
- thaiWordsOnly.forEach(word => {
104
- const rtgs = getWordTranscription(word, 'rtgs');
105
- console.log(`${getWordText(word)} → ${rtgs} (${word.metadata.partOfSpeech})`);
106
- });
107
- // Show Japanese words with romaji
108
- const japaneseWordsOnly = allWords.filter(word => word.lang === 'ja');
109
- console.log('\n=== Japanese Words ===');
110
- japaneseWordsOnly.forEach(word => {
111
- const romaji = getWordTranscription(word, 'romaji');
112
- console.log(`${getWordText(word)} → ${romaji} (${word.metadata.partOfSpeech})`);
113
- });
114
- // Validate the tree
115
- const validationErrors = validateGLOSTTree(document);
116
- if (validationErrors.length === 0) {
117
- console.log('\n✅ Document is valid!');
118
- }
119
- else {
120
- console.log('\n❌ Validation errors:');
121
- validationErrors.forEach((error) => console.log(` - ${error}`));
122
- }
123
- // Show document structure
124
- console.log('\n=== Document Structure ===');
125
- console.log(`Language: ${document.lang}`);
126
- console.log(`Script: ${document.script}`);
127
- console.log(`Paragraphs: ${document.children.length}`);
128
- console.log(`Sentences: ${document.children.reduce((acc, p) => {
129
- if (p.type === 'ParagraphNode') {
130
- return acc + (p.children?.length || 0);
131
- }
132
- return acc;
133
- }, 0)}`);
134
- console.log(`Words: ${allWords.length}`);
135
- }
136
- // Export for use in other files
137
- export { thaiWords, japaneseWords, thaiSentence, japaneseSentence, thaiParagraph, japaneseParagraph, document };
138
- //# sourceMappingURL=example.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example.js","sourceRoot":"","sources":["../src/example.ts"],"names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STSource, GLOSTSymbol, GLOSTText, GLOSTWhiteSpace, GLOSTWord, GLOSTNode } from "./types.js";
2
- /**
3
- * Type guard to check if a node is an GLOSTWord
4
- */
5
- export declare function isGLOSTWord(node: unknown): node is GLOSTWord;
6
- /**
7
- * Type guard to check if a node is an GLOSTSentence
8
- */
9
- export declare function isGLOSTSentence(node: unknown): node is GLOSTSentence;
10
- /**
11
- * Type guard to check if a node is an GLOSTParagraph
12
- */
13
- export declare function isGLOSTParagraph(node: unknown): node is GLOSTParagraph;
14
- /**
15
- * Type guard to check if a node is an GLOSTRoot
16
- */
17
- export declare function isGLOSTRoot(node: unknown): node is GLOSTRoot;
18
- /**
19
- * Type guard to check if a node is an GLOSTText
20
- */
21
- export declare function isGLOSTText(node: unknown): node is GLOSTText;
22
- /**
23
- * Type guard to check if a node is an GLOSTPunctuation
24
- */
25
- export declare function isGLOSTPunctuation(node: unknown): node is GLOSTPunctuation;
26
- /**
27
- * Type guard to check if a node is an GLOSTSymbol
28
- */
29
- export declare function isGLOSTSymbol(node: unknown): node is GLOSTSymbol;
30
- /**
31
- * Type guard to check if a node is an GLOSTWhiteSpace
32
- */
33
- export declare function isGLOSTWhiteSpace(node: unknown): node is GLOSTWhiteSpace;
34
- /**
35
- * Type guard to check if a node is an GLOSTSource
36
- */
37
- export declare function isGLOSTSource(node: unknown): node is GLOSTSource;
38
- /**
39
- * Type guard to check if a node is GLOSTNode (any GLOST node)
40
- */
41
- export declare function isGLOSTNode(node: unknown): node is GLOSTNode;
42
- /**
43
- * Type guard to check if a node is an GLOSTDocument (Root or Content)
44
- */
45
- export declare function isGLOSTDocument(node: unknown): node is GLOSTRoot;
46
- /**
47
- * Type guard to check if an array contains only GLOSTWord nodes
48
- */
49
- export declare function isGLOSTWordArray(nodes: unknown[]): nodes is GLOSTWord[];
50
- /**
51
- * Type guard to check if an array contains only GLOSTSentence nodes
52
- */
53
- export declare function isGLOSTSentenceArray(nodes: unknown[]): nodes is GLOSTSentence[];
54
- /**
55
- * Type guard to check if an array contains only GLOSTParagraph nodes
56
- */
57
- export declare function isGLOSTParagraphArray(nodes: unknown[]): nodes is GLOSTParagraph[];
58
- /**
59
- * Type guard to check if an array contains only GLOSTContent nodes
60
- */
61
- export declare function isGLOSTContentArray(nodes: unknown[]): nodes is (GLOSTWord | GLOSTSentence | GLOSTParagraph | GLOSTText | GLOSTPunctuation | GLOSTSymbol | GLOSTWhiteSpace | GLOSTSource)[];
62
- /**
63
- * Type guard to check if a node has children
64
- */
65
- export declare function hasChildren(node: unknown): node is {
66
- children: unknown[];
67
- };
68
- /**
69
- * Type guard to check if a node has metadata
70
- */
71
- export declare function hasMetadata(node: unknown): node is {
72
- metadata: Record<string, unknown>;
73
- };
74
- /**
75
- * Type guard to check if a node has transcription
76
- */
77
- export declare function hasTranscription(node: unknown): node is {
78
- transcription: Record<string, unknown>;
79
- };
80
- /**
81
- * Type guard to check if a node has extras
82
- */
83
- export declare function hasExtras(node: unknown): node is {
84
- extras: Record<string, unknown>;
85
- };
86
- /**
87
- * Check if a node has valid GLOST structure (type guard based validation)
88
- * For schema-based validation, use validateGLOSTNode from validators.ts
89
- */
90
- export declare function isGLOSTNodeWithValidChildren(node: unknown): node is GLOSTNode;
91
- /**
92
- * Check if an array contains valid GLOST nodes (type guard based)
93
- */
94
- export declare function isGLOSTNodeArrayValid(nodes: unknown[]): nodes is GLOSTNode[];
95
- /**
96
- * Check if a node is a leaf node (no children)
97
- */
98
- export declare function isLeafNode(node: GLOSTNode): boolean;
99
- /**
100
- * Check if a node is a container node (has children)
101
- */
102
- export declare function isContainerNode(node: GLOSTNode): boolean;
103
- //# sourceMappingURL=guards.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EACf,SAAS,EACT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