@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
|
@@ -12,7 +12,7 @@ export const DraftStateMixin = {
|
|
|
12
12
|
* @param {Object} [options={}] - options
|
|
13
13
|
* @returns {Proxy}
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
_createDraftProxy(apiClient, server = {}, draft = {}, allowedFields = [], transforms = {}, options = {}) {
|
|
16
16
|
return new Proxy({}, {
|
|
17
17
|
get: (_, prop) => {
|
|
18
18
|
const val = prop in draft ? draft[prop] : server[prop];
|
|
@@ -96,7 +96,7 @@ export const DraftStateMixin = {
|
|
|
96
96
|
return [...new Set(fields)];
|
|
97
97
|
},
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
_buildDraftAndProxy({ data = {}, serverData = null, constant, apiClient, transforms = {}, throwOnError = true, removeFields = [] }) {
|
|
100
100
|
const constants = Array.isArray(constant) ? constant : [constant];
|
|
101
101
|
const combinedSchema = {
|
|
102
102
|
allOf: [],
|
|
@@ -138,12 +138,12 @@ export const DraftStateMixin = {
|
|
|
138
138
|
if (transformed !== undefined) draft[key] = transformed;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const proxy = this.
|
|
141
|
+
const proxy = this._createDraftProxy(apiClient, serverData, draft, allowed, transforms, { throwOnError });
|
|
142
142
|
|
|
143
143
|
return { draft, proxy };
|
|
144
144
|
},
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
_extractChangedFieldsFromSchema(apiClient, constant, data = {}, getInitialDraft, removeFields = []) {
|
|
147
147
|
const schema = apiClient.getRequestSchema(constant);
|
|
148
148
|
let allowed = this._extractWritableFields(schema, data);
|
|
149
149
|
const changed = {};
|
package/src/mixin/EntityMixin.js
CHANGED
|
@@ -101,7 +101,7 @@ export const EntityMixin = {
|
|
|
101
101
|
* Constant : PROFIL_IMAGE
|
|
102
102
|
*/
|
|
103
103
|
async updateImageProfil({ profil_avatar: image }) {
|
|
104
|
-
image = await this.
|
|
104
|
+
image = await this._validateImage(image);
|
|
105
105
|
const data = { pathParams: { folder: this.getEntityType(), ownerId: this.id }, profil_avatar: image };
|
|
106
106
|
return this.callIsConnected(() => this.endpointApi.profilImage(data));
|
|
107
107
|
}
|
package/src/mixin/UtilMixin.js
CHANGED
|
@@ -87,7 +87,7 @@ export const UtilMixin = {
|
|
|
87
87
|
return await this.callIsConnected(param, data);
|
|
88
88
|
},
|
|
89
89
|
|
|
90
|
-
async
|
|
90
|
+
async _validateImage(imageInput){
|
|
91
91
|
const image = await this._validateUploadInput(imageInput, {
|
|
92
92
|
allowedMimeTypes: ["image/jpeg", "image/png", "image/jpg"],
|
|
93
93
|
expectedType: "image"
|
|
@@ -95,7 +95,7 @@ export const UtilMixin = {
|
|
|
95
95
|
return image;
|
|
96
96
|
},
|
|
97
97
|
|
|
98
|
-
async
|
|
98
|
+
async _validateFile(fileInput){
|
|
99
99
|
const file = await this._validateUploadInput(fileInput, {
|
|
100
100
|
allowedMimeTypes: ["application/pdf", "text/plain", "text/csv"],
|
|
101
101
|
expectedType: "file"
|