@tstdl/base 0.82.4 → 0.82.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/api/types.d.ts +2 -1
  2. package/api/types.js.map +1 -1
  3. package/authentication/authentication-credentials.repository.d.ts +5 -0
  4. package/authentication/{authentication-credentials.service.js → authentication-credentials.repository.js} +6 -6
  5. package/authentication/authentication-credentials.repository.js.map +1 -0
  6. package/authentication/authentication-session.repository.d.ts +13 -4
  7. package/authentication/authentication-session.repository.js +2 -13
  8. package/authentication/authentication-session.repository.js.map +1 -1
  9. package/authentication/authentication.api.d.ts +28 -0
  10. package/authentication/authentication.api.js +53 -0
  11. package/authentication/authentication.api.js.map +1 -0
  12. package/authentication/authentication.service.d.ts +13 -13
  13. package/authentication/authentication.service.js +50 -25
  14. package/authentication/authentication.service.js.map +1 -1
  15. package/authentication/models/authentication-credentials.model.d.ts +7 -5
  16. package/authentication/models/authentication-credentials.model.js +28 -7
  17. package/authentication/models/authentication-credentials.model.js.map +1 -1
  18. package/authentication/models/authentication-session.model.d.ts +13 -6
  19. package/authentication/models/authentication-session.model.js +47 -9
  20. package/authentication/models/authentication-session.model.js.map +1 -1
  21. package/authentication/models/index.d.ts +1 -0
  22. package/authentication/models/index.js +1 -0
  23. package/authentication/models/index.js.map +1 -1
  24. package/authentication/models/token-payload-base.model.d.ts +5 -0
  25. package/{orm/test.js → authentication/models/token-payload-base.model.js} +19 -10
  26. package/authentication/models/token-payload-base.model.js.map +1 -0
  27. package/authentication/mongo/mongo-authentication-credentials.repository.d.ts +25 -0
  28. package/authentication/mongo/mongo-authentication-credentials.repository.js +65 -0
  29. package/authentication/mongo/mongo-authentication-credentials.repository.js.map +1 -0
  30. package/authentication/mongo/mongo-authentication-session.repository.d.ts +26 -0
  31. package/authentication/mongo/mongo-authentication-session.repository.js +64 -0
  32. package/authentication/mongo/mongo-authentication-session.repository.js.map +1 -0
  33. package/database/mongo/model/document.d.ts +0 -1
  34. package/database/mongo/model/document.js +1 -10
  35. package/database/mongo/model/document.js.map +1 -1
  36. package/database/mongo/module.js +0 -3
  37. package/database/mongo/module.js.map +1 -1
  38. package/database/mongo/query-converter.js.map +1 -1
  39. package/database/query.d.ts +1 -1
  40. package/examples/mail/basic.js +3 -3
  41. package/examples/mail/templates/hello-name.js +7 -2
  42. package/examples/mail/templates/hello-name.js.map +1 -1
  43. package/examples/pdf/basic.js +3 -3
  44. package/examples/pdf/templates/hello-name.js +1 -1
  45. package/examples/pdf/templates/hello-name.js.map +1 -1
  46. package/examples/template/basic.js +13 -7
  47. package/examples/template/basic.js.map +1 -1
  48. package/examples/template/templates/hello-jsx.d.ts +2 -0
  49. package/examples/template/templates/hello-jsx.js +15 -0
  50. package/examples/template/templates/hello-jsx.js.map +1 -0
  51. package/examples/template/templates/hello-name.js +1 -1
  52. package/examples/template/templates/hello-name.js.map +1 -1
  53. package/http/client/adapters/undici-http-client.adapter.js.map +1 -1
  54. package/http/types.d.ts +3 -3
  55. package/mail/mail.service.d.ts +4 -3
  56. package/mail/mail.service.js +5 -8
  57. package/mail/mail.service.js.map +1 -1
  58. package/mail/models/mail-log.model.d.ts +1 -1
  59. package/mail/models/mail-template.model.d.ts +1 -1
  60. package/mail/models/mail-template.model.js +2 -1
  61. package/mail/models/mail-template.model.js.map +1 -1
  62. package/notification/models/notification.model.d.ts +23 -5
  63. package/notification/models/notification.model.js +47 -3
  64. package/notification/models/notification.model.js.map +1 -1
  65. package/notification/notification.repository.d.ts +5 -0
  66. package/notification/notification.repository.js +7 -0
  67. package/notification/notification.repository.js.map +1 -0
  68. package/notification/notification.service.d.ts +2 -2
  69. package/notification/notification.service.js +4 -4
  70. package/notification/notification.service.js.map +1 -1
  71. package/package.json +6 -4
  72. package/pdf/pdf.service.d.ts +5 -4
  73. package/pdf/pdf.service.js +7 -6
  74. package/pdf/pdf.service.js.map +1 -1
  75. package/schema/schemas/assign.d.ts +3 -3
  76. package/schema/utils/schema.js.map +1 -1
  77. package/templates/providers/{file.provider-template.d.ts → file.template-provider.d.ts} +1 -1
  78. package/templates/providers/{file.provider-template.js → file.template-provider.js} +2 -2
  79. package/templates/providers/file.template-provider.js.map +1 -0
  80. package/templates/providers/memory.template-provider.d.ts +1 -1
  81. package/templates/providers/memory.template-provider.js +1 -1
  82. package/templates/providers/memory.template-provider.js.map +1 -1
  83. package/templates/renderers/handlebars.template-renderer.js.map +1 -1
  84. package/templates/renderers/jsx.template-renderer.d.ts +16 -0
  85. package/templates/renderers/jsx.template-renderer.js +40 -0
  86. package/templates/renderers/jsx.template-renderer.js.map +1 -0
  87. package/templates/renderers/mjml.template-renderer.d.ts +1 -1
  88. package/templates/renderers/string.template-renderer.d.ts +2 -2
  89. package/templates/renderers/string.template-renderer.js +1 -1
  90. package/templates/renderers/string.template-renderer.js.map +1 -1
  91. package/templates/resolvers/file.template-resolver.d.ts +2 -2
  92. package/templates/resolvers/jsx.template-resolver.d.ts +15 -0
  93. package/templates/resolvers/jsx.template-resolver.js +45 -0
  94. package/templates/resolvers/jsx.template-resolver.js.map +1 -0
  95. package/templates/resolvers/string.template-resolver.d.ts +1 -1
  96. package/templates/resolvers/string.template-resolver.js +1 -1
  97. package/templates/resolvers/string.template-resolver.js.map +1 -1
  98. package/templates/template.model.d.ts +3 -1
  99. package/templates/template.model.js +8 -1
  100. package/templates/template.model.js.map +1 -1
  101. package/templates/template.provider.d.ts +1 -1
  102. package/templates/template.renderer.d.ts +5 -2
  103. package/templates/template.renderer.js +6 -1
  104. package/templates/template.renderer.js.map +1 -1
  105. package/templates/template.resolver.d.ts +2 -2
  106. package/templates/template.service.d.ts +3 -2
  107. package/templates/template.service.js +6 -1
  108. package/templates/template.service.js.map +1 -1
  109. package/templates/tokens.d.ts +1 -1
  110. package/text/localization.service.js +1 -1
  111. package/text/localization.service.js.map +1 -1
  112. package/tsconfig.json +5 -0
  113. package/types.d.ts +6 -32
  114. package/utils/jwt.js +2 -2
  115. package/utils/jwt.js.map +1 -1
  116. package/utils/object/object.d.ts +1 -1
  117. package/utils/object/object.js +6 -5
  118. package/utils/object/object.js.map +1 -1
  119. package/authentication/authentication-credentials.service.d.ts +0 -6
  120. package/authentication/authentication-credentials.service.js.map +0 -1
  121. package/orm/decorators.d.ts +0 -26
  122. package/orm/decorators.js +0 -172
  123. package/orm/decorators.js.map +0 -1
  124. package/orm/entity-definition.model.d.ts +0 -51
  125. package/orm/entity-definition.model.js +0 -27
  126. package/orm/entity-definition.model.js.map +0 -1
  127. package/orm/index.d.ts +0 -1
  128. package/orm/index.js +0 -18
  129. package/orm/index.js.map +0 -1
  130. package/orm/models/entity.d.ts +0 -22
  131. package/orm/models/entity.js +0 -87
  132. package/orm/models/entity.js.map +0 -1
  133. package/orm/models/index.d.ts +0 -1
  134. package/orm/models/index.js +0 -18
  135. package/orm/models/index.js.map +0 -1
  136. package/orm/repository/mongo/classes.d.ts +0 -25
  137. package/orm/repository/mongo/classes.js +0 -33
  138. package/orm/repository/mongo/classes.js.map +0 -1
  139. package/orm/repository/mongo/module.d.ts +0 -8
  140. package/orm/repository/mongo/module.js +0 -88
  141. package/orm/repository/mongo/module.js.map +0 -1
  142. package/orm/repository/mongo/mongo-repository.d.ts +0 -11
  143. package/orm/repository/mongo/mongo-repository.js +0 -55
  144. package/orm/repository/mongo/mongo-repository.js.map +0 -1
  145. package/orm/repository/mongo/mongo-transaction.d.ts +0 -10
  146. package/orm/repository/mongo/mongo-transaction.js +0 -28
  147. package/orm/repository/mongo/mongo-transaction.js.map +0 -1
  148. package/orm/repository/repository.d.ts +0 -75
  149. package/orm/repository/repository.js +0 -182
  150. package/orm/repository/repository.js.map +0 -1
  151. package/orm/repository/transaction.d.ts +0 -26
  152. package/orm/repository/transaction.js +0 -65
  153. package/orm/repository/transaction.js.map +0 -1
  154. package/orm/sql/sql-repository.d.ts +0 -6
  155. package/orm/sql/sql-repository.js +0 -15
  156. package/orm/sql/sql-repository.js.map +0 -1
  157. package/orm/test.d.ts +0 -1
  158. package/orm/test.js.map +0 -1
  159. package/orm/types/definition.d.ts +0 -19
  160. package/orm/types/definition.js +0 -55
  161. package/orm/types/definition.js.map +0 -1
  162. package/orm/types/index.d.ts +0 -3
  163. package/orm/types/index.js +0 -20
  164. package/orm/types/index.js.map +0 -1
  165. package/orm/types/options.d.ts +0 -36
  166. package/orm/types/options.js +0 -5
  167. package/orm/types/options.js.map +0 -1
  168. package/orm/types/query.d.ts +0 -110
  169. package/orm/types/query.js +0 -10
  170. package/orm/types/query.js.map +0 -1
  171. package/templates/providers/file.provider-template.js.map +0 -1
package/orm/decorators.js DELETED
@@ -1,172 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/naming-convention */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getEntityDefinition = exports.Index = exports.RevisionField = exports.DeletedField = exports.UpdatedField = exports.CreatedField = exports.PrimaryGeneratedField = exports.PrimaryField = exports.NullableField = exports.Field = exports.Entity = exports.createFieldDecorator = exports.createEntityDecorator = void 0;
5
- const error_1 = require("../error");
6
- const json_path_1 = require("../json-path");
7
- const reflection_1 = require("../reflection");
8
- const enumeration_1 = require("../schema/constraints/enumeration");
9
- const integer_1 = require("../schema/constraints/integer");
10
- const types_1 = require("../schema/types");
11
- const utils_1 = require("../schema/utils");
12
- const array_1 = require("../utils/array/array");
13
- const distinct_1 = require("../utils/iterable-helpers/distinct");
14
- const map_1 = require("../utils/iterable-helpers/map");
15
- const object_1 = require("../utils/object");
16
- const type_guards_1 = require("../utils/type-guards");
17
- function getEntityOptions(typeOrMetadata) {
18
- const metadata = (0, type_guards_1.isFunction)(typeOrMetadata) ? reflection_1.reflectionRegistry.getMetadata(typeOrMetadata) : typeOrMetadata;
19
- (0, type_guards_1.assert)(metadata?.metadataType == 'type', 'EntityOptions is only available for classes.');
20
- return metadata.data.tryGet('orm') ?? {};
21
- }
22
- function getFieldOptions(typeOrMetadata, property) {
23
- const metadata = (0, type_guards_1.isFunction)(typeOrMetadata) ? reflection_1.reflectionRegistry.getMetadata(typeOrMetadata)?.properties.get((0, type_guards_1.assertDefinedPass)(property, 'Missing property parameter.')) : typeOrMetadata;
24
- (0, type_guards_1.assert)(metadata?.metadataType == 'property', 'FieldOptions is only available for properties.');
25
- return metadata.data.tryGet('orm') ?? {};
26
- }
27
- function createEntityDecorator(options) {
28
- return (0, reflection_1.createClassDecorator)({ data: { orm: options }, mergeData: true });
29
- }
30
- exports.createEntityDecorator = createEntityDecorator;
31
- function createFieldDecorator(options) {
32
- return (0, reflection_1.createPropertyDecorator)({ data: { orm: options }, mergeData: true });
33
- }
34
- exports.createFieldDecorator = createFieldDecorator;
35
- function Entity(options = {}) {
36
- return createEntityDecorator(options);
37
- }
38
- exports.Entity = Entity;
39
- function Field(options = {}) {
40
- return createFieldDecorator(options);
41
- }
42
- exports.Field = Field;
43
- function NullableField(options = {}) {
44
- return Field({ ...options, nullable: true });
45
- }
46
- exports.NullableField = NullableField;
47
- function PrimaryField(options) {
48
- return Field({ ...options, primary: true });
49
- }
50
- exports.PrimaryField = PrimaryField;
51
- function PrimaryGeneratedField(options) {
52
- return PrimaryField({ ...options, generated: true });
53
- }
54
- exports.PrimaryGeneratedField = PrimaryGeneratedField;
55
- function CreatedField(options) {
56
- return Field({ ...options, type: 'created' });
57
- }
58
- exports.CreatedField = CreatedField;
59
- function UpdatedField(options) {
60
- return Field({ ...options, type: 'updated', nullable: true });
61
- }
62
- exports.UpdatedField = UpdatedField;
63
- function DeletedField(options) {
64
- return Field({ ...options, type: 'deleted', nullable: true });
65
- }
66
- exports.DeletedField = DeletedField;
67
- function RevisionField(options) {
68
- return Field({ ...options, type: 'revision' });
69
- }
70
- exports.RevisionField = RevisionField;
71
- function Index(fieldsOrOptions, optionsOrNothing) {
72
- const fields = (0, type_guards_1.isArray)(fieldsOrOptions) ? fieldsOrOptions : undefined;
73
- const options = ((0, type_guards_1.isArray)(fieldsOrOptions) ? optionsOrNothing : fieldsOrOptions) ?? {};
74
- return (0, reflection_1.createDecorator)({ class: true, property: true }, (data, metadata) => {
75
- switch (data.type) {
76
- case 'class':
77
- const entityOptions = getEntityOptions(metadata);
78
- (0, type_guards_1.assertArray)(fields, 'Fields can only be specified on class index decorator.');
79
- Entity({ indexes: [...(entityOptions.indexes ?? []), { fields, ...options }] })(data.constructor);
80
- break;
81
- case 'property':
82
- const fieldOptions = getFieldOptions(metadata);
83
- Field({ indexes: [...(fieldOptions.indexes ?? []), options] })(data.prototype, data.propertyKey);
84
- break;
85
- default:
86
- throw new error_1.NotSupportedError('Only works for classes and properties.');
87
- }
88
- });
89
- }
90
- exports.Index = Index;
91
- function getEntityDefinition(typeOrData, path = json_path_1.JsonPath.ROOT) {
92
- const type = (0, type_guards_1.isFunction)(typeOrData) ? typeOrData : undefined;
93
- const typeMetadata = (0, type_guards_1.isDefined)(type) ? reflection_1.reflectionRegistry.getMetadata(type) : undefined;
94
- if ((0, type_guards_1.isUndefined)(typeMetadata)) {
95
- throw new Error(`Type not found in reflection. Missing decorators? (${path.path})`);
96
- }
97
- const entityOptions = (0, type_guards_1.isDefined)(typeMetadata) ? getEntityOptions(typeMetadata) : typeOrData.entityOptions;
98
- const objectSchema = (0, type_guards_1.isFunction)(typeOrData) ? (0, utils_1.tryGetObjectSchemaFromReflection)(typeOrData) : typeOrData.objectSchema;
99
- const properties = [...(0, distinct_1.distinct)([...typeMetadata.properties.keys(), ...(0, object_1.objectKeys)(objectSchema?.properties ?? {})])];
100
- const fieldEntries = (0, map_1.map)(properties, (property) => {
101
- const propertyName = property.toString();
102
- const propertyMetadata = typeMetadata.properties.get(propertyName);
103
- const fieldOptions = (0, type_guards_1.isDefined)(propertyMetadata) ? getFieldOptions(propertyMetadata) : undefined;
104
- const propertySchema = objectSchema?.properties[propertyName];
105
- const fieldType = fieldOptions?.type
106
- ?? getFieldTypeFromSchema((0, type_guards_1.assertNotArrayPass)((0, type_guards_1.assertDefinedPass)(propertySchema, 'Could not get field type from schema.'), 'Only a single type is allowed as field type.'), path.add(propertyName));
107
- return [propertyName, (0, object_1.filterObject)({
108
- name: fieldOptions?.name,
109
- type: fieldType,
110
- primary: fieldOptions?.primary,
111
- generated: fieldOptions?.generated,
112
- nullable: fieldOptions?.nullable ?? ((0, types_1.isValueSchema)(propertySchema) ? (((propertySchema.nullable ?? false) || (propertySchema.optional ?? false)) ? true : undefined) : undefined),
113
- indexes: fieldOptions?.indexes
114
- }, type_guards_1.isDefined)];
115
- });
116
- return {
117
- name: (0, type_guards_1.assertDefinedPass)(entityOptions?.name ?? type?.name, 'Entity name not defined.'),
118
- indexes: entityOptions?.indexes,
119
- fields: Object.fromEntries(fieldEntries)
120
- };
121
- }
122
- exports.getEntityDefinition = getEntityDefinition;
123
- function getFieldTypeFromSchema(schema, path) {
124
- if ((0, types_1.isObjectSchema)(schema)) {
125
- return { nested: getEntityDefinition({ objectSchema: schema }) };
126
- }
127
- if ((0, type_guards_1.isFunction)(schema)) {
128
- return getFieldTypeFromType(schema, path);
129
- }
130
- if ((0, type_guards_1.isString)(schema)) {
131
- throw new error_1.NotSupportedError(`Schema type "${schema}" is not supported as field type.`);
132
- }
133
- if ((0, types_1.isDeferredValueType)(schema)) {
134
- return getFieldTypeFromSchema((0, types_1.resolveValueType)(schema), path);
135
- }
136
- if ((0, types_1.isTypeSchema)(schema)) {
137
- return getFieldTypeFromSchema((0, types_1.resolveValueType)(schema.type), path);
138
- }
139
- return getFieldTypeFromValueSchema(schema, path);
140
- }
141
- function getFieldTypeFromValueSchema(schema, path) {
142
- if ((0, type_guards_1.isDefined)(schema.valueConstraints)) {
143
- const constraints = (0, array_1.toArray)(schema.valueConstraints ?? []);
144
- const enumerationConstraint = constraints.find((constraint) => constraint instanceof enumeration_1.EnumerationConstraint);
145
- const integerConstraint = constraints.find((constraint) => constraint instanceof integer_1.IntegerConstraint);
146
- if ((0, type_guards_1.isDefined)(enumerationConstraint)) {
147
- return { enumeration: enumerationConstraint.enumeration };
148
- }
149
- if ((0, type_guards_1.isDefined)(integerConstraint)) {
150
- return 'integer';
151
- }
152
- }
153
- const innerSchemas = (0, array_1.toArray)(schema.schema);
154
- (0, type_guards_1.assert)(innerSchemas.length == 1, `Could not get field type from schema type as exactly 1 schema is required, but ${innerSchemas.length} were given.`);
155
- const innerSchema = innerSchemas[0];
156
- return getFieldTypeFromSchema(innerSchema, path);
157
- }
158
- function getFieldTypeFromType(type, path) {
159
- switch (type) {
160
- case String:
161
- return 'string';
162
- case Number:
163
- return 'float';
164
- case Boolean:
165
- return 'boolean';
166
- case Date:
167
- return 'date-time';
168
- default:
169
- return { nested: getEntityDefinition(type, path) };
170
- }
171
- }
172
- //# sourceMappingURL=decorators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../source/orm/decorators.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAEzD,oCAA4C;AAC5C,4CAAuC;AAEvC,8CAAkH;AAClH,mEAAyE;AACzE,2DAAiE;AAGjE,2CAAoH;AACpH,2CAAkE;AAElE,gDAA8C;AAC9C,iEAA6D;AAC7D,uDAAmD;AACnD,4CAA0D;AAC1D,sDAAwJ;AAMxJ,SAAS,gBAAgB,CAAC,cAAwD;IAChF,MAAM,QAAQ,GAAG,IAAA,wBAAU,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,+BAAkB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IAE9G,IAAA,oBAAM,EAAC,QAAQ,EAAE,YAAY,IAAI,MAAM,EAAE,8CAA8C,CAAC,CAAC;IACzF,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAgB,KAAK,CAAC,IAAI,EAAE,CAAC;AAC1D,CAAC;AAID,SAAS,eAAe,CAAC,cAAwD,EAAE,QAA0B;IAC3G,MAAM,QAAQ,GAAG,IAAA,wBAAU,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,+BAAkB,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,I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AAI;YACP,OAAO,WAAW,CAAC;QAErB;YACE,OAAO,EAAE,MAAM,EAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;KACtD;AACH,CAAC"}
@@ -1,51 +0,0 @@
1
- import type { AbstractConstructor, Enumeration, Paths, Record } from "../types";
2
- export type FieldType = SpecialFieldType | 'string' | 'integer' | 'float' | 'boolean' | 'date-time' | 'date' | 'time' | 'json' | {
3
- nested: EntityDefinition;
4
- } | {
5
- enumeration: Enumeration;
6
- };
7
- export type SpecialFieldType = 'created' | 'updated' | 'deleted' | 'revision';
8
- export type IndexOptions = {
9
- unique?: boolean;
10
- };
11
- export type IndexDirection = 1 | -1 | 'asc' | 'desc';
12
- export type EntityIndexDefinition<T = any> = IndexOptions & {
13
- fields: (Paths<T> | [Paths<T>, IndexDirection])[] | {
14
- [P in Paths<T>]?: IndexDirection;
15
- };
16
- };
17
- export type FieldIndexDefinition = IndexOptions;
18
- export type FieldDefinition = {
19
- /** type of field in database */
20
- type: FieldType;
21
- /** type of property in object (used for conversion) */
22
- propertyType?: AbstractConstructor | 'numeric-date';
23
- /** field name in database */
24
- name?: string;
25
- primary?: boolean;
26
- generated?: boolean;
27
- nullable?: boolean;
28
- indexes?: FieldIndexDefinition[];
29
- };
30
- export type EntityDefinition = {
31
- name: string;
32
- fields: Record<string, FieldDefinition>;
33
- indexes?: EntityIndexDefinition[];
34
- };
35
- export type NormalizedEntityDefinition = {
36
- name: string;
37
- fields: Record<string, NormalizedFieldDefinition>;
38
- fieldsEntries: (readonly [string, NormalizedFieldDefinition])[];
39
- indexes: EntityIndexDefinition[];
40
- };
41
- export type NormalizedFieldDefinition = {
42
- type: FieldType;
43
- propertyType?: AbstractConstructor | 'numeric-date' | 'numeric-time';
44
- name: string;
45
- primary: boolean;
46
- generated: boolean;
47
- nullable: boolean;
48
- indexes: FieldIndexDefinition[];
49
- };
50
- export declare function normalizeEntityDefinition(definition: EntityDefinition): NormalizedEntityDefinition;
51
- export declare function normalizeFieldDefinition(field: string, definition: FieldDefinition): NormalizedFieldDefinition;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeFieldDefinition = exports.normalizeEntityDefinition = void 0;
4
- const object_1 = require("../utils/object");
5
- function normalizeEntityDefinition(definition) {
6
- const fieldsEntries = (0, object_1.objectEntries)(definition.fields).map(([field, fieldDefinition]) => [field, normalizeFieldDefinition(field, fieldDefinition)]);
7
- return {
8
- name: definition.name,
9
- fields: Object.fromEntries(fieldsEntries),
10
- fieldsEntries,
11
- indexes: definition.indexes ?? []
12
- };
13
- }
14
- exports.normalizeEntityDefinition = normalizeEntityDefinition;
15
- function normalizeFieldDefinition(field, definition) {
16
- return {
17
- type: definition.type,
18
- propertyType: definition.propertyType,
19
- name: definition.name ?? field,
20
- primary: definition.primary ?? false,
21
- generated: definition.generated ?? false,
22
- nullable: definition.nullable ?? false,
23
- indexes: definition.indexes ?? []
24
- };
25
- }
26
- exports.normalizeFieldDefinition = normalizeFieldDefinition;
27
- //# sourceMappingURL=entity-definition.model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity-definition.model.js","sourceRoot":"","sources":["../../source/orm/entity-definition.model.ts"],"names":[],"mappings":";;;AACA,4CAA+C;AAyD/C,SAAgB,yBAAyB,CAAC,UAA4B;IACpE,MAAM,aAAa,GAAG,IAAA,sBAAa,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,wBAAwB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAU,CAAC,CAAC;IAE7J,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC;QACzC,aAAa;QACb,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;KAClC,CAAC;AACJ,CAAC;AATD,8DASC;AAED,SAAgB,wBAAwB,CAAC,KAAa,EAAE,UAA2B;IACjF,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,KAAK;QAC9B,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,KAAK;QACpC,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,KAAK;QACxC,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,KAAK;QACtC,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;KAClC,CAAC;AACJ,CAAC;AAVD,4DAUC"}
package/orm/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './models';
package/orm/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./models"), exports);
18
- //# sourceMappingURL=index.js.map
package/orm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/orm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
@@ -1,22 +0,0 @@
1
- import type { ObjectLiteral, PartialProperty, Type } from "../../types";
2
- export type Id = string | number;
3
- export declare abstract class EntityMetadata {
4
- revision: number;
5
- created: Date;
6
- updated?: Date;
7
- deleted?: Date;
8
- }
9
- export declare abstract class Entity {
10
- id: string;
11
- }
12
- export declare abstract class EntityWithMetadata extends Entity {
13
- metadata: EntityMetadata;
14
- }
15
- export declare abstract class NewEntityBase {
16
- id?: string;
17
- }
18
- export type NewEntity<T> = T extends Entity ? PartialProperty<T, 'id'> : T;
19
- export type MaybeNewEntity<T> = T | NewEntity<T>;
20
- export declare function newEntity<T extends ObjectLiteral>(type: Type<T>): Type<NewEntity<T>>;
21
- export declare function toEntity<T extends Entity>(entity: T | NewEntity<T>): T;
22
- export declare function isId(value: any): value is Id;
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.isId = exports.toEntity = exports.newEntity = exports.NewEntityBase = exports.EntityWithMetadata = exports.Entity = exports.EntityMetadata = void 0;
13
- const database_1 = require("../../database");
14
- const schema_1 = require("../../schema");
15
- const type_guards_1 = require("../../utils/type-guards");
16
- const decorators_1 = require("../decorators");
17
- class EntityMetadata {
18
- revision;
19
- created;
20
- updated;
21
- deleted;
22
- }
23
- __decorate([
24
- (0, decorators_1.RevisionField)(),
25
- __metadata("design:type", Number)
26
- ], EntityMetadata.prototype, "revision", void 0);
27
- __decorate([
28
- (0, decorators_1.CreatedField)(),
29
- __metadata("design:type", Date)
30
- ], EntityMetadata.prototype, "created", void 0);
31
- __decorate([
32
- (0, decorators_1.UpdatedField)(),
33
- __metadata("design:type", Date)
34
- ], EntityMetadata.prototype, "updated", void 0);
35
- __decorate([
36
- (0, decorators_1.DeletedField)(),
37
- __metadata("design:type", Date)
38
- ], EntityMetadata.prototype, "deleted", void 0);
39
- exports.EntityMetadata = EntityMetadata;
40
- class Entity {
41
- id;
42
- }
43
- __decorate([
44
- (0, schema_1.Property)(),
45
- __metadata("design:type", String)
46
- ], Entity.prototype, "id", void 0);
47
- exports.Entity = Entity;
48
- class EntityWithMetadata extends Entity {
49
- metadata;
50
- }
51
- __decorate([
52
- (0, schema_1.Property)(),
53
- __metadata("design:type", EntityMetadata)
54
- ], EntityWithMetadata.prototype, "metadata", void 0);
55
- exports.EntityWithMetadata = EntityWithMetadata;
56
- class NewEntityBase {
57
- id;
58
- }
59
- __decorate([
60
- (0, schema_1.Optional)(String),
61
- __metadata("design:type", String)
62
- ], NewEntityBase.prototype, "id", void 0);
63
- exports.NewEntityBase = NewEntityBase;
64
- function newEntity(type) {
65
- const newName = `New${type.name}Base`;
66
- const newClass = {
67
- [newName]: class extends NewEntityBase {
68
- }
69
- }[newName];
70
- Reflect.decorate([(0, schema_1.Class)({ schema: (0, schema_1.assign)(NewEntityBase, (0, schema_1.partial)(type, 'id')) })], newClass);
71
- return newClass;
72
- }
73
- exports.newEntity = newEntity;
74
- function toEntity(entity) {
75
- const { id, ...entityRest } = entity;
76
- const entityWithId = {
77
- id: id ?? (0, database_1.getNewId)(),
78
- ...entityRest
79
- };
80
- return entityWithId;
81
- }
82
- exports.toEntity = toEntity;
83
- function isId(value) {
84
- return (0, type_guards_1.isString)(value) || (0, type_guards_1.isNumber)(value);
85
- }
86
- exports.isId = isId;
87
- //# sourceMappingURL=entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../source/orm/models/entity.ts"],"names":[],"mappings":";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AAG,UAAU,EAAE,GAAG,MAAM,CAAC;IAErC,MAAM,YAAY,GAAG;QACnB,EAAE,EAAE,EAAE,IAAI,IAAA,mBAAQ,GAAE;QACpB,GAAG,UAAU;KACT,CAAC;IAEP,OAAO,YAAY,CAAC;AACtB,CAAC;AATD,4BASC;AAED,SAAgB,IAAI,CAAC,KAAU;IAC7B,OAAO,IAAA,sBAAQ,EAAC,KAAK,CAAC,IAAI,IAAA,sBAAQ,EAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAFD,oBAEC"}
@@ -1 +0,0 @@
1
- export * from './entity';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./entity"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/orm/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
@@ -1,25 +0,0 @@
1
- import type { Injectable } from "../../../container";
2
- import { resolveArgumentType } from "../../../container";
3
- import type { MongoClientOptions } from 'mongodb';
4
- import { Collection as MongoCollection, Db, MongoClient as MongoMongoClient } from 'mongodb';
5
- export type MongoConnection = {
6
- url: string;
7
- } & MongoClientOptions;
8
- export type MongoClientArgument = MongoConnection;
9
- /** database name */
10
- export type DatabaseArgument = string | {
11
- connection?: MongoConnection;
12
- database?: string;
13
- };
14
- export type CollectionArgument = string | (DatabaseArgument & {
15
- collection: string;
16
- });
17
- export declare class MongoClient extends MongoMongoClient implements Injectable<MongoClientArgument> {
18
- readonly [resolveArgumentType]: MongoClientArgument;
19
- }
20
- export declare class Database extends Db implements Injectable<DatabaseArgument> {
21
- readonly [resolveArgumentType]: DatabaseArgument;
22
- }
23
- export declare class Collection extends MongoCollection implements Injectable<CollectionArgument> {
24
- readonly [resolveArgumentType]: CollectionArgument;
25
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Collection = exports.Database = exports.MongoClient = void 0;
10
- const container_1 = require("../../../container");
11
- const mongodb_1 = require("mongodb");
12
- let MongoClient = class MongoClient extends mongodb_1.MongoClient {
13
- [container_1.resolveArgumentType];
14
- };
15
- MongoClient = __decorate([
16
- (0, container_1.replaceClass)(mongodb_1.MongoClient)
17
- ], MongoClient);
18
- exports.MongoClient = MongoClient;
19
- let Database = class Database extends mongodb_1.Db {
20
- [container_1.resolveArgumentType];
21
- };
22
- Database = __decorate([
23
- (0, container_1.replaceClass)(mongodb_1.Db)
24
- ], Database);
25
- exports.Database = Database;
26
- let Collection = class Collection extends mongodb_1.Collection {
27
- [container_1.resolveArgumentType];
28
- };
29
- Collection = __decorate([
30
- (0, container_1.replaceClass)(mongodb_1.Collection)
31
- ], Collection);
32
- exports.Collection = Collection;
33
- //# sourceMappingURL=classes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"classes.js","sourceRoot":"","sources":["../../../../source/orm/repository/mongo/classes.ts"],"names":[],"mappings":";;;;;;;;;AAEA,kDAAgE;AAEhE,qCAA6F;AActF,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,qBAAgB;IACtC,CAAC,+BAAmB,CAAC,CAAsB;CACrD,CAAA;AAFY,WAAW;IADvB,IAAA,wBAAY,EAAC,qBAAgB,CAAC;GAClB,WAAW,CAEvB;AAFY,kCAAW;AAKjB,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,YAAE;IACrB,CAAC,+BAAmB,CAAC,CAAmB;CAClD,CAAA;AAFY,QAAQ;IADpB,IAAA,wBAAY,EAAC,YAAE,CAAC;GACJ,QAAQ,CAEpB;AAFY,4BAAQ;AAKd,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,oBAAe;IACpC,CAAC,+BAAmB,CAAC,CAAqB;CACpD,CAAA;AAFY,UAAU;IADtB,IAAA,wBAAY,EAAC,oBAAe,CAAC;GACjB,UAAU,CAEtB;AAFY,gCAAU"}
@@ -1,8 +0,0 @@
1
- import type { MongoConnection } from './classes';
2
- export type MongoOrmModuleConfig = {
3
- defaultConnection: MongoConnection;
4
- defaultDatabase: string | undefined;
5
- logPrefix: string;
6
- };
7
- export declare const mongoOrmModuleConfig: MongoOrmModuleConfig;
8
- export declare function configureMongoOrm(config: Partial<MongoOrmModuleConfig>): void;
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configureMongoOrm = exports.mongoOrmModuleConfig = void 0;
4
- const container_1 = require("../../../container");
5
- const core_1 = require("../../../core");
6
- const logger_1 = require("../../../logger");
7
- const object_1 = require("../../../utils/object");
8
- const type_guards_1 = require("../../../utils/type-guards");
9
- const Mongo = require("mongodb");
10
- const classes_1 = require("./classes");
11
- exports.mongoOrmModuleConfig = {
12
- defaultConnection: { url: 'mongodb://localhost:27017/test-db' },
13
- defaultDatabase: undefined,
14
- logPrefix: 'MONGO'
15
- };
16
- function configureMongoOrm(config) {
17
- exports.mongoOrmModuleConfig.defaultDatabase = config.defaultDatabase ?? exports.mongoOrmModuleConfig.defaultDatabase;
18
- exports.mongoOrmModuleConfig.defaultConnection = config.defaultConnection ?? exports.mongoOrmModuleConfig.defaultConnection;
19
- exports.mongoOrmModuleConfig.logPrefix = config.logPrefix ?? exports.mongoOrmModuleConfig.logPrefix;
20
- const mongoLogger = container_1.container.resolve(logger_1.Logger, exports.mongoOrmModuleConfig.logPrefix);
21
- Mongo.Logger.setCurrentLogger((message, parameters) => mongoLogger.verbose(JSON.stringify({ message, parameters }, undefined, 2)));
22
- }
23
- exports.configureMongoOrm = configureMongoOrm;
24
- container_1.container.registerSingleton(classes_1.MongoClient, {
25
- useFactory: async (argument, context) => {
26
- (0, type_guards_1.assertDefined)(argument, 'mongo connection resolve argument missing');
27
- const { url, ...options } = argument;
28
- const logger = context.resolve(logger_1.Logger, exports.mongoOrmModuleConfig.logPrefix);
29
- const client = new classes_1.MongoClient(url, options);
30
- client
31
- .on('fullsetup', () => logger.verbose('connection setup'))
32
- .on('reconnect', () => logger.warn('reconnected'))
33
- .on('timeout', () => logger.warn('connection timed out'))
34
- .on('close', () => logger.verbose('connection closed'));
35
- core_1.disposer.add(async () => client.close(), 10000);
36
- await (0, core_1.connect)(`mongo at ${url}`, async () => client.connect(), logger);
37
- return client;
38
- }
39
- }, {
40
- defaultArgumentProvider: () => exports.mongoOrmModuleConfig.defaultConnection,
41
- argumentIdentityProvider: (argument) => {
42
- if ((0, type_guards_1.isUndefined)(argument)) {
43
- return undefined;
44
- }
45
- const configObject = (0, type_guards_1.isString)(argument) ? { url: argument } : argument;
46
- return JSON.stringify((0, object_1.filterObject)(configObject, type_guards_1.isDefined));
47
- }
48
- });
49
- container_1.container.registerSingleton(classes_1.Database, {
50
- useFactory: async (argument, context) => {
51
- const connection = (0, type_guards_1.isObject)(argument) ? argument.connection : exports.mongoOrmModuleConfig.defaultConnection;
52
- const name = ((0, type_guards_1.isString)(argument) ? argument : (0, type_guards_1.isObject)(argument) ? argument.database : undefined) ?? exports.mongoOrmModuleConfig.defaultDatabase;
53
- const client = await context.resolveAsync(classes_1.MongoClient, connection);
54
- return client.db(name);
55
- }
56
- }, {
57
- defaultArgumentProvider: () => ({ database: exports.mongoOrmModuleConfig.defaultDatabase, connection: exports.mongoOrmModuleConfig.defaultConnection }),
58
- argumentIdentityProvider: (argument) => {
59
- if ((0, type_guards_1.isUndefined)(argument)) {
60
- return undefined;
61
- }
62
- const configObject = (0, type_guards_1.isString)(argument) ? { database: argument } : argument;
63
- return JSON.stringify((0, object_1.filterObject)(configObject, type_guards_1.isDefined));
64
- }
65
- });
66
- container_1.container.registerSingleton(classes_1.Collection, {
67
- useFactory: async (config, context) => {
68
- (0, type_guards_1.assertDefined)(config, 'Mongo repository config resolve argument missing.');
69
- const configCollectionName = (0, type_guards_1.isString)(config) ? config : config.collection;
70
- const database = await context.resolveAsync(classes_1.Database, (0, type_guards_1.isString)(config) ? undefined : config);
71
- const existingCollections = await database.collections();
72
- for (const collection of existingCollections) {
73
- if (collection.collectionName == configCollectionName) {
74
- return collection;
75
- }
76
- }
77
- return database.createCollection(configCollectionName);
78
- }
79
- }, {
80
- argumentIdentityProvider: (argument) => {
81
- if ((0, type_guards_1.isUndefined)(argument)) {
82
- return undefined;
83
- }
84
- const configObject = (0, type_guards_1.isString)(argument) ? { collection: argument } : argument;
85
- return JSON.stringify((0, object_1.filterObject)(configObject, type_guards_1.isDefined));
86
- }
87
- });
88
- //# sourceMappingURL=module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../source/orm/repository/mongo/module.ts"],"names":[],"mappings":";;;AAAA,kDAAwC;AACxC,wCAA2C;AAC3C,4CAAkC;AAClC,kDAA8C;AAC9C,4DAAgG;AAChG,iCAAiC;AAEjC,uCAA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CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QAE3E,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,kBAAQ,EAAE,IAAA,sBAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7F,MAAM,mBAAmB,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;QAEzD,KAAK,MAAM,UAAU,IAAI,mBAAmB,EAAE;YAC5C,IAAI,UAAU,CAAC,cAAc,IAAI,oBAAoB,EAAE;gBACrD,OAAO,UAA0C,CAAC;aACnD;SACF;QAED,OAAO,QAAQ,CAAC,gBAAgB,CAAC,oBAAoB,CAAiB,CAAC;IACzE,CAAC;CACF,EAAE;IACD,wBAAwB,EAAE,CAAC,QAAQ,EAAE,EAAE;QACrC,IAAI,IAAA,yBAAW,EAAC,QAAQ,CAAC,EAAE;YACzB,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,YAAY,GAAuB,IAAA,sBAAQ,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QAClG,OAAO,IAAI,CAAC,SAAS,CAAC,IAAA,qBAAY,EAAC,YAAY,EAAE,uBAAS,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { RepositoryOptions } from '../repository';
2
- import type { IsolationLevel, Transaction } from '../transaction';
3
- import { Collection, MongoClient } from './classes';
4
- export declare class MongoRepository {
5
- private options;
6
- private readonly client;
7
- private readonly collection;
8
- constructor(client: MongoClient, collection: Collection, options: RepositoryOptions);
9
- protected initializeTransaction(isolationLevel: IsolationLevel): Transaction;
10
- protected duplicateInstance(): this;
11
- }