@pittica/drive-folder-qrcode 1.2.3 → 1.2.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/dist/drive/folder.js +39 -23
- package/dist/generator/generate.js +10 -4
- package/package.json +1 -1
package/dist/drive/folder.js
CHANGED
@@ -90,6 +90,7 @@ var list = exports.list = /*#__PURE__*/function () {
|
|
90
90
|
/**
|
91
91
|
* Creates a file in the given Drive folder.
|
92
92
|
*
|
93
|
+
* @param {GoogleAuth} client Google Auth client instance.
|
93
94
|
* @param {string} folder Folder ID.
|
94
95
|
* @param {string} content File content.
|
95
96
|
* @param {string} name File name.
|
@@ -98,12 +99,12 @@ var list = exports.list = /*#__PURE__*/function () {
|
|
98
99
|
* @returns {File} The created file.
|
99
100
|
*/
|
100
101
|
var createFile = exports.createFile = /*#__PURE__*/function () {
|
101
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(folder, content, name, mimeType
|
102
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, folder, content, name, mimeType) {
|
102
103
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
103
104
|
while (1) switch (_context2.prev = _context2.next) {
|
104
105
|
case 0:
|
105
106
|
_context2.next = 2;
|
106
|
-
return
|
107
|
+
return client.files.create({
|
107
108
|
requestBody: {
|
108
109
|
name: name,
|
109
110
|
parents: [folder]
|
@@ -112,9 +113,20 @@ var createFile = exports.createFile = /*#__PURE__*/function () {
|
|
112
113
|
mimeType: mimeType,
|
113
114
|
body: content
|
114
115
|
},
|
115
|
-
fields: "id",
|
116
|
+
fields: ["id", "name"],
|
116
117
|
uploadType: "multipart",
|
117
118
|
supportsAllDrives: true
|
119
|
+
}).then(function (_ref3) {
|
120
|
+
var data = _ref3.data,
|
121
|
+
status = _ref3.status;
|
122
|
+
if (status >= 200 && status < 300) {
|
123
|
+
console.info("QR code for \"".concat(folder, "\", \"").concat(data.id, "\", created."));
|
124
|
+
} else {
|
125
|
+
console.error("Errore creating QR code for \"".concat(folder, "\"."));
|
126
|
+
}
|
127
|
+
return data;
|
128
|
+
})["catch"](function () {
|
129
|
+
return console.error("Errore creating QR code for \"".concat(folder, "\"."));
|
118
130
|
});
|
119
131
|
case 2:
|
120
132
|
return _context2.abrupt("return", _context2.sent);
|
@@ -140,59 +152,63 @@ var createFile = exports.createFile = /*#__PURE__*/function () {
|
|
140
152
|
* @returns {File} The created file.
|
141
153
|
*/
|
142
154
|
var uploadFile = exports.uploadFile = /*#__PURE__*/function () {
|
143
|
-
var
|
155
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(folder, content, name, mimeType, credentials) {
|
144
156
|
var client;
|
145
157
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
146
158
|
while (1) switch (_context5.prev = _context5.next) {
|
147
159
|
case 0:
|
148
|
-
|
149
|
-
|
150
|
-
|
160
|
+
_context5.next = 2;
|
161
|
+
return (0, _client["default"])(credentials);
|
162
|
+
case 2:
|
163
|
+
client = _context5.sent;
|
164
|
+
_context5.next = 5;
|
165
|
+
return client.files.list({
|
151
166
|
q: "'".concat(folder, "' in parents AND mimeType = '").concat(mimeType, "' AND name = '").concat(name, "' AND trashed = false"),
|
152
167
|
pageSize: 1,
|
153
|
-
fields: "
|
168
|
+
fields: "files(id, name, trashed, webViewLink)",
|
154
169
|
spaces: "drive",
|
155
170
|
includeItemsFromAllDrives: true,
|
156
171
|
supportsAllDrives: true
|
157
172
|
}).then(/*#__PURE__*/function () {
|
158
|
-
var
|
173
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
|
159
174
|
var files;
|
160
175
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
161
176
|
while (1) switch (_context3.prev = _context3.next) {
|
162
177
|
case 0:
|
163
|
-
files =
|
178
|
+
files = _ref5.data.files;
|
164
179
|
if (!(files.length > 0)) {
|
165
|
-
_context3.next =
|
180
|
+
_context3.next = 8;
|
166
181
|
break;
|
167
182
|
}
|
168
|
-
|
183
|
+
console.info("QR code for \"".concat(folder, "\", \"").concat(files[0].name, "\", already exists."), files[0].webViewLink);
|
184
|
+
_context3.next = 5;
|
169
185
|
return client.files.get({
|
170
186
|
fileId: files[0].id,
|
171
187
|
alt: "media",
|
172
188
|
supportsAllDrives: true
|
173
189
|
});
|
174
|
-
case
|
175
|
-
return _context3.abrupt("return", _context3.sent);
|
176
|
-
case 7:
|
177
|
-
_context3.next = 9;
|
178
|
-
return createFile(folder, content, name, mimeType, credentials);
|
179
|
-
case 9:
|
190
|
+
case 5:
|
180
191
|
return _context3.abrupt("return", _context3.sent);
|
192
|
+
case 8:
|
193
|
+
_context3.next = 10;
|
194
|
+
return createFile(client, folder, content, name, mimeType);
|
181
195
|
case 10:
|
196
|
+
return _context3.abrupt("return", _context3.sent);
|
197
|
+
case 11:
|
182
198
|
case "end":
|
183
199
|
return _context3.stop();
|
184
200
|
}
|
185
201
|
}, _callee3);
|
186
202
|
}));
|
187
203
|
return function (_x12) {
|
188
|
-
return
|
204
|
+
return _ref6.apply(this, arguments);
|
189
205
|
};
|
190
206
|
}())["catch"](/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
191
207
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
192
208
|
while (1) switch (_context4.prev = _context4.next) {
|
193
209
|
case 0:
|
194
210
|
_context4.next = 2;
|
195
|
-
return createFile(folder, content, name, mimeType
|
211
|
+
return createFile(client, folder, content, name, mimeType);
|
196
212
|
case 2:
|
197
213
|
return _context4.abrupt("return", _context4.sent);
|
198
214
|
case 3:
|
@@ -201,15 +217,15 @@ var uploadFile = exports.uploadFile = /*#__PURE__*/function () {
|
|
201
217
|
}
|
202
218
|
}, _callee4);
|
203
219
|
})));
|
204
|
-
case
|
220
|
+
case 5:
|
205
221
|
return _context5.abrupt("return", _context5.sent);
|
206
|
-
case
|
222
|
+
case 6:
|
207
223
|
case "end":
|
208
224
|
return _context5.stop();
|
209
225
|
}
|
210
226
|
}, _callee5);
|
211
227
|
}));
|
212
228
|
return function uploadFile(_x7, _x8, _x9, _x10, _x11) {
|
213
|
-
return
|
229
|
+
return _ref4.apply(this, arguments);
|
214
230
|
};
|
215
231
|
}();
|
@@ -44,10 +44,16 @@ var _default = exports["default"] = /*#__PURE__*/function () {
|
|
44
44
|
folders = _context.sent;
|
45
45
|
console.info("Processing \"".concat(drive, "\"..."));
|
46
46
|
return _context.abrupt("return", folders.map(function (folder) {
|
47
|
-
|
48
|
-
folder:
|
49
|
-
|
50
|
-
|
47
|
+
try {
|
48
|
+
var qr = (0, _image["default"])(folder, size, margin, logo, data ? (0, _logo.resize)(data, size) : null, colors, font);
|
49
|
+
console.info("Creating QR code for \"".concat(folder.name, "\"."));
|
50
|
+
return {
|
51
|
+
folder: folder,
|
52
|
+
qr: qr
|
53
|
+
};
|
54
|
+
} catch (_unused) {
|
55
|
+
console.error("Error creating QR code for \"".concat(folder.name, "\"."));
|
56
|
+
}
|
51
57
|
}));
|
52
58
|
case 9:
|
53
59
|
case "end":
|