@luzzle/core 0.0.37 → 0.0.38
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/README.md +9 -36
- package/dist/src/database/migrations/2026-02-11T23:03:45Z-clear-pieces-cache.d.ts +3 -0
- package/dist/src/database/migrations/2026-02-11T23:03:45Z-clear-pieces-cache.js +8 -0
- package/dist/src/database/migrations/2026-02-11T23:03:45Z-clear-pieces-cache.js.map +1 -0
- package/dist/src/lib/ajv.test.js +1 -1
- package/dist/src/lib/ajv.test.js.map +1 -1
- package/dist/src/llm/google.d.ts +1 -1
- package/dist/src/pieces/Piece.d.ts +2 -2
- package/dist/src/pieces/Piece.fixtures.d.ts +21 -27
- package/dist/src/pieces/Piece.fixtures.js +34 -21
- package/dist/src/pieces/Piece.fixtures.js.map +1 -1
- package/dist/src/pieces/Piece.js +45 -42
- package/dist/src/pieces/Piece.js.map +1 -1
- package/dist/src/pieces/Piece.test.js +487 -739
- package/dist/src/pieces/Piece.test.js.map +1 -1
- package/dist/src/pieces/item.js +29 -17
- package/dist/src/pieces/item.js.map +1 -1
- package/dist/src/pieces/item.test.js +137 -115
- package/dist/src/pieces/item.test.js.map +1 -1
- package/dist/src/pieces/manager.test.js +1 -1
- package/dist/src/pieces/manager.test.js.map +1 -1
- package/dist/src/pieces/utils/frontmatter.d.ts +42 -10
- package/dist/src/pieces/utils/frontmatter.js +112 -44
- package/dist/src/pieces/utils/frontmatter.js.map +1 -1
- package/dist/src/pieces/utils/frontmatter.path.d.ts +5 -0
- package/dist/src/pieces/utils/frontmatter.path.js +92 -0
- package/dist/src/pieces/utils/frontmatter.path.js.map +1 -0
- package/dist/src/pieces/utils/frontmatter.path.test.d.ts +1 -0
- package/dist/src/pieces/utils/frontmatter.path.test.js +172 -0
- package/dist/src/pieces/utils/frontmatter.path.test.js.map +1 -0
- package/dist/src/pieces/utils/frontmatter.test.js +200 -169
- package/dist/src/pieces/utils/frontmatter.test.js.map +1 -1
- package/dist/src/pieces/utils/piece.js +3 -2
- package/dist/src/pieces/utils/piece.js.map +1 -1
- package/dist/src/pieces/utils/piece.test.js +1 -1
- package/dist/src/pieces/utils/piece.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/pieces/utils/piece.fixtures.d.ts +0 -19
- package/dist/src/pieces/utils/piece.fixtures.js +0 -39
- package/dist/src/pieces/utils/piece.fixtures.js.map +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import * as paths from './frontmatter.path.js';
|
|
3
|
+
describe('pieces/utils/frontmatter.path.ts', () => {
|
|
4
|
+
describe('get', () => {
|
|
5
|
+
test('gets top level value', () => {
|
|
6
|
+
const obj = { title: 'hello' };
|
|
7
|
+
expect(paths.get(obj, 'title')).toBe('hello');
|
|
8
|
+
});
|
|
9
|
+
test('gets nested value', () => {
|
|
10
|
+
const obj = { meta: { author: 'Alice' } };
|
|
11
|
+
expect(paths.get(obj, 'meta.author')).toBe('Alice');
|
|
12
|
+
});
|
|
13
|
+
test('gets array element', () => {
|
|
14
|
+
const obj = { tags: ['a', 'b'] };
|
|
15
|
+
expect(paths.get(obj, 'tags.1')).toBe('b');
|
|
16
|
+
});
|
|
17
|
+
test('returns undefined for missing path', () => {
|
|
18
|
+
const obj = { title: 'hello' };
|
|
19
|
+
expect(paths.get(obj, 'missing')).toBeUndefined();
|
|
20
|
+
expect(paths.get(obj, 'title.sub')).toBeUndefined();
|
|
21
|
+
});
|
|
22
|
+
test('returns undefined for null values in path', () => {
|
|
23
|
+
const obj = { meta: null };
|
|
24
|
+
expect(paths.get(obj, 'meta.author')).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('set', () => {
|
|
28
|
+
test('sets top level value', () => {
|
|
29
|
+
const obj = {};
|
|
30
|
+
paths.set(obj, 'title', 'hello');
|
|
31
|
+
expect(obj.title).toBe('hello');
|
|
32
|
+
});
|
|
33
|
+
test('sets nested value creating objects', () => {
|
|
34
|
+
const obj = {};
|
|
35
|
+
paths.set(obj, 'meta.author', 'Alice');
|
|
36
|
+
const meta = obj.meta;
|
|
37
|
+
expect(meta.author).toBe('Alice');
|
|
38
|
+
});
|
|
39
|
+
test('appends to existing array', () => {
|
|
40
|
+
const obj = { tags: ['a'] };
|
|
41
|
+
paths.set(obj, 'tags', 'b');
|
|
42
|
+
expect(obj.tags).toEqual(['a', 'b']);
|
|
43
|
+
});
|
|
44
|
+
test('overwrites non-array scalar', () => {
|
|
45
|
+
const obj = { title: 'old' };
|
|
46
|
+
paths.set(obj, 'title', 'new');
|
|
47
|
+
expect(obj.title).toBe('new');
|
|
48
|
+
});
|
|
49
|
+
test('handles existing non-object intermediate values', () => {
|
|
50
|
+
const obj = { meta: 'not-an-object' };
|
|
51
|
+
paths.set(obj, 'meta.author', 'Alice');
|
|
52
|
+
const meta = obj.meta;
|
|
53
|
+
expect(meta.author).toBe('Alice');
|
|
54
|
+
});
|
|
55
|
+
test('handles null intermediate values', () => {
|
|
56
|
+
const obj = { meta: null };
|
|
57
|
+
paths.set(obj, 'meta.author', 'Alice');
|
|
58
|
+
const meta = obj.meta;
|
|
59
|
+
expect(meta.author).toBe('Alice');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('unset', () => {
|
|
63
|
+
test('unsets top level key', () => {
|
|
64
|
+
const obj = { title: 'hello' };
|
|
65
|
+
paths.unset(obj, 'title');
|
|
66
|
+
expect(obj.title).toBeUndefined();
|
|
67
|
+
});
|
|
68
|
+
test('unsets nested key', () => {
|
|
69
|
+
const obj = { meta: { author: 'Alice' } };
|
|
70
|
+
paths.unset(obj, 'meta.author');
|
|
71
|
+
const meta = obj.meta;
|
|
72
|
+
expect(meta.author).toBeUndefined();
|
|
73
|
+
});
|
|
74
|
+
test('removes array element by index', () => {
|
|
75
|
+
const obj = { tags: ['a', 'b', 'c'] };
|
|
76
|
+
paths.unset(obj, 'tags.1');
|
|
77
|
+
expect(obj.tags).toEqual(['a', 'c']);
|
|
78
|
+
});
|
|
79
|
+
test('removes whole array if base path given', () => {
|
|
80
|
+
const obj = { tags: ['a'] };
|
|
81
|
+
paths.unset(obj, 'tags');
|
|
82
|
+
expect(obj.tags).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
test('does nothing if path does not exist', () => {
|
|
85
|
+
const obj = { title: 'hello' };
|
|
86
|
+
paths.unset(obj, 'missing.key');
|
|
87
|
+
expect(obj).toEqual({ title: 'hello' });
|
|
88
|
+
});
|
|
89
|
+
test('handles intermediate null values', () => {
|
|
90
|
+
const obj = { meta: null };
|
|
91
|
+
paths.unset(obj, 'meta.author');
|
|
92
|
+
expect(obj.meta).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe('findField', () => {
|
|
96
|
+
const mockFields = {
|
|
97
|
+
title: { type: 'string' },
|
|
98
|
+
meta: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
author: { type: 'string' },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
tags: {
|
|
105
|
+
type: 'array',
|
|
106
|
+
items: { type: 'string', format: 'asset' },
|
|
107
|
+
},
|
|
108
|
+
gallery: {
|
|
109
|
+
type: 'array',
|
|
110
|
+
items: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
url: { type: 'string', format: 'asset' },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
matrix: {
|
|
118
|
+
type: 'array',
|
|
119
|
+
items: {
|
|
120
|
+
type: 'array',
|
|
121
|
+
items: { type: 'string' },
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
const fields = Object.keys(mockFields).map((name) => ({ name, ...mockFields[name] }));
|
|
126
|
+
test('finds top level field', () => {
|
|
127
|
+
const field = paths.findField(fields, 'title');
|
|
128
|
+
expect(field?.name).toBe('title');
|
|
129
|
+
expect(field?.type).toBe('string');
|
|
130
|
+
});
|
|
131
|
+
test('finds nested object field', () => {
|
|
132
|
+
const field = paths.findField(fields, 'meta.author');
|
|
133
|
+
expect(field?.name).toBe('author');
|
|
134
|
+
expect(field?.type).toBe('string');
|
|
135
|
+
});
|
|
136
|
+
test('finds array item field by index', () => {
|
|
137
|
+
const field = paths.findField(fields, 'tags.0');
|
|
138
|
+
expect(field?.type).toBe('string');
|
|
139
|
+
expect(field?.format).toBe('asset');
|
|
140
|
+
});
|
|
141
|
+
test('finds nested array item by index', () => {
|
|
142
|
+
const field = paths.findField(fields, 'matrix.0.0');
|
|
143
|
+
expect(field?.type).toBe('string');
|
|
144
|
+
});
|
|
145
|
+
test('finds nested property in array of objects', () => {
|
|
146
|
+
const field = paths.findField(fields, 'gallery.url');
|
|
147
|
+
expect(field?.name).toBe('url');
|
|
148
|
+
expect(field?.format).toBe('asset');
|
|
149
|
+
});
|
|
150
|
+
test('finds nested property in array of objects by index', () => {
|
|
151
|
+
const field = paths.findField(fields, 'gallery.0.url');
|
|
152
|
+
expect(field?.name).toBe('url');
|
|
153
|
+
expect(field?.format).toBe('asset');
|
|
154
|
+
});
|
|
155
|
+
test('returns undefined for missing field', () => {
|
|
156
|
+
expect(paths.findField(fields, 'missing')).toBeUndefined();
|
|
157
|
+
expect(paths.findField(fields, 'meta.missing')).toBeUndefined();
|
|
158
|
+
});
|
|
159
|
+
test('returns undefined for index on non-array field', () => {
|
|
160
|
+
expect(paths.findField(fields, 'title.0')).toBeUndefined();
|
|
161
|
+
});
|
|
162
|
+
test('returns undefined for top level index', () => {
|
|
163
|
+
expect(paths.findField(fields, '0')).toBeUndefined();
|
|
164
|
+
});
|
|
165
|
+
test('returns undefined for invalid traversal', () => {
|
|
166
|
+
expect(paths.findField(fields, 'title.something')).toBeUndefined();
|
|
167
|
+
expect(paths.findField(fields, 'tags.0.something')).toBeUndefined();
|
|
168
|
+
expect(paths.findField(fields, 'tags.someProp')).toBeUndefined();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
//# sourceMappingURL=frontmatter.path.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.path.test.js","sourceRoot":"","sources":["../../../../src/pieces/utils/frontmatter.path.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAA;AAI9C,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IACjD,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;QACpB,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;YACjC,MAAM,GAAG,GAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAChD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC9B,MAAM,GAAG,GAAqB,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAA;YAC3D,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;YAC/B,MAAM,GAAG,GAAqB,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;YAClD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;Y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MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACpD,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,aAAa,EAAE,CAAA;YAClE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,aAAa,EAAE,CAAA;YACnE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,aAAa,EAAE,CAAA;QACjE,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,184 +1,215 @@
|
|
|
1
1
|
import { describe, expect, test, vi, afterEach } from 'vitest';
|
|
2
2
|
import * as frontmatter from './frontmatter.js';
|
|
3
|
-
import { makeSchema } from '
|
|
3
|
+
import { makeSchema } from '../Piece.fixtures.js';
|
|
4
4
|
describe('pieces/utils/frontmatter.ts', () => {
|
|
5
5
|
afterEach(() => {
|
|
6
6
|
vi.resetAllMocks();
|
|
7
7
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
describe('getPieceFrontmatterSchemaFields', () => {
|
|
9
|
+
test('handles basic scalar fields', () => {
|
|
10
|
+
const schema = makeSchema({
|
|
11
|
+
field: { type: 'string' },
|
|
12
|
+
field2: { type: 'string', nullable: true, format: 'date', pattern: 'pattern' },
|
|
13
|
+
});
|
|
14
|
+
const fields = frontmatter.getPieceFrontmatterSchemaFields(schema);
|
|
15
|
+
expect(fields).toContainEqual({ name: 'field', type: 'string', nullable: true });
|
|
16
|
+
expect(fields).toContainEqual({
|
|
17
|
+
name: 'field2',
|
|
18
|
+
type: 'string',
|
|
19
|
+
format: 'date',
|
|
20
|
+
pattern: 'pattern',
|
|
21
|
+
nullable: true,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
test('handles required and nullable fields', () => {
|
|
25
|
+
const schema = makeSchema({
|
|
26
|
+
requiredField: { type: 'string' },
|
|
27
|
+
optionalField: { type: 'string', nullable: true },
|
|
28
|
+
});
|
|
29
|
+
schema.required = ['requiredField'];
|
|
30
|
+
const fields = frontmatter.getPieceFrontmatterSchemaFields(schema);
|
|
31
|
+
const requiredField = fields.find((f) => f.name === 'requiredField');
|
|
32
|
+
const optionalField = fields.find((f) => f.name === 'optionalField');
|
|
33
|
+
expect(optionalField?.nullable).toBe(true);
|
|
34
|
+
expect(requiredField?.nullable).toBe(false);
|
|
21
35
|
});
|
|
22
36
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
format: 'comma-separated',
|
|
75
|
-
});
|
|
76
|
-
expect(date).toBeTypeOf('number');
|
|
77
|
-
expect(one).toBe(1);
|
|
78
|
-
expect(zero).toBe(0);
|
|
79
|
-
expect(list).toBe('a,b');
|
|
80
|
-
expect(nil).toBe(null);
|
|
81
|
-
expect(ten).toBe(10);
|
|
82
|
-
expect(csv).toBe('["one","two","three"]');
|
|
83
|
-
});
|
|
84
|
-
test('databaseValueToPieceFrontMatterValue', () => {
|
|
85
|
-
const dateString = '12/31/2021';
|
|
86
|
-
const date = frontmatter.databaseValueToPieceFrontmatterValue(new Date(dateString).getTime(), {
|
|
87
|
-
format: 'date',
|
|
88
|
-
type: 'string',
|
|
89
|
-
name: 'date',
|
|
90
|
-
});
|
|
91
|
-
const one = frontmatter.databaseValueToPieceFrontmatterValue(1, {
|
|
92
|
-
type: 'boolean',
|
|
93
|
-
name: 'bool',
|
|
94
|
-
});
|
|
95
|
-
const zero = frontmatter.databaseValueToPieceFrontmatterValue(0, {
|
|
96
|
-
type: 'boolean',
|
|
97
|
-
name: 'bool',
|
|
98
|
-
});
|
|
99
|
-
const csv = frontmatter.databaseValueToPieceFrontmatterValue('["one", "two", "three"]', {
|
|
100
|
-
type: 'string',
|
|
101
|
-
format: 'comma-separated',
|
|
102
|
-
name: 'tags',
|
|
103
|
-
});
|
|
104
|
-
const list = frontmatter.databaseValueToPieceFrontmatterValue('a,b', {
|
|
105
|
-
type: 'array',
|
|
106
|
-
name: 'list',
|
|
107
|
-
items: { type: 'string' },
|
|
108
|
-
});
|
|
109
|
-
expect(date).toBe(dateString);
|
|
110
|
-
expect(one).toBe(true);
|
|
111
|
-
expect(zero).toBe(false);
|
|
112
|
-
expect(list).toEqual(['a', 'b']);
|
|
113
|
-
expect(csv).toBe('one,two,three');
|
|
114
|
-
});
|
|
115
|
-
test('databaseValueToPieceFrontmatterValue for array of numbers', () => {
|
|
116
|
-
const value = '1,2,3';
|
|
117
|
-
const field = {
|
|
118
|
-
type: 'array',
|
|
119
|
-
name: 'numbers',
|
|
120
|
-
items: { type: 'integer' },
|
|
121
|
-
};
|
|
122
|
-
const result = frontmatter.databaseValueToPieceFrontmatterValue(value, field);
|
|
123
|
-
expect(result).toEqual([1, 2, 3]);
|
|
124
|
-
});
|
|
125
|
-
test('initializePieceFrontMatter', () => {
|
|
126
|
-
const schema = {
|
|
127
|
-
type: 'object',
|
|
128
|
-
properties: {
|
|
129
|
-
title: { type: 'string', examples: ['title'] },
|
|
130
|
-
keywords: { type: 'string', examples: ['keyword1'], nullable: true },
|
|
131
|
-
subtitle: { type: 'string', default: 'a subtitle', nullable: true },
|
|
132
|
-
},
|
|
133
|
-
required: ['title'],
|
|
134
|
-
additionalProperties: true,
|
|
135
|
-
};
|
|
136
|
-
const front = frontmatter.initializePieceFrontMatter(schema);
|
|
137
|
-
expect(front).toEqual({
|
|
138
|
-
title: 'title',
|
|
139
|
-
keywords: 'keyword1',
|
|
140
|
-
subtitle: 'a subtitle',
|
|
37
|
+
describe('pieceFrontmatterValueToDatabaseValue', () => {
|
|
38
|
+
test('converts basic scalars', () => {
|
|
39
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue('2021-01-01', {
|
|
40
|
+
format: 'date',
|
|
41
|
+
type: 'string',
|
|
42
|
+
})).toBeTypeOf('number');
|
|
43
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue(true, { type: 'boolean' })).toBe(1);
|
|
44
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue(false, { type: 'boolean' })).toBe(0);
|
|
45
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue(10, { type: 'integer' })).toBe(10);
|
|
46
|
+
});
|
|
47
|
+
test('handles null and undefined', () => {
|
|
48
|
+
const prop = { type: 'string' };
|
|
49
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue(null, prop)).toBe(null);
|
|
50
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue(undefined, prop)).toBe(null);
|
|
51
|
+
});
|
|
52
|
+
test('handles unknown field type', () => {
|
|
53
|
+
const prop = { type: 'unknown' };
|
|
54
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue('val', prop)).toBe('val');
|
|
55
|
+
});
|
|
56
|
+
test('handles default string type', () => {
|
|
57
|
+
const prop = { type: 'string' };
|
|
58
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue('val', prop)).toBe('val');
|
|
59
|
+
});
|
|
60
|
+
test('converts comma-separated format', () => {
|
|
61
|
+
const prop = {
|
|
62
|
+
type: 'string',
|
|
63
|
+
format: 'comma-separated',
|
|
64
|
+
};
|
|
65
|
+
expect(frontmatter.pieceFrontmatterValueToDatabaseValue('a,b', prop)).toBe('["a","b"]');
|
|
66
|
+
});
|
|
67
|
+
test('converts arrays to native arrays (not CSV)', () => {
|
|
68
|
+
const prop = {
|
|
69
|
+
type: 'array',
|
|
70
|
+
items: { type: 'string' },
|
|
71
|
+
};
|
|
72
|
+
const value = ['a', 'b,withComma'];
|
|
73
|
+
const result = frontmatter.pieceFrontmatterValueToDatabaseValue(value, prop);
|
|
74
|
+
expect(result).toEqual(['a', 'b,withComma']);
|
|
75
|
+
expect(result).not.toBe('a,b,withComma');
|
|
76
|
+
});
|
|
77
|
+
test('converts objects recursively', () => {
|
|
78
|
+
const prop = {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
date: { type: 'string', format: 'date' },
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const value = { date: '2023-01-01', extra: 'keep-me' };
|
|
85
|
+
const result = frontmatter.pieceFrontmatterValueToDatabaseValue(value, prop);
|
|
86
|
+
expect(result.date).toBeTypeOf('number');
|
|
87
|
+
expect(result.extra).toBe('keep-me');
|
|
141
88
|
});
|
|
142
89
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
90
|
+
describe('databaseValueToPieceFrontmatterValue', () => {
|
|
91
|
+
test('restores basic scalars', () => {
|
|
92
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue(1609459200000, {
|
|
93
|
+
format: 'date',
|
|
94
|
+
type: 'string',
|
|
95
|
+
})).toBeTypeOf('string');
|
|
96
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue(1, { type: 'boolean' })).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
test('restores integers', () => {
|
|
99
|
+
const prop = { type: 'integer' };
|
|
100
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue('10', prop)).toBe(10);
|
|
101
|
+
});
|
|
102
|
+
test('restores arrays from native arrays', () => {
|
|
103
|
+
const prop = {
|
|
104
|
+
type: 'array',
|
|
105
|
+
items: { type: 'string' },
|
|
106
|
+
};
|
|
107
|
+
const value = ['a', 'b,withComma'];
|
|
108
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue(value, prop)).toEqual(value);
|
|
109
|
+
});
|
|
110
|
+
test('restores arrays from legacy CSV strings', () => {
|
|
111
|
+
const prop = {
|
|
112
|
+
type: 'array',
|
|
113
|
+
items: { type: 'string' },
|
|
114
|
+
};
|
|
115
|
+
const value = 'a,b';
|
|
116
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue(value, prop)).toEqual(['a', 'b']);
|
|
117
|
+
});
|
|
118
|
+
test('restores objects recursively', () => {
|
|
119
|
+
const prop = {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
date: { type: 'string', format: 'date' },
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
const value = { date: 1672531200000, extra: 'prop' };
|
|
126
|
+
const result = frontmatter.databaseValueToPieceFrontmatterValue(value, prop);
|
|
127
|
+
expect(typeof result.date).toBe('string');
|
|
128
|
+
expect(result.extra).toBe('prop');
|
|
129
|
+
});
|
|
130
|
+
test('handles null and undefined', () => {
|
|
131
|
+
const prop = { type: 'string' };
|
|
132
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue(null, prop)).toBe(null);
|
|
133
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue(undefined, prop)).toBe(null);
|
|
134
|
+
});
|
|
135
|
+
test('handles non-json comma-separated strings', () => {
|
|
136
|
+
const prop = {
|
|
137
|
+
type: 'string',
|
|
138
|
+
format: 'comma-separated',
|
|
139
|
+
};
|
|
140
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue('invalid', prop)).toBe('invalid');
|
|
141
|
+
});
|
|
142
|
+
test('handles default string type', () => {
|
|
143
|
+
const prop = { type: 'string' };
|
|
144
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue('val', prop)).toBe('val');
|
|
145
|
+
});
|
|
146
|
+
test('handles unknown field type', () => {
|
|
147
|
+
const prop = { type: 'unknown' };
|
|
148
|
+
expect(frontmatter.databaseValueToPieceFrontmatterValue('val', prop)).toBe('val');
|
|
157
149
|
});
|
|
158
150
|
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
151
|
+
describe('initializePieceFrontMatter', () => {
|
|
152
|
+
test('initializes nested objects', () => {
|
|
153
|
+
const schema = {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {
|
|
156
|
+
title: { type: 'string', examples: ['title'] },
|
|
157
|
+
metadata: {
|
|
158
|
+
type: 'object',
|
|
159
|
+
properties: {
|
|
160
|
+
author: { type: 'string', examples: ['Author'] },
|
|
161
|
+
},
|
|
162
|
+
required: ['author'],
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
required: ['title', 'metadata'],
|
|
166
|
+
};
|
|
167
|
+
const front = frontmatter.initializePieceFrontMatter(schema);
|
|
168
|
+
expect(front).toEqual({
|
|
169
|
+
title: 'title',
|
|
170
|
+
metadata: { author: 'Author' },
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
test('initializes empty object if required but no subfields initialized', () => {
|
|
174
|
+
const properties = {
|
|
175
|
+
metadata: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
properties: {
|
|
178
|
+
author: { type: 'string' },
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
const schema = makeSchema(properties);
|
|
183
|
+
schema.required = ['title', 'metadata'];
|
|
184
|
+
const front = frontmatter.initializePieceFrontMatter(schema, true);
|
|
185
|
+
expect(front).toEqual({ title: 'title', metadata: {} });
|
|
186
|
+
});
|
|
187
|
+
test('honors minimal flag recursively', () => {
|
|
188
|
+
const schema = {
|
|
189
|
+
type: 'object',
|
|
190
|
+
properties: {
|
|
191
|
+
title: { type: 'string', examples: ['title'] },
|
|
192
|
+
metadata: {
|
|
193
|
+
type: 'object',
|
|
194
|
+
properties: {
|
|
195
|
+
author: { type: 'string', examples: ['Author'] },
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
required: ['title'],
|
|
200
|
+
};
|
|
201
|
+
const front = frontmatter.initializePieceFrontMatter(schema, true);
|
|
202
|
+
expect(front).toEqual({ title: 'title' });
|
|
203
|
+
});
|
|
204
|
+
test('fails if required field has no initial value', () => {
|
|
205
|
+
const schema = {
|
|
206
|
+
type: 'object',
|
|
207
|
+
properties: {
|
|
208
|
+
title: { type: 'string' },
|
|
209
|
+
},
|
|
210
|
+
required: ['title'],
|
|
211
|
+
};
|
|
212
|
+
expect(() => frontmatter.initializePieceFrontMatter(schema)).toThrow('can not initialize field "title"');
|
|
182
213
|
});
|
|
183
214
|
});
|
|
184
215
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.test.js","sourceRoot":"","sources":["../../../../src/pieces/utils/frontmatter.test.ts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