Email Sorter Beta

Ich habe soweit automatisiert the Emails sortieren aber ich muss noch schauen was es fur bugs es gibt wenn die app online  ist deswegen wurde ich mit diesen Commit die website veroffentlichen obwohjl es sein konnte  das es noch nicht fertig ist und verkaufs bereit
This commit is contained in:
2026-01-22 19:32:12 +01:00
parent 95349af50b
commit abf761db07
596 changed files with 56405 additions and 51231 deletions

View File

@@ -7,6 +7,9 @@ const OPTIONS_KEYS = [
'maxNetworkRetries',
'timeout',
'host',
'authenticator',
'stripeContext',
'additionalHeaders',
];
export function isOptionsHash(o) {
return (o &&
@@ -17,10 +20,11 @@ export function isOptionsHash(o) {
* Stringifies an Object, accommodating nested objects
* (forming the conventional key 'parent[child]=value')
*/
export function stringifyRequestData(data) {
export function queryStringifyRequestData(data, apiMode) {
return (qs
.stringify(data, {
serializeDate: (d) => Math.floor(d.getTime() / 1000).toString(),
arrayFormat: apiMode == 'v2' ? 'repeat' : 'indices',
})
// Don't use strict form encoding by changing the square bracket control
// characters back to their literals. This is fine by the server, and
@@ -87,7 +91,6 @@ export function getDataFromArgs(args) {
*/
export function getOptionsFromArgs(args) {
const opts = {
auth: null,
host: null,
headers: {},
settings: {},
@@ -95,7 +98,7 @@ export function getOptionsFromArgs(args) {
if (args.length > 0) {
const arg = args[args.length - 1];
if (typeof arg === 'string') {
opts.auth = args.pop();
opts.authenticator = createApiKeyAuthenticator(args.pop());
}
else if (isOptionsHash(arg)) {
const params = Object.assign({}, args.pop());
@@ -104,7 +107,7 @@ export function getOptionsFromArgs(args) {
emitWarning(`Invalid options found (${extraKeys.join(', ')}); ignoring.`);
}
if (params.apiKey) {
opts.auth = params.apiKey;
opts.authenticator = createApiKeyAuthenticator(params.apiKey);
}
if (params.idempotencyKey) {
opts.headers['Idempotency-Key'] = params.idempotencyKey;
@@ -112,6 +115,12 @@ export function getOptionsFromArgs(args) {
if (params.stripeAccount) {
opts.headers['Stripe-Account'] = params.stripeAccount;
}
if (params.stripeContext) {
if (opts.headers['Stripe-Account']) {
throw new Error("Can't specify both stripeAccount and stripeContext.");
}
opts.headers['Stripe-Context'] = params.stripeContext;
}
if (params.apiVersion) {
opts.headers['Stripe-Version'] = params.apiVersion;
}
@@ -124,6 +133,19 @@ export function getOptionsFromArgs(args) {
if (params.host) {
opts.host = params.host;
}
if (params.authenticator) {
if (params.apiKey) {
throw new Error("Can't specify both apiKey and authenticator.");
}
if (typeof params.authenticator !== 'function') {
throw new Error('The authenticator must be a function ' +
'receiving a request as the first parameter.');
}
opts.authenticator = params.authenticator;
}
if (params.additionalHeaders) {
opts.headers = params.additionalHeaders;
}
}
}
return opts;
@@ -229,9 +251,7 @@ export function isObject(obj) {
export function flattenAndStringify(data) {
const result = {};
const step = (obj, prevKey) => {
Object.keys(obj).forEach((key) => {
// @ts-ignore
const value = obj[key];
Object.entries(obj).forEach(([key, value]) => {
const newKey = prevKey ? `${prevKey}[${key}]` : key;
if (isObject(value)) {
if (!(value instanceof Uint8Array) &&
@@ -272,6 +292,15 @@ export function determineProcessUserAgentProperties() {
platform: process.platform,
};
}
export function createApiKeyAuthenticator(apiKey) {
const authenticator = (request) => {
request.headers.Authorization = 'Bearer ' + apiKey;
return Promise.resolve();
};
// For testing
authenticator._apiKey = apiKey;
return authenticator;
}
/**
* Joins an array of Uint8Arrays into a single Uint8Array
*/
@@ -285,3 +314,27 @@ export function concat(arrays) {
});
return merged;
}
/**
* Replaces Date objects with Unix timestamps
*/
function dateTimeReplacer(key, value) {
if (this[key] instanceof Date) {
return Math.floor(this[key].getTime() / 1000).toString();
}
return value;
}
/**
* JSON stringifies an Object, replacing Date objects with Unix timestamps
*/
export function jsonStringifyRequestData(data) {
return JSON.stringify(data, dateTimeReplacer);
}
/**
* Inspects the given path to determine if the endpoint is for v1 or v2 API
*/
export function getAPIMode(path) {
if (!path) {
return 'v1';
}
return path.startsWith('/v2') ? 'v2' : 'v1';
}