This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module NodeJS { | |
interface Global { | |
// TODO Использовать Symbol? | |
appConfig: { | |
/** | |
* Продукты которые необходимо добавить в заказ | |
*/ | |
appedingProducts: Array<{ | |
/** Ссылка на товар в API */ | |
ref: `entity/${string}/${string}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
S3Client, | |
PutObjectCommand, | |
GetObjectCommand, | |
HeadObjectCommand | |
} from '@aws-sdk/client-s3' | |
import { getSignedUrl } from '@aws-sdk/s3-request-presigner' | |
import path from 'node:path' | |
import mime from 'mime-types' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import assert from "node:assert"; | |
import { readFileSync } from "node:fs"; | |
let inputText; | |
try { | |
inputText = readFileSync(process.stdin.fd, "utf-8"); | |
} catch (err) { | |
assert.ok(err instanceof Error); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import farmhash from "farmhash"; | |
/** | |
* Returns a farmhash | |
* | |
* @param {string} content | |
*/ | |
export function getFarmhash(content) { | |
return farmhash.hash64(stable); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import assert from 'node:assert' | |
const YA_DATE_REGEX = /(\d\d)-(\d\d)-(\d\d\d\d)(?:\s(\d\d):(\d\d):(\d\d))?/g | |
/** | |
* Разбор даты в формате `ДД-ММ-ГГГГ ЧЧ:ММ:СС` | |
* @param {string} date | |
*/ | |
export const parseYaMarketDate = date => { | |
YA_DATE_REGEX.lastIndex = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parse } from 'csv-parse/sync' | |
import { fetch } from 'undici' | |
/** | |
* Возвращает Map для сопоставления | |
* | |
* @param {string} matchTableCsvUrl | |
* @param {string} fieldFrom | |
* @param {string} fieldTo | |
* @returns {Promise<Map<string, string>>} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks if the value is neither `null` or `undefined`. | |
* @template T | |
* @param {T} value The value to check. | |
* @returns { value is NonNullable<T> } Returns `true` if `value` is non-nullable, else `false`. | |
*/ | |
export default function isNonNullable(value) { | |
return value != null | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ImapFlow } from 'imapflow' | |
import { simpleParser } from 'mailparser' | |
import { writeFile } from 'node:fs/promises' | |
import path from 'node:path' | |
import { env } from './env.js' | |
const { EMAIL_HOST, EMAIL_PORT, EMAIL_USER, EMAIL_PASSWORD } = env | |
const client = new ImapFlow({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getLocationHashMap = () => { | |
const hash = window.location.hash.substring( | |
window.location.hash.substring(0, 2) === "#!" ? 2 : 1 | |
); | |
const hashMap = hash | |
.split("&") | |
.map((entry) => { | |
const eqIndex = entry.indexOf("="); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { request } from "undici"; | |
import nodePath from "node:path"; | |
const OZON_API_ENDPOINT = "api-seller.ozon.ru"; | |
export class Ozon { | |
/** @type {OzonOptions} */ | |
#options; | |
/** |