@communecter/cocolight-api-client 1.0.28 → 1.0.29
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/cocolight-api-client.browser.js +1 -1
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
- package/package.json +1 -1
- package/src/api/BaseEntity.js +5 -3
package/package.json
CHANGED
package/src/api/BaseEntity.js
CHANGED
|
@@ -54,10 +54,10 @@ export class BaseEntity {
|
|
|
54
54
|
* @throws {ApiError} Si les dépendances ou parent sont invalides.
|
|
55
55
|
*/
|
|
56
56
|
constructor(parent, data = {}, deps = {}, config = {}) {
|
|
57
|
-
this.__entityTag = config.entityTag || this.constructor.name
|
|
57
|
+
this.__entityTag = config.entityTag || this.getEntityTag(this.constructor.name) || "BaseEntity";
|
|
58
58
|
this.deps = deps;
|
|
59
59
|
|
|
60
|
-
if (parent?.__entityTag === "ApiClient") {
|
|
60
|
+
if (this.getEntityTag(parent?.__entityTag) === "ApiClient") {
|
|
61
61
|
/** @type {ApiClient} */
|
|
62
62
|
this.apiClient = parent;
|
|
63
63
|
this.parent = null;
|
|
@@ -66,7 +66,7 @@ export class BaseEntity {
|
|
|
66
66
|
/** @type {ApiClient} */
|
|
67
67
|
this.apiClient = parent.apiClient;
|
|
68
68
|
this.parent = parent;
|
|
69
|
-
if (parent?.__entityTag === "User") {
|
|
69
|
+
if (this.getEntityTag(parent?.__entityTag) === "User") {
|
|
70
70
|
this.userContext = parent;
|
|
71
71
|
} else if (parent?.userContext) {
|
|
72
72
|
this.userContext = parent.userContext;
|
|
@@ -102,6 +102,8 @@ export class BaseEntity {
|
|
|
102
102
|
this.data = proxy;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
getEntityTag = (__entityTag) => __entityTag?.replace(/^_/, "");
|
|
106
|
+
|
|
105
107
|
/** @returns {string|null} Identifiant de l'entité */
|
|
106
108
|
get id() {
|
|
107
109
|
return this._draftData.id || null;
|