@digipair/skill-web-interact 0.13.4 → 0.13.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
@@ -42,6 +42,52 @@ Object.defineProperty(exports, '__esModule', { value: true });
42
42
  async reload(_params, _pinsSettingsList, _context) {
43
43
  window.location.reload();
44
44
  }
45
+ async upload(params, _pinsSettingsList, _context) {
46
+ const { accept = '*' } = params;
47
+ const result = await new Promise((resolve)=>{
48
+ const input = document.createElement('input');
49
+ input.type = 'file';
50
+ input.multiple = false;
51
+ input.accept = accept;
52
+ input.onchange = (event)=>{
53
+ const files = event.target.files;
54
+ const file = files[0];
55
+ const reader = new FileReader();
56
+ reader.readAsDataURL(file);
57
+ reader.onload = ()=>{
58
+ resolve({
59
+ value: reader.result,
60
+ filename: file.name
61
+ });
62
+ };
63
+ };
64
+ input.click();
65
+ });
66
+ return result;
67
+ }
68
+ async uploadText(params, _pinsSettingsList, _context) {
69
+ const { accept = 'text/plain' } = params;
70
+ const result = await new Promise((resolve)=>{
71
+ const input = document.createElement('input');
72
+ input.type = 'file';
73
+ input.multiple = false;
74
+ input.accept = accept;
75
+ input.onchange = (event)=>{
76
+ const files = event.target.files;
77
+ const file = files[0];
78
+ const reader = new FileReader();
79
+ reader.readAsText(file);
80
+ reader.onload = ()=>{
81
+ resolve({
82
+ value: reader.result,
83
+ filename: file.name
84
+ });
85
+ };
86
+ };
87
+ input.click();
88
+ });
89
+ return result;
90
+ }
45
91
  };
46
92
  const setAttribute = (params, pinsSettingsList, context)=>new DomService().setAttribute(params, pinsSettingsList, context);
47
93
  const getAttribute = (params, pinsSettingsList, context)=>new DomService().getAttribute(params, pinsSettingsList, context);
@@ -49,6 +95,8 @@ const dispatchEvent = (params, pinsSettingsList, context)=>new DomService().disp
49
95
  const execute = (params, pinsSettingsList, context)=>new DomService().execute(params, pinsSettingsList, context);
50
96
  const goTo = (params, pinsSettingsList, context)=>new DomService().goTo(params, pinsSettingsList, context);
51
97
  const reload = (params, pinsSettingsList, context)=>new DomService().reload(params, pinsSettingsList, context);
98
+ const upload = (params, pinsSettingsList, context)=>new DomService().upload(params, pinsSettingsList, context);
99
+ const uploadText = (params, pinsSettingsList, context)=>new DomService().uploadText(params, pinsSettingsList, context);
52
100
 
53
101
  exports.dispatchEvent = dispatchEvent;
54
102
  exports.execute = execute;
@@ -56,3 +104,5 @@ exports.getAttribute = getAttribute;
56
104
  exports.goTo = goTo;
57
105
  exports.reload = reload;
58
106
  exports.setAttribute = setAttribute;
107
+ exports.upload = upload;
108
+ exports.uploadText = uploadText;
package/index.esm.js CHANGED
@@ -38,6 +38,52 @@
38
38
  async reload(_params, _pinsSettingsList, _context) {
39
39
  window.location.reload();
40
40
  }
41
+ async upload(params, _pinsSettingsList, _context) {
42
+ const { accept = '*' } = params;
43
+ const result = await new Promise((resolve)=>{
44
+ const input = document.createElement('input');
45
+ input.type = 'file';
46
+ input.multiple = false;
47
+ input.accept = accept;
48
+ input.onchange = (event)=>{
49
+ const files = event.target.files;
50
+ const file = files[0];
51
+ const reader = new FileReader();
52
+ reader.readAsDataURL(file);
53
+ reader.onload = ()=>{
54
+ resolve({
55
+ value: reader.result,
56
+ filename: file.name
57
+ });
58
+ };
59
+ };
60
+ input.click();
61
+ });
62
+ return result;
63
+ }
64
+ async uploadText(params, _pinsSettingsList, _context) {
65
+ const { accept = 'text/plain' } = params;
66
+ const result = await new Promise((resolve)=>{
67
+ const input = document.createElement('input');
68
+ input.type = 'file';
69
+ input.multiple = false;
70
+ input.accept = accept;
71
+ input.onchange = (event)=>{
72
+ const files = event.target.files;
73
+ const file = files[0];
74
+ const reader = new FileReader();
75
+ reader.readAsText(file);
76
+ reader.onload = ()=>{
77
+ resolve({
78
+ value: reader.result,
79
+ filename: file.name
80
+ });
81
+ };
82
+ };
83
+ input.click();
84
+ });
85
+ return result;
86
+ }
41
87
  };
42
88
  const setAttribute = (params, pinsSettingsList, context)=>new DomService().setAttribute(params, pinsSettingsList, context);
43
89
  const getAttribute = (params, pinsSettingsList, context)=>new DomService().getAttribute(params, pinsSettingsList, context);
@@ -45,5 +91,7 @@ const dispatchEvent = (params, pinsSettingsList, context)=>new DomService().disp
45
91
  const execute = (params, pinsSettingsList, context)=>new DomService().execute(params, pinsSettingsList, context);
46
92
  const goTo = (params, pinsSettingsList, context)=>new DomService().goTo(params, pinsSettingsList, context);
47
93
  const reload = (params, pinsSettingsList, context)=>new DomService().reload(params, pinsSettingsList, context);
94
+ const upload = (params, pinsSettingsList, context)=>new DomService().upload(params, pinsSettingsList, context);
95
+ const uploadText = (params, pinsSettingsList, context)=>new DomService().uploadText(params, pinsSettingsList, context);
48
96
 
49
- export { dispatchEvent, execute, getAttribute, goTo, reload, setAttribute };
97
+ export { dispatchEvent, execute, getAttribute, goTo, reload, setAttribute, upload, uploadText };
@@ -5,3 +5,5 @@ export declare const dispatchEvent: (params: any, pinsSettingsList: PinsSettings
5
5
  export declare const execute: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
6
6
  export declare const goTo: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
7
7
  export declare const reload: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
8
+ export declare const upload: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
9
+ export declare const uploadText: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-web-interact",
3
- "version": "0.13.4",
3
+ "version": "0.13.5",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
package/schema.json CHANGED
@@ -186,6 +186,44 @@
186
186
  "parameters": [],
187
187
  "x-events": []
188
188
  }
189
+ },
190
+ "/upload": {
191
+ "post": {
192
+ "tags": ["web"],
193
+ "summary": "Uploader un fichier binaire",
194
+ "description": "Permet d'uploader un fichier binaire en base64",
195
+ "parameters": [
196
+ {
197
+ "name": "accept",
198
+ "summary": "Type de fichier",
199
+ "required": false,
200
+ "description": "Type de fichier accepté",
201
+ "schema": {
202
+ "type": "string"
203
+ }
204
+ }
205
+ ],
206
+ "x-events": []
207
+ }
208
+ },
209
+ "/uploadText": {
210
+ "post": {
211
+ "tags": ["web"],
212
+ "summary": "Uploader un fichier texte",
213
+ "description": "Permet d'uploader un fichier en texte",
214
+ "parameters": [
215
+ {
216
+ "name": "accept",
217
+ "summary": "Type de fichier",
218
+ "required": false,
219
+ "description": "Type de fichier accepté",
220
+ "schema": {
221
+ "type": "string"
222
+ }
223
+ }
224
+ ],
225
+ "x-events": []
226
+ }
189
227
  }
190
228
  },
191
229
  "components": {