Skip to content

Commit 4099e34

Browse files
authored
Merge pull request #232 from overture-stack/release-2.0.0-beta.2
Release 2.0.0 beta.2
2 parents c99b726 + fb6ec77 commit 4099e34

File tree

13 files changed

+119
-37
lines changed

13 files changed

+119
-37
lines changed

apps/server/.mocharc.integration.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extension": ["ts"],
3+
"require": "ts-node/register",
4+
"spec": "test/integration/**/*.spec.ts",
5+
"timeout": 35000
6+
}

apps/server/.mocharc.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"extension": ["ts"],
33
"require": "ts-node/register",
44
"spec": "test/**/*.spec.ts",
5+
"ignore": ["test/integration/**/*"],
56
"timeout": 35000
67
}

apps/server/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "@overture-stack/lectern-server",
33
"private": true,
4-
"version": "2.0.0-beta.1",
4+
"version": "2.0.0-beta.2",
55
"description": "Overture Data Dictionary Management",
66
"scripts": {
77
"build": "tsc -p tsconfig.build.json",
88
"debug": "nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec node --inspect -r ts-node/register ./src/server.ts",
99
"start": "NODE_ENV=production ts-node -T src/server.ts",
10-
"test": "nyc mocha"
10+
"test": "nyc mocha",
11+
"test:integration": "nyc mocha --config .mocharc.integration.json"
1112
},
1213
"repository": {
1314
"type": "git",

docs/dictionary-reference.md

+25-25
Large diffs are not rendered by default.

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
{
22
"name": "@overture-stack/lectern",
33
"private": true,
4-
"version": "2.0.0-next.0",
4+
"version": "2.0.0-beta.2",
55
"description": "Schema Manager and Validation for Data Dictionaries",
66
"scripts": {
77
"build:all": "pnpm nx run-many --all --target=build",
88
"build:dictionary": "pnpm nx build @overture-stack/lectern-dictionary",
99
"build:validation": "pnpm nx build @overture-stack/lectern-validation",
1010
"build:server": "pnpm nx build @overture-stack/lectern-server",
1111
"build:client": "pnpm nx build @overture-stack/lectern-client",
12-
"test:all": "pnpm nx run-many --all --target=test",
13-
"test:dictionary": "pnpm nx test @overture-stack/lectern-dictionary",
14-
"test:validation": "pnpm nx test @overture-stack/lectern-validation",
15-
"test:server": "pnpm nx test @overture-stack/lectern-server",
16-
"test:client": "pnpm nx test @overture-stack/lectern-client",
12+
"test:all": "pnpm nx run-many --all --target=test,test:integration",
13+
"test:unit:all": "pnpm nx run-many --all --target=test",
14+
"test:unit:dictionary": "pnpm nx test @overture-stack/lectern-dictionary",
15+
"test:unit:validation": "pnpm nx test @overture-stack/lectern-validation",
16+
"test:unit:server": "pnpm nx test @overture-stack/lectern-server",
17+
"test:unit:client": "pnpm nx test @overture-stack/lectern-client",
18+
"test:integration:server": "pnpm nx test:integration @overture-stack/lectern-server",
1719
"generate": "pnpm build:dictionary && pnpm -C scripts generate"
1820
},
1921
"keywords": [],

packages/client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@overture-stack/lectern-client",
3-
"version": "2.0.0-beta.1",
3+
"version": "2.0.0-beta.2",
44
"files": [
55
"dist/"
66
],

packages/client/src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,19 @@ export type {
3636
TestResult,
3737
TestResultValid,
3838
TestResultInvalid,
39+
SchemaValidationRecordErrorDetails,
3940
SchemaRecordError,
41+
DictionaryValidationRecordErrorDetails,
4042
DictionaryValidationError,
43+
FieldValidationErrorRestrictionInfo,
4144
FieldValidationError,
4245
ParseDictionaryData,
4346
ParseDictionaryFailure,
4447
ParseDictionaryResult,
4548
ParseSchemaError,
4649
ParseSchemaFailureData,
4750
ParseSchemaResult,
51+
ParseRecordFailureData,
4852
ParseRecordResult,
4953
} from '@overture-stack/lectern-validation';
5054

packages/dictionary/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@overture-stack/lectern-dictionary",
3-
"version": "2.0.0-beta.1",
3+
"version": "2.0.0-beta.2",
44
"description": "",
55
"files": [
66
"dist/"

packages/dictionary/src/metaSchema/dictionarySchemas.ts

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export const SchemaFieldBase = zod
181181
.object({
182182
name: NameValue,
183183
description: zod.string().optional(),
184+
delimiter: zod.string().min(1).optional(),
184185
isArray: zod.boolean().optional(),
185186
meta: DictionaryMeta.optional(),
186187
unique: zod.boolean().optional(),

packages/dictionary/test/metaSchema/dictionarySchemas.spec.ts

+38
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,44 @@ describe('Dictionary Schemas', () => {
151151
};
152152
expect(SchemaField.safeParse(fieldBoolean).success, 'Boolean field invalid.').true;
153153
});
154+
describe('Delimiter', () => {
155+
it('Field can have delimiter', () => {
156+
const field: SchemaField = {
157+
name: 'some-name',
158+
valueType: 'string',
159+
isArray: true,
160+
delimiter: '|',
161+
};
162+
expect(SchemaField.safeParse(field).success).true;
163+
});
164+
it('Delimiter values must have minimum length 1', () => {
165+
const field: SchemaField = {
166+
name: 'some-name',
167+
valueType: 'string',
168+
isArray: true,
169+
delimiter: '',
170+
};
171+
expect(SchemaField.safeParse(field).success).false;
172+
});
173+
it('Delimiter value can have multiple characters', () => {
174+
const field: SchemaField = {
175+
name: 'some-name',
176+
valueType: 'string',
177+
isArray: true,
178+
delimiter: '-/-',
179+
};
180+
expect(SchemaField.safeParse(field).success).true;
181+
});
182+
it('Delimiter value can be whitespace', () => {
183+
const field: SchemaField = {
184+
name: 'some-name',
185+
valueType: 'string',
186+
isArray: true,
187+
delimiter: ' ',
188+
};
189+
expect(SchemaField.safeParse(field).success).true;
190+
});
191+
});
154192
});
155193
describe('Schema', () => {
156194
it("Can't have repeated field names", () => {

packages/validation/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@overture-stack/lectern-validation",
3-
"version": "2.0.0-beta.1",
3+
"version": "2.0.0-beta.2",
44
"description": "Logic for validating data using a Lectern dictionary",
55
"files": [
66
"dist/"

packages/validation/src/parseValues/parseValues.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const convertArrayValue = (value: string, fieldDefinition: SchemaField): Result<
138138

139139
/* === Start of convertArrayValue logic === */
140140
const { valueType } = fieldDefinition;
141-
const delimiter = DEFAULT_DELIMITER;
141+
const delimiter = fieldDefinition.delimiter !== undefined ? fieldDefinition.delimiter : DEFAULT_DELIMITER;
142142

143143
const normalizedValue = normalizeValue(value);
144144
if (normalizedValue === '') {

packages/validation/test/parseValues/parseField.spec.ts

+29
Original file line numberDiff line numberDiff line change
@@ -300,5 +300,34 @@ describe('Parse Values - parseFieldValue', () => {
300300
it('Boolean array field, rejects array where value is missing (two delimiters are adjacent)');
301301
expect(parseFieldValue(',true,false,TRUE', fieldBooleanArrayRequired).success).false;
302302
});
303+
describe('Custom delimiter', () => {
304+
it('Uses a `,` as the delimiter when none is defined', () => {
305+
const result = parseFieldValue(':,_,|,/', fieldStringArrayRequired);
306+
expect(result.success).true;
307+
expect(result.data).deep.equal([':', '_', '|', '/']);
308+
});
309+
it('Splits array on the delimiter when defined', () => {
310+
const customDelimiterField = { ...fieldStringArrayRequired, delimiter: '|' };
311+
const result = parseFieldValue(':,_,|,/', customDelimiterField);
312+
expect(result.success).true;
313+
expect(result.data).deep.equal([':,_,', ',/']);
314+
315+
const result2 = parseFieldValue('abc|def|ghi', customDelimiterField);
316+
expect(result2.success).true;
317+
expect(result2.data).deep.equal(['abc', 'def', 'ghi']);
318+
});
319+
it('Splits arrays with delimiters with more than 1 character', () => {
320+
const customDelimiterField = { ...fieldStringArrayRequired, delimiter: '-/-' };
321+
const result = parseFieldValue('a-/-b-/-c-/-d', customDelimiterField);
322+
expect(result.success).true;
323+
expect(result.data).deep.equal(['a', 'b', 'c', 'd']);
324+
});
325+
it('Splits arrays with delimiters that are entirely whitespace', () => {
326+
const customDelimiterField = { ...fieldStringArrayRequired, delimiter: ' ' };
327+
const result = parseFieldValue('a b c d', customDelimiterField);
328+
expect(result.success).true;
329+
expect(result.data).deep.equal(['a', 'b', 'c', 'd']);
330+
});
331+
});
303332
});
304333
});

0 commit comments

Comments
 (0)