@runnerpro/backend 1.11.3 → 1.11.6
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.
|
@@ -151,13 +151,12 @@ const isDateString = (value) => {
|
|
|
151
151
|
];
|
|
152
152
|
return datePatterns.some((pattern) => pattern.test(value));
|
|
153
153
|
};
|
|
154
|
-
// Función para convertir fecha a
|
|
155
|
-
const
|
|
154
|
+
// Función para convertir string de fecha a objeto Date de JavaScript
|
|
155
|
+
const convertToJSDate = (dateString) => {
|
|
156
156
|
if (!isDateString(dateString))
|
|
157
|
-
return
|
|
157
|
+
return null;
|
|
158
158
|
try {
|
|
159
159
|
let day, month, year;
|
|
160
|
-
// Detectar si es formato DD/MM/YYYY o YYYY/MM/DD
|
|
161
160
|
const parts = dateString.split('/');
|
|
162
161
|
if (parts[0].length === 4) {
|
|
163
162
|
// Formato YYYY/MM/DD
|
|
@@ -171,38 +170,43 @@ const formatDateForGoogleSheets = (dateString) => {
|
|
|
171
170
|
month = parseInt(parts[1]);
|
|
172
171
|
year = parseInt(parts[2]);
|
|
173
172
|
}
|
|
174
|
-
//
|
|
173
|
+
// Crear objeto Date (mes - 1 porque Date usa 0-11 para meses)
|
|
175
174
|
const date = new Date(year, month - 1, day);
|
|
175
|
+
// Validar que sea una fecha válida
|
|
176
176
|
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
|
|
177
|
-
return
|
|
177
|
+
return null;
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
return `${month.toString().padStart(2, '0')}/${day.toString().padStart(2, '0')}/${year}`;
|
|
179
|
+
return date;
|
|
181
180
|
}
|
|
182
181
|
catch (error) {
|
|
183
|
-
return
|
|
182
|
+
return null;
|
|
184
183
|
}
|
|
185
184
|
};
|
|
186
|
-
// Función para procesar array de valores y formatear fechas
|
|
187
|
-
const processValuesForGoogleSheets = (values) => {
|
|
188
|
-
return values.map((value) => {
|
|
189
|
-
// if (typeof value === 'string' && isDateString(value)) {
|
|
190
|
-
// return formatDateForGoogleSheets(value);
|
|
191
|
-
// }
|
|
192
|
-
return value;
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
185
|
const appendSheet = ({ sheetInstance, sheetName, sheetPage, cellValues, cellPositionAppend }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
186
|
try {
|
|
197
187
|
if (!sheetInstance)
|
|
198
188
|
sheetInstance = yield getSheetInstance();
|
|
199
|
-
// Procesar los valores para
|
|
200
|
-
const processedValues =
|
|
189
|
+
// Procesar los valores: mantener fechas como están y usar USER_ENTERED solo para fechas
|
|
190
|
+
const processedValues = cellValues.map((value) => {
|
|
191
|
+
if (typeof value === 'string' && isDateString(value)) {
|
|
192
|
+
// Para fechas, convertir a formato que Google Sheets reconozca mejor
|
|
193
|
+
const jsDate = convertToJSDate(value);
|
|
194
|
+
if (jsDate) {
|
|
195
|
+
// Formatear como YYYY-MM-DD que Google Sheets reconoce mejor
|
|
196
|
+
const year = jsDate.getFullYear();
|
|
197
|
+
const month = (jsDate.getMonth() + 1).toString().padStart(2, '0');
|
|
198
|
+
const day = jsDate.getDate().toString().padStart(2, '0');
|
|
199
|
+
return `${year}-${month}-${day}`;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return value;
|
|
203
|
+
});
|
|
204
|
+
// Insertar los datos procesados
|
|
201
205
|
yield sheetInstance.spreadsheets.values.append({
|
|
202
206
|
auth: googleAuth,
|
|
203
207
|
spreadsheetId: googleSheeIds[sheetName],
|
|
204
208
|
range: `${sheetPage}!${cellPositionAppend}`,
|
|
205
|
-
valueInputOption: '
|
|
209
|
+
valueInputOption: 'USER_ENTERED',
|
|
206
210
|
insertDataOption: 'INSERT_ROWS',
|
|
207
211
|
resource: {
|
|
208
212
|
values: [processedValues],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/googleSheet/index.ts"],"names":[],"mappings":"AA6BA,iBAAe,SAAS,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE;;;;;;CAAA,gBAgBnG;AAED,QAAA,MAAM,eAAe;;;;;;;;;0BAiCpB,CAAC;AAGF,iBAAS,SAAS,CAAC,MAAM,KAAA,UAaxB;AAED,iBAAS,iBAAiB,CAAC,MAAM,KAAA,UAOhC;AAED,QAAA,MAAM,UAAU;;;;;;mBAkBf,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/googleSheet/index.ts"],"names":[],"mappings":"AA6BA,iBAAe,SAAS,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE;;;;;;CAAA,gBAgBnG;AAED,QAAA,MAAM,eAAe;;;;;;;;;0BAiCpB,CAAC;AAGF,iBAAS,SAAS,CAAC,MAAM,KAAA,UAaxB;AAED,iBAAS,iBAAiB,CAAC,MAAM,KAAA,UAOhC;AAED,QAAA,MAAM,UAAU;;;;;;mBAkBf,CAAC;AAkDF,QAAA,MAAM,WAAW;;;;;;mBAoChB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC"}
|