@communecter/cocolight-api-client 1.0.27 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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 || "BaseEntity";
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;