@fjell/lib-sequelize 4.4.14 → 4.4.16

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 (91) hide show
  1. package/dist/{types/Operations.d.ts → Operations.d.ts} +5 -5
  2. package/dist/{types/SequelizeLibraryFactory.d.ts → SequelizeLibraryFactory.d.ts} +4 -4
  3. package/dist/{types/contained → contained}/SequelizeLibrary.d.ts +4 -4
  4. package/dist/index.js +1488 -0
  5. package/dist/index.js.map +7 -0
  6. package/dist/logger.d.ts +2 -0
  7. package/dist/{types/ops → ops}/all.d.ts +3 -3
  8. package/dist/{types/ops → ops}/create.d.ts +3 -3
  9. package/dist/{types/ops → ops}/find.d.ts +3 -3
  10. package/dist/{types/ops → ops}/get.d.ts +1 -1
  11. package/dist/{types/ops → ops}/one.d.ts +3 -3
  12. package/dist/{types/ops → ops}/remove.d.ts +4 -3
  13. package/dist/{types/ops → ops}/update.d.ts +3 -3
  14. package/dist/{types/primary → primary}/SequelizeLibrary.d.ts +4 -4
  15. package/package.json +17 -20
  16. package/dist/cjs/AggregationBuilder.cjs +0 -65
  17. package/dist/cjs/Coordinate.cjs +0 -24
  18. package/dist/cjs/Definition.cjs +0 -25
  19. package/dist/cjs/EventCoordinator.cjs +0 -54
  20. package/dist/cjs/KeyMaster.cjs +0 -151
  21. package/dist/cjs/OperationContext.cjs +0 -161
  22. package/dist/cjs/Operations.cjs +0 -34
  23. package/dist/cjs/Options.cjs +0 -46
  24. package/dist/cjs/QueryBuilder.cjs +0 -296
  25. package/dist/cjs/ReferenceBuilder.cjs +0 -76
  26. package/dist/cjs/RowProcessor.cjs +0 -56
  27. package/dist/cjs/SequelizeLibrary.cjs +0 -56
  28. package/dist/cjs/SequelizeLibraryFactory.cjs +0 -25
  29. package/dist/cjs/contained/SequelizeLibrary.cjs +0 -31
  30. package/dist/cjs/contained/index.cjs +0 -11
  31. package/dist/cjs/index.cjs +0 -26
  32. package/dist/cjs/logger.cjs +0 -10
  33. package/dist/cjs/ops/all.cjs +0 -145
  34. package/dist/cjs/ops/create.cjs +0 -252
  35. package/dist/cjs/ops/find.cjs +0 -47
  36. package/dist/cjs/ops/get.cjs +0 -92
  37. package/dist/cjs/ops/one.cjs +0 -27
  38. package/dist/cjs/ops/remove.cjs +0 -114
  39. package/dist/cjs/ops/update.cjs +0 -120
  40. package/dist/cjs/primary/SequelizeLibrary.cjs +0 -41
  41. package/dist/cjs/primary/index.cjs +0 -11
  42. package/dist/cjs/util/general.cjs +0 -48
  43. package/dist/cjs/util/relationshipUtils.cjs +0 -117
  44. package/dist/es/AggregationBuilder.js +0 -61
  45. package/dist/es/Coordinate.js +0 -19
  46. package/dist/es/Definition.js +0 -21
  47. package/dist/es/EventCoordinator.js +0 -48
  48. package/dist/es/KeyMaster.js +0 -146
  49. package/dist/es/OperationContext.js +0 -155
  50. package/dist/es/Operations.js +0 -30
  51. package/dist/es/Options.js +0 -23
  52. package/dist/es/QueryBuilder.js +0 -290
  53. package/dist/es/ReferenceBuilder.js +0 -72
  54. package/dist/es/RowProcessor.js +0 -52
  55. package/dist/es/SequelizeLibrary.js +0 -32
  56. package/dist/es/SequelizeLibraryFactory.js +0 -21
  57. package/dist/es/contained/SequelizeLibrary.js +0 -26
  58. package/dist/es/contained/index.js +0 -2
  59. package/dist/es/index.js +0 -11
  60. package/dist/es/logger.js +0 -6
  61. package/dist/es/ops/all.js +0 -141
  62. package/dist/es/ops/create.js +0 -248
  63. package/dist/es/ops/find.js +0 -43
  64. package/dist/es/ops/get.js +0 -88
  65. package/dist/es/ops/one.js +0 -23
  66. package/dist/es/ops/remove.js +0 -110
  67. package/dist/es/ops/update.js +0 -116
  68. package/dist/es/primary/SequelizeLibrary.js +0 -36
  69. package/dist/es/primary/index.js +0 -2
  70. package/dist/es/util/general.js +0 -44
  71. package/dist/es/util/relationshipUtils.js +0 -112
  72. package/dist/index.cjs +0 -1853
  73. package/dist/index.cjs.map +0 -1
  74. package/dist/types/AggregationBuilder.d.ts +0 -5
  75. package/dist/types/EventCoordinator.d.ts +0 -6
  76. package/dist/types/KeyMaster.d.ts +0 -4
  77. package/dist/types/OperationContext.d.ts +0 -72
  78. package/dist/types/QueryBuilder.d.ts +0 -12
  79. package/dist/types/ReferenceBuilder.d.ts +0 -4
  80. package/dist/types/RowProcessor.d.ts +0 -6
  81. package/dist/types/logger.d.ts +0 -2
  82. package/dist/types/util/general.d.ts +0 -4
  83. package/dist/types/util/relationshipUtils.d.ts +0 -21
  84. package/dist/{types/Coordinate.d.ts → Coordinate.d.ts} +0 -0
  85. package/dist/{types/Definition.d.ts → Definition.d.ts} +0 -0
  86. package/dist/{types/Options.d.ts → Options.d.ts} +1 -1
  87. package/dist/{types/Registry.d.ts → Registry.d.ts} +0 -0
  88. package/dist/{types/SequelizeLibrary.d.ts → SequelizeLibrary.d.ts} +1 -1
  89. /package/dist/{types/contained → contained}/index.d.ts +0 -0
  90. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  91. /package/dist/{types/primary → primary}/index.d.ts +0 -0
@@ -1,296 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const core = require('@fjell/core');
6
- const sequelize = require('sequelize');
7
- const logger$1 = require('./logger.cjs');
8
- const general = require('./util/general.cjs');
9
-
10
- const logger = logger$1.default.get('sequelize', 'QueryBuilder');
11
- const addDeleteQuery = (options, model)=>{
12
- logger.default(`QueryBuilder adding delete query with options: ${general.stringifyJSON(options)}`);
13
- if (model.getAttributes().deletedAt) {
14
- options.where['deletedAt'] = {
15
- [sequelize.Op.eq]: null
16
- };
17
- } else if (model.getAttributes().isDeleted) {
18
- options.where['isDeleted'] = {
19
- [sequelize.Op.eq]: false
20
- };
21
- }
22
- return options;
23
- };
24
- const addEventQueries = (options, events, model)=>{
25
- logger.default(`QueryBuilder adding event queries with options: ${general.stringifyJSON(options)}, events: ${general.stringifyJSON(events)}`);
26
- Object.keys(events).forEach((key)=>{
27
- if (!model.getAttributes()[`${key}At`]) {
28
- throw new Error(`Event ${key} is not supported on this model, column ${key}At not found`);
29
- }
30
- let whereClauses = {};
31
- const event = events[key];
32
- if (event.start) {
33
- whereClauses = {
34
- ...whereClauses,
35
- [sequelize.Op.gte]: new Date(event.start)
36
- };
37
- }
38
- if (event.end) {
39
- whereClauses = {
40
- ...whereClauses,
41
- [sequelize.Op.lt]: new Date(event.end)
42
- };
43
- }
44
- if (event.by) {
45
- if (!model.getAttributes()[`${key}By`]) {
46
- throw new Error(`Event ${key} is not supported on this model, column ${key}By not found`);
47
- }
48
- whereClauses = {
49
- ...whereClauses,
50
- [sequelize.Op.eq]: event.by
51
- };
52
- }
53
- options.where[`${key}At`] = whereClauses;
54
- });
55
- return options;
56
- };
57
- // Add the references to the query
58
- const addReferenceQueries = (options, references, model)=>{
59
- logger.default(`QueryBuilder adding reference queries with options: ${general.stringifyJSON(options)}, references: ${general.stringifyJSON(references)}`);
60
- Object.keys(references).forEach((key)=>{
61
- logger.default(`QueryBuilder adding reference query for key: ${key}, references: ${general.stringifyJSON(references)}`);
62
- if (!model.getAttributes()[`${key}Id`]) {
63
- throw new Error(`Reference ${key} is not supported on this model, column ${key}Id not found`);
64
- }
65
- if (core.isPriKey(references[key])) {
66
- const priKey = references[key];
67
- if (priKey.pk == null || priKey.pk === '' || typeof priKey.pk === 'object' && Object.keys(priKey.pk).length === 0) {
68
- logger.error(`Reference key '${key}' has invalid pk value: ${general.stringifyJSON(priKey.pk)}`, {
69
- priKey,
70
- references
71
- });
72
- throw new Error(`Reference key '${key}' has invalid pk value: ${general.stringifyJSON(priKey.pk)}`);
73
- }
74
- logger.trace(`[QueryBuilder] Setting reference where clause: ${key}Id = ${general.stringifyJSON(priKey.pk)} (type: ${typeof priKey.pk})`);
75
- options.where[`${key}Id`] = {
76
- [sequelize.Op.eq]: priKey.pk
77
- };
78
- } else if (core.isComKey(references[key])) {
79
- throw new Error('ComKeys are not supported in Sequelize');
80
- }
81
- });
82
- return options;
83
- };
84
- const addCompoundCondition = (options, compoundCondition, model)=>{
85
- // Ensure options.where exists
86
- options.where = options.where || {};
87
- let compoundOp;
88
- const compoundType = compoundCondition.compoundType;
89
- if (compoundType === "AND") {
90
- compoundOp = sequelize.Op.and;
91
- } else {
92
- compoundOp = sequelize.Op.or;
93
- }
94
- let conditions = {};
95
- compoundCondition.conditions.forEach((condition)=>{
96
- if (core.isCondition(condition)) {
97
- conditions = addCondition(conditions, condition, model);
98
- } else {
99
- throw new Error('Nest Compound conditions not supported');
100
- }
101
- });
102
- // Merge with existing where conditions instead of replacing
103
- if (Object.keys(options.where).length > 0) {
104
- // If there are existing conditions, wrap everything in an AND
105
- options.where = {
106
- [sequelize.Op.and]: [
107
- options.where,
108
- {
109
- [compoundOp]: conditions
110
- }
111
- ]
112
- };
113
- } else {
114
- // If no existing conditions, just set the compound condition
115
- options.where[compoundOp] = conditions;
116
- }
117
- return options;
118
- };
119
- const getSequelizeOperator = (operator)=>{
120
- if (operator === '==') {
121
- return sequelize.Op.eq;
122
- } else if (operator === '<') {
123
- return sequelize.Op.lt;
124
- } else if (operator === '>') {
125
- return sequelize.Op.gt;
126
- } else if (operator === '<=') {
127
- return sequelize.Op.lte;
128
- } else if (operator === '>=') {
129
- return sequelize.Op.gte;
130
- } else if (operator === 'in') {
131
- return sequelize.Op.in;
132
- } else {
133
- throw new Error(`Operator ${operator} not supported`);
134
- }
135
- };
136
- const addAssociationCondition = (conditions, condition, model)=>{
137
- const [associationName, attributeName] = condition.column.split('.', 2);
138
- // Check if the association exists on the model
139
- if (!model.associations || !model.associations[associationName]) {
140
- throw new Error(`Association ${associationName} not found on model ${model.name}`);
141
- }
142
- const association = model.associations[associationName];
143
- const associatedModel = association.target;
144
- // Check if the attribute exists on the associated model
145
- if (!associatedModel.getAttributes()[attributeName]) {
146
- throw new Error(`Attribute ${attributeName} not found on associated model ${associatedModel.name} for association ${associationName}`);
147
- }
148
- // Use Sequelize's $association.attribute$ syntax for querying associated models
149
- const sequelizeAssociationColumn = `$${associationName}.${attributeName}$`;
150
- const conditionOp = getSequelizeOperator(condition.operator);
151
- if (condition.value == null && condition.operator !== '==' && condition.operator !== 'in') {
152
- logger.error(`Association condition for '${associationName}.${attributeName}' has undefined/null value`, {
153
- condition
154
- });
155
- throw new Error(`Association condition for '${associationName}.${attributeName}' has undefined/null value`);
156
- }
157
- logger.trace(`[QueryBuilder] Setting association condition: ${sequelizeAssociationColumn} = ${general.stringifyJSON(condition.value)} (type: ${typeof condition.value})`);
158
- conditions[sequelizeAssociationColumn] = {
159
- [conditionOp]: condition.value
160
- };
161
- return conditions;
162
- };
163
- const addAttributeCondition = (conditions, condition, model)=>{
164
- const conditionColumn = condition.column;
165
- if (!model.getAttributes()[conditionColumn]) {
166
- throw new Error(`Condition column ${conditionColumn} not found on model ${model.name}`);
167
- }
168
- const conditionOp = getSequelizeOperator(condition.operator);
169
- if (condition.value == null && condition.operator !== '==' && condition.operator !== 'in') {
170
- logger.error(`Attribute condition for '${conditionColumn}' has undefined/null value`, {
171
- condition
172
- });
173
- throw new Error(`Attribute condition for '${conditionColumn}' has undefined/null value`);
174
- }
175
- logger.trace(`[QueryBuilder] Setting attribute condition: ${conditionColumn} = ${general.stringifyJSON(condition.value)} (type: ${typeof condition.value})`);
176
- conditions[conditionColumn] = {
177
- [conditionOp]: condition.value
178
- };
179
- return conditions;
180
- };
181
- const addCondition = (conditions, condition, model)=>{
182
- const conditionColumn = condition.column;
183
- // Check if this is an association query (contains a dot)
184
- if (conditionColumn.includes('.')) {
185
- return addAssociationCondition(conditions, condition, model);
186
- }
187
- // Handle regular column queries
188
- return addAttributeCondition(conditions, condition, model);
189
- };
190
- const collectAssociationsFromConditions = (conditions)=>{
191
- const associations = new Set();
192
- const processObject = (obj)=>{
193
- if (typeof obj === 'object' && obj !== null) {
194
- // Check string keys
195
- Object.keys(obj).forEach((key)=>{
196
- // Check if this is an association reference ($association.attribute$)
197
- if (typeof key === 'string' && key.startsWith('$') && key.endsWith('$') && key.includes('.')) {
198
- const associationName = key.substring(1, key.indexOf('.'));
199
- associations.add(associationName);
200
- }
201
- // Recursively process nested objects
202
- if (typeof obj[key] === 'object') {
203
- processObject(obj[key]);
204
- }
205
- });
206
- // Also check Symbol keys (for compound conditions like Op.and, Op.or)
207
- Object.getOwnPropertySymbols(obj).forEach((symbol)=>{
208
- if (typeof obj[symbol] === 'object') {
209
- processObject(obj[symbol]);
210
- }
211
- });
212
- }
213
- // Handle arrays (for compound conditions that might be arrays)
214
- if (Array.isArray(obj)) {
215
- obj.forEach((item)=>{
216
- if (typeof item === 'object') {
217
- processObject(item);
218
- }
219
- });
220
- }
221
- };
222
- processObject(conditions);
223
- return associations;
224
- };
225
- const addAssociationIncludes = (options, model)=>{
226
- // Collect all association names used in conditions
227
- const referencedAssociations = collectAssociationsFromConditions(options.where);
228
- if (referencedAssociations.size > 0) {
229
- options.include = options.include || [];
230
- // Add each referenced association to the include array
231
- referencedAssociations.forEach((associationName)=>{
232
- // Check if this association is already included
233
- const alreadyIncluded = options.include.some((inc)=>typeof inc === 'string' && inc === associationName || typeof inc === 'object' && inc.association === associationName);
234
- if (!alreadyIncluded && model.associations && model.associations[associationName]) {
235
- options.include.push({
236
- model: model.associations[associationName].target,
237
- as: associationName,
238
- required: false // Use LEFT JOIN so records without associations are still returned
239
- });
240
- }
241
- });
242
- }
243
- return options;
244
- };
245
- const buildQuery = (itemQuery, model)=>{
246
- logger.default(`QueryBuilder build called with itemQuery: ${general.stringifyJSON(itemQuery)}`);
247
- let options = {
248
- where: {}
249
- };
250
- if (itemQuery.compoundCondition) {
251
- logger.default(`QueryBuilder adding conditions: ${general.stringifyJSON(itemQuery.compoundCondition)}`);
252
- options = addCompoundCondition(options, itemQuery.compoundCondition, model);
253
- }
254
- // If the model has a deletedAt column, we need to add a delete query
255
- if (model.getAttributes().deletedAt || model.getAttributes().isDeleted) {
256
- options = addDeleteQuery(options, model);
257
- }
258
- if (itemQuery.refs) {
259
- options = addReferenceQueries(options, itemQuery.refs, model);
260
- }
261
- if (itemQuery.events) {
262
- options = addEventQueries(options, itemQuery.events, model);
263
- }
264
- // TODO: Once we start to support Aggs on the server-side, we'll need to parse agg queries
265
- // Apply a limit to the result set
266
- if (itemQuery.limit) {
267
- logger.default(`QueryBuilder applying limit: ${itemQuery.limit}`);
268
- options.limit = itemQuery.limit;
269
- }
270
- // Apply an offset to the result set
271
- if (itemQuery.offset) {
272
- options.offset = itemQuery.offset;
273
- }
274
- // Add orderBy to the query
275
- if (itemQuery.orderBy) {
276
- itemQuery.orderBy.forEach((orderBy)=>{
277
- if (!model.getAttributes()[orderBy.field]) {
278
- throw new Error(`Order by field ${orderBy.field} not found on model ${model.name}`);
279
- }
280
- options.order = [
281
- [
282
- orderBy.field,
283
- orderBy.direction
284
- ]
285
- ];
286
- });
287
- }
288
- // Add includes for any associations referenced in conditions
289
- options = addAssociationIncludes(options, model);
290
- return options;
291
- };
292
-
293
- exports.addCompoundCondition = addCompoundCondition;
294
- exports.addCondition = addCondition;
295
- exports.buildQuery = buildQuery;
296
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUXVlcnlCdWlsZGVyLmNqcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,76 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const logger$1 = require('./logger.cjs');
6
-
7
- const logger = logger$1.default.get('sequelize', 'ReferenceBuilder');
8
- const buildReference = async (item, referenceDefinition, registry, context)=>{
9
- // Check if there is more than one key type
10
- if (referenceDefinition.kta.length > 1) {
11
- throw new Error("The ReferenceBuilder doesn't work with more than one key type yet");
12
- }
13
- // Check if dependencies exist
14
- if (!registry) {
15
- throw new Error("This model definition has a reference definition, but the registry is not present");
16
- }
17
- // Find the Library.Instance for the key type
18
- const library = registry.get(referenceDefinition.kta);
19
- if (!library) {
20
- throw new Error("This model definition has a reference definition, but the dependency is not present");
21
- }
22
- // Check if the column value is null - if so, skip the reference
23
- const columnValue = item[referenceDefinition.column];
24
- if (columnValue == null) {
25
- item[referenceDefinition.property] = null;
26
- return item;
27
- }
28
- // Create a PriKey using the column value from item
29
- const priKey = {
30
- kt: referenceDefinition.kta[0],
31
- pk: columnValue
32
- };
33
- let referencedItem;
34
- if (context) {
35
- // Check if we already have this item cached
36
- if (context.isCached(priKey)) {
37
- logger.default('Using cached reference', {
38
- priKey,
39
- property: referenceDefinition.property
40
- });
41
- referencedItem = context.getCached(priKey);
42
- } else if (context.isInProgress(priKey)) {
43
- logger.default('Circular dependency detected, creating reference placeholder', {
44
- priKey,
45
- property: referenceDefinition.property
46
- });
47
- // Create a minimal reference object with just the key to break the cycle
48
- referencedItem = {
49
- key: priKey
50
- };
51
- } else {
52
- // Mark this key as in progress before loading
53
- context.markInProgress(priKey);
54
- try {
55
- // Get the referenced item using the Library.Operations get method (context now managed internally)
56
- referencedItem = await library.operations.get(priKey);
57
- // Cache the result
58
- context.setCached(priKey, referencedItem);
59
- } finally{
60
- // Always mark as complete, even if there was an error
61
- context.markComplete(priKey);
62
- }
63
- }
64
- } else {
65
- // Fallback to original behavior if no context provided
66
- referencedItem = await library.operations.get(priKey);
67
- }
68
- // TODO: In a Fjell-compliant implementation, this value should be stored in the ref property
69
- // For now, we'll just populate the property directly
70
- // Store the result in the property on item
71
- item[referenceDefinition.property] = referencedItem;
72
- return item;
73
- };
74
-
75
- exports.buildReference = buildReference;
76
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmVmZXJlbmNlQnVpbGRlci5janMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,56 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const logger$1 = require('./logger.cjs');
6
- const KeyMaster = require('./KeyMaster.cjs');
7
- const ReferenceBuilder = require('./ReferenceBuilder.cjs');
8
- const AggregationBuilder = require('./AggregationBuilder.cjs');
9
- const general = require('./util/general.cjs');
10
- const EventCoordinator = require('./EventCoordinator.cjs');
11
- const OperationContext = require('./OperationContext.cjs');
12
-
13
- const logger = logger$1.default.get('sequelize', 'RowProcessor');
14
- const processRow = async (row, keyTypes, referenceDefinitions, aggregationDefinitions, registry, context)=>{
15
- logger.default('Processing Row', {
16
- row
17
- });
18
- // Use provided context or create new one
19
- const operationContext = context || OperationContext.createOperationContext();
20
- // Process the row within the context to ensure all operations share the same context
21
- return OperationContext.contextManager.withContext(operationContext, async ()=>{
22
- let item = row.get({
23
- plain: true
24
- });
25
- logger.default('Adding Key to Item with Key Types: %s', general.stringifyJSON(keyTypes));
26
- item = KeyMaster.addKey(row, item, keyTypes);
27
- item = EventCoordinator.populateEvents(item);
28
- logger.default('Key Added to Item: %s', general.stringifyJSON(item.key));
29
- // Mark this item as in progress to detect circular references
30
- operationContext.markInProgress(item.key);
31
- try {
32
- if (referenceDefinitions && referenceDefinitions.length > 0) {
33
- for (const referenceDefinition of referenceDefinitions){
34
- logger.default('Processing Reference for %s to %s', item.key.kt, general.stringifyJSON(referenceDefinition.kta));
35
- item = await ReferenceBuilder.buildReference(item, referenceDefinition, registry, operationContext);
36
- }
37
- }
38
- if (aggregationDefinitions && aggregationDefinitions.length > 0) {
39
- for (const aggregationDefinition of aggregationDefinitions){
40
- logger.default('Processing Aggregation for %s from %s', item.key.kt, general.stringifyJSON(aggregationDefinition.kta));
41
- item = await AggregationBuilder.buildAggregation(item, aggregationDefinition, registry, operationContext);
42
- }
43
- }
44
- // Cache the fully processed item
45
- operationContext.setCached(item.key, item);
46
- } finally{
47
- // Mark this item as complete
48
- operationContext.markComplete(item.key);
49
- }
50
- logger.default('Processed Row: %j', general.stringifyJSON(item));
51
- return item;
52
- });
53
- };
54
-
55
- exports.processRow = processRow;
56
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUm93UHJvY2Vzc29yLmNqcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,56 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const Library = require('@fjell/lib');
6
- const Operations = require('./Operations.cjs');
7
- const logger$1 = require('./logger.cjs');
8
-
9
- function _interopNamespaceDefault(e) {
10
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
11
- if (e) {
12
- for (const k in e) {
13
- if (k !== 'default') {
14
- const d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: () => e[k]
18
- });
19
- }
20
- }
21
- }
22
- n.default = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- const Library__namespace = /*#__PURE__*/_interopNamespaceDefault(Library);
27
-
28
- const logger = logger$1.default.get("SequelizeLibrary");
29
- /**
30
- * Creates a new SequelizeLibrary that extends the fjell-lib Library
31
- * with Sequelize-specific functionality
32
- */ const createSequelizeLibrary = (registry, coordinate, models, options)=>{
33
- logger.debug("createSequelizeLibrary", {
34
- coordinate,
35
- models,
36
- registry,
37
- options
38
- });
39
- // Create Sequelize-specific operations
40
- const operations = Operations.createOperations(models, coordinate, registry, options);
41
- // Create the base fjell-lib library
42
- const libLibrary = Library__namespace.createLibrary(registry, coordinate, operations, options);
43
- return {
44
- ...libLibrary,
45
- models
46
- };
47
- };
48
- /**
49
- * Type guard to check if an object is a SequelizeLibrary
50
- */ const isSequelizeLibrary = (library)=>{
51
- return library != null && library.coordinate != null && library.operations != null && library.options != null && library.registry != null && library.models != null && Array.isArray(library.models);
52
- };
53
-
54
- exports.createSequelizeLibrary = createSequelizeLibrary;
55
- exports.isSequelizeLibrary = isSequelizeLibrary;
56
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2VxdWVsaXplTGlicmFyeS5janMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const SequelizeLibrary = require('./SequelizeLibrary.cjs');
6
- const logger$1 = require('./logger.cjs');
7
-
8
- const logger = logger$1.default.get("InstanceFactory");
9
- /**
10
- * Factory function for creating Sequelize libraries
11
- * This extends the fjell-lib pattern by adding Sequelize-specific models
12
- */ const createSequelizeLibraryFactory = (models, options)=>{
13
- return (coordinate, context)=>{
14
- logger.debug("Creating Sequelize instance", {
15
- coordinate,
16
- registry: context.registry,
17
- models: models.map((m)=>m.name),
18
- options
19
- });
20
- return SequelizeLibrary.createSequelizeLibrary(context.registry, coordinate, models, options);
21
- };
22
- };
23
-
24
- exports.createSequelizeLibraryFactory = createSequelizeLibraryFactory;
25
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2VxdWVsaXplTGlicmFyeUZhY3RvcnkuY2pzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const Library = require('@fjell/lib');
6
- const Operations = require('../Operations.cjs');
7
- const Options = require('../Options.cjs');
8
- const Coordinate = require('../Coordinate.cjs');
9
-
10
- function createSequelizeLibrary(keyTypes, models, libOptions = {}, scopes = [], registry) {
11
- // Create coordinate and options separately following new pattern
12
- const coordinate = Coordinate.createCoordinate(keyTypes, scopes);
13
- const options = Options.createOptions(libOptions);
14
- // Create operations with the new signature
15
- const operations = Operations.createOperations(models, coordinate, registry, options);
16
- // Wrap operations for contained pattern
17
- const wrappedOperations = Library.Contained.wrapOperations(operations, options, coordinate, registry);
18
- return {
19
- coordinate,
20
- registry,
21
- operations: wrappedOperations,
22
- options,
23
- models
24
- };
25
- }
26
- // Legacy exports for backwards compatibility
27
- const createInstance = createSequelizeLibrary;
28
-
29
- exports.createInstance = createInstance;
30
- exports.createSequelizeLibrary = createSequelizeLibrary;
31
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2VxdWVsaXplTGlicmFyeS5janMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const SequelizeLibrary = require('./SequelizeLibrary.cjs');
6
-
7
-
8
-
9
- exports.createInstance = SequelizeLibrary.createInstance;
10
- exports.createSequelizeLibrary = SequelizeLibrary.createSequelizeLibrary;
11
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguY2pzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OyJ9
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const Definition = require('./Definition.cjs');
6
- const SequelizeLibrary = require('./SequelizeLibrary.cjs');
7
- const SequelizeLibraryFactory = require('./SequelizeLibraryFactory.cjs');
8
- const Options = require('./Options.cjs');
9
- const Operations = require('./Operations.cjs');
10
- const index = require('./contained/index.cjs');
11
- const index$1 = require('./primary/index.cjs');
12
- const Coordinate = require('./Coordinate.cjs');
13
-
14
-
15
-
16
- exports.createDefinition = Definition.createDefinition;
17
- exports.createSequelizeLibrary = SequelizeLibrary.createSequelizeLibrary;
18
- exports.isSequelizeLibrary = SequelizeLibrary.isSequelizeLibrary;
19
- exports.createSequelizeLibraryFactory = SequelizeLibraryFactory.createSequelizeLibraryFactory;
20
- exports.createOptions = Options.createOptions;
21
- exports.createOperations = Operations.createOperations;
22
- exports.Contained = index;
23
- exports.Primary = index$1;
24
- exports.SCOPE_SEQUELIZE = Coordinate.SCOPE_SEQUELIZE;
25
- exports.createCoordinate = Coordinate.createCoordinate;
26
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguY2pzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const Logging = require('@fjell/logging');
6
-
7
- const LibLogger = Logging.getLogger('@fjell/lib-sequelize');
8
-
9
- exports.default = LibLogger;
10
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyLmNqcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7In0=