@digipair/skill-service 0.98.4 → 0.98.5

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/index.cjs.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var engine = require('@digipair/engine');
6
6
 
7
7
  const multer = require('multer');
8
- const upload = multer({
8
+ const uploadMulter = multer({
9
9
  storage: multer.memoryStorage()
10
10
  });
11
11
  let ServiceService = class ServiceService {
@@ -25,19 +25,29 @@ let ServiceService = class ServiceService {
25
25
  const { headers } = params;
26
26
  return context.protected.res.set(headers);
27
27
  }
28
- async files(_params, _pinsSettingsList, context) {
29
- await new Promise((resolve, reject)=>upload.any()(context.protected.req, context.protected.res, (err)=>err ? reject(err) : resolve(void 0)));
30
- return context.protected.req.files;
28
+ async upload(_params, _pinsSettingsList, context) {
29
+ await new Promise((resolve, reject)=>uploadMulter.any()(context.protected.req, context.protected.res, (err)=>err ? reject(err) : resolve(void 0)));
30
+ return {
31
+ body: context.protected.req.body,
32
+ files: context.protected.req.files.map((file)=>({
33
+ fieldname: file.fieldname,
34
+ originalname: file.originalname,
35
+ encoding: file.encoding,
36
+ mimetype: file.mimetype,
37
+ size: file.size,
38
+ content: `data:${file.mimetype};base64,${file.buffer.toString('base64')}`
39
+ }))
40
+ };
31
41
  }
32
42
  };
33
43
  const service = (params, pinsSettingsList, context)=>new ServiceService().service(params, pinsSettingsList, context);
34
44
  const send = (params, pinsSettingsList, context)=>new ServiceService().send(params, pinsSettingsList, context);
35
45
  const status = (params, pinsSettingsList, context)=>new ServiceService().status(params, pinsSettingsList, context);
36
46
  const headers = (params, pinsSettingsList, context)=>new ServiceService().headers(params, pinsSettingsList, context);
37
- const files = (params, pinsSettingsList, context)=>new ServiceService().files(params, pinsSettingsList, context);
47
+ const upload = (params, pinsSettingsList, context)=>new ServiceService().upload(params, pinsSettingsList, context);
38
48
 
39
- exports.files = files;
40
49
  exports.headers = headers;
41
50
  exports.send = send;
42
51
  exports.service = service;
43
52
  exports.status = status;
53
+ exports.upload = upload;
package/index.esm.js CHANGED
@@ -23899,14 +23899,14 @@ function indent(str, spaces) {
23899
23899
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23900
23900
  // match is required
23901
23901
  if (!match) {
23902
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
23902
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23903
23903
  v: nextMatch1
23904
23904
  };
23905
23905
  }
23906
23906
  var token = match.token, offset = match.offset;
23907
23907
  i1 += offset;
23908
23908
  if (token === " ") {
23909
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
23909
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23910
23910
  }
23911
23911
  tokens1 = _to_consumable_array$1(tokens1).concat([
23912
23912
  token
@@ -23925,7 +23925,7 @@ function indent(str, spaces) {
23925
23925
  if (contextKeys.some(function(el) {
23926
23926
  return el.startsWith(name);
23927
23927
  })) {
23928
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
23928
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23929
23929
  }
23930
23930
  if (dateTimeIdentifiers.some(function(el) {
23931
23931
  return el === name;
@@ -23944,9 +23944,9 @@ function indent(str, spaces) {
23944
23944
  if (dateTimeIdentifiers.some(function(el) {
23945
23945
  return el.startsWith(name);
23946
23946
  })) {
23947
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
23947
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23948
23948
  }
23949
- return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
23949
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23950
23950
  v: nextMatch1
23951
23951
  };
23952
23952
  };
@@ -27981,7 +27981,7 @@ const preparePinsSettings = (settings, context)=>{
27981
27981
  };
27982
27982
 
27983
27983
  const multer = require('multer');
27984
- const upload = multer({
27984
+ const uploadMulter = multer({
27985
27985
  storage: multer.memoryStorage()
27986
27986
  });
27987
27987
  let ServiceService = class ServiceService {
@@ -28001,15 +28001,25 @@ let ServiceService = class ServiceService {
28001
28001
  const { headers } = params;
28002
28002
  return context.protected.res.set(headers);
28003
28003
  }
28004
- async files(_params, _pinsSettingsList, context) {
28005
- await new Promise((resolve, reject)=>upload.any()(context.protected.req, context.protected.res, (err)=>err ? reject(err) : resolve(void 0)));
28006
- return context.protected.req.files;
28004
+ async upload(_params, _pinsSettingsList, context) {
28005
+ await new Promise((resolve, reject)=>uploadMulter.any()(context.protected.req, context.protected.res, (err)=>err ? reject(err) : resolve(void 0)));
28006
+ return {
28007
+ body: context.protected.req.body,
28008
+ files: context.protected.req.files.map((file)=>({
28009
+ fieldname: file.fieldname,
28010
+ originalname: file.originalname,
28011
+ encoding: file.encoding,
28012
+ mimetype: file.mimetype,
28013
+ size: file.size,
28014
+ content: `data:${file.mimetype};base64,${file.buffer.toString('base64')}`
28015
+ }))
28016
+ };
28007
28017
  }
28008
28018
  };
28009
28019
  const service = (params, pinsSettingsList, context)=>new ServiceService().service(params, pinsSettingsList, context);
28010
28020
  const send = (params, pinsSettingsList, context)=>new ServiceService().send(params, pinsSettingsList, context);
28011
28021
  const status = (params, pinsSettingsList, context)=>new ServiceService().status(params, pinsSettingsList, context);
28012
28022
  const headers = (params, pinsSettingsList, context)=>new ServiceService().headers(params, pinsSettingsList, context);
28013
- const files = (params, pinsSettingsList, context)=>new ServiceService().files(params, pinsSettingsList, context);
28023
+ const upload = (params, pinsSettingsList, context)=>new ServiceService().upload(params, pinsSettingsList, context);
28014
28024
 
28015
- export { files, headers, send, service, status };
28025
+ export { headers, send, service, status, upload };
@@ -3,4 +3,7 @@ export declare const service: (params: any, pinsSettingsList: PinsSettings[], co
3
3
  export declare const send: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
4
4
  export declare const status: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
5
5
  export declare const headers: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
6
- export declare const files: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
6
+ export declare const upload: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<{
7
+ body: any;
8
+ files: any;
9
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-service",
3
- "version": "0.98.4",
3
+ "version": "0.98.5",
4
4
  "keywords": [
5
5
  "digipair",
6
6
  "service",
package/schema.fr.json CHANGED
@@ -113,7 +113,7 @@
113
113
  "x-events": []
114
114
  }
115
115
  },
116
- "/files": {
116
+ "/upload": {
117
117
  "post": {
118
118
  "tags": [
119
119
  "service"
@@ -127,50 +127,50 @@
127
127
  "content": {
128
128
  "application/json": {
129
129
  "schema": {
130
- "type": "array",
131
- "description": "Tableau d'objets de fichiers téléchargés traités par multer",
132
- "items": {
133
- "type": "object",
134
- "properties": {
135
- "fieldname": {
136
- "type": "string",
137
- "description": "Nom du champ spécifié dans le formulaire"
138
- },
139
- "originalname": {
140
- "type": "string",
141
- "description": "Nom du fichier sur l'ordinateur de l'utilisateur"
142
- },
143
- "encoding": {
144
- "type": "string",
145
- "description": "Type d'encodage du fichier"
146
- },
147
- "mimetype": {
148
- "type": "string",
149
- "description": "Type MIME du fichier"
150
- },
151
- "size": {
152
- "type": "number",
153
- "description": "Taille du fichier en octets"
154
- },
155
- "destination": {
156
- "type": "string",
157
- "description": "Dossier dans lequel le fichier a été sauvegardé (DiskStorage uniquement)"
158
- },
159
- "filename": {
160
- "type": "string",
161
- "description": "Nom du fichier dans le dossier de destination (DiskStorage uniquement)"
162
- },
163
- "path": {
164
- "type": "string",
165
- "description": "Chemin complet vers le fichier téléchargé (DiskStorage uniquement)"
166
- },
167
- "buffer": {
130
+ "type": "object",
131
+ "description": "Objet contenant les données du formulaire et les fichiers téléchargés avec contenu base64",
132
+ "properties": {
133
+ "body": {
134
+ "type": "object",
135
+ "description": "Données du corps du formulaire",
136
+ "additionalProperties": true
137
+ },
138
+ "files": {
139
+ "type": "array",
140
+ "description": "Tableau d'objets de fichiers téléchargés avec contenu encodé en base64",
141
+ "items": {
168
142
  "type": "object",
169
- "description": "Buffer de l'intégralité du fichier (MemoryStorage uniquement)"
143
+ "properties": {
144
+ "fieldname": {
145
+ "type": "string",
146
+ "description": "Nom du champ spécifié dans le formulaire"
147
+ },
148
+ "originalname": {
149
+ "type": "string",
150
+ "description": "Nom du fichier sur l'ordinateur de l'utilisateur"
151
+ },
152
+ "encoding": {
153
+ "type": "string",
154
+ "description": "Type d'encodage du fichier"
155
+ },
156
+ "mimetype": {
157
+ "type": "string",
158
+ "description": "Type MIME du fichier"
159
+ },
160
+ "size": {
161
+ "type": "number",
162
+ "description": "Taille du fichier en octets"
163
+ },
164
+ "content": {
165
+ "type": "string",
166
+ "description": "Contenu du fichier encodé en base64 au format data URI"
167
+ }
168
+ },
169
+ "required": ["fieldname", "originalname", "encoding", "mimetype", "size", "content"]
170
170
  }
171
- },
172
- "required": ["fieldname", "originalname", "encoding", "mimetype", "size"]
173
- }
171
+ }
172
+ },
173
+ "required": ["body", "files"]
174
174
  }
175
175
  }
176
176
  }
package/schema.json CHANGED
@@ -113,7 +113,7 @@
113
113
  "x-events": []
114
114
  }
115
115
  },
116
- "/files": {
116
+ "/upload": {
117
117
  "post": {
118
118
  "tags": [
119
119
  "service"
@@ -127,50 +127,50 @@
127
127
  "content": {
128
128
  "application/json": {
129
129
  "schema": {
130
- "type": "array",
131
- "description": "Array of uploaded file objects processed by multer",
132
- "items": {
133
- "type": "object",
134
- "properties": {
135
- "fieldname": {
136
- "type": "string",
137
- "description": "Field name specified in the form"
138
- },
139
- "originalname": {
140
- "type": "string",
141
- "description": "Name of the file on the user's computer"
142
- },
143
- "encoding": {
144
- "type": "string",
145
- "description": "Encoding type of the file"
146
- },
147
- "mimetype": {
148
- "type": "string",
149
- "description": "MIME type of the file"
150
- },
151
- "size": {
152
- "type": "number",
153
- "description": "Size of the file in bytes"
154
- },
155
- "destination": {
156
- "type": "string",
157
- "description": "Folder to which the file has been saved (DiskStorage only)"
158
- },
159
- "filename": {
160
- "type": "string",
161
- "description": "Name of the file within the destination (DiskStorage only)"
162
- },
163
- "path": {
164
- "type": "string",
165
- "description": "Full path to the uploaded file (DiskStorage only)"
166
- },
167
- "buffer": {
130
+ "type": "object",
131
+ "description": "Object containing form body and uploaded files with base64 content",
132
+ "properties": {
133
+ "body": {
134
+ "type": "object",
135
+ "description": "Form body data",
136
+ "additionalProperties": true
137
+ },
138
+ "files": {
139
+ "type": "array",
140
+ "description": "Array of uploaded file objects with base64 encoded content",
141
+ "items": {
168
142
  "type": "object",
169
- "description": "Buffer of the entire file (MemoryStorage only)"
143
+ "properties": {
144
+ "fieldname": {
145
+ "type": "string",
146
+ "description": "Field name specified in the form"
147
+ },
148
+ "originalname": {
149
+ "type": "string",
150
+ "description": "Name of the file on the user's computer"
151
+ },
152
+ "encoding": {
153
+ "type": "string",
154
+ "description": "Encoding type of the file"
155
+ },
156
+ "mimetype": {
157
+ "type": "string",
158
+ "description": "MIME type of the file"
159
+ },
160
+ "size": {
161
+ "type": "number",
162
+ "description": "Size of the file in bytes"
163
+ },
164
+ "content": {
165
+ "type": "string",
166
+ "description": "Base64 encoded file content with data URI format"
167
+ }
168
+ },
169
+ "required": ["fieldname", "originalname", "encoding", "mimetype", "size", "content"]
170
170
  }
171
- },
172
- "required": ["fieldname", "originalname", "encoding", "mimetype", "size"]
173
- }
171
+ }
172
+ },
173
+ "required": ["body", "files"]
174
174
  }
175
175
  }
176
176
  }