bigal 13.0.0-beta3 → 13.0.0-beta5

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.
@@ -1,369 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('lodash');
4
-
5
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
6
-
7
- const ___default = /*#__PURE__*/_interopDefaultCompat(_);
8
-
9
- var __defProp$5 = Object.defineProperty;
10
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __publicField$5 = (obj, key, value) => {
12
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
13
- return value;
14
- };
15
- class MetadataStorage {
16
- constructor() {
17
- __publicField$5(this, "models", []);
18
- // All columns for all models. This data only represents @column specifics, not additional column modifiers
19
- __publicField$5(this, "columns", []);
20
- // This represents additional column behavior separate from the main @column decorator. For example, @primaryColumn, @versionColumn, etc
21
- // This behavior will be merged over defaults from @column()
22
- __publicField$5(this, "columnModifiers", []);
23
- }
24
- }
25
-
26
- var __defProp$4 = Object.defineProperty;
27
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
28
- var __publicField$4 = (obj, key, value) => {
29
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
30
- return value;
31
- };
32
- class ColumnBaseMetadata {
33
- constructor({
34
- target,
35
- name,
36
- propertyName,
37
- required = false,
38
- insert = true,
39
- update = true,
40
- primary = false,
41
- createDate = false,
42
- updateDate = false,
43
- version = false
44
- }) {
45
- /**
46
- * Name of class with @table decorator
47
- */
48
- __publicField$4(this, "target");
49
- /**
50
- * Column name in the database
51
- */
52
- __publicField$4(this, "name");
53
- /**
54
- * Class property to which the column is applied
55
- */
56
- __publicField$4(this, "propertyName");
57
- /**
58
- * Indicates if a value is required for creates.
59
- */
60
- __publicField$4(this, "required");
61
- /**
62
- * Indicates if column is inserted by default. Default is true
63
- */
64
- __publicField$4(this, "insert");
65
- /**
66
- * Indicates if column value is updated by "save" operation. Default is true
67
- */
68
- __publicField$4(this, "update");
69
- /**
70
- * Indicates if this column is a primary key.
71
- * Same can be achieved when @primaryColumn decorator is used
72
- */
73
- __publicField$4(this, "primary");
74
- /**
75
- * Value will be equal to `new Date()` when the row is inserted into the table
76
- * Same can be achieved when @createDateColumn decorator is used
77
- */
78
- __publicField$4(this, "createDate");
79
- /**
80
- * Value will be equal to `new Date()` when the row is updated
81
- * Same can be achieved when @updateDateColumn decorator is used
82
- */
83
- __publicField$4(this, "updateDate");
84
- /**
85
- * Value will be set to 1 when the row is inserted. Value will be incremented by one when the row is updated
86
- * Same can be achieved when @versionColumn decorator is used
87
- */
88
- __publicField$4(this, "version");
89
- this.target = target;
90
- this.name = name;
91
- this.propertyName = propertyName;
92
- this.required = required;
93
- this.insert = insert;
94
- this.update = update;
95
- this.primary = primary;
96
- this.createDate = createDate;
97
- this.updateDate = updateDate;
98
- this.version = version;
99
- }
100
- }
101
-
102
- var __defProp$3 = Object.defineProperty;
103
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
104
- var __publicField$3 = (obj, key, value) => {
105
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
106
- return value;
107
- };
108
- class ColumnCollectionMetadata extends ColumnBaseMetadata {
109
- constructor({
110
- target,
111
- //
112
- name,
113
- propertyName,
114
- required,
115
- insert,
116
- update,
117
- primary,
118
- createDate,
119
- updateDate,
120
- version,
121
- collection,
122
- via,
123
- through
124
- }) {
125
- super({
126
- target,
127
- name,
128
- propertyName,
129
- required,
130
- insert,
131
- update,
132
- primary,
133
- createDate,
134
- updateDate,
135
- version
136
- });
137
- __publicField$3(this, "_collectionString");
138
- __publicField$3(this, "_collectionFn");
139
- __publicField$3(this, "_throughString");
140
- __publicField$3(this, "_throughFn");
141
- /**
142
- * Property name of the on the collection item type
143
- */
144
- __publicField$3(this, "via");
145
- this.via = via;
146
- if (typeof collection === "string") {
147
- this._collectionString = collection;
148
- } else {
149
- this._collectionFn = collection;
150
- }
151
- if (typeof through === "string") {
152
- this._throughString = through;
153
- } else if (through) {
154
- this._throughFn = through;
155
- }
156
- }
157
- /**
158
- * Type of the items in the collection
159
- */
160
- get collection() {
161
- if (this._collectionString) {
162
- return this._collectionString;
163
- }
164
- if (!this._collectionFn) {
165
- throw new Error(`Unable to determine collection type for ${this.target}#${this.propertyName}`);
166
- }
167
- this._collectionString = this._collectionFn();
168
- return this._collectionString;
169
- }
170
- /**
171
- * Name of the junction table for multi-multi associations
172
- */
173
- get through() {
174
- if (this._throughString) {
175
- return this._throughString;
176
- }
177
- if (this._throughFn) {
178
- this._throughString = this._throughFn();
179
- return this._throughString;
180
- }
181
- return void 0;
182
- }
183
- }
184
-
185
- var __defProp$2 = Object.defineProperty;
186
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
187
- var __publicField$2 = (obj, key, value) => {
188
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
189
- return value;
190
- };
191
- class ColumnModelMetadata extends ColumnBaseMetadata {
192
- constructor({
193
- target,
194
- //
195
- name,
196
- propertyName,
197
- required,
198
- insert,
199
- update,
200
- primary,
201
- createDate,
202
- updateDate,
203
- version,
204
- model
205
- }) {
206
- super({
207
- target,
208
- name,
209
- propertyName,
210
- required,
211
- insert,
212
- update,
213
- primary,
214
- createDate,
215
- updateDate,
216
- version
217
- });
218
- __publicField$2(this, "_modelString");
219
- __publicField$2(this, "_modelFn");
220
- if (typeof model === "string") {
221
- this._modelString = model;
222
- } else {
223
- this._modelFn = model;
224
- }
225
- }
226
- /**
227
- * Name of the model represented by this column id
228
- */
229
- get model() {
230
- if (this._modelString) {
231
- return this._modelString;
232
- }
233
- if (!this._modelFn) {
234
- throw new Error(`Unable to determine model type for ${this.target}#${this.propertyName}`);
235
- }
236
- this._modelString = this._modelFn();
237
- return this._modelString;
238
- }
239
- }
240
-
241
- var __defProp$1 = Object.defineProperty;
242
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
243
- var __publicField$1 = (obj, key, value) => {
244
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
245
- return value;
246
- };
247
- class ColumnTypeMetadata extends ColumnBaseMetadata {
248
- constructor(options) {
249
- super({
250
- target: options.target,
251
- name: options.name,
252
- propertyName: options.propertyName,
253
- required: options.required,
254
- insert: options.insert,
255
- update: options.update,
256
- primary: options.primary,
257
- createDate: options.createDate,
258
- updateDate: options.updateDate,
259
- version: options.version
260
- });
261
- /**
262
- * Type of the column
263
- */
264
- __publicField$1(this, "type");
265
- /**
266
- * Default database value
267
- */
268
- __publicField$1(this, "defaultsTo");
269
- /**
270
- * Array of possible enumerated values
271
- */
272
- __publicField$1(this, "enum");
273
- /**
274
- * If set, enforces a maximum length check on the column
275
- *
276
- * Applies to types: string | string[]
277
- */
278
- __publicField$1(this, "maxLength");
279
- this.type = options.type;
280
- this.defaultsTo = options.defaultsTo;
281
- this.enum = options.enum;
282
- this.maxLength = options.maxLength;
283
- }
284
- }
285
-
286
- var __defProp = Object.defineProperty;
287
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
288
- var __publicField = (obj, key, value) => {
289
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
290
- return value;
291
- };
292
- class ModelMetadata {
293
- constructor({
294
- name,
295
- //
296
- type,
297
- connection,
298
- tableName,
299
- readonly = false
300
- }) {
301
- __publicField(this, "_columns", []);
302
- __publicField(this, "_primaryKeyColumn");
303
- __publicField(this, "_createDateColumns", []);
304
- __publicField(this, "_updateDateColumns", []);
305
- __publicField(this, "_versionDateColumns", []);
306
- __publicField(this, "name");
307
- __publicField(this, "type");
308
- __publicField(this, "connection");
309
- __publicField(this, "tableName");
310
- __publicField(this, "readonly");
311
- __publicField(this, "columnsByColumnName", {});
312
- __publicField(this, "columnsByPropertyName", {});
313
- this.name = name;
314
- this.type = type;
315
- this.connection = connection;
316
- this.tableName = tableName ?? ___default.snakeCase(name);
317
- this.readonly = readonly;
318
- }
319
- set columns(columns) {
320
- this._columns = columns;
321
- this.columnsByColumnName = {};
322
- this.columnsByPropertyName = {};
323
- for (const column of columns) {
324
- this.columnsByColumnName[column.name] = column;
325
- this.columnsByPropertyName[column.propertyName] = column;
326
- if (column.primary) {
327
- this._primaryKeyColumn = column;
328
- }
329
- if (column.createDate) {
330
- this._createDateColumns.push(column);
331
- }
332
- if (column.updateDate) {
333
- this._updateDateColumns.push(column);
334
- }
335
- if (column.version) {
336
- this._versionDateColumns.push(column);
337
- }
338
- }
339
- }
340
- get columns() {
341
- return this._columns;
342
- }
343
- get primaryKeyColumn() {
344
- return this._primaryKeyColumn;
345
- }
346
- get createDateColumns() {
347
- return this._createDateColumns;
348
- }
349
- get updateDateColumns() {
350
- return this._updateDateColumns;
351
- }
352
- get versionColumns() {
353
- return this._versionDateColumns;
354
- }
355
- }
356
-
357
- function getMetadataStorage() {
358
- if (!global.bigAlMetadataArgsStorage) {
359
- global.bigAlMetadataArgsStorage = new MetadataStorage();
360
- }
361
- return global.bigAlMetadataArgsStorage;
362
- }
363
-
364
- exports.ColumnBaseMetadata = ColumnBaseMetadata;
365
- exports.ColumnCollectionMetadata = ColumnCollectionMetadata;
366
- exports.ColumnModelMetadata = ColumnModelMetadata;
367
- exports.ColumnTypeMetadata = ColumnTypeMetadata;
368
- exports.ModelMetadata = ModelMetadata;
369
- exports.getMetadataStorage = getMetadataStorage;
@@ -1 +0,0 @@
1
- export { h as ColumnBaseMetadata, f as ColumnBaseMetadataOptions, j as ColumnCollectionMetadata, i as ColumnCollectionMetadataOptions, k as ColumnMetadata, m as ColumnModelMetadata, l as ColumnModelMetadataOptions, n as ColumnModifierMetadata, p as ColumnTypeMetadata, o as ColumnTypeMetadataOptions, M as ModelMetadata, q as ModelMetadataOptions, g as getMetadataStorage } from '../shared/bigal.7bdb464e.cjs';
@@ -1 +0,0 @@
1
- export { h as ColumnBaseMetadata, f as ColumnBaseMetadataOptions, j as ColumnCollectionMetadata, i as ColumnCollectionMetadataOptions, k as ColumnMetadata, m as ColumnModelMetadata, l as ColumnModelMetadataOptions, n as ColumnModifierMetadata, p as ColumnTypeMetadata, o as ColumnTypeMetadataOptions, M as ModelMetadata, q as ModelMetadataOptions, g as getMetadataStorage } from '../shared/bigal.7bdb464e.mjs';
@@ -1 +0,0 @@
1
- export { h as ColumnBaseMetadata, f as ColumnBaseMetadataOptions, j as ColumnCollectionMetadata, i as ColumnCollectionMetadataOptions, k as ColumnMetadata, m as ColumnModelMetadata, l as ColumnModelMetadataOptions, n as ColumnModifierMetadata, p as ColumnTypeMetadata, o as ColumnTypeMetadataOptions, M as ModelMetadata, q as ModelMetadataOptions, g as getMetadataStorage } from '../shared/bigal.7bdb464e.js';