@fjell/lib-sequelize 4.4.12 → 4.4.14

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 (2) hide show
  1. package/dist/index.cjs +31 -31
  2. package/package.json +15 -10
package/dist/index.cjs CHANGED
@@ -79,7 +79,7 @@ const createDefinition = (kta, scopes, libOptions)=>{
79
79
  };
80
80
 
81
81
  //Recursive implementation of jSON.stringify;
82
- const general.stringifyJSON = function(obj, visited = new Set()) {
82
+ const stringifyJSON = function(obj, visited = new Set()) {
83
83
  const arrOfKeyVals = [];
84
84
  const arrVals = [];
85
85
  let objKeys = [];
@@ -94,7 +94,7 @@ const general.stringifyJSON = function(obj, visited = new Set()) {
94
94
  // Add array to visited before processing its elements
95
95
  visited.add(obj);
96
96
  obj.forEach(function(el) {
97
- arrVals.push(general.stringifyJSON(el, visited));
97
+ arrVals.push(stringifyJSON(el, visited));
98
98
  });
99
99
  return '[' + arrVals + ']';
100
100
  }
@@ -112,7 +112,7 @@ const general.stringifyJSON = function(obj, visited = new Set()) {
112
112
  else if (typeof keyValOut === 'string') arrOfKeyVals.push(keyOut + '"' + keyValOut + '"');
113
113
  else if (typeof keyValOut === 'boolean' || typeof keyValOut === 'number' || keyValOut === null) arrOfKeyVals.push(keyOut + keyValOut);
114
114
  else if (keyValOut instanceof Object) {
115
- arrOfKeyVals.push(keyOut + general.stringifyJSON(keyValOut, visited));
115
+ arrOfKeyVals.push(keyOut + stringifyJSON(keyValOut, visited));
116
116
  }
117
117
  });
118
118
  return '{' + arrOfKeyVals + '}';
@@ -122,7 +122,7 @@ const general.stringifyJSON = function(obj, visited = new Set()) {
122
122
 
123
123
  const logger$g = logger$1.default.get('sequelize', 'QueryBuilder');
124
124
  const addDeleteQuery = (options, model)=>{
125
- logger$g.default(`QueryBuilder adding delete query with options: ${general.stringifyJSON(options)}`);
125
+ logger$g.default(`QueryBuilder adding delete query with options: ${stringifyJSON(options)}`);
126
126
  if (model.getAttributes().deletedAt) {
127
127
  options.where['deletedAt'] = {
128
128
  [sequelize.Op.eq]: null
@@ -135,7 +135,7 @@ const addDeleteQuery = (options, model)=>{
135
135
  return options;
136
136
  };
137
137
  const addEventQueries = (options, events, model)=>{
138
- logger$g.default(`QueryBuilder adding event queries with options: ${general.stringifyJSON(options)}, events: ${general.stringifyJSON(events)}`);
138
+ logger$g.default(`QueryBuilder adding event queries with options: ${stringifyJSON(options)}, events: ${stringifyJSON(events)}`);
139
139
  Object.keys(events).forEach((key)=>{
140
140
  if (!model.getAttributes()[`${key}At`]) {
141
141
  throw new Error(`Event ${key} is not supported on this model, column ${key}At not found`);
@@ -169,22 +169,22 @@ const addEventQueries = (options, events, model)=>{
169
169
  };
170
170
  // Add the references to the query
171
171
  const addReferenceQueries = (options, references, model)=>{
172
- logger$g.default(`QueryBuilder adding reference queries with options: ${general.stringifyJSON(options)}, references: ${general.stringifyJSON(references)}`);
172
+ logger$g.default(`QueryBuilder adding reference queries with options: ${stringifyJSON(options)}, references: ${stringifyJSON(references)}`);
173
173
  Object.keys(references).forEach((key)=>{
174
- logger$g.default(`QueryBuilder adding reference query for key: ${key}, references: ${general.stringifyJSON(references)}`);
174
+ logger$g.default(`QueryBuilder adding reference query for key: ${key}, references: ${stringifyJSON(references)}`);
175
175
  if (!model.getAttributes()[`${key}Id`]) {
176
176
  throw new Error(`Reference ${key} is not supported on this model, column ${key}Id not found`);
177
177
  }
178
178
  if (core.isPriKey(references[key])) {
179
179
  const priKey = references[key];
180
180
  if (priKey.pk == null || priKey.pk === '' || typeof priKey.pk === 'object' && Object.keys(priKey.pk).length === 0) {
181
- logger$g.error(`Reference key '${key}' has invalid pk value: ${general.stringifyJSON(priKey.pk)}`, {
181
+ logger$g.error(`Reference key '${key}' has invalid pk value: ${stringifyJSON(priKey.pk)}`, {
182
182
  priKey,
183
183
  references
184
184
  });
185
- throw new Error(`Reference key '${key}' has invalid pk value: ${general.stringifyJSON(priKey.pk)}`);
185
+ throw new Error(`Reference key '${key}' has invalid pk value: ${stringifyJSON(priKey.pk)}`);
186
186
  }
187
- logger$g.trace(`[QueryBuilder] Setting reference where clause: ${key}Id = ${general.stringifyJSON(priKey.pk)} (type: ${typeof priKey.pk})`);
187
+ logger$g.trace(`[QueryBuilder] Setting reference where clause: ${key}Id = ${stringifyJSON(priKey.pk)} (type: ${typeof priKey.pk})`);
188
188
  options.where[`${key}Id`] = {
189
189
  [sequelize.Op.eq]: priKey.pk
190
190
  };
@@ -267,7 +267,7 @@ const addAssociationCondition = (conditions, condition, model)=>{
267
267
  });
268
268
  throw new Error(`Association condition for '${associationName}.${attributeName}' has undefined/null value`);
269
269
  }
270
- logger$g.trace(`[QueryBuilder] Setting association condition: ${sequelizeAssociationColumn} = ${general.stringifyJSON(condition.value)} (type: ${typeof condition.value})`);
270
+ logger$g.trace(`[QueryBuilder] Setting association condition: ${sequelizeAssociationColumn} = ${stringifyJSON(condition.value)} (type: ${typeof condition.value})`);
271
271
  conditions[sequelizeAssociationColumn] = {
272
272
  [conditionOp]: condition.value
273
273
  };
@@ -285,7 +285,7 @@ const addAttributeCondition = (conditions, condition, model)=>{
285
285
  });
286
286
  throw new Error(`Attribute condition for '${conditionColumn}' has undefined/null value`);
287
287
  }
288
- logger$g.trace(`[QueryBuilder] Setting attribute condition: ${conditionColumn} = ${general.stringifyJSON(condition.value)} (type: ${typeof condition.value})`);
288
+ logger$g.trace(`[QueryBuilder] Setting attribute condition: ${conditionColumn} = ${stringifyJSON(condition.value)} (type: ${typeof condition.value})`);
289
289
  conditions[conditionColumn] = {
290
290
  [conditionOp]: condition.value
291
291
  };
@@ -356,12 +356,12 @@ const addAssociationIncludes = (options, model)=>{
356
356
  return options;
357
357
  };
358
358
  const buildQuery = (itemQuery, model)=>{
359
- logger$g.default(`QueryBuilder build called with itemQuery: ${general.stringifyJSON(itemQuery)}`);
359
+ logger$g.default(`QueryBuilder build called with itemQuery: ${stringifyJSON(itemQuery)}`);
360
360
  let options = {
361
361
  where: {}
362
362
  };
363
363
  if (itemQuery.compoundCondition) {
364
- logger$g.default(`QueryBuilder adding conditions: ${general.stringifyJSON(itemQuery.compoundCondition)}`);
364
+ logger$g.default(`QueryBuilder adding conditions: ${stringifyJSON(itemQuery.compoundCondition)}`);
365
365
  options = addCompoundCondition(options, itemQuery.compoundCondition, model);
366
366
  }
367
367
  // If the model has a deletedAt column, we need to add a delete query
@@ -983,22 +983,22 @@ const processRow = async (row, keyTypes, referenceDefinitions, aggregationDefini
983
983
  let item = row.get({
984
984
  plain: true
985
985
  });
986
- logger$a.default('Adding Key to Item with Key Types: %s', general.stringifyJSON(keyTypes));
986
+ logger$a.default('Adding Key to Item with Key Types: %s', stringifyJSON(keyTypes));
987
987
  item = addKey(row, item, keyTypes);
988
988
  item = populateEvents(item);
989
- logger$a.default('Key Added to Item: %s', general.stringifyJSON(item.key));
989
+ logger$a.default('Key Added to Item: %s', stringifyJSON(item.key));
990
990
  // Mark this item as in progress to detect circular references
991
991
  operationContext.markInProgress(item.key);
992
992
  try {
993
993
  if (referenceDefinitions && referenceDefinitions.length > 0) {
994
994
  for (const referenceDefinition of referenceDefinitions){
995
- logger$a.default('Processing Reference for %s to %s', item.key.kt, general.stringifyJSON(referenceDefinition.kta));
995
+ logger$a.default('Processing Reference for %s to %s', item.key.kt, stringifyJSON(referenceDefinition.kta));
996
996
  item = await buildReference(item, referenceDefinition, registry, operationContext);
997
997
  }
998
998
  }
999
999
  if (aggregationDefinitions && aggregationDefinitions.length > 0) {
1000
1000
  for (const aggregationDefinition of aggregationDefinitions){
1001
- logger$a.default('Processing Aggregation for %s from %s', item.key.kt, general.stringifyJSON(aggregationDefinition.kta));
1001
+ logger$a.default('Processing Aggregation for %s from %s', item.key.kt, stringifyJSON(aggregationDefinition.kta));
1002
1002
  item = await buildAggregation(item, aggregationDefinition, registry, operationContext);
1003
1003
  }
1004
1004
  }
@@ -1008,7 +1008,7 @@ const processRow = async (row, keyTypes, referenceDefinitions, aggregationDefini
1008
1008
  // Mark this item as complete
1009
1009
  operationContext.markComplete(item.key);
1010
1010
  }
1011
- logger$a.default('Processed Row: %j', general.stringifyJSON(item));
1011
+ logger$a.default('Processed Row: %j', stringifyJSON(item));
1012
1012
  return item;
1013
1013
  });
1014
1014
  };
@@ -1071,11 +1071,11 @@ const all.getAllOperation = (models, definition, registry)=>{
1071
1071
  // Handle direct location keys (simple foreign key constraints)
1072
1072
  for (const locKey of directLocations){
1073
1073
  if (locKey.lk === undefined || locKey.lk == null || locKey.lk === '' || typeof locKey.lk === 'object' && Object.keys(locKey.lk).length === 0) {
1074
- logger$9.error(`Location key '${locKey.kt}' has invalid lk value: ${general.stringifyJSON(locKey.lk)}`, {
1074
+ logger$9.error(`Location key '${locKey.kt}' has invalid lk value: ${stringifyJSON(locKey.lk)}`, {
1075
1075
  locKey,
1076
1076
  locations: loc
1077
1077
  });
1078
- throw new Error(`Location key '${locKey.kt}' has invalid lk value: ${general.stringifyJSON(locKey.lk)}`);
1078
+ throw new Error(`Location key '${locKey.kt}' has invalid lk value: ${stringifyJSON(locKey.lk)}`);
1079
1079
  }
1080
1080
  const foreignKeyField = locKey.kt + 'Id';
1081
1081
  // Check if this field already has a condition from the itemQuery
@@ -1083,7 +1083,7 @@ const all.getAllOperation = (models, definition, registry)=>{
1083
1083
  logger$9.debug(`[ALL] Field ${foreignKeyField} already constrained by itemQuery, skipping location constraint to avoid conflicts`);
1084
1084
  continue; // Skip this location constraint to avoid conflicts
1085
1085
  }
1086
- logger$9.trace(`[ALL] Setting direct location where clause: ${foreignKeyField} = ${general.stringifyJSON(locKey.lk)} (type: ${typeof locKey.lk})`);
1086
+ logger$9.trace(`[ALL] Setting direct location where clause: ${foreignKeyField} = ${stringifyJSON(locKey.lk)} (type: ${typeof locKey.lk})`);
1087
1087
  options.where[foreignKeyField] = {
1088
1088
  [sequelize.Op.eq]: locKey.lk
1089
1089
  };
@@ -1091,11 +1091,11 @@ const all.getAllOperation = (models, definition, registry)=>{
1091
1091
  // Handle hierarchical location keys (requires relationship traversal)
1092
1092
  for (const locKey of hierarchicalLocations){
1093
1093
  if (locKey.lk === undefined || locKey.lk == null || locKey.lk === '' || typeof locKey.lk === 'object' && Object.keys(locKey.lk).length === 0) {
1094
- logger$9.error(`Hierarchical location key '${locKey.kt}' has invalid lk value: ${general.stringifyJSON(locKey.lk)}`, {
1094
+ logger$9.error(`Hierarchical location key '${locKey.kt}' has invalid lk value: ${stringifyJSON(locKey.lk)}`, {
1095
1095
  locKey,
1096
1096
  locations: loc
1097
1097
  });
1098
- throw new Error(`Hierarchical location key '${locKey.kt}' has invalid lk value: ${general.stringifyJSON(locKey.lk)}`);
1098
+ throw new Error(`Hierarchical location key '${locKey.kt}' has invalid lk value: ${stringifyJSON(locKey.lk)}`);
1099
1099
  }
1100
1100
  const relationshipInfo = relationshipUtils.buildRelationshipPath(model, locKey.kt, kta);
1101
1101
  if (relationshipInfo.found && relationshipInfo.path) {
@@ -1105,7 +1105,7 @@ const all.getAllOperation = (models, definition, registry)=>{
1105
1105
  continue; // Skip this location constraint to avoid conflicts
1106
1106
  }
1107
1107
  // Add the relationship constraint using the path
1108
- logger$9.trace(`[ALL] Setting hierarchical location where clause: ${relationshipInfo.path} = ${general.stringifyJSON(locKey.lk)} (type: ${typeof locKey.lk})`);
1108
+ logger$9.trace(`[ALL] Setting hierarchical location where clause: ${relationshipInfo.path} = ${stringifyJSON(locKey.lk)} (type: ${typeof locKey.lk})`);
1109
1109
  options.where[relationshipInfo.path] = {
1110
1110
  [sequelize.Op.eq]: locKey.lk
1111
1111
  };
@@ -1368,7 +1368,7 @@ const getCreateOperation = (models, definition, registry)=>{
1368
1368
  }
1369
1369
  // Create the record
1370
1370
  try {
1371
- logger$8.trace(`[CREATE] Executing ${model.name}.create() with data: ${general.stringifyJSON(itemData)}`);
1371
+ logger$8.trace(`[CREATE] Executing ${model.name}.create() with data: ${stringifyJSON(itemData)}`);
1372
1372
  const createdRecord = await model.create(itemData);
1373
1373
  // Add key and events
1374
1374
  const processedRecord = await processRow(createdRecord, kta, references, aggregations, registry);
@@ -1393,7 +1393,7 @@ const getFindOperation = (models, definition, registry)=>{
1393
1393
  if (finders && finders[finder]) {
1394
1394
  const finderMethod = finders[finder];
1395
1395
  if (finderMethod) {
1396
- logger$7.trace(`[FIND] Executing finder '${finder}' on ${models[0].name} with params: ${general.stringifyJSON(finderParams)}, locations: ${general.stringifyJSON(locations)}`);
1396
+ logger$7.trace(`[FIND] Executing finder '${finder}' on ${models[0].name} with params: ${stringifyJSON(finderParams)}, locations: ${stringifyJSON(locations)}`);
1397
1397
  const results = await finderMethod(finderParams, locations);
1398
1398
  if (results && results.length > 0) {
1399
1399
  const processedResults = await Promise.all(results.map(async (row)=>{
@@ -1480,7 +1480,7 @@ const getGetOperation = (models, definition, registry)=>{
1480
1480
  logger$6.default('Composite key query', {
1481
1481
  queryOptions
1482
1482
  });
1483
- logger$6.trace(`[GET] Executing ${model.name}.findOne() with options: ${general.stringifyJSON(queryOptions)}`);
1483
+ logger$6.trace(`[GET] Executing ${model.name}.findOne() with options: ${stringifyJSON(queryOptions)}`);
1484
1484
  item = await model.findOne(queryOptions);
1485
1485
  }
1486
1486
  if (!item) {
@@ -1575,7 +1575,7 @@ registry)=>{
1575
1575
  const comKey = key;
1576
1576
  const queryOptions = processCompositeKey(comKey, model, kta);
1577
1577
  logger$4.default(`Remove composite key query for ${model.name} with where fields: ${queryOptions.where ? Object.keys(queryOptions.where).join(', ') : 'none'}`);
1578
- logger$4.debug(`[REMOVE] Executing ${model.name}.findOne() with options: ${general.stringifyJSON(queryOptions)}`);
1578
+ logger$4.debug(`[REMOVE] Executing ${model.name}.findOne() with options: ${stringifyJSON(queryOptions)}`);
1579
1579
  item = await model.findOne(queryOptions);
1580
1580
  }
1581
1581
  if (!item) {
@@ -1693,7 +1693,7 @@ const getUpdateOperation = (models, definition, registry)=>{
1693
1693
  queryOptions.include = mergeIncludes([], additionalIncludes);
1694
1694
  }
1695
1695
  logger$3.default(`Update composite key query for ${model.name} with where fields: ${queryOptions.where ? Object.keys(queryOptions.where).join(', ') : 'none'}`);
1696
- logger$3.trace(`[UPDATE] Executing ${model.name}.findOne() with options: ${general.stringifyJSON(queryOptions)}`);
1696
+ logger$3.trace(`[UPDATE] Executing ${model.name}.findOne() with options: ${stringifyJSON(queryOptions)}`);
1697
1697
  response = await model.findOne(queryOptions);
1698
1698
  }
1699
1699
  if (response) {
@@ -1705,7 +1705,7 @@ const getUpdateOperation = (models, definition, registry)=>{
1705
1705
  logger$3.default(`Update found ${model.name} record to modify`);
1706
1706
  logger$3.default(`Update properties configured: ${Object.keys(updateProps).join(', ')}`);
1707
1707
  // Update the object
1708
- logger$3.trace(`[UPDATE] Executing ${model.name}.update() with properties: ${general.stringifyJSON(updateProps)}`);
1708
+ logger$3.trace(`[UPDATE] Executing ${model.name}.update() with properties: ${stringifyJSON(updateProps)}`);
1709
1709
  response = await response.update(updateProps);
1710
1710
  // Populate the key and events
1711
1711
  const processedItem = await processRow(response, kta, references, aggregations, registry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjell/lib-sequelize",
3
- "version": "4.4.12",
3
+ "version": "4.4.14",
4
4
  "license": "Apache-2.0",
5
5
  "keywords": [
6
6
  "library",
@@ -29,10 +29,10 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@fjell/core": "^4.4.7",
33
- "@fjell/lib": "^4.4.13",
34
- "@fjell/logging": "^4.4.7",
35
- "@fjell/registry": "^4.4.11",
32
+ "@fjell/core": "^4.4.13",
33
+ "@fjell/lib": "^4.4.21",
34
+ "@fjell/logging": "^4.4.17",
35
+ "@fjell/registry": "^4.4.16",
36
36
  "dayjs": "^1.11.13",
37
37
  "deepmerge": "^4.3.1",
38
38
  "sequelize": "^6.37.7"
@@ -40,11 +40,12 @@
40
40
  "devDependencies": {
41
41
  "@eslint/eslintrc": "^3.3.1",
42
42
  "@eslint/js": "^9.31.0",
43
- "@swc/core": "^1.13.1",
43
+ "@fjell/eslint-config": "^1.0.5",
44
+ "@swc/core": "^1.13.2",
44
45
  "@tsconfig/recommended": "^1.0.10",
45
- "@types/node": "^24.0.15",
46
- "@typescript-eslint/eslint-plugin": "^8.37.0",
47
- "@typescript-eslint/parser": "^8.37.0",
46
+ "@types/node": "^24.1.0",
47
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
48
+ "@typescript-eslint/parser": "^8.38.0",
48
49
  "@vitest/coverage-v8": "^3.2.4",
49
50
  "@vitest/ui": "^3.2.4",
50
51
  "eslint": "^9.31.0",
@@ -66,6 +67,10 @@
66
67
  "dev": "vite build --watch",
67
68
  "lint": "eslint . --ext .ts --fix",
68
69
  "clean": "rimraf dist",
69
- "test": "vitest run --coverage"
70
+ "test": "vitest run --coverage",
71
+ "docs:dev": "cd docs && pnpm run dev",
72
+ "docs:build": "cd docs && pnpm run build",
73
+ "docs:preview": "cd docs && pnpm run preview",
74
+ "docs:test": "cd docs && pnpm run test"
70
75
  }
71
76
  }