@adaas/a-concept 0.3.2 → 0.3.4
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/browser/index.d.mts +58 -15
- package/dist/browser/index.mjs +2 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/index.cjs +58 -22
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.mts +58 -15
- package/dist/node/index.d.ts +58 -15
- package/dist/node/index.mjs +58 -22
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Abstraction/A-Abstraction-Extend.decorator.ts +1 -1
- package/src/lib/A-Container/A-Container.meta.ts +1 -1
- package/src/lib/A-Context/A-Context.class.ts +6 -5
- package/src/lib/A-Entity/A-Entity.class.ts +10 -9
- package/src/lib/A-Entity/A-Entity.constants.ts +5 -5
- package/src/lib/A-Entity/A-Entity.meta.ts +1 -1
- package/src/lib/A-Entity/A-Entity.types.ts +2 -1
- package/src/lib/A-Meta/A-Meta.class.ts +22 -26
- package/src/lib/A-Scope/A-Scope.class.ts +65 -7
- package/tests/A-Meta.test.ts +44 -1
- package/tests/A-Scope.test.ts +17 -0
package/dist/node/index.cjs
CHANGED
|
@@ -964,6 +964,20 @@ var A_EntityError = class extends A_Error {
|
|
|
964
964
|
*/
|
|
965
965
|
A_EntityError.ValidationError = "A-Entity Validation Error";
|
|
966
966
|
|
|
967
|
+
// src/lib/A-Entity/A-Entity.constants.ts
|
|
968
|
+
var A_TYPES__EntityMetaKey = /* @__PURE__ */ ((A_TYPES__EntityMetaKey2) => {
|
|
969
|
+
A_TYPES__EntityMetaKey2["EXTENSIONS"] = "a-component-extensions";
|
|
970
|
+
A_TYPES__EntityMetaKey2["FEATURES"] = "a-component-features";
|
|
971
|
+
A_TYPES__EntityMetaKey2["ABSTRACTIONS"] = "a-component-abstractions";
|
|
972
|
+
A_TYPES__EntityMetaKey2["INJECTIONS"] = "a-component-injections";
|
|
973
|
+
return A_TYPES__EntityMetaKey2;
|
|
974
|
+
})(A_TYPES__EntityMetaKey || {});
|
|
975
|
+
var A_TYPES__EntityFeatures = {
|
|
976
|
+
SAVE: "_A_Entity__Save",
|
|
977
|
+
DESTROY: "_A_Entity__Destroy",
|
|
978
|
+
LOAD: "_A_Entity__Load"
|
|
979
|
+
};
|
|
980
|
+
|
|
967
981
|
// src/lib/A-Entity/A-Entity.class.ts
|
|
968
982
|
var A_Entity = class {
|
|
969
983
|
// ====================================================================
|
|
@@ -1119,20 +1133,20 @@ var A_Entity = class {
|
|
|
1119
1133
|
/**
|
|
1120
1134
|
* The default method that can be called and extended to load entity data.
|
|
1121
1135
|
*/
|
|
1122
|
-
|
|
1123
|
-
return this.call(
|
|
1136
|
+
load(scope) {
|
|
1137
|
+
return this.call(A_TYPES__EntityFeatures.LOAD, scope);
|
|
1124
1138
|
}
|
|
1125
1139
|
/**
|
|
1126
1140
|
* The default method that can be called and extended to destroy entity data.
|
|
1127
1141
|
*/
|
|
1128
|
-
|
|
1129
|
-
return this.call(
|
|
1142
|
+
destroy(scope) {
|
|
1143
|
+
return this.call(A_TYPES__EntityFeatures.DESTROY, scope);
|
|
1130
1144
|
}
|
|
1131
1145
|
/**
|
|
1132
1146
|
* The default method that can be called and extended to save entity data.
|
|
1133
1147
|
*/
|
|
1134
|
-
|
|
1135
|
-
return this.call(
|
|
1148
|
+
save(scope) {
|
|
1149
|
+
return this.call(A_TYPES__EntityFeatures.SAVE, scope);
|
|
1136
1150
|
}
|
|
1137
1151
|
// ====================================================================
|
|
1138
1152
|
// ================== Entity Serialization ============================
|
|
@@ -1258,6 +1272,17 @@ var A_Meta = class _A_Meta {
|
|
|
1258
1272
|
this.meta = new Map(meta.meta);
|
|
1259
1273
|
return this;
|
|
1260
1274
|
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Allows to create a copy of the meta object with the same values, this is needed to ensure that when we inherit meta from the parent component, we create a copy of it, not a reference to the same object. This allows us to modify the meta of the child component without affecting the meta of the parent component.
|
|
1277
|
+
*
|
|
1278
|
+
* @returns
|
|
1279
|
+
*/
|
|
1280
|
+
clone() {
|
|
1281
|
+
const ctor = this.constructor;
|
|
1282
|
+
const copy = new ctor();
|
|
1283
|
+
copy.meta = new Map(this.meta);
|
|
1284
|
+
return copy;
|
|
1285
|
+
}
|
|
1261
1286
|
/**
|
|
1262
1287
|
* Method to set values in the map
|
|
1263
1288
|
*
|
|
@@ -1369,9 +1394,20 @@ var A_Meta = class _A_Meta {
|
|
|
1369
1394
|
clear() {
|
|
1370
1395
|
this.meta.clear();
|
|
1371
1396
|
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Method to convert the meta to an array of key-value pairs
|
|
1399
|
+
*
|
|
1400
|
+
* @returns
|
|
1401
|
+
*/
|
|
1372
1402
|
toArray() {
|
|
1373
1403
|
return Array.from(this.meta.entries());
|
|
1374
1404
|
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Helper method to recursively convert the meta object to a JSON-compatible format. It handles nested A_Meta instances, Maps, Arrays, and plain objects.
|
|
1407
|
+
*
|
|
1408
|
+
* @param value
|
|
1409
|
+
* @returns
|
|
1410
|
+
*/
|
|
1375
1411
|
recursiveToJSON(value) {
|
|
1376
1412
|
switch (true) {
|
|
1377
1413
|
case value instanceof _A_Meta:
|
|
@@ -1409,21 +1445,6 @@ var A_Meta = class _A_Meta {
|
|
|
1409
1445
|
}
|
|
1410
1446
|
};
|
|
1411
1447
|
|
|
1412
|
-
// src/lib/A-Entity/A-Entity.constants.ts
|
|
1413
|
-
var A_TYPES__EntityMetaKey = /* @__PURE__ */ ((A_TYPES__EntityMetaKey2) => {
|
|
1414
|
-
A_TYPES__EntityMetaKey2["EXTENSIONS"] = "a-component-extensions";
|
|
1415
|
-
A_TYPES__EntityMetaKey2["FEATURES"] = "a-component-features";
|
|
1416
|
-
A_TYPES__EntityMetaKey2["ABSTRACTIONS"] = "a-component-abstractions";
|
|
1417
|
-
A_TYPES__EntityMetaKey2["INJECTIONS"] = "a-component-injections";
|
|
1418
|
-
return A_TYPES__EntityMetaKey2;
|
|
1419
|
-
})(A_TYPES__EntityMetaKey || {});
|
|
1420
|
-
var A_TYPES__EntityFeatures = /* @__PURE__ */ ((A_TYPES__EntityFeatures2) => {
|
|
1421
|
-
A_TYPES__EntityFeatures2["SAVE"] = "save";
|
|
1422
|
-
A_TYPES__EntityFeatures2["DESTROY"] = "destroy";
|
|
1423
|
-
A_TYPES__EntityFeatures2["LOAD"] = "load";
|
|
1424
|
-
return A_TYPES__EntityFeatures2;
|
|
1425
|
-
})(A_TYPES__EntityFeatures || {});
|
|
1426
|
-
|
|
1427
1448
|
// src/lib/A-Entity/A-Entity.meta.ts
|
|
1428
1449
|
var A_EntityMeta = class extends A_Meta {
|
|
1429
1450
|
/**
|
|
@@ -4124,6 +4145,21 @@ var A_Scope = class {
|
|
|
4124
4145
|
return slice.length === 1 && count !== -1 ? slice[0] : slice.length ? slice : void 0;
|
|
4125
4146
|
}
|
|
4126
4147
|
resolveConstructor(name) {
|
|
4148
|
+
switch (true) {
|
|
4149
|
+
case A_TypeGuards.isComponentConstructor(name):
|
|
4150
|
+
return Array.from(this.allowedComponents).find((c) => A_CommonHelper.isInheritedFrom(c, name));
|
|
4151
|
+
case A_TypeGuards.isEntityConstructor(name):
|
|
4152
|
+
return Array.from(this.allowedEntities).find((e) => A_CommonHelper.isInheritedFrom(e, name));
|
|
4153
|
+
case A_TypeGuards.isFragmentConstructor(name):
|
|
4154
|
+
return Array.from(this.allowedFragments).find((f) => A_CommonHelper.isInheritedFrom(f, name));
|
|
4155
|
+
case A_TypeGuards.isErrorConstructor(name):
|
|
4156
|
+
return Array.from(this.allowedErrors).find((e) => A_CommonHelper.isInheritedFrom(e, name));
|
|
4157
|
+
}
|
|
4158
|
+
if (!A_TypeGuards.isString(name))
|
|
4159
|
+
throw new A_ScopeError(
|
|
4160
|
+
A_ScopeError.ResolutionError,
|
|
4161
|
+
`Invalid constructor name provided: ${name}`
|
|
4162
|
+
);
|
|
4127
4163
|
const component = Array.from(this.allowedComponents).find(
|
|
4128
4164
|
(c) => c.name === name || c.name === A_FormatterHelper.toPascalCase(name)
|
|
4129
4165
|
);
|
|
@@ -5026,7 +5062,7 @@ var A_Context = class _A_Context {
|
|
|
5026
5062
|
}
|
|
5027
5063
|
if (!inheritedMeta)
|
|
5028
5064
|
inheritedMeta = new metaType();
|
|
5029
|
-
instance._metaStorage.set(property,
|
|
5065
|
+
instance._metaStorage.set(property, inheritedMeta.clone());
|
|
5030
5066
|
}
|
|
5031
5067
|
return instance._metaStorage.get(property);
|
|
5032
5068
|
}
|