@rvoh/dream 0.45.1 → 0.45.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.
- package/dist/cjs/src/bin/index.js +6 -2
- package/dist/cjs/src/cli/index.js +41 -5
- package/dist/cjs/src/helpers/cli/generateDream.js +2 -0
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +6 -2
- package/dist/cjs/src/helpers/cli/generateFactoryContent.js +27 -17
- package/dist/cjs/src/helpers/cli/generateMigrationContent.js +45 -39
- package/dist/cjs/src/helpers/cli/generateSerializer.js +2 -1
- package/dist/cjs/src/helpers/cli/generateSerializerContent.js +20 -8
- package/dist/esm/src/bin/index.js +6 -2
- package/dist/esm/src/cli/index.js +41 -5
- package/dist/esm/src/helpers/cli/generateDream.js +2 -0
- package/dist/esm/src/helpers/cli/generateDreamContent.js +6 -2
- package/dist/esm/src/helpers/cli/generateFactoryContent.js +27 -17
- package/dist/esm/src/helpers/cli/generateMigrationContent.js +45 -39
- package/dist/esm/src/helpers/cli/generateSerializer.js +2 -1
- package/dist/esm/src/helpers/cli/generateSerializerContent.js +20 -8
- package/dist/types/src/helpers/cli/generateDream.d.ts +1 -0
- package/dist/types/src/helpers/cli/generateDreamContent.d.ts +2 -1
- package/dist/types/src/helpers/cli/generateSerializer.d.ts +2 -1
- package/dist/types/src/helpers/cli/generateSerializerContent.d.ts +3 -2
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +136 -136
- package/docs/classes/DreamApp.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamLogos.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializerBuilder.html +8 -8
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/ObjectSerializerBuilder.html +8 -8
- package/docs/classes/Query.html +60 -60
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/DreamSerializer.html +1 -1
- package/docs/functions/ObjectSerializer.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/cloneDeepSafe.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/expandStiClasses.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/groupBy.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/inferSerializersFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/intersection.html +1 -1
- package/docs/functions/isDreamSerializer.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/normalizeUnicode.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/sortObjectByKey.html +1 -1
- package/docs/functions/sortObjectByValue.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/BelongsToStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamAppInitOptions.html +2 -2
- package/docs/interfaces/DreamAppOpts.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/OpenapiDescription.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/SerializerRendererOpts.html +2 -2
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.html +1 -1
- package/docs/types/DbTypes.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamModelSerializerType.html +1 -1
- package/docs/types/DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializable.html +1 -1
- package/docs/types/DreamSerializableArray.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/HasManyStatement.html +1 -1
- package/docs/types/HasOneStatement.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializerCasing.html +1 -1
- package/docs/types/SimpleObjectSerializerType.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModel.html +1 -1
- package/docs/types/ViewModelClass.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +2 -2
|
@@ -10,37 +10,47 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
|
|
|
10
10
|
const belongsToNames = [];
|
|
11
11
|
const belongsToTypedNames = [];
|
|
12
12
|
const associationCreationStatements = [];
|
|
13
|
-
const
|
|
14
|
-
let
|
|
13
|
+
const attributeDefaults = [];
|
|
14
|
+
let counterVariableIncremented = false;
|
|
15
15
|
for (const attribute of columnsWithTypes) {
|
|
16
16
|
const [attributeName, attributeType, ...descriptors] = attribute.split(':');
|
|
17
17
|
if (attributeName === undefined)
|
|
18
18
|
continue;
|
|
19
|
-
const fullyQualifiedAssociatedModelName = standardizeFullyQualifiedModelName(attributeName);
|
|
20
|
-
const associationModelName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedAssociatedModelName);
|
|
21
|
-
const associationFactoryImportStatement = `import create${associationModelName} from '${relativeDreamPath('factories', 'factories', fullyQualifiedModelName, fullyQualifiedAssociatedModelName)}'`;
|
|
22
|
-
const associationName = camelize(associationModelName);
|
|
23
19
|
if (attributeName === undefined)
|
|
24
20
|
continue;
|
|
25
|
-
|
|
21
|
+
const attributeVariable = camelize(attributeName.replace(/\//g, ''));
|
|
22
|
+
if (/(_type|_id)$/.test(attributeName))
|
|
26
23
|
continue;
|
|
27
24
|
if (!attributeType)
|
|
28
|
-
throw new Error(`Must pass a column type for ${
|
|
25
|
+
throw new Error(`Must pass a column type for ${attributeName} (i.e. ${attributeName}:string)`);
|
|
29
26
|
switch (attributeType) {
|
|
30
|
-
case 'belongs_to':
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
case 'belongs_to': {
|
|
28
|
+
const fullyQualifiedAssociatedModelName = standardizeFullyQualifiedModelName(attributeName);
|
|
29
|
+
const associationModelName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedAssociatedModelName);
|
|
30
|
+
const associationFactoryImportStatement = `import create${associationModelName} from '${relativeDreamPath('factories', 'factories', fullyQualifiedModelName, fullyQualifiedAssociatedModelName)}'`;
|
|
31
|
+
belongsToNames.push(attributeVariable);
|
|
32
|
+
belongsToTypedNames.push(`${attributeVariable}: ${associationModelName}`);
|
|
33
33
|
additionalImports.push(associationFactoryImportStatement);
|
|
34
|
-
associationCreationStatements.push(`${
|
|
34
|
+
associationCreationStatements.push(`${attributeVariable}: attrs.${attributeVariable} ? null : await create${associationModelName}(),`);
|
|
35
35
|
break;
|
|
36
|
+
}
|
|
36
37
|
case 'string':
|
|
37
38
|
case 'text':
|
|
38
39
|
case 'citext':
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
attributeDefaults.push(`${attributeVariable}: \`${fullyQualifiedModelName} ${attributeVariable} ${counterVariableIncremented ? '${counter}' : '${++counter}'}\`,`);
|
|
41
|
+
counterVariableIncremented = true;
|
|
41
42
|
break;
|
|
42
43
|
case 'enum':
|
|
43
|
-
|
|
44
|
+
attributeDefaults.push(`${attributeVariable}: '${(descriptors.at(-1) || '<tbd>').split(',')[0]}',`);
|
|
45
|
+
break;
|
|
46
|
+
case 'integer':
|
|
47
|
+
attributeDefaults.push(`${attributeVariable}: 1,`);
|
|
48
|
+
break;
|
|
49
|
+
case 'bigint':
|
|
50
|
+
attributeDefaults.push(`${attributeVariable}: '11111111111111111',`);
|
|
51
|
+
break;
|
|
52
|
+
case 'decimal':
|
|
53
|
+
attributeDefaults.push(`${attributeVariable}: 1.1,`);
|
|
44
54
|
break;
|
|
45
55
|
default:
|
|
46
56
|
// noop
|
|
@@ -51,10 +61,10 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
|
|
|
51
61
|
return `\
|
|
52
62
|
import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'
|
|
53
63
|
import ${modelClassName} from '${relativePath}'${additionalImports.length ? '\n' + uniq(additionalImports).join('\n') : ''}
|
|
54
|
-
${
|
|
64
|
+
${counterVariableIncremented ? '\nlet counter = 0\n' : ''}
|
|
55
65
|
export default async function create${modelClassName}(attrs: UpdateableProperties<${modelClassName}> = {}) {
|
|
56
66
|
return await ${modelClassName}.create({
|
|
57
|
-
${associationCreationStatements.length ? associationCreationStatements.join('\n ') + '\n ' : ''}${
|
|
67
|
+
${associationCreationStatements.length ? associationCreationStatements.join('\n ') + '\n ' : ''}${attributeDefaults.length ? attributeDefaults.join('\n ') + '\n ' : ''}...attrs,
|
|
58
68
|
})
|
|
59
69
|
}
|
|
60
70
|
`;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import pluralize from 'pluralize-esm';
|
|
2
2
|
import InvalidDecimalFieldPassedToGenerator from '../../errors/InvalidDecimalFieldPassedToGenerator.js';
|
|
3
|
+
import compact from '../compact.js';
|
|
3
4
|
import foreignKeyTypeFromPrimaryKey from '../db/foreignKeyTypeFromPrimaryKey.js';
|
|
4
5
|
import snakeify from '../snakeify.js';
|
|
5
6
|
const STI_TYPE_COLUMN_NAME = 'type';
|
|
6
7
|
const COLUMNS_TO_INDEX = [STI_TYPE_COLUMN_NAME];
|
|
7
|
-
const NOT_NULL_COLUMNS = [STI_TYPE_COLUMN_NAME];
|
|
8
8
|
export default function generateMigrationContent({ table, columnsWithTypes = [], primaryKeyType = 'bigserial', createOrAlter = 'create', } = {}) {
|
|
9
9
|
const altering = createOrAlter === 'alter';
|
|
10
10
|
let requireCitextExtension = false;
|
|
11
11
|
const { columnDefs, columnDrops, indexDefs, indexDrops } = columnsWithTypes.reduce((acc, attribute) => {
|
|
12
12
|
const { columnDefs, columnDrops, indexDefs, indexDrops } = acc;
|
|
13
13
|
const [nonStandardAttributeName, attributeType, ...descriptors] = attribute.split(':');
|
|
14
|
+
const optional = optionalFromDescriptors(descriptors);
|
|
15
|
+
const sqlAttributeType = getAttributeType(attributeType, descriptors);
|
|
14
16
|
let attributeName = snakeify(nonStandardAttributeName);
|
|
15
17
|
if (attributeName === undefined)
|
|
16
18
|
return acc;
|
|
@@ -18,30 +20,29 @@ export default function generateMigrationContent({ table, columnsWithTypes = [],
|
|
|
18
20
|
return acc;
|
|
19
21
|
if (attributeType === 'citext')
|
|
20
22
|
requireCitextExtension = true;
|
|
21
|
-
const coercedAttributeType = getAttributeType(attribute);
|
|
22
23
|
switch (attributeType) {
|
|
23
24
|
case 'belongs_to':
|
|
24
25
|
columnDefs.push(generateBelongsToStr(attributeName, {
|
|
25
26
|
primaryKeyType,
|
|
26
|
-
optional
|
|
27
|
+
optional,
|
|
27
28
|
}));
|
|
28
29
|
attributeName = associationNameToForeignKey(attributeName);
|
|
29
30
|
break;
|
|
30
31
|
case 'enum':
|
|
31
|
-
columnDefs.push(generateEnumStr(
|
|
32
|
+
columnDefs.push(generateEnumStr(attributeName, { descriptors, optional }));
|
|
32
33
|
break;
|
|
33
34
|
case 'decimal':
|
|
34
|
-
columnDefs.push(generateDecimalStr(
|
|
35
|
+
columnDefs.push(generateDecimalStr(attributeName, { descriptors, optional }));
|
|
35
36
|
break;
|
|
36
37
|
case 'boolean':
|
|
37
|
-
columnDefs.push(generateBooleanStr(attributeName));
|
|
38
|
+
columnDefs.push(generateBooleanStr(attributeName, { optional }));
|
|
38
39
|
break;
|
|
39
40
|
case 'encrypted':
|
|
40
|
-
columnDefs.push(generateColumnStr(`encrypted_${attributeName}`, 'text', descriptors));
|
|
41
|
+
columnDefs.push(generateColumnStr(`encrypted_${attributeName}`, 'text', descriptors, { optional }));
|
|
41
42
|
break;
|
|
42
43
|
default:
|
|
43
|
-
if (
|
|
44
|
-
columnDefs.push(generateColumnStr(attributeName,
|
|
44
|
+
if (sqlAttributeType !== undefined) {
|
|
45
|
+
columnDefs.push(generateColumnStr(attributeName, sqlAttributeType, descriptors, { optional }));
|
|
45
46
|
}
|
|
46
47
|
break;
|
|
47
48
|
}
|
|
@@ -106,31 +107,29 @@ export async function down(db: Kysely<any>): Promise<void> {
|
|
|
106
107
|
}\
|
|
107
108
|
`;
|
|
108
109
|
}
|
|
109
|
-
function getAttributeType(
|
|
110
|
-
const [, attributeType, ...descriptors] = attribute.split(':');
|
|
111
|
-
if (attributeType === 'enum') {
|
|
112
|
-
return enumAttributeType(attribute)[0];
|
|
113
|
-
}
|
|
110
|
+
function getAttributeType(attributeType, descriptors) {
|
|
114
111
|
switch (attributeType) {
|
|
115
|
-
case 'datetime':
|
|
116
|
-
return 'timestamp';
|
|
117
112
|
case 'string':
|
|
118
113
|
return `varchar(${descriptors[0] || 255})`;
|
|
114
|
+
case 'enum':
|
|
115
|
+
return enumAttributeType(descriptors);
|
|
116
|
+
case 'datetime':
|
|
117
|
+
return 'timestamp';
|
|
119
118
|
default:
|
|
120
119
|
return attributeType;
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
|
-
function enumAttributeType(
|
|
124
|
-
const [, , ...descriptors] = attribute.split(':');
|
|
122
|
+
function enumAttributeType(descriptors) {
|
|
125
123
|
return `sql\`${descriptors[0]}_enum\``;
|
|
126
124
|
}
|
|
127
125
|
function generateEnumStatements(columnsWithTypes) {
|
|
128
126
|
const enumStatements = columnsWithTypes.filter(attribute => /:enum:.*:/.test(attribute));
|
|
129
|
-
const finalStatements = enumStatements.map(statement => {
|
|
130
|
-
const enumName = statement.split(':')
|
|
131
|
-
|
|
127
|
+
const finalStatements = compact(enumStatements.map(statement => {
|
|
128
|
+
const [, , enumName, ...descriptors] = statement.split(':');
|
|
129
|
+
optionalFromDescriptors(descriptors);
|
|
130
|
+
const columnsWithTypesString = descriptors[0];
|
|
132
131
|
if (columnsWithTypesString === undefined)
|
|
133
|
-
return
|
|
132
|
+
return;
|
|
134
133
|
const columnsWithTypes = columnsWithTypesString.split(/,\s{0,}/);
|
|
135
134
|
return ` await db.schema
|
|
136
135
|
.createType('${enumName}_enum')
|
|
@@ -138,40 +137,41 @@ function generateEnumStatements(columnsWithTypes) {
|
|
|
138
137
|
${columnsWithTypes.map(attr => `'${attr}'`).join(',\n ')}
|
|
139
138
|
])
|
|
140
139
|
.execute()`;
|
|
141
|
-
});
|
|
140
|
+
}));
|
|
142
141
|
return finalStatements.length ? finalStatements.join('\n\n') + '\n\n' : '';
|
|
143
142
|
}
|
|
144
143
|
function generateEnumDropStatements(columnsWithTypes) {
|
|
145
144
|
const enumStatements = columnsWithTypes.filter(attribute => /:enum:.*:/.test(attribute));
|
|
146
|
-
const finalStatements = enumStatements.map(statement => {
|
|
147
|
-
const enumName = statement.split(':')
|
|
145
|
+
const finalStatements = compact(enumStatements.map(statement => {
|
|
146
|
+
const [, , enumName, ...descriptors] = statement.split(':');
|
|
147
|
+
optionalFromDescriptors(descriptors);
|
|
148
|
+
const columnsWithTypesString = descriptors[0];
|
|
149
|
+
if (columnsWithTypesString === undefined)
|
|
150
|
+
return;
|
|
148
151
|
return `await db.schema.dropType('${enumName}_enum').execute()`;
|
|
149
|
-
});
|
|
152
|
+
}));
|
|
150
153
|
return finalStatements.length ? '\n\n ' + finalStatements.join('\n ') : '';
|
|
151
154
|
}
|
|
152
|
-
function generateBooleanStr(attributeName) {
|
|
153
|
-
return `.addColumn('${attributeName}', 'boolean', col => col.notNull().defaultTo(false))`;
|
|
155
|
+
function generateBooleanStr(attributeName, { optional }) {
|
|
156
|
+
return `.addColumn('${attributeName}', 'boolean'${optional ? '' : ', col => col.notNull().defaultTo(false)'})`;
|
|
154
157
|
}
|
|
155
|
-
function generateEnumStr(
|
|
156
|
-
const computedAttributeType = enumAttributeType(
|
|
157
|
-
const attributeName = attribute.split(':')[0];
|
|
158
|
+
function generateEnumStr(attributeName, { descriptors, optional }) {
|
|
159
|
+
const computedAttributeType = enumAttributeType(descriptors);
|
|
158
160
|
if (attributeName === undefined)
|
|
159
161
|
return '';
|
|
160
|
-
|
|
161
|
-
return `.addColumn('${attributeName}', ${computedAttributeType}${notNull ? ', col => col.notNull()' : ''})`;
|
|
162
|
+
return `.addColumn('${attributeName}', ${computedAttributeType}${optional ? '' : ', col => col.notNull()'})`;
|
|
162
163
|
}
|
|
163
|
-
function generateDecimalStr(
|
|
164
|
-
const [, , ...descriptors] = attribute.split(':');
|
|
164
|
+
function generateDecimalStr(attributeName, { descriptors, optional }) {
|
|
165
165
|
const [scale, precision] = descriptors[0]?.split(',') || [null, null];
|
|
166
166
|
if (!scale || !precision)
|
|
167
|
-
throw new InvalidDecimalFieldPassedToGenerator(
|
|
168
|
-
return `.addColumn('${
|
|
167
|
+
throw new InvalidDecimalFieldPassedToGenerator(attributeName);
|
|
168
|
+
return `.addColumn('${attributeName}', 'decimal(${scale}, ${precision})'${optional ? '' : ', col => col.notNull()'})`;
|
|
169
169
|
}
|
|
170
|
-
function generateColumnStr(attributeName, attributeType, descriptors) {
|
|
170
|
+
function generateColumnStr(attributeName, attributeType, descriptors, { optional }) {
|
|
171
171
|
let returnStr = `.addColumn('${attributeName}', ${attributeTypeString(attributeType)}`;
|
|
172
172
|
const providedDefaultArg = descriptors.find(d => /^default\(/.test(d));
|
|
173
173
|
const providedDefault = providedDefaultArg?.replace(/^default\(/, '')?.replace(/\)$/, '');
|
|
174
|
-
const notNull =
|
|
174
|
+
const notNull = !optional;
|
|
175
175
|
const hasExtraValues = providedDefault || notNull;
|
|
176
176
|
if (hasExtraValues)
|
|
177
177
|
returnStr += ', col => col';
|
|
@@ -223,3 +223,9 @@ function generateIdStr({ primaryKeyType }) {
|
|
|
223
223
|
function associationNameToForeignKey(associationName) {
|
|
224
224
|
return snakeify(associationName.replace(/\//g, '_').replace(/_id$/, '') + '_id');
|
|
225
225
|
}
|
|
226
|
+
function optionalFromDescriptors(descriptors) {
|
|
227
|
+
const optional = descriptors.at(-1) === 'optional';
|
|
228
|
+
if (optional)
|
|
229
|
+
descriptors.pop();
|
|
230
|
+
return optional;
|
|
231
|
+
}
|
|
@@ -3,7 +3,7 @@ import dreamFileAndDirPaths from '../path/dreamFileAndDirPaths.js';
|
|
|
3
3
|
import dreamPath from '../path/dreamPath.js';
|
|
4
4
|
import standardizeFullyQualifiedModelName from '../standardizeFullyQualifiedModelName.js';
|
|
5
5
|
import generateSerializerContent from './generateSerializerContent.js';
|
|
6
|
-
export default async function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, }) {
|
|
6
|
+
export default async function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, }) {
|
|
7
7
|
fullyQualifiedModelName = standardizeFullyQualifiedModelName(fullyQualifiedModelName);
|
|
8
8
|
const { relFilePath, absDirPath, absFilePath } = dreamFileAndDirPaths(dreamPath('serializers'), `${fullyQualifiedModelName}Serializer.ts`);
|
|
9
9
|
try {
|
|
@@ -14,6 +14,7 @@ export default async function generateSerializer({ fullyQualifiedModelName, colu
|
|
|
14
14
|
columnsWithTypes,
|
|
15
15
|
fullyQualifiedParentName,
|
|
16
16
|
stiBaseSerializer,
|
|
17
|
+
includeAdminSerializers,
|
|
17
18
|
}));
|
|
18
19
|
}
|
|
19
20
|
catch (error) {
|
|
@@ -4,7 +4,7 @@ import globalClassNameFromFullyQualifiedModelName from '../globalClassNameFromFu
|
|
|
4
4
|
import relativeDreamPath from '../path/relativeDreamPath.js';
|
|
5
5
|
import standardizeFullyQualifiedModelName from '../standardizeFullyQualifiedModelName.js';
|
|
6
6
|
import uniq from '../uniq.js';
|
|
7
|
-
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes = [], fullyQualifiedParentName, stiBaseSerializer
|
|
7
|
+
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes = [], fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, }) {
|
|
8
8
|
fullyQualifiedModelName = standardizeFullyQualifiedModelName(fullyQualifiedModelName);
|
|
9
9
|
const additionalImports = [];
|
|
10
10
|
const dreamImports = [];
|
|
@@ -24,7 +24,7 @@ export default function generateSerializerContent({ fullyQualifiedModelName, col
|
|
|
24
24
|
: `(${modelInstanceName}: ${modelClassName})`;
|
|
25
25
|
const modelSerializerArgs = `${modelInstanceName}`;
|
|
26
26
|
const dreamSerializerArgs = `${stiBaseSerializer ? 'StiChildClass' : modelClassName}, ${modelInstanceName}`;
|
|
27
|
-
const
|
|
27
|
+
const serializerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName));
|
|
28
28
|
const summarySerializerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName), 'summary');
|
|
29
29
|
const defaultSerializerExtends = isSTI
|
|
30
30
|
? `${serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedParentName))}(${modelClassName}, ${modelSerializerArgs})`
|
|
@@ -32,16 +32,18 @@ export default function generateSerializerContent({ fullyQualifiedModelName, col
|
|
|
32
32
|
const summarySerializerExtends = isSTI
|
|
33
33
|
? `${serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedParentName), 'summary')}(${modelClassName}, ${modelSerializerArgs})`
|
|
34
34
|
: `DreamSerializer(${dreamSerializerArgs})`;
|
|
35
|
+
// Admin variants
|
|
36
|
+
const adminSerializerClassName = serializerClassName.replace(/Serializer$/, 'AdminSerializer');
|
|
37
|
+
const adminSummarySerializerClassName = summarySerializerClassName.replace(/SummarySerializer$/, 'AdminSummarySerializer');
|
|
38
|
+
// end:Admin variants
|
|
35
39
|
const additionalModelImports = [];
|
|
36
40
|
const dreamImport = dreamImports.length
|
|
37
41
|
? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n`
|
|
38
42
|
: '';
|
|
39
43
|
const additionalImportsStr = uniq(additionalImports).join('');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export const ${serialzerClassName} = ${modelSerializerSignature} =>
|
|
44
|
+
const summarySerializer = `export const ${summarySerializerClassName} = ${modelSerializerSignature} =>
|
|
45
|
+
${summarySerializerExtends}${isSTI ? '' : `\n .attribute('id')`}`;
|
|
46
|
+
const defaultSerializer = `export const ${serializerClassName} = ${modelSerializerSignature} =>
|
|
45
47
|
${defaultSerializerExtends}${columnsWithTypes
|
|
46
48
|
.map(attr => {
|
|
47
49
|
const [name, type] = attr.split(':');
|
|
@@ -51,7 +53,17 @@ export const ${serialzerClassName} = ${modelSerializerSignature} =>
|
|
|
51
53
|
return '';
|
|
52
54
|
return `\n ${attribute(name, type, attr)}`;
|
|
53
55
|
})
|
|
54
|
-
.join('
|
|
56
|
+
.join('')}`;
|
|
57
|
+
return `${dreamImport}${additionalImportsStr}${relatedModelImport}${additionalModelImports.join('')}
|
|
58
|
+
${summarySerializer}
|
|
59
|
+
|
|
60
|
+
${defaultSerializer}${!includeAdminSerializers
|
|
61
|
+
? ''
|
|
62
|
+
: `
|
|
63
|
+
|
|
64
|
+
${summarySerializer.replace(summarySerializerClassName, adminSummarySerializerClassName)}
|
|
65
|
+
|
|
66
|
+
${defaultSerializer.replace(serializerClassName, adminSerializerClassName).replace(summarySerializerClassName, adminSummarySerializerClassName)}`}
|
|
55
67
|
`;
|
|
56
68
|
}
|
|
57
69
|
function attribute(name, type, attr) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export default function generateDreamContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, serializer, }: {
|
|
1
|
+
export default function generateDreamContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, serializer, includeAdminSerializers, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
3
|
columnsWithTypes: string[];
|
|
4
4
|
fullyQualifiedParentName?: string | undefined;
|
|
5
5
|
serializer: boolean;
|
|
6
|
+
includeAdminSerializers: boolean;
|
|
6
7
|
}): string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export default function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, }: {
|
|
1
|
+
export default function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
3
|
columnsWithTypes: string[];
|
|
4
4
|
fullyQualifiedParentName?: string | undefined;
|
|
5
5
|
stiBaseSerializer: boolean;
|
|
6
|
+
includeAdminSerializers: boolean;
|
|
6
7
|
}): Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, }: {
|
|
1
|
+
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
3
|
columnsWithTypes?: string[] | undefined;
|
|
4
4
|
fullyQualifiedParentName?: string | undefined;
|
|
5
|
-
stiBaseSerializer
|
|
5
|
+
stiBaseSerializer: boolean;
|
|
6
|
+
includeAdminSerializers: boolean;
|
|
6
7
|
}): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Benchmark | @rvoh/dream</title><meta name="description" content="Documentation for @rvoh/dream"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@rvoh/dream</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@rvoh/dream</a></li><li><a href="Benchmark.html">Benchmark</a></li></ul><h1>Class Benchmark</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Benchmark | @rvoh/dream</title><meta name="description" content="Documentation for @rvoh/dream"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@rvoh/dream</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@rvoh/dream</a></li><li><a href="Benchmark.html">Benchmark</a></li></ul><h1>Class Benchmark</h1></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/605422b2ac68c94b3f0fd8eb8077784dafe370d7/src/helpers/benchmark.ts#L6">src/helpers/benchmark.ts:6</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="Benchmark.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
|
|
2
2
|
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="Benchmark.html#mark" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>mark</span></a>
|
|
3
3
|
<a href="Benchmark.html#start" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>start</span></a>
|
|
4
|
-
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_Benchmark" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Benchmark</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Benchmark.html" class="tsd-signature-type tsd-kind-class">Benchmark</a><a href="#constructor.new_Benchmark" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="Benchmark.html" class="tsd-signature-type tsd-kind-class">Benchmark</a></h4></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="mark" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>mark</span><a href="#mark" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="mark.mark-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">mark</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">message</span>, <span class="tsd-kind-parameter">level</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#mark.mark-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">message</span>: <span class="tsd-signature-type">string</span></span></li><li><span><span class="tsd-kind-parameter">level</span>: <span class="tsd-signature-type">BenchmarkLogLevel</span><span class="tsd-signature-symbol"> = 'log'</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
4
|
+
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_Benchmark" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Benchmark</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Benchmark.html" class="tsd-signature-type tsd-kind-class">Benchmark</a><a href="#constructor.new_Benchmark" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="Benchmark.html" class="tsd-signature-type tsd-kind-class">Benchmark</a></h4></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member"><a id="mark" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>mark</span><a href="#mark" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="mark.mark-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">mark</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">message</span>, <span class="tsd-kind-parameter">level</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#mark.mark-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">message</span>: <span class="tsd-signature-type">string</span></span></li><li><span><span class="tsd-kind-parameter">level</span>: <span class="tsd-signature-type">BenchmarkLogLevel</span><span class="tsd-signature-symbol"> = 'log'</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/605422b2ac68c94b3f0fd8eb8077784dafe370d7/src/helpers/benchmark.ts#L12">src/helpers/benchmark.ts:12</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="start" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>start</span><a href="#start" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="start.start-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">start</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#start.start-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/605422b2ac68c94b3f0fd8eb8077784dafe370d7/src/helpers/benchmark.ts#L8">src/helpers/benchmark.ts:8</a></li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#mark" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>mark</span></a><a href="#start" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>start</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@rvoh/dream</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|