@fjell/lib-sequelize 4.3.4 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Coordinate.js +13 -0
- package/dist/Definition.js +23 -0
- package/dist/EventCoordinator.js +30 -0
- package/dist/Instance.js +16 -0
- package/dist/KeyMaster.js +84 -0
- package/dist/{src/Operations.d.ts → Operations.d.ts} +3 -3
- package/dist/Operations.js +25 -0
- package/dist/Options.js +19 -0
- package/dist/{src/QueryBuilder.js → QueryBuilder.js} +67 -46
- package/dist/{src/RowProcessor.d.ts → RowProcessor.d.ts} +2 -2
- package/dist/RowProcessor.js +18 -0
- package/dist/contained/Instance.js +16 -0
- package/dist/contained/index.js +2 -0
- package/dist/index.js +10 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +6 -0
- package/dist/{src/ops → ops}/all.d.ts +3 -3
- package/dist/{src/ops → ops}/all.js +21 -13
- package/dist/{src/ops → ops}/create.d.ts +3 -3
- package/dist/ops/create.js +18 -0
- package/dist/{src/ops → ops}/find.d.ts +3 -3
- package/dist/{src/ops → ops}/find.js +14 -9
- package/dist/ops/get.js +45 -0
- package/dist/{src/ops → ops}/one.d.ts +3 -3
- package/dist/ops/one.js +22 -0
- package/dist/{src/ops → ops}/remove.d.ts +3 -4
- package/dist/ops/remove.js +67 -0
- package/dist/{src/ops → ops}/update.d.ts +3 -3
- package/dist/ops/update.js +57 -0
- package/dist/primary/Instance.js +26 -0
- package/dist/primary/index.js +2 -0
- package/package.json +26 -21
- package/src/Instance.ts +1 -2
- package/src/Operations.ts +1 -1
- package/src/contained/Instance.ts +1 -2
- package/src/ops/all.ts +1 -1
- package/src/ops/find.ts +1 -1
- package/src/primary/Instance.ts +1 -2
- package/dist/src/Coordinate.js +0 -7
- package/dist/src/Coordinate.js.map +0 -1
- package/dist/src/Definition.js +0 -16
- package/dist/src/Definition.js.map +0 -1
- package/dist/src/EventCoordinator.js +0 -56
- package/dist/src/EventCoordinator.js.map +0 -1
- package/dist/src/Instance.js +0 -14
- package/dist/src/Instance.js.map +0 -1
- package/dist/src/KeyMaster.js +0 -58
- package/dist/src/KeyMaster.js.map +0 -1
- package/dist/src/Operations.js +0 -22
- package/dist/src/Operations.js.map +0 -1
- package/dist/src/Options.js +0 -16
- package/dist/src/Options.js.map +0 -1
- package/dist/src/QueryBuilder.js.map +0 -1
- package/dist/src/RowProcessor.js +0 -11
- package/dist/src/RowProcessor.js.map +0 -1
- package/dist/src/contained/Instance.js +0 -14
- package/dist/src/contained/Instance.js.map +0 -1
- package/dist/src/contained/index.js +0 -2
- package/dist/src/contained/index.js.map +0 -1
- package/dist/src/index.js +0 -8
- package/dist/src/index.js.map +0 -1
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/logger.js +0 -4
- package/dist/src/logger.js.map +0 -1
- package/dist/src/ops/all.js.map +0 -1
- package/dist/src/ops/create.js +0 -14
- package/dist/src/ops/create.js.map +0 -1
- package/dist/src/ops/find.js.map +0 -1
- package/dist/src/ops/get.js +0 -36
- package/dist/src/ops/get.js.map +0 -1
- package/dist/src/ops/one.js +0 -17
- package/dist/src/ops/one.js.map +0 -1
- package/dist/src/ops/remove.js +0 -56
- package/dist/src/ops/remove.js.map +0 -1
- package/dist/src/ops/update.js +0 -49
- package/dist/src/ops/update.js.map +0 -1
- package/dist/src/primary/Instance.js +0 -17
- package/dist/src/primary/Instance.js.map +0 -1
- package/dist/src/primary/index.js +0 -2
- package/dist/src/primary/index.js.map +0 -1
- package/eslint.config.mjs +0 -70
- package/dist/{src/Coordinate.d.ts → Coordinate.d.ts} +0 -0
- package/dist/{src/Definition.d.ts → Definition.d.ts} +1 -1
- package/dist/{src/EventCoordinator.d.ts → EventCoordinator.d.ts} +0 -0
- package/dist/{src/Instance.d.ts → Instance.d.ts} +1 -1
- package/dist/{src/KeyMaster.d.ts → KeyMaster.d.ts} +0 -0
- package/dist/{src/Options.d.ts → Options.d.ts} +1 -1
- /package/dist/{src/QueryBuilder.d.ts → QueryBuilder.d.ts} +0 -0
- /package/dist/{src/contained → contained}/Instance.d.ts +0 -0
- /package/dist/{src/contained → contained}/index.d.ts +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/ops → ops}/get.d.ts +0 -0
- /package/dist/{src/primary → primary}/Instance.d.ts +0 -0
- /package/dist/{src/primary → primary}/index.d.ts +0 -0
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import LibLogger from '../logger';
|
|
1
|
+
import LibLogger from '../logger.js';
|
|
2
|
+
|
|
2
3
|
const logger = LibLogger.get('sequelize', 'ops', 'find');
|
|
3
|
-
|
|
4
|
+
const getFindOperation = (models, definition)=>{
|
|
4
5
|
const { options } = definition;
|
|
5
|
-
const find = async (finder, finderParams, locations)
|
|
6
|
-
logger.default('Find', {
|
|
6
|
+
const find = async (finder, finderParams, locations)=>{
|
|
7
|
+
logger.default('Find', {
|
|
8
|
+
finder,
|
|
9
|
+
finderParams,
|
|
10
|
+
locations
|
|
11
|
+
});
|
|
7
12
|
// Note that we execute the createFinders function here because we want to make sure we're always getting the
|
|
8
13
|
// most up to date methods.
|
|
9
14
|
if (options.finders && options.finders[finder]) {
|
|
10
15
|
const finderMethod = options.finders[finder];
|
|
11
16
|
if (finderMethod) {
|
|
12
17
|
return finderMethod(finderParams, locations);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
18
|
+
} else {
|
|
15
19
|
logger.error(`Finder %s not found`, finder);
|
|
16
20
|
throw new Error(`Finder ${finder} not found`);
|
|
17
21
|
}
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
22
|
+
} else {
|
|
20
23
|
logger.error(`No finders have been defined for this lib`);
|
|
21
24
|
throw new Error(`No finders found`);
|
|
22
25
|
}
|
|
23
26
|
};
|
|
24
27
|
return find;
|
|
25
28
|
};
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
export { getFindOperation };
|
|
31
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmluZC5qcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
|
package/dist/ops/get.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isValidItemKey, isPriKey, isComKey, validateKeys } from '@fjell/core';
|
|
2
|
+
import LibLogger from '../logger.js';
|
|
3
|
+
import { processRow } from '../RowProcessor.js';
|
|
4
|
+
import { NotFoundError } from '@fjell/lib';
|
|
5
|
+
|
|
6
|
+
const logger = LibLogger.get('sequelize', 'ops', 'get');
|
|
7
|
+
const getGetOperation = (models, definition)=>{
|
|
8
|
+
const { coordinate } = definition;
|
|
9
|
+
const { kta } = coordinate;
|
|
10
|
+
const get = async (key)=>{
|
|
11
|
+
logger.default('Get', {
|
|
12
|
+
key
|
|
13
|
+
});
|
|
14
|
+
if (!isValidItemKey(key)) {
|
|
15
|
+
logger.error('Key for Get is not a valid ItemKey: %j', key);
|
|
16
|
+
throw new Error('Key for Get is not a valid ItemKey');
|
|
17
|
+
}
|
|
18
|
+
const itemKey = key;
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const model = models[0];
|
|
21
|
+
let item;
|
|
22
|
+
if (isPriKey(itemKey)) {
|
|
23
|
+
item = await model.findByPk(itemKey.pk);
|
|
24
|
+
} else if (isComKey(itemKey)) {
|
|
25
|
+
var _comKey_loc_, _comKey_loc_1;
|
|
26
|
+
const comKey = itemKey;
|
|
27
|
+
// TODO: This should probably interrogate the model?
|
|
28
|
+
item = await model.findOne({
|
|
29
|
+
where: {
|
|
30
|
+
id: comKey.pk,
|
|
31
|
+
[(comKey === null || comKey === void 0 ? void 0 : (_comKey_loc_ = comKey.loc[0]) === null || _comKey_loc_ === void 0 ? void 0 : _comKey_loc_.kt) + 'Id']: comKey === null || comKey === void 0 ? void 0 : (_comKey_loc_1 = comKey.loc[0]) === null || _comKey_loc_1 === void 0 ? void 0 : _comKey_loc_1.lk
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (!item) {
|
|
36
|
+
throw new NotFoundError('get', coordinate, key);
|
|
37
|
+
} else {
|
|
38
|
+
return validateKeys(processRow(item, kta), kta);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return get;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { getGetOperation };
|
|
45
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Item, ItemQuery, LocKeyArray } from
|
|
2
|
-
import { Definition } from
|
|
3
|
-
import { ModelStatic } from
|
|
1
|
+
import { Item, ItemQuery, LocKeyArray } from '@fjell/core';
|
|
2
|
+
import { Definition } from '../Definition';
|
|
3
|
+
import { ModelStatic } from 'sequelize';
|
|
4
4
|
export declare const getOneOperation: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(models: ModelStatic<any>[], definition: Definition<V, S, L1, L2, L3, L4, L5>) => (itemQuery: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V | null>;
|
package/dist/ops/one.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import LibLogger from '../logger.js';
|
|
2
|
+
import { getAllOperation } from './all.js';
|
|
3
|
+
|
|
4
|
+
const logger = LibLogger.get('sequelize', 'ops', 'one');
|
|
5
|
+
const getOneOperation = (models, definition)=>{
|
|
6
|
+
const one = async (itemQuery, locations = [])=>{
|
|
7
|
+
logger.default('One', {
|
|
8
|
+
itemQuery,
|
|
9
|
+
locations
|
|
10
|
+
});
|
|
11
|
+
const items = await getAllOperation(models, definition)(itemQuery, locations);
|
|
12
|
+
if (items.length > 0) {
|
|
13
|
+
return items[0];
|
|
14
|
+
} else {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return one;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { getOneOperation };
|
|
22
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib25lLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ComKey, PriKey } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ModelStatic } from "sequelize";
|
|
1
|
+
import { ComKey, PriKey, Item } from '@fjell/core';
|
|
2
|
+
import { Definition } from '../Definition';
|
|
3
|
+
import { ModelStatic } from 'sequelize';
|
|
5
4
|
export declare const getRemoveOperation: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(models: ModelStatic<any>[], definition: Definition<V, S, L1, L2, L3, L4, L5>) => (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>) => Promise<V>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { isValidItemKey, abbrevIK, isPriKey, isComKey } from '@fjell/core';
|
|
2
|
+
import { populateEvents } from '../EventCoordinator.js';
|
|
3
|
+
import { populateKey } from '../KeyMaster.js';
|
|
4
|
+
import LibLogger from '../logger.js';
|
|
5
|
+
|
|
6
|
+
const logger = LibLogger.get('sequelize', 'ops', 'remove');
|
|
7
|
+
const getRemoveOperation = (models, definition)=>{
|
|
8
|
+
const { coordinate, options } = definition;
|
|
9
|
+
const { kta } = coordinate;
|
|
10
|
+
const remove = async (key)=>{
|
|
11
|
+
logger.default('Remove', {
|
|
12
|
+
key
|
|
13
|
+
});
|
|
14
|
+
if (!isValidItemKey(key)) {
|
|
15
|
+
logger.error('Key for Remove is not a valid ItemKey: %j', key);
|
|
16
|
+
throw new Error('Key for Remove is not a valid ItemKey');
|
|
17
|
+
}
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const model = models[0];
|
|
20
|
+
let item;
|
|
21
|
+
let returnItem;
|
|
22
|
+
logger.debug('remove: %s', abbrevIK(key));
|
|
23
|
+
if (isPriKey(key)) {
|
|
24
|
+
item = await model.findByPk(key.pk);
|
|
25
|
+
} else if (isComKey(key)) {
|
|
26
|
+
var _comKey_loc_, _comKey_loc_1;
|
|
27
|
+
const comKey = key;
|
|
28
|
+
item = await model.findOne({
|
|
29
|
+
where: {
|
|
30
|
+
id: comKey.pk,
|
|
31
|
+
[(comKey === null || comKey === void 0 ? void 0 : (_comKey_loc_ = comKey.loc[0]) === null || _comKey_loc_ === void 0 ? void 0 : _comKey_loc_.kt) + 'Id']: comKey === null || comKey === void 0 ? void 0 : (_comKey_loc_1 = comKey.loc[0]) === null || _comKey_loc_1 === void 0 ? void 0 : _comKey_loc_1.lk
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const isDeletedAttribute = model.getAttributes().isDeleted;
|
|
36
|
+
const deletedAtAttribute = model.getAttributes().deletedAt;
|
|
37
|
+
if (isDeletedAttribute || deletedAtAttribute) {
|
|
38
|
+
if (model.getAttributes().isDeleted) {
|
|
39
|
+
item.isDeleted = true;
|
|
40
|
+
}
|
|
41
|
+
if (model.getAttributes().deletedAt) {
|
|
42
|
+
item.deletedAt = new Date();
|
|
43
|
+
}
|
|
44
|
+
// Save the object
|
|
45
|
+
await (item === null || item === void 0 ? void 0 : item.save());
|
|
46
|
+
returnItem = item === null || item === void 0 ? void 0 : item.get({
|
|
47
|
+
plain: true
|
|
48
|
+
});
|
|
49
|
+
returnItem = populateKey(returnItem, kta);
|
|
50
|
+
returnItem = populateEvents(returnItem);
|
|
51
|
+
} else if (options.deleteOnRemove) {
|
|
52
|
+
await (item === null || item === void 0 ? void 0 : item.destroy());
|
|
53
|
+
returnItem = item === null || item === void 0 ? void 0 : item.get({
|
|
54
|
+
plain: true
|
|
55
|
+
});
|
|
56
|
+
returnItem = populateKey(returnItem, kta);
|
|
57
|
+
returnItem = populateEvents(returnItem);
|
|
58
|
+
} else {
|
|
59
|
+
throw new Error('No deletedAt or isDeleted attribute found in model, and deleteOnRemove is not set');
|
|
60
|
+
}
|
|
61
|
+
return returnItem;
|
|
62
|
+
};
|
|
63
|
+
return remove;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { getRemoveOperation };
|
|
67
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVtb3ZlLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComKey, Item, PriKey, TypesProperties } from
|
|
2
|
-
import { Definition } from
|
|
3
|
-
import { ModelStatic } from
|
|
1
|
+
import { ComKey, Item, PriKey, TypesProperties } from '@fjell/core';
|
|
2
|
+
import { Definition } from '../Definition';
|
|
3
|
+
import { ModelStatic } from 'sequelize';
|
|
4
4
|
export declare const getUpdateOperation: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(models: ModelStatic<any>[], definition: Definition<V, S, L1, L2, L3, L4, L5>) => (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>) => Promise<V>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { abbrevIK, isPriKey, isComKey } from '@fjell/core';
|
|
2
|
+
import { removeEvents, populateEvents } from '../EventCoordinator.js';
|
|
3
|
+
import { removeKey, populateKey } from '../KeyMaster.js';
|
|
4
|
+
import LibLogger from '../logger.js';
|
|
5
|
+
import { NotFoundError } from '@fjell/lib';
|
|
6
|
+
|
|
7
|
+
const logger = LibLogger.get('sequelize', 'ops', 'update');
|
|
8
|
+
const getUpdateOperation = (models, definition)=>{
|
|
9
|
+
const update = async (key, item)=>{
|
|
10
|
+
const { coordinate } = definition;
|
|
11
|
+
const { kta } = coordinate;
|
|
12
|
+
logger.debug('update: %s, %j', abbrevIK(key), item);
|
|
13
|
+
// Find the object we're updating
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
const model = models[0];
|
|
16
|
+
let response;
|
|
17
|
+
if (isPriKey(key)) {
|
|
18
|
+
// Find the model by using the PK
|
|
19
|
+
const priKey = key;
|
|
20
|
+
response = await model.findByPk(priKey.pk);
|
|
21
|
+
} else if (isComKey(key)) {
|
|
22
|
+
var _comKey_loc_, _comKey_loc_1;
|
|
23
|
+
const comKey = key;
|
|
24
|
+
// Find the model by using both of the identifiers.
|
|
25
|
+
response = await model.findOne({
|
|
26
|
+
where: {
|
|
27
|
+
[(comKey === null || comKey === void 0 ? void 0 : (_comKey_loc_ = comKey.loc[0]) === null || _comKey_loc_ === void 0 ? void 0 : _comKey_loc_.kt) + 'Id']: comKey === null || comKey === void 0 ? void 0 : (_comKey_loc_1 = comKey.loc[0]) === null || _comKey_loc_1 === void 0 ? void 0 : _comKey_loc_1.lk,
|
|
28
|
+
id: comKey === null || comKey === void 0 ? void 0 : comKey.pk
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (response) {
|
|
33
|
+
// Remove the key and events
|
|
34
|
+
let updateProps = removeKey(item);
|
|
35
|
+
updateProps = removeEvents(item);
|
|
36
|
+
// Update the object
|
|
37
|
+
response = {
|
|
38
|
+
...response,
|
|
39
|
+
...updateProps
|
|
40
|
+
};
|
|
41
|
+
await (response === null || response === void 0 ? void 0 : response.save());
|
|
42
|
+
// Populate the key and events
|
|
43
|
+
let returnItem = response === null || response === void 0 ? void 0 : response.get({
|
|
44
|
+
plain: true
|
|
45
|
+
});
|
|
46
|
+
returnItem = populateKey(returnItem, kta);
|
|
47
|
+
returnItem = populateEvents(returnItem);
|
|
48
|
+
return returnItem;
|
|
49
|
+
} else {
|
|
50
|
+
throw new NotFoundError('update', coordinate, key);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return update;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { getUpdateOperation };
|
|
57
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBkYXRlLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Primary } from '@fjell/lib';
|
|
2
|
+
import { createDefinition } from '../Definition.js';
|
|
3
|
+
import { createOperations } from '../Operations.js';
|
|
4
|
+
import LibLogger from '../logger.js';
|
|
5
|
+
|
|
6
|
+
const logger = LibLogger.get('lib-sequelize', 'primary', 'instance');
|
|
7
|
+
function createInstance(keyType, models, libOptions = {}, scopes = []) {
|
|
8
|
+
logger.debug('createInstance', {
|
|
9
|
+
keyType,
|
|
10
|
+
models,
|
|
11
|
+
libOptions,
|
|
12
|
+
scopes
|
|
13
|
+
});
|
|
14
|
+
const definition = createDefinition([
|
|
15
|
+
keyType
|
|
16
|
+
], scopes, libOptions);
|
|
17
|
+
const operations = createOperations(models, definition);
|
|
18
|
+
return {
|
|
19
|
+
definition,
|
|
20
|
+
operations: Primary.wrapOperations(operations, definition),
|
|
21
|
+
models
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { createInstance };
|
|
26
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW5zdGFuY2UuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
|
package/package.json
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/lib-sequelize",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "4.4.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"description": "Sequelize Library for Fjell",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=21"
|
|
8
8
|
},
|
|
9
|
-
"main": "dist/
|
|
9
|
+
"main": "dist/index.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "yarn run lint && tsc && tsc-alias -p tsconfig.json",
|
|
20
|
-
"dev": "concurrently \"tsc -w\" \"tsc-alias -w\"",
|
|
21
|
-
"lint": "eslint .",
|
|
22
|
-
"clean": "rimraf dist",
|
|
23
|
-
"test": "yarn run lint && NODE_OPTIONS='--experimental-require-module' yarn run jest --coverage"
|
|
24
|
-
},
|
|
25
18
|
"dependencies": {
|
|
26
|
-
"@fjell/core": "^4.
|
|
27
|
-
"@fjell/lib": "^4.
|
|
28
|
-
"@fjell/logging": "^4.
|
|
19
|
+
"@fjell/core": "^4.4.2",
|
|
20
|
+
"@fjell/lib": "^4.4.0",
|
|
21
|
+
"@fjell/logging": "^4.4.2",
|
|
29
22
|
"dayjs": "^1.11.13",
|
|
30
23
|
"deepmerge": "^4.3.1",
|
|
31
24
|
"multer": "^1.4.5-lts.1",
|
|
@@ -37,25 +30,37 @@
|
|
|
37
30
|
"@babel/preset-env": "^7.26.9",
|
|
38
31
|
"@babel/preset-react": "^7.26.3",
|
|
39
32
|
"@babel/preset-typescript": "^7.26.0",
|
|
33
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
34
|
+
"@eslint/js": "^9.27.0",
|
|
35
|
+
"@jest/globals": "^29.7.0",
|
|
36
|
+
"@swc/core": "^1.11.24",
|
|
40
37
|
"@tsconfig/recommended": "^1.0.8",
|
|
41
38
|
"@types/jest": "^29.5.14",
|
|
42
39
|
"@types/multer": "^1.4.12",
|
|
43
40
|
"@types/node": "^20.17.19",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
45
|
-
"@typescript-eslint/parser": "^
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
42
|
+
"@typescript-eslint/parser": "^8.32.1",
|
|
46
43
|
"concurrently": "^8.2.2",
|
|
47
|
-
"eslint": "^
|
|
44
|
+
"eslint": "^9.27.0",
|
|
48
45
|
"jest": "^29.7.0",
|
|
49
46
|
"nodemon": "^3.1.9",
|
|
50
47
|
"rimraf": "^6.0.1",
|
|
51
48
|
"ts-jest": "^29.2.5",
|
|
52
49
|
"ts-node": "^10.9.2",
|
|
53
50
|
"tsc-alias": "^1.8.10",
|
|
54
|
-
"typescript": "^5.7.3"
|
|
51
|
+
"typescript": "^5.7.3",
|
|
52
|
+
"vite": "^6.3.5",
|
|
53
|
+
"vite-plugin-dts": "^4.5.4",
|
|
54
|
+
"vite-plugin-node": "^5.0.1"
|
|
55
55
|
},
|
|
56
|
-
"packageManager": "yarn@4.6.0",
|
|
57
56
|
"repository": {
|
|
58
57
|
"type": "git",
|
|
59
58
|
"url": "git+https://github.com/getfjell/lib-sequelize.git"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsc --noEmit && vite build",
|
|
62
|
+
"lint": "eslint . --ext .ts --fix",
|
|
63
|
+
"clean": "rimraf dist",
|
|
64
|
+
"test": "pnpm run lint && NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --coverage"
|
|
60
65
|
}
|
|
61
66
|
}
|
package/src/Instance.ts
CHANGED
|
@@ -16,8 +16,7 @@ export interface Instance<
|
|
|
16
16
|
> extends Library.Instance<V, S, L1, L2, L3, L4, L5> {
|
|
17
17
|
models: ModelStatic<any>[];
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line max-params
|
|
19
|
+
|
|
21
20
|
export function createInstance<
|
|
22
21
|
V extends Item<S, L1, L2, L3, L4, L5>,
|
|
23
22
|
S extends string,
|
package/src/Operations.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const createOperations = <
|
|
|
22
22
|
>(
|
|
23
23
|
models: Array<ModelStatic<any>>,
|
|
24
24
|
definition: Definition<V, S, L1, L2, L3, L4, L5>,
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
): Library.Operations<V, S, L1, L2, L3, L4, L5> => {
|
|
27
27
|
|
|
28
28
|
const operations = {} as Library.Operations<V, S, L1, L2, L3, L4, L5>;
|
|
@@ -16,8 +16,7 @@ export interface Instance<
|
|
|
16
16
|
> extends AbstractSequelizeInstance<V, S, L1, L2, L3, L4, L5> {
|
|
17
17
|
models: ModelStatic<any>[];
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line max-params
|
|
19
|
+
|
|
21
20
|
export function createInstance<
|
|
22
21
|
V extends Item<S, L1, L2, L3, L4, L5>,
|
|
23
22
|
S extends string,
|
package/src/ops/all.ts
CHANGED
|
@@ -26,7 +26,7 @@ L5 extends string = never
|
|
|
26
26
|
const all = async (
|
|
27
27
|
itemQuery: ItemQuery,
|
|
28
28
|
locations?: LocKeyArray<L1, L2, L3, L4, L5> | [] | undefined,
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
): Promise<V[]> => {
|
|
31
31
|
logger.default('All', { itemQuery, locations });
|
|
32
32
|
const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations || [];
|
package/src/ops/find.ts
CHANGED
|
@@ -25,7 +25,7 @@ L5 extends string = never
|
|
|
25
25
|
finder: string,
|
|
26
26
|
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
27
27
|
locations?: LocKeyArray<L1, L2, L3, L4, L5> | [],
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
): Promise<V[]> => {
|
|
30
30
|
logger.default('Find', { finder, finderParams, locations });
|
|
31
31
|
|
package/src/primary/Instance.ts
CHANGED
package/dist/src/Coordinate.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as Library from '@fjell/lib';
|
|
2
|
-
export const SCOPE_SEQUELIZE = 'sequelize';
|
|
3
|
-
export const createCoordinate = (kta, scopes) => {
|
|
4
|
-
const coordinate = Library.createCoordinate(kta, [SCOPE_SEQUELIZE, ...(scopes || [])]);
|
|
5
|
-
return coordinate;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=Coordinate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Coordinate.js","sourceRoot":"","sources":["../../src/Coordinate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAO9B,GAAyC,EAAE,MAAiB,EAAE,EAAE;IAChE,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAC,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IACrF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC"}
|
package/dist/src/Definition.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as Library from '@fjell/lib';
|
|
2
|
-
import { createCoordinate } from './Coordinate';
|
|
3
|
-
import { createOptions } from './Options';
|
|
4
|
-
import LibLogger from './logger';
|
|
5
|
-
const logger = LibLogger.get('lib-sequelize', 'Definition');
|
|
6
|
-
export function createDefinition(kta, scopes, libOptions) {
|
|
7
|
-
logger.debug('createDefinition', { kta, scopes, libOptions });
|
|
8
|
-
const coordinate = createCoordinate(kta, scopes);
|
|
9
|
-
const options = createOptions(libOptions);
|
|
10
|
-
const definition = Library.createDefinition(coordinate, options);
|
|
11
|
-
return {
|
|
12
|
-
...definition,
|
|
13
|
-
options,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=Definition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Definition.js","sourceRoot":"","sources":["../../src/Definition.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,SAAS,MAAM,UAAU,CAAC;AAEjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;AAc5D,MAAM,UAAU,gBAAgB,CAS9B,GAAyC,EACzC,MAAgB,EAChB,UAA8C;IAE9C,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IAE1C,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAEjE,OAAO;QACL,GAAG,UAAU;QACb,OAAO;KACR,CAAA;AACH,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import deepmerge from 'deepmerge';
|
|
2
|
-
import LibLogger from './logger';
|
|
3
|
-
const logger = LibLogger.get("sequelize", "EventCoordinator");
|
|
4
|
-
export const createEvents = (item) => {
|
|
5
|
-
logger.default('Creating Events', { item });
|
|
6
|
-
const currentDate = new Date();
|
|
7
|
-
let events = item.events;
|
|
8
|
-
if (events) {
|
|
9
|
-
if (!events.created) {
|
|
10
|
-
events = deepmerge(events, { created: { at: currentDate } });
|
|
11
|
-
}
|
|
12
|
-
if (!events.updated) {
|
|
13
|
-
events = deepmerge(events, { updated: { at: currentDate } });
|
|
14
|
-
}
|
|
15
|
-
if (!events.deleted) {
|
|
16
|
-
events = deepmerge(events, { deleted: { at: null } });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
events = {
|
|
21
|
-
created: { at: currentDate },
|
|
22
|
-
updated: { at: currentDate },
|
|
23
|
-
deleted: { at: null },
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return deepmerge(item, { events });
|
|
27
|
-
};
|
|
28
|
-
export const updateEvents = (item) => {
|
|
29
|
-
logger.default('Updating Events', { item });
|
|
30
|
-
const currentDate = new Date();
|
|
31
|
-
const events = {
|
|
32
|
-
updated: { at: currentDate },
|
|
33
|
-
};
|
|
34
|
-
// TODO: This is clean-up code, we should remove it
|
|
35
|
-
// If the event lacks a created data, let's just insert it here...
|
|
36
|
-
if (!item.events || !item.events.created || !item.events.created.at) {
|
|
37
|
-
events.created = { at: currentDate };
|
|
38
|
-
}
|
|
39
|
-
return deepmerge(item, { events });
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
export const populateEvents = (item) => {
|
|
43
|
-
const events = {
|
|
44
|
-
created: { at: item.createdAt },
|
|
45
|
-
updated: { at: item.updatedAt },
|
|
46
|
-
deleted: { at: null }
|
|
47
|
-
};
|
|
48
|
-
item.events = events;
|
|
49
|
-
return item;
|
|
50
|
-
};
|
|
51
|
-
export const removeEvents = (item) => {
|
|
52
|
-
logger.default('Removing Events', { item });
|
|
53
|
-
delete item.events;
|
|
54
|
-
return item;
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=EventCoordinator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventCoordinator.js","sourceRoot":"","sources":["../../src/EventCoordinator.ts"],"names":[],"mappings":"AAKA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,SAAS,MAAM,UAAU,CAAC;AAEjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,YAAY,GAAG,CAOxB,IAA2C,EACL,EAAE;IAC1C,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAE/B,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAEzB,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,GAAG,SAAS,CAAC,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AAE;IACxF,MAAM,MAAM,GAAkB;QAC5B,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE;QAC/B,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE;QAC/B,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE;KACtB,CAAC;IACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACrB,OAAO,IAAI,CAAC;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAOxB,IAA2C,EAAyC,EAAE;IACxF,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC,MAAM,CAAC;IACnB,OAAO,IAAI,CAAC;AACd,CAAC,CAAA"}
|
package/dist/src/Instance.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as Library from '@fjell/lib';
|
|
2
|
-
import { createDefinition } from './Definition';
|
|
3
|
-
import { createOperations } from './Operations';
|
|
4
|
-
// eslint-disable-next-line max-params
|
|
5
|
-
export function createInstance(keyTypes, models, libOptions = {}, scopes = []) {
|
|
6
|
-
const definition = createDefinition(keyTypes, scopes, libOptions);
|
|
7
|
-
const operations = createOperations(models, definition);
|
|
8
|
-
return {
|
|
9
|
-
definition,
|
|
10
|
-
operations: Library.wrapOperations(operations, definition),
|
|
11
|
-
models
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=Instance.js.map
|
package/dist/src/Instance.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.js","sourceRoot":"","sources":["../../src/Instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAgBhD,sCAAsC;AACtC,MAAM,UAAU,cAAc,CAS5B,QAA8C,EAC9C,MAA0B,EAC1B,aAAgD,EAAE,EAClD,SAAmB,EAAE;IAGrB,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAExD,OAAO;QACL,UAAU;QACV,UAAU,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,CAAC;QAC1D,MAAM;KACP,CAAA;AAEH,CAAC"}
|
package/dist/src/KeyMaster.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import LibLogger from './logger';
|
|
2
|
-
const logger = LibLogger.get('sequelize', 'KeyMaster');
|
|
3
|
-
export const removeKey = (item) => {
|
|
4
|
-
logger.default('Removing Key', { item });
|
|
5
|
-
delete item.key;
|
|
6
|
-
return item;
|
|
7
|
-
};
|
|
8
|
-
export const populateKey = (item, keyTypes) => {
|
|
9
|
-
if (keyTypes.length === 1) {
|
|
10
|
-
item.key = { kt: keyTypes[0], pk: item.id };
|
|
11
|
-
delete item.id;
|
|
12
|
-
}
|
|
13
|
-
else if (keyTypes.length === 2) {
|
|
14
|
-
item.key = {
|
|
15
|
-
kt: keyTypes[0], pk: item.id,
|
|
16
|
-
// TODO: Shouldn't this be inspecting the model to get the primary key type?
|
|
17
|
-
loc: [{ kt: keyTypes[1], lk: item[keyTypes[1] + 'Id'] }],
|
|
18
|
-
};
|
|
19
|
-
delete item.id;
|
|
20
|
-
delete item[keyTypes[1] + 'Id'];
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
throw new Error('Not implemented');
|
|
24
|
-
}
|
|
25
|
-
return item;
|
|
26
|
-
};
|
|
27
|
-
export const addKey = (item, keyTypes) => {
|
|
28
|
-
logger.default('Adding Key', { item });
|
|
29
|
-
const key = {};
|
|
30
|
-
if (Array.isArray(keyTypes) && keyTypes.length > 1) {
|
|
31
|
-
const type = [...keyTypes];
|
|
32
|
-
const pkType = type.shift();
|
|
33
|
-
Object.assign(key, { kt: pkType, pk: item.id });
|
|
34
|
-
// TODO: This is really just for primary items
|
|
35
|
-
if (type.length === 1) {
|
|
36
|
-
// TODO: This should be looking at the model to get the primary key of the reference item or association
|
|
37
|
-
const locKeyTypeId = type[0] + 'Id';
|
|
38
|
-
Object.assign(key, { loc: [{ kt: type[0], lk: item[locKeyTypeId] }] });
|
|
39
|
-
}
|
|
40
|
-
else if (type.length === 2) {
|
|
41
|
-
throw new Error('Not implemented');
|
|
42
|
-
}
|
|
43
|
-
else if (type.length === 3) {
|
|
44
|
-
throw new Error('Not implemented');
|
|
45
|
-
}
|
|
46
|
-
else if (type.length === 4) {
|
|
47
|
-
throw new Error('Not implemented');
|
|
48
|
-
}
|
|
49
|
-
else if (type.length === 5) {
|
|
50
|
-
throw new Error('Not implemented');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
Object.assign(key, { kt: keyTypes[0], pk: item.id });
|
|
55
|
-
}
|
|
56
|
-
Object.assign(item, { key });
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=KeyMaster.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KeyMaster.js","sourceRoot":"","sources":["../../src/KeyMaster.ts"],"names":[],"mappings":"AAMA,OAAO,SAAS,MAAM,UAAU,CAAC;AAEjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,SAAS,GAAG,CAQrB,IAA2C,EACJ,EAAE;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,GAAG,CAAC;IAChB,OAAO,IAAI,CAAC;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAQ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