@communecter/cocolight-api-client 1.0.13 → 1.0.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.
- package/dist/cocolight-api-client.browser.js +3 -3
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/package.json +2 -4
- package/src/api/EndpointApi.js +638 -343
- package/src/api/News.js +5 -5
- package/src/api/Organization.js +5 -5
- package/src/api/Project.js +5 -5
- package/src/api/User.js +4 -4
- package/src/endpoints.module.js +2 -2
- package/src/mixin/DraftStateMixin.js +4 -4
- package/src/mixin/EntityMixin.js +1 -1
- package/src/mixin/UtilMixin.js +2 -2
package/src/api/News.js
CHANGED
|
@@ -49,7 +49,7 @@ export class News {
|
|
|
49
49
|
|
|
50
50
|
this.#serverData = null;
|
|
51
51
|
|
|
52
|
-
const { draft, proxy } = this.
|
|
52
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
53
53
|
data: { ...data, ...this.defaultFields },
|
|
54
54
|
serverData: this.#serverData,
|
|
55
55
|
constant: News.SCHEMA_CONSTANTS,
|
|
@@ -97,7 +97,7 @@ export class News {
|
|
|
97
97
|
_setData(newData) {
|
|
98
98
|
this.#serverData = { ...newData };
|
|
99
99
|
|
|
100
|
-
const { draft, proxy } = this.
|
|
100
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
101
101
|
data: { ...newData, ...this.defaultFields },
|
|
102
102
|
serverData: this.#serverData,
|
|
103
103
|
constant: News.SCHEMA_CONSTANTS,
|
|
@@ -118,7 +118,7 @@ export class News {
|
|
|
118
118
|
const instance = new News(parent, {}, deps);
|
|
119
119
|
instance.#serverData = { ...data };
|
|
120
120
|
|
|
121
|
-
const { draft, proxy } = instance.
|
|
121
|
+
const { draft, proxy } = instance._buildDraftAndProxy({
|
|
122
122
|
data: { ...data, ...instance.defaultFields },
|
|
123
123
|
serverData: instance.#serverData,
|
|
124
124
|
constant: News.SCHEMA_CONSTANTS,
|
|
@@ -244,7 +244,7 @@ export class News {
|
|
|
244
244
|
* Constant : ADD_IMAGE_NEWS
|
|
245
245
|
*/
|
|
246
246
|
async addImage(image) {
|
|
247
|
-
image = await this.
|
|
247
|
+
image = await this._validateImage(image);
|
|
248
248
|
const data = { pathParams: { folder: this.parent.getEntityType(), ownerId: this.parent.id }, newsImage: image };
|
|
249
249
|
const dataImage = await this.callIsConnected(() => this.endpointApi.addImageNews(data));
|
|
250
250
|
if (this.#draftData.mediaImg) {
|
|
@@ -261,7 +261,7 @@ export class News {
|
|
|
261
261
|
* Constant : ADD_FILE_NEWS
|
|
262
262
|
*/
|
|
263
263
|
async addFile(file) {
|
|
264
|
-
file = await this.
|
|
264
|
+
file = await this._validateFile(file);
|
|
265
265
|
const data = { pathParams: { folder: this.parent.getEntityType(), ownerId: this.parent.id }, newsFile: file };
|
|
266
266
|
const dataFile = await this.callIsConnected(() =>this.endpointApi.addFileNews(data));
|
|
267
267
|
if (this.#draftData.mediaFile) {
|
package/src/api/Organization.js
CHANGED
|
@@ -83,7 +83,7 @@ export class Organization {
|
|
|
83
83
|
|
|
84
84
|
this.#serverData = null;
|
|
85
85
|
|
|
86
|
-
const { draft, proxy } = this.
|
|
86
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
87
87
|
data: { ...data, ...this.defaultFields },
|
|
88
88
|
serverData: this.#serverData,
|
|
89
89
|
constant: Organization.SCHEMA_CONSTANTS,
|
|
@@ -117,7 +117,7 @@ export class Organization {
|
|
|
117
117
|
_setData(newData) {
|
|
118
118
|
this.#serverData = { ...newData };
|
|
119
119
|
|
|
120
|
-
const { draft, proxy } = this.
|
|
120
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
121
121
|
data: { ...newData, ...this.defaultFields },
|
|
122
122
|
serverData: this.#serverData,
|
|
123
123
|
constant: Organization.SCHEMA_CONSTANTS,
|
|
@@ -158,7 +158,7 @@ export class Organization {
|
|
|
158
158
|
const instance = new Organization(parent, {}, deps);
|
|
159
159
|
instance.#serverData = { ...data };
|
|
160
160
|
|
|
161
|
-
const { draft, proxy } = instance.
|
|
161
|
+
const { draft, proxy } = instance._buildDraftAndProxy({
|
|
162
162
|
data: { ...data, ...instance.defaultFields },
|
|
163
163
|
serverData: instance.#serverData,
|
|
164
164
|
constant: Organization.SCHEMA_CONSTANTS,
|
|
@@ -211,7 +211,7 @@ export class Organization {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
for (const [constant, methodName] of Organization.ADD_BLOCKS) {
|
|
214
|
-
const blockData = this.
|
|
214
|
+
const blockData = this._extractChangedFieldsFromSchema(
|
|
215
215
|
this.apiClient,
|
|
216
216
|
constant,
|
|
217
217
|
{ ...payload, ...this.defaultFields},
|
|
@@ -246,7 +246,7 @@ export class Organization {
|
|
|
246
246
|
|
|
247
247
|
// Sinon, on fait les updates en blocs
|
|
248
248
|
for (const [constant, methodName] of Organization.UPDATE_BLOCKS) {
|
|
249
|
-
const blockData = this.
|
|
249
|
+
const blockData = this._extractChangedFieldsFromSchema(
|
|
250
250
|
this.apiClient,
|
|
251
251
|
constant,
|
|
252
252
|
{ ...payload, ...this.defaultFields},
|
package/src/api/Project.js
CHANGED
|
@@ -77,7 +77,7 @@ export class Project {
|
|
|
77
77
|
? deps.EndpointApi
|
|
78
78
|
: (() => { throw new ApiError("deps.EndpointApi must be a class or instance."); })());
|
|
79
79
|
|
|
80
|
-
const { draft, proxy } = this.
|
|
80
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
81
81
|
data: { ...data, ...this.defaultFields },
|
|
82
82
|
serverData: this.#serverData,
|
|
83
83
|
constant: Project.SCHEMA_CONSTANTS,
|
|
@@ -137,7 +137,7 @@ export class Project {
|
|
|
137
137
|
|
|
138
138
|
_setData(newData) {
|
|
139
139
|
this.#serverData = { ...newData };
|
|
140
|
-
const { draft, proxy } = this.
|
|
140
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
141
141
|
data: { ...newData, ...this.defaultFields },
|
|
142
142
|
serverData: this.#serverData,
|
|
143
143
|
constant: Project.SCHEMA_CONSTANTS,
|
|
@@ -188,7 +188,7 @@ export class Project {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
for (const [constant, methodName] of Project.ADD_BLOCKS) {
|
|
191
|
-
const blockData = this.
|
|
191
|
+
const blockData = this._extractChangedFieldsFromSchema(
|
|
192
192
|
this.apiClient,
|
|
193
193
|
constant,
|
|
194
194
|
{ ...payload, ...this.defaultFields},
|
|
@@ -222,7 +222,7 @@ export class Project {
|
|
|
222
222
|
|
|
223
223
|
// Sinon, on fait les updates en blocs
|
|
224
224
|
for (const [constant, methodName] of Project.UPDATE_BLOCKS) {
|
|
225
|
-
const blockData = this.
|
|
225
|
+
const blockData = this._extractChangedFieldsFromSchema(
|
|
226
226
|
this.apiClient,
|
|
227
227
|
constant,
|
|
228
228
|
{ ...payload, ...this.defaultFields},
|
|
@@ -256,7 +256,7 @@ export class Project {
|
|
|
256
256
|
const instance = new Project(parent, {}, deps);
|
|
257
257
|
instance.#serverData = { ...data };
|
|
258
258
|
|
|
259
|
-
const { draft, proxy } = instance.
|
|
259
|
+
const { draft, proxy } = instance._buildDraftAndProxy({
|
|
260
260
|
data: { ...data, ...instance.defaultFields },
|
|
261
261
|
serverData: instance.#serverData,
|
|
262
262
|
constant: Project.SCHEMA_CONSTANTS,
|
package/src/api/User.js
CHANGED
|
@@ -75,7 +75,7 @@ export class User {
|
|
|
75
75
|
|
|
76
76
|
this.#serverData = null;
|
|
77
77
|
|
|
78
|
-
const { draft, proxy } = this.
|
|
78
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
79
79
|
data: { ...data, ...this.defaultFields },
|
|
80
80
|
serverData: this.#serverData,
|
|
81
81
|
constant: User.SCHEMA_CONSTANTS,
|
|
@@ -108,7 +108,7 @@ export class User {
|
|
|
108
108
|
_setData(newData) {
|
|
109
109
|
this.#serverData = { ...newData };
|
|
110
110
|
|
|
111
|
-
const { draft, proxy } = this.
|
|
111
|
+
const { draft, proxy } = this._buildDraftAndProxy({
|
|
112
112
|
data: { ...newData, ...this.defaultFields },
|
|
113
113
|
serverData: this.#serverData,
|
|
114
114
|
constant: User.SCHEMA_CONSTANTS,
|
|
@@ -228,7 +228,7 @@ export class User {
|
|
|
228
228
|
|
|
229
229
|
// Sinon, on fait les updates en blocs
|
|
230
230
|
for (const [constant, methodName] of User.UPDATE_BLOCKS) {
|
|
231
|
-
const blockData = this.
|
|
231
|
+
const blockData = this._extractChangedFieldsFromSchema(
|
|
232
232
|
this.apiClient,
|
|
233
233
|
constant,
|
|
234
234
|
{ ...payload, ...this.defaultFields},
|
|
@@ -310,7 +310,7 @@ export class User {
|
|
|
310
310
|
* Constant : PROFIL_IMAGE
|
|
311
311
|
*/
|
|
312
312
|
async updateImageProfil({ profil_avatar: image }) {
|
|
313
|
-
image = await this.
|
|
313
|
+
image = await this._validateImage(image);
|
|
314
314
|
return this.callIsMe(() => this.endpointApi.profilImage({ profil_avatar: image }));
|
|
315
315
|
}
|
|
316
316
|
|