Skip to content

Commit 9b0202f

Browse files
committed
Rename sourceContent -> knowledgeSourceContent
1 parent 9534b9b commit 9b0202f

15 files changed

+31
-28
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,10 @@ Compile via remote server
681681

682682
### `0.83.0` _(2025-01-20)_
683683

684-
Export parsing internals to `@promptbook/editable`
684+
`@promptbook/editable`
685+
686+
- Export parsing internals to `@promptbook/editable`
687+
- Rename `sourceContent` -> `knowledgeSourceContent`
685688

686689
## In pre-release
687690

src/commands/KNOWLEDGE/KnowledgeCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import type { string_knowledge_source_content } from '../../types/typeAliases';
88
*/
99
export type KnowledgeCommand = {
1010
readonly type: 'KNOWLEDGE';
11-
readonly sourceContent: string_knowledge_source_content;
11+
readonly knowledgeSourceContent: string_knowledge_source_content;
1212
};

src/commands/KNOWLEDGE/knowledgeCommand.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ describe('how KNOWLEDGE command in .book.md files works', () => {
66
it('should parse KNOWLEDGE command', () => {
77
expect(parseCommand('KNOWLEDGE https://www.pavolhejny.com/', 'PIPELINE_HEAD')).toEqual({
88
type: 'KNOWLEDGE',
9-
sourceContent: 'https://www.pavolhejny.com/',
9+
knowledgeSourceContent: 'https://www.pavolhejny.com/',
1010
});
1111
expect(parseCommand('KNOWLEDGE ./hejny-cv.pdf', 'PIPELINE_HEAD')).toEqual({
1212
// <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
1313
type: 'KNOWLEDGE',
14-
sourceContent: './hejny-cv.pdf',
14+
knowledgeSourceContent: './hejny-cv.pdf',
1515
});
1616
});
1717

src/commands/KNOWLEDGE/utils/knowledgeSourceContentToName.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { normalizeToKebabCase } from '../../../utils/normalization/normalize-to-
88
*
99
* @public exported from `@promptbook/editable`
1010
*/
11-
export function knowledgeSourceContentToName(sourceContent: string_knowledge_source_content): string_name {
11+
export function knowledgeSourceContentToName(knowledgeSourceContent: string_knowledge_source_content): string_name {
1212
const hash = sha256(hexEncoder.parse(JSON.stringify(sourceContent)))
1313
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
1414
.toString(/* hex */)

src/commands/KNOWLEDGE/utils/sourceContentToName.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { normalizeToKebabCase } from '../../../utils/normalization/normalize-to-
88
*
99
* @public exported from `@promptbook/editable`
1010
*/
11-
export function knowledgeSourceContentToName(sourceContent: string_knowledge_source_content): string_name {
11+
export function knowledgeSourceContentToName(knowledgeSourceContent: string_knowledge_source_content): string_name {
1212
const hash = sha256(hexEncoder.parse(JSON.stringify(sourceContent)))
1313
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
1414
.toString(/* hex */)

src/commands/SECTION/sectionCommandParser.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import { SectionTypes } from '../../types/SectionType';
88
import type { string_markdown_text } from '../../types/typeAliases';
99
import { keepUnused } from '../../utils/organization/keepUnused';
1010
import { knowledgeCommandParser } from '../KNOWLEDGE/knowledgeCommandParser';
11-
import type { $PipelineJson } from '../_common/types/CommandParser';
12-
import type { $TaskJson } from '../_common/types/CommandParser';
13-
import type { CommandParserInput } from '../_common/types/CommandParser';
14-
import type { PipelineTaskCommandParser } from '../_common/types/CommandParser';
11+
import type {
12+
$PipelineJson,
13+
$TaskJson,
14+
CommandParserInput,
15+
PipelineTaskCommandParser,
16+
} from '../_common/types/CommandParser';
1517
import type { SectionCommand } from './SectionCommand';
1618

1719
/**
@@ -192,7 +194,7 @@ export const sectionCommandParser: PipelineTaskCommandParser<SectionCommand> = {
192194
knowledgeCommandParser.$applyToPipelineJson(
193195
{
194196
type: 'KNOWLEDGE',
195-
sourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
197+
knowledgeSourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
196198
},
197199
$pipelineJson,
198200
);

src/pipeline/PipelineJson/KnowledgeSourceJson.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { number_id } from '../../types/typeAliases';
2-
import type { string_knowledge_source_content } from '../../types/typeAliases';
3-
import type { string_name } from '../../types/typeAliases';
1+
import type { number_id, string_knowledge_source_content, string_name } from '../../types/typeAliases';
42

53
/**
64
* Defines one source of knowledge in the pipeline
@@ -26,7 +24,7 @@ export type KnowledgeSourceJson = {
2624
* For example `"Pavol Hejný has web https://pavolhejny.com/"`
2725
* For example `"Pavol Hejný is web developer and creator of Promptbook and Collboard"`
2826
*/
29-
readonly sourceContent: string_knowledge_source_content;
27+
readonly knowledgeSourceContent: string_knowledge_source_content;
3028
};
3129

3230
/**

src/scrapers/document-legacy/LegacyDocumentScraper.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('how creating knowledge from docx works', () => {
2626
legacyDocumentScraperPromise,
2727
makeKnowledgeSourceHandler(
2828
{
29-
sourceContent: '10-simple.doc',
29+
knowledgeSourceContent: '10-simple.doc',
3030
},
3131
{ fs: $provideFilesystemForNode() },
3232
{ rootDirname },
@@ -47,7 +47,7 @@ describe('how creating knowledge from docx works', () => {
4747
legacyDocumentScraperPromise,
4848
makeKnowledgeSourceHandler(
4949
{
50-
sourceContent: '10-simple.rtf',
50+
knowledgeSourceContent: '10-simple.rtf',
5151
},
5252
{ fs: $provideFilesystemForNode() },
5353
{ rootDirname },
@@ -68,7 +68,7 @@ describe('how creating knowledge from docx works', () => {
6868
legacyDocumentScraperPromise,
6969
makeKnowledgeSourceHandler(
7070
{
71-
sourceContent: '10-simple.doc',
71+
knowledgeSourceContent: '10-simple.doc',
7272
},
7373
{ fs: $provideFilesystemForNode() },
7474
{ rootDirname },

src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function playground() {
5151

5252
const knowledge = await legacyDocumentScraper.scrape(
5353
await makeKnowledgeSourceHandler(
54-
{ sourceContent: example },
54+
{ knowledgeSourceContent: example },
5555
{ fs: $provideFilesystemForNode() },
5656
{ rootDirname },
5757
),

src/scrapers/document/DocumentScraper.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('how creating knowledge from docx works', () => {
2727
documentScraperPromise,
2828
makeKnowledgeSourceHandler(
2929
{
30-
sourceContent: '10-simple.docx',
30+
knowledgeSourceContent: '10-simple.docx',
3131
},
3232
{ fs: $provideFilesystemForNode() },
3333
{ rootDirname },
@@ -48,7 +48,7 @@ describe('how creating knowledge from docx works', () => {
4848
documentScraperPromise,
4949
makeKnowledgeSourceHandler(
5050
{
51-
sourceContent: '10-simple.odt',
51+
knowledgeSourceContent: '10-simple.odt',
5252
},
5353
{ fs: $provideFilesystemForNode() },
5454
{ rootDirname },
@@ -69,7 +69,7 @@ describe('how creating knowledge from docx works', () => {
6969
documentScraperPromise,
7070
makeKnowledgeSourceHandler(
7171
{
72-
sourceContent: '10-simple.docx',
72+
knowledgeSourceContent: '10-simple.docx',
7373
},
7474
{ fs: $provideFilesystemForNode() },
7575
{ rootDirname },

src/scrapers/document/playground/document-scraper-playground.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function playground() {
5151

5252
const knowledge = await documentScraper.scrape(
5353
await makeKnowledgeSourceHandler(
54-
{ sourceContent: example },
54+
{ knowledgeSourceContent: example },
5555
{ fs: $provideFilesystemForNode() },
5656
{ rootDirname },
5757
),

src/scrapers/markdown/MarkdownScraper.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('how creating knowledge from markdown works', () => {
2525
.then(() =>
2626
makeKnowledgeSourceHandler(
2727
{
28-
sourceContent: '10-simple.md',
28+
knowledgeSourceContent: '10-simple.md',
2929
},
3030
{ fs: $provideFilesystemForNode() },
3131
{ rootDirname },
@@ -46,7 +46,7 @@ describe('how creating knowledge from markdown works', () => {
4646
.then(() =>
4747
makeKnowledgeSourceHandler(
4848
{
49-
sourceContent: '10-simple.md',
49+
knowledgeSourceContent: '10-simple.md',
5050
},
5151
{ fs: $provideFilesystemForNode() },
5252
{ rootDirname },

src/scrapers/markdown/playground/markdown-scraper-playground.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function playground() {
4545

4646
const knowledge = await markdownScraper.scrape(
4747
await makeKnowledgeSourceHandler(
48-
{ sourceContent: example },
48+
{ knowledgeSourceContent: example },
4949
{ fs: $provideFilesystemForNode() },
5050
{ rootDirname },
5151
),

src/scrapers/pdf/playground/pdf-scraper-playground.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function playground() {
4646

4747
const knowledge = await pdfScraper.scrape(
4848
await makeKnowledgeSourceHandler(
49-
{ sourceContent: example },
49+
{ knowledgeSourceContent: example },
5050
{ fs: $provideFilesystemForNode() },
5151
{ rootDirname },
5252
),

src/scrapers/website/playground/website-scraper-playground.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function playground() {
4646
);
4747

4848
const source = await makeKnowledgeSourceHandler(
49-
{ sourceContent: example },
49+
{ knowledgeSourceContent: example },
5050
{ fs: $provideFilesystemForNode() },
5151
{ rootDirname },
5252
);

0 commit comments

Comments
 (0)