Line endings fixed so that we don't have CRLF in Git. Better now than later.

This commit is contained in:
Tomas Bures 2019-03-27 09:49:29 +01:00
parent 2fe7f82be3
commit d482d214d9
69 changed files with 6405 additions and 6405 deletions

View file

@ -1,78 +1,78 @@
'use strict';
const CampaignSource = {
MIN: 1,
TEMPLATE: 1,
CUSTOM: 2,
CUSTOM_FROM_TEMPLATE: 3,
CUSTOM_FROM_CAMPAIGN: 4,
URL: 5,
MAX: 5
};
const CampaignType = {
MIN: 1,
REGULAR: 1,
RSS: 2,
RSS_ENTRY: 3,
TRIGGERED: 4,
MAX: 4
};
const CampaignStatus = {
MIN: 1,
// For campaign types: NORMAL, RSS_ENTRY
IDLE: 1,
SCHEDULED: 2,
FINISHED: 3,
PAUSED: 4,
// For campaign types: RSS, TRIGGERED
INACTIVE: 5,
ACTIVE: 6,
// For campaign types: NORMAL, RSS_ENTRY
SENDING: 7,
MAX: 8
};
const campaignOverridables = ['from_name', 'from_email', 'reply_to', 'subject'];
function getSendConfigurationPermissionRequiredForSend(campaign, sendConfiguration) {
let allowedOverride = false;
let disallowedOverride = false;
for (const overridable of campaignOverridables) {
if (campaign[overridable + '_override'] !== null) {
if (sendConfiguration[overridable + '_overridable']) {
allowedOverride = true;
} else {
disallowedOverride = true;
}
}
}
let requiredPermission = 'sendWithoutOverrides';
if (allowedOverride) {
requiredPermission = 'sendWithAllowedOverrides';
}
if (disallowedOverride) {
requiredPermission = 'sendWithAnyOverrides';
}
return requiredPermission;
}
module.exports = {
CampaignSource,
CampaignType,
CampaignStatus,
campaignOverridables,
getSendConfigurationPermissionRequiredForSend
'use strict';
const CampaignSource = {
MIN: 1,
TEMPLATE: 1,
CUSTOM: 2,
CUSTOM_FROM_TEMPLATE: 3,
CUSTOM_FROM_CAMPAIGN: 4,
URL: 5,
MAX: 5
};
const CampaignType = {
MIN: 1,
REGULAR: 1,
RSS: 2,
RSS_ENTRY: 3,
TRIGGERED: 4,
MAX: 4
};
const CampaignStatus = {
MIN: 1,
// For campaign types: NORMAL, RSS_ENTRY
IDLE: 1,
SCHEDULED: 2,
FINISHED: 3,
PAUSED: 4,
// For campaign types: RSS, TRIGGERED
INACTIVE: 5,
ACTIVE: 6,
// For campaign types: NORMAL, RSS_ENTRY
SENDING: 7,
MAX: 8
};
const campaignOverridables = ['from_name', 'from_email', 'reply_to', 'subject'];
function getSendConfigurationPermissionRequiredForSend(campaign, sendConfiguration) {
let allowedOverride = false;
let disallowedOverride = false;
for (const overridable of campaignOverridables) {
if (campaign[overridable + '_override'] !== null) {
if (sendConfiguration[overridable + '_overridable']) {
allowedOverride = true;
} else {
disallowedOverride = true;
}
}
}
let requiredPermission = 'sendWithoutOverrides';
if (allowedOverride) {
requiredPermission = 'sendWithAllowedOverrides';
}
if (disallowedOverride) {
requiredPermission = 'sendWithAnyOverrides';
}
return requiredPermission;
}
module.exports = {
CampaignSource,
CampaignType,
CampaignStatus,
campaignOverridables,
getSendConfigurationPermissionRequiredForSend
};

View file

@ -1,75 +1,75 @@
'use strict';
const moment = require('moment');
const birthdayYear = 2000;
const DateFormat = {
US: 'us',
EU: 'eur',
INTL: 'intl'
};
const dateFormatStrings = {
'us': 'MM/DD/YYYY',
'eur': 'DD/MM/YYYY',
'intl': 'YYYY-MM-DD'
};
const birthdayFormatStrings = {
'us': 'MM/DD',
'eur': 'DD/MM',
'intl': 'MM/DD'
};
function parseDate(format, text) {
const date = moment.utc(text, dateFormatStrings[format]);
if (date.isValid()) {
return date.toDate();
}
}
function parseBirthday(format, text) {
const fullDateStr = format === DateFormat.INTL ? birthdayYear + '-' + text : text + '-' + birthdayYear;
const date = moment.utc(fullDateStr, dateFormatStrings[format]);
if (date.isValid()) {
return date.toDate();
}
}
function formatDate(format, date) {
if (date === null) {
return '';
} else {
return moment.utc(date).format(dateFormatStrings[format]);
}
}
function formatBirthday(format, date) {
if (date === null) {
return '';
} else {
return moment.utc(date).format(birthdayFormatStrings[format]);
}
}
function getDateFormatString(format) {
return dateFormatStrings[format];
}
function getBirthdayFormatString(format) {
return birthdayFormatStrings[format];
}
module.exports = {
DateFormat,
birthdayYear,
parseDate,
parseBirthday,
formatDate,
formatBirthday,
getDateFormatString,
getBirthdayFormatString
'use strict';
const moment = require('moment');
const birthdayYear = 2000;
const DateFormat = {
US: 'us',
EU: 'eur',
INTL: 'intl'
};
const dateFormatStrings = {
'us': 'MM/DD/YYYY',
'eur': 'DD/MM/YYYY',
'intl': 'YYYY-MM-DD'
};
const birthdayFormatStrings = {
'us': 'MM/DD',
'eur': 'DD/MM',
'intl': 'MM/DD'
};
function parseDate(format, text) {
const date = moment.utc(text, dateFormatStrings[format]);
if (date.isValid()) {
return date.toDate();
}
}
function parseBirthday(format, text) {
const fullDateStr = format === DateFormat.INTL ? birthdayYear + '-' + text : text + '-' + birthdayYear;
const date = moment.utc(fullDateStr, dateFormatStrings[format]);
if (date.isValid()) {
return date.toDate();
}
}
function formatDate(format, date) {
if (date === null) {
return '';
} else {
return moment.utc(date).format(dateFormatStrings[format]);
}
}
function formatBirthday(format, date) {
if (date === null) {
return '';
} else {
return moment.utc(date).format(birthdayFormatStrings[format]);
}
}
function getDateFormatString(format) {
return dateFormatStrings[format];
}
function getBirthdayFormatString(format) {
return birthdayFormatStrings[format];
}
module.exports = {
DateFormat,
birthdayYear,
parseDate,
parseBirthday,
formatDate,
formatBirthday,
getDateFormatString,
getBirthdayFormatString
};

View file

@ -1,82 +1,82 @@
'use strict';
const ImportSource = {
MIN: 0,
CSV_FILE: 0,
LIST: 1,
MAX: 1
};
const MappingType = {
MIN: 0,
BASIC_SUBSCRIBE: 0,
BASIC_UNSUBSCRIBE: 1,
MAX: 1
};
const ImportStatus = {
PREP_SCHEDULED: 0,
PREP_RUNNING: 1,
PREP_STOPPING: 2,
PREP_FINISHED: 3,
PREP_FAILED: 4,
RUN_SCHEDULED: 5,
RUN_RUNNING: 6,
RUN_STOPPING: 7,
RUN_FINISHED: 8,
RUN_FAILED: 9
};
const RunStatus = {
SCHEDULED: 0,
RUNNING: 1,
STOPPING: 2,
FINISHED: 3,
FAILED: 4
};
function prepInProgress(status) {
return status === ImportStatus.PREP_SCHEDULED || status === ImportStatus.PREP_RUNNING || status === ImportStatus.PREP_STOPPING;
}
function runInProgress(status) {
return status === ImportStatus.RUN_SCHEDULED || status === ImportStatus.RUN_RUNNING || status === ImportStatus.RUN_STOPPING;
}
function inProgress(status) {
return status === ImportStatus.PREP_SCHEDULED || status === ImportStatus.PREP_RUNNING || status === ImportStatus.PREP_STOPPING ||
status === ImportStatus.RUN_SCHEDULED || status === ImportStatus.RUN_RUNNING || status === ImportStatus.RUN_STOPPING;
}
function prepFinished(status) {
return status === ImportStatus.PREP_FINISHED ||
status === ImportStatus.RUN_SCHEDULED || status === ImportStatus.RUN_RUNNING || status === ImportStatus.RUN_STOPPING ||
status === ImportStatus.RUN_FINISHED || status === ImportStatus.RUN_FAILED;
}
function prepFinishedAndNotInProgress(status) {
return status === ImportStatus.PREP_FINISHED ||
status === ImportStatus.RUN_FINISHED || status === ImportStatus.RUN_FAILED;
}
function runStatusInProgress(status) {
return status === RunStatus.SCHEDULED || status === RunStatus.RUNNING || status === RunStatus.STOPPING;
}
module.exports = {
ImportSource,
MappingType,
ImportStatus,
RunStatus,
prepInProgress,
runInProgress,
prepFinished,
prepFinishedAndNotInProgress,
inProgress,
runStatusInProgress
'use strict';
const ImportSource = {
MIN: 0,
CSV_FILE: 0,
LIST: 1,
MAX: 1
};
const MappingType = {
MIN: 0,
BASIC_SUBSCRIBE: 0,
BASIC_UNSUBSCRIBE: 1,
MAX: 1
};
const ImportStatus = {
PREP_SCHEDULED: 0,
PREP_RUNNING: 1,
PREP_STOPPING: 2,
PREP_FINISHED: 3,
PREP_FAILED: 4,
RUN_SCHEDULED: 5,
RUN_RUNNING: 6,
RUN_STOPPING: 7,
RUN_FINISHED: 8,
RUN_FAILED: 9
};
const RunStatus = {
SCHEDULED: 0,
RUNNING: 1,
STOPPING: 2,
FINISHED: 3,
FAILED: 4
};
function prepInProgress(status) {
return status === ImportStatus.PREP_SCHEDULED || status === ImportStatus.PREP_RUNNING || status === ImportStatus.PREP_STOPPING;
}
function runInProgress(status) {
return status === ImportStatus.RUN_SCHEDULED || status === ImportStatus.RUN_RUNNING || status === ImportStatus.RUN_STOPPING;
}
function inProgress(status) {
return status === ImportStatus.PREP_SCHEDULED || status === ImportStatus.PREP_RUNNING || status === ImportStatus.PREP_STOPPING ||
status === ImportStatus.RUN_SCHEDULED || status === ImportStatus.RUN_RUNNING || status === ImportStatus.RUN_STOPPING;
}
function prepFinished(status) {
return status === ImportStatus.PREP_FINISHED ||
status === ImportStatus.RUN_SCHEDULED || status === ImportStatus.RUN_RUNNING || status === ImportStatus.RUN_STOPPING ||
status === ImportStatus.RUN_FINISHED || status === ImportStatus.RUN_FAILED;
}
function prepFinishedAndNotInProgress(status) {
return status === ImportStatus.PREP_FINISHED ||
status === ImportStatus.RUN_FINISHED || status === ImportStatus.RUN_FAILED;
}
function runStatusInProgress(status) {
return status === RunStatus.SCHEDULED || status === RunStatus.RUNNING || status === RunStatus.STOPPING;
}
module.exports = {
ImportSource,
MappingType,
ImportStatus,
RunStatus,
prepInProgress,
runInProgress,
prepFinished,
prepFinishedAndNotInProgress,
inProgress,
runStatusInProgress
};

View file

@ -1,150 +1,150 @@
'use strict';
class InteroperableError extends Error {
constructor(type, msg, data) {
super(msg);
this.type = type;
this.data = data;
}
}
class NotLoggedInError extends InteroperableError {
constructor(msg, data) {
super('NotLoggedInError', msg, data);
}
}
class ChangedError extends InteroperableError {
constructor(msg, data) {
super('ChangedError', msg, data);
}
}
class NotFoundError extends InteroperableError {
constructor(msg, data) {
super('NotFoundError', msg || 'Not Found', data);
this.status = 404;
}
}
class LoopDetectedError extends InteroperableError {
constructor(msg, data) {
super('LoopDetectedError', msg, data);
}
}
class DuplicitNameError extends InteroperableError {
constructor(msg, data) {
super('DuplicitNameError', msg, data);
}
}
class DuplicitEmailError extends InteroperableError {
constructor(msg, data) {
super('DuplicitEmailError', msg, data);
}
}
class DuplicitKeyError extends InteroperableError {
constructor(msg, data) {
super('DuplicitKeyError', msg, data);
}
}
class IncorrectPasswordError extends InteroperableError {
constructor(msg, data) {
super('IncorrectPasswordError', msg, data);
}
}
class InvalidTokenError extends InteroperableError {
constructor(msg, data) {
super('InvalidTokenError', msg, data);
}
}
class DependencyNotFoundError extends InteroperableError {
constructor(msg, data) {
super('DependencyNotFoundError', msg, data);
}
}
class NamespaceNotFoundError extends InteroperableError {
constructor(msg, data) {
super('NamespaceNotFoundError', msg, data);
}
}
class PermissionDeniedError extends InteroperableError {
constructor(msg, data) {
super('PermissionDeniedError', msg || 'Permission Denied', data);
this.status = 403;
}
}
class InvalidConfirmationForSubscriptionError extends InteroperableError {
constructor(msg, data) {
super('InvalidConfirmationForSubscriptionError', msg, data);
}
}
class InvalidConfirmationForAddressChangeError extends InteroperableError {
constructor(msg, data) {
super('InvalidConfirmationForAddressChangeError', msg, data);
}
}
class InvalidConfirmationForUnsubscriptionError extends InteroperableError {
constructor(msg, data) {
super('InvalidConfirmationForUnsubscriptionError', msg, data);
}
}
class DependencyPresentError extends InteroperableError {
constructor(msg, data) {
super('DependencyPresentError', msg, data);
}
}
class InvalidStateError extends InteroperableError {
constructor(msg, data) {
super('InvalidStateError', msg, data);
}
}
const errorTypes = {
InteroperableError,
NotLoggedInError,
ChangedError,
NotFoundError,
LoopDetectedError,
DuplicitNameError,
DuplicitEmailError,
DuplicitKeyError,
IncorrectPasswordError,
InvalidTokenError,
DependencyNotFoundError,
NamespaceNotFoundError,
PermissionDeniedError,
InvalidConfirmationForSubscriptionError,
InvalidConfirmationForAddressChangeError,
InvalidConfirmationForUnsubscriptionError,
DependencyPresentError,
InvalidStateError
};
function deserialize(errorObj) {
if (errorObj.type) {
const ctor = errorTypes[errorObj.type];
if (ctor) {
return new ctor(errorObj.message, errorObj.data);
} else {
console.log('Warning unknown type of interoperable error: ' + errorObj.type);
}
}
}
module.exports = Object.assign({}, errorTypes, {
deserialize
'use strict';
class InteroperableError extends Error {
constructor(type, msg, data) {
super(msg);
this.type = type;
this.data = data;
}
}
class NotLoggedInError extends InteroperableError {
constructor(msg, data) {
super('NotLoggedInError', msg, data);
}
}
class ChangedError extends InteroperableError {
constructor(msg, data) {
super('ChangedError', msg, data);
}
}
class NotFoundError extends InteroperableError {
constructor(msg, data) {
super('NotFoundError', msg || 'Not Found', data);
this.status = 404;
}
}
class LoopDetectedError extends InteroperableError {
constructor(msg, data) {
super('LoopDetectedError', msg, data);
}
}
class DuplicitNameError extends InteroperableError {
constructor(msg, data) {
super('DuplicitNameError', msg, data);
}
}
class DuplicitEmailError extends InteroperableError {
constructor(msg, data) {
super('DuplicitEmailError', msg, data);
}
}
class DuplicitKeyError extends InteroperableError {
constructor(msg, data) {
super('DuplicitKeyError', msg, data);
}
}
class IncorrectPasswordError extends InteroperableError {
constructor(msg, data) {
super('IncorrectPasswordError', msg, data);
}
}
class InvalidTokenError extends InteroperableError {
constructor(msg, data) {
super('InvalidTokenError', msg, data);
}
}
class DependencyNotFoundError extends InteroperableError {
constructor(msg, data) {
super('DependencyNotFoundError', msg, data);
}
}
class NamespaceNotFoundError extends InteroperableError {
constructor(msg, data) {
super('NamespaceNotFoundError', msg, data);
}
}
class PermissionDeniedError extends InteroperableError {
constructor(msg, data) {
super('PermissionDeniedError', msg || 'Permission Denied', data);
this.status = 403;
}
}
class InvalidConfirmationForSubscriptionError extends InteroperableError {
constructor(msg, data) {
super('InvalidConfirmationForSubscriptionError', msg, data);
}
}
class InvalidConfirmationForAddressChangeError extends InteroperableError {
constructor(msg, data) {
super('InvalidConfirmationForAddressChangeError', msg, data);
}
}
class InvalidConfirmationForUnsubscriptionError extends InteroperableError {
constructor(msg, data) {
super('InvalidConfirmationForUnsubscriptionError', msg, data);
}
}
class DependencyPresentError extends InteroperableError {
constructor(msg, data) {
super('DependencyPresentError', msg, data);
}
}
class InvalidStateError extends InteroperableError {
constructor(msg, data) {
super('InvalidStateError', msg, data);
}
}
const errorTypes = {
InteroperableError,
NotLoggedInError,
ChangedError,
NotFoundError,
LoopDetectedError,
DuplicitNameError,
DuplicitEmailError,
DuplicitKeyError,
IncorrectPasswordError,
InvalidTokenError,
DependencyNotFoundError,
NamespaceNotFoundError,
PermissionDeniedError,
InvalidConfirmationForSubscriptionError,
InvalidConfirmationForAddressChangeError,
InvalidConfirmationForUnsubscriptionError,
DependencyPresentError,
InvalidStateError
};
function deserialize(errorObj) {
if (errorObj.type) {
const ctor = errorTypes[errorObj.type];
if (ctor) {
return new ctor(errorObj.message, errorObj.data);
} else {
console.log('Warning unknown type of interoperable error: ' + errorObj.type);
}
}
}
module.exports = Object.assign({}, errorTypes, {
deserialize
});

View file

@ -1,66 +1,66 @@
'use strict';
function convertToFake(dict) {
function convertValueToFakeLang(str) {
let from = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+\\|`~[{]};:'\",<.>/?";
let to = "ɐqɔpǝɟƃɥıɾʞʅɯuodbɹsʇnʌʍxʎz∀ԐↃᗡƎℲ⅁HIſӼ⅂WNOԀÒᴚS⊥∩ɅX⅄Z0123456789¡@#$%ᵥ⅋⁎()-_=+\\|,~[{]};:,„´<.>/¿";
return str.replace(/(\{\{[^\}]+\}\}|%s)/g, '\x00\x04$1\x00').split('\x00').map(c => {
if (c.charAt(0) === '\x04') {
return c;
}
let r = '';
for (let i = 0, len = c.length; i < len; i++) {
let pos = from.indexOf(c.charAt(i));
if (pos < 0) {
r += c.charAt(i);
} else {
r += to.charAt(pos);
}
}
return r;
}).join('\x00').replace(/[\x00\x04]/g, '');
}
function _convertToFake(dict, fakeDict) {
for (const key in dict) {
const val = dict[key];
if (typeof val === 'string') {
fakeDict[key] = convertValueToFakeLang(val);
} else {
fakeDict[key] = _convertToFake(val, {});
}
}
return fakeDict;
}
return _convertToFake(dict, {});
}
// The langugage labels below are intentionally not localized so that they are always native in the langugae of their speaker (regardless of the currently selected language)
const langCodes = {
'en-US': {
getShortLabel: t => 'EN',
getLabel: t => 'English',
longCode: 'en-US'
},
'es-ES': {
getShortLabel: t => 'ES',
getLabel: t => 'Español',
longCode: 'es-ES'
},
'fk-FK': {
getShortLabel: t => 'FK',
getLabel: t => 'Fake',
longCode: 'fk-FK'
}
}
function getLang(lng) {
return langCodes[lng];
}
module.exports.convertToFake = convertToFake;
'use strict';
function convertToFake(dict) {
function convertValueToFakeLang(str) {
let from = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+\\|`~[{]};:'\",<.>/?";
let to = "ɐqɔpǝɟƃɥıɾʞʅɯuodbɹsʇnʌʍxʎz∀ԐↃᗡƎℲ⅁HIſӼ⅂WNOԀÒᴚS⊥∩ɅX⅄Z0123456789¡@#$%ᵥ⅋⁎()-_=+\\|,~[{]};:,„´<.>/¿";
return str.replace(/(\{\{[^\}]+\}\}|%s)/g, '\x00\x04$1\x00').split('\x00').map(c => {
if (c.charAt(0) === '\x04') {
return c;
}
let r = '';
for (let i = 0, len = c.length; i < len; i++) {
let pos = from.indexOf(c.charAt(i));
if (pos < 0) {
r += c.charAt(i);
} else {
r += to.charAt(pos);
}
}
return r;
}).join('\x00').replace(/[\x00\x04]/g, '');
}
function _convertToFake(dict, fakeDict) {
for (const key in dict) {
const val = dict[key];
if (typeof val === 'string') {
fakeDict[key] = convertValueToFakeLang(val);
} else {
fakeDict[key] = _convertToFake(val, {});
}
}
return fakeDict;
}
return _convertToFake(dict, {});
}
// The langugage labels below are intentionally not localized so that they are always native in the langugae of their speaker (regardless of the currently selected language)
const langCodes = {
'en-US': {
getShortLabel: t => 'EN',
getLabel: t => 'English',
longCode: 'en-US'
},
'es-ES': {
getShortLabel: t => 'ES',
getLabel: t => 'Español',
longCode: 'es-ES'
},
'fk-FK': {
getShortLabel: t => 'FK',
getLabel: t => 'Fake',
longCode: 'fk-FK'
}
}
function getLang(lng) {
return langCodes[lng];
}
module.exports.convertToFake = convertToFake;
module.exports.getLang = getLang;

View file

@ -1,51 +1,51 @@
'use strict';
const UnsubscriptionMode = {
MIN: 0,
ONE_STEP: 0,
ONE_STEP_WITH_FORM: 1,
TWO_STEP: 2,
TWO_STEP_WITH_FORM: 3,
MANUAL: 4,
MAX: 4
};
const SubscriptionStatus = {
MIN: 0,
SUBSCRIBED: 1,
UNSUBSCRIBED: 2,
BOUNCED: 3,
COMPLAINED: 4,
MAX: 4
};
const SubscriptionSource = {
ADMIN_FORM: -1,
SUBSCRIPTION_FORM: -2,
API: -3,
NOT_IMPORTED_V1: -4,
IMPORTED_V1: -5,
ERASED: -6
};
const FieldWizard = {
NONE: 'none',
NAME: 'full_name',
FIRST_LAST_NAME: 'first_last_name'
}
function getFieldColumn(field) {
return field.column || 'grouped_' + field.id;
}
module.exports = {
UnsubscriptionMode,
SubscriptionStatus,
SubscriptionSource,
FieldWizard,
getFieldColumn
'use strict';
const UnsubscriptionMode = {
MIN: 0,
ONE_STEP: 0,
ONE_STEP_WITH_FORM: 1,
TWO_STEP: 2,
TWO_STEP_WITH_FORM: 3,
MANUAL: 4,
MAX: 4
};
const SubscriptionStatus = {
MIN: 0,
SUBSCRIBED: 1,
UNSUBSCRIBED: 2,
BOUNCED: 3,
COMPLAINED: 4,
MAX: 4
};
const SubscriptionSource = {
ADMIN_FORM: -1,
SUBSCRIPTION_FORM: -2,
API: -3,
NOT_IMPORTED_V1: -4,
IMPORTED_V1: -5,
ERASED: -6
};
const FieldWizard = {
NONE: 'none',
NAME: 'full_name',
FIRST_LAST_NAME: 'first_last_name'
}
function getFieldColumn(field) {
return field.column || 'grouped_' + field.id;
}
module.exports = {
UnsubscriptionMode,
SubscriptionStatus,
SubscriptionSource,
FieldWizard,
getFieldColumn
};

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,9 @@
'use strict';
function getGlobalNamespaceId() {
return 1;
}
module.exports = {
getGlobalNamespaceId
'use strict';
function getGlobalNamespaceId() {
return 1;
}
module.exports = {
getGlobalNamespaceId
};

View file

@ -1,37 +1,37 @@
'use strict';
const util = require('util');
const owaspPasswordStrengthTest = require('owasp-password-strength-test');
function passwordValidator(t) {
const config = {
allowPassphrases: true,
maxLength: 128,
minLength: 10,
minPhraseLength: 20,
minOptionalTestsToPass: 4
};
if (t) {
config.translate = {
minLength: function (minLength) {
return t('thePasswordMustBeAtLeastMinLength', { minLength });
},
maxLength: function (maxLength) {
return t('thePasswordMustBeFewerThanMaxLength', { maxLength });
},
repeat: t('thePasswordMayNotContainSequencesOfThree'),
lowercase: t('thePasswordMustContainAtLeastOne'),
uppercase: t('thePasswordMustContainAtLeastOne-1'),
number: t('thePasswordMustContainAtLeastOneNumber'),
special: t('thePasswordMustContainAtLeastOneSpecial')
}
}
const passwordValidator = owaspPasswordStrengthTest.create();
passwordValidator.config(config);
return passwordValidator;
}
'use strict';
const util = require('util');
const owaspPasswordStrengthTest = require('owasp-password-strength-test');
function passwordValidator(t) {
const config = {
allowPassphrases: true,
maxLength: 128,
minLength: 10,
minPhraseLength: 20,
minOptionalTestsToPass: 4
};
if (t) {
config.translate = {
minLength: function (minLength) {
return t('thePasswordMustBeAtLeastMinLength', { minLength });
},
maxLength: function (maxLength) {
return t('thePasswordMustBeFewerThanMaxLength', { maxLength });
},
repeat: t('thePasswordMayNotContainSequencesOfThree'),
lowercase: t('thePasswordMustContainAtLeastOne'),
uppercase: t('thePasswordMustContainAtLeastOne-1'),
number: t('thePasswordMustContainAtLeastOneNumber'),
special: t('thePasswordMustContainAtLeastOneSpecial')
}
}
const passwordValidator = owaspPasswordStrengthTest.create();
passwordValidator.config(config);
return passwordValidator;
}
module.exports = passwordValidator;

View file

@ -1,16 +1,16 @@
'use strict';
const ReportState = {
MIN: 0,
SCHEDULED: 0,
PROCESSING: 1,
FINISHED: 2,
FAILED: 3,
MAX: 3
};
module.exports = {
ReportState
'use strict';
const ReportState = {
MIN: 0,
SCHEDULED: 0,
PROCESSING: 1,
FINISHED: 2,
FAILED: 3,
MAX: 3
};
module.exports = {
ReportState
};

View file

@ -1,29 +1,29 @@
'use strict';
const MailerType = {
GENERIC_SMTP: 'generic_smtp',
ZONE_MTA: 'zone_mta',
AWS_SES: 'aws_ses'
};
const ZoneMTAType = {
REGULAR: 0,
WITH_HTTP_CONF: 1,
WITH_MAILTRAIN_HEADER_CONF: 2,
BUILTIN: 3
}
function getSystemSendConfigurationId() {
return 1;
}
function getSystemSendConfigurationCid() {
return 'system';
}
module.exports = {
MailerType,
ZoneMTAType,
getSystemSendConfigurationId,
getSystemSendConfigurationCid
'use strict';
const MailerType = {
GENERIC_SMTP: 'generic_smtp',
ZONE_MTA: 'zone_mta',
AWS_SES: 'aws_ses'
};
const ZoneMTAType = {
REGULAR: 0,
WITH_HTTP_CONF: 1,
WITH_MAILTRAIN_HEADER_CONF: 2,
BUILTIN: 3
}
function getSystemSendConfigurationId() {
return 1;
}
function getSystemSendConfigurationCid() {
return 'system';
}
module.exports = {
MailerType,
ZoneMTAType,
getSystemSendConfigurationId,
getSystemSendConfigurationCid
};

View file

@ -1,62 +1,62 @@
'use strict';
function _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
if (trustedBaseUrl.endsWith('/')) {
trustedBaseUrl = trustedBaseUrl.substring(0, trustedBaseUrl.length - 1);
}
if (sandboxBaseUrl.endsWith('/')) {
sandboxBaseUrl = sandboxBaseUrl.substring(0, sandboxBaseUrl.length - 1);
}
if (publicBaseUrl.endsWith('/')) {
publicBaseUrl = publicBaseUrl.substring(0, publicBaseUrl.length - 1);
}
return {trustedBaseUrl, sandboxBaseUrl, publicBaseUrl};
}
function getMergeTagsForBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
return {
URL_BASE: bases.publicBaseUrl,
TRUSTED_URL_BASE: bases.trustedBaseUrl,
SANDBOX_URL_BASE: bases.sandboxBaseUrl,
ENCODED_URL_BASE: encodeURIComponent(bases.publicBaseUrl),
ENCODED_TRUSTED_URL_BASE: encodeURIComponent(bases.trustedBaseUrl),
ENCODED_SANDBOX_URL_BASE: encodeURIComponent(bases.sandboxBaseUrl)
};
}
function base(text, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
text = text.split('[URL_BASE]').join(bases.publicBaseUrl);
text = text.split('[TRUSTED_URL_BASE]').join(bases.trustedBaseUrl);
text = text.split('[SANDBOX_URL_BASE]').join(bases.sandboxBaseUrl);
text = text.split('[ENCODED_URL_BASE]').join(encodeURIComponent(bases.publicBaseUrl));
text = text.split('[ENCODED_TRUSTED_URL_BASE]').join(encodeURIComponent(bases.trustedBaseUrl));
text = text.split('[ENCODED_SANDBOX_URL_BASE]').join(encodeURIComponent(bases.sandboxBaseUrl));
return text;
}
function unbase(text, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl, treatAllAsPublic = false) {
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
text = text.split(bases.publicBaseUrl).join('[URL_BASE]');
text = text.split(bases.trustedBaseUrl).join(treatAllAsPublic ? '[URL_BASE]' : '[TRUSTED_URL_BASE]');
text = text.split(bases.sandboxBaseUrl).join(treatAllAsPublic ? '[URL_BASE]' : '[SANDBOX_URL_BASE]');
text = text.split(encodeURIComponent(bases.publicBaseUrl)).join('[ENCODED_URL_BASE]');
text = text.split(encodeURIComponent(bases.trustedBaseUrl)).join(treatAllAsPublic ? '[ENCODED_URL_BASE]' : '[ENCODED_TRUSTED_URL_BASE]');
text = text.split(encodeURIComponent(bases.sandboxBaseUrl)).join(treatAllAsPublic ? '[ENCODED_URL_BASE]' : '[ENCODED_SANDBOX_URL_BASE]');
return text;
}
module.exports = {
base,
unbase,
getMergeTagsForBases
'use strict';
function _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
if (trustedBaseUrl.endsWith('/')) {
trustedBaseUrl = trustedBaseUrl.substring(0, trustedBaseUrl.length - 1);
}
if (sandboxBaseUrl.endsWith('/')) {
sandboxBaseUrl = sandboxBaseUrl.substring(0, sandboxBaseUrl.length - 1);
}
if (publicBaseUrl.endsWith('/')) {
publicBaseUrl = publicBaseUrl.substring(0, publicBaseUrl.length - 1);
}
return {trustedBaseUrl, sandboxBaseUrl, publicBaseUrl};
}
function getMergeTagsForBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
return {
URL_BASE: bases.publicBaseUrl,
TRUSTED_URL_BASE: bases.trustedBaseUrl,
SANDBOX_URL_BASE: bases.sandboxBaseUrl,
ENCODED_URL_BASE: encodeURIComponent(bases.publicBaseUrl),
ENCODED_TRUSTED_URL_BASE: encodeURIComponent(bases.trustedBaseUrl),
ENCODED_SANDBOX_URL_BASE: encodeURIComponent(bases.sandboxBaseUrl)
};
}
function base(text, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl) {
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
text = text.split('[URL_BASE]').join(bases.publicBaseUrl);
text = text.split('[TRUSTED_URL_BASE]').join(bases.trustedBaseUrl);
text = text.split('[SANDBOX_URL_BASE]').join(bases.sandboxBaseUrl);
text = text.split('[ENCODED_URL_BASE]').join(encodeURIComponent(bases.publicBaseUrl));
text = text.split('[ENCODED_TRUSTED_URL_BASE]').join(encodeURIComponent(bases.trustedBaseUrl));
text = text.split('[ENCODED_SANDBOX_URL_BASE]').join(encodeURIComponent(bases.sandboxBaseUrl));
return text;
}
function unbase(text, trustedBaseUrl, sandboxBaseUrl, publicBaseUrl, treatAllAsPublic = false) {
const bases = _getBases(trustedBaseUrl, sandboxBaseUrl, publicBaseUrl);
text = text.split(bases.publicBaseUrl).join('[URL_BASE]');
text = text.split(bases.trustedBaseUrl).join(treatAllAsPublic ? '[URL_BASE]' : '[TRUSTED_URL_BASE]');
text = text.split(bases.sandboxBaseUrl).join(treatAllAsPublic ? '[URL_BASE]' : '[SANDBOX_URL_BASE]');
text = text.split(encodeURIComponent(bases.publicBaseUrl)).join('[ENCODED_URL_BASE]');
text = text.split(encodeURIComponent(bases.trustedBaseUrl)).join(treatAllAsPublic ? '[ENCODED_URL_BASE]' : '[ENCODED_TRUSTED_URL_BASE]');
text = text.split(encodeURIComponent(bases.sandboxBaseUrl)).join(treatAllAsPublic ? '[ENCODED_URL_BASE]' : '[ENCODED_SANDBOX_URL_BASE]');
return text;
}
module.exports = {
base,
unbase,
getMergeTagsForBases
};

View file

@ -1,48 +1,48 @@
'use strict';
const Entity = {
SUBSCRIPTION: 'subscription',
CAMPAIGN: 'campaign'
};
const Event = {
[Entity.SUBSCRIPTION]: {
CREATED: 'created',
LATEST_OPEN: 'latest_open',
LATEST_CLICK: 'latest_click'
},
[Entity.CAMPAIGN]: {
DELIVERED: 'delivered',
OPENED: 'opened',
CLICKED: 'clicked',
NOT_OPENED: 'not_opened',
NOT_CLICKED: 'not_clicked'
}
};
const EntityVals = {
subscription: 'SUBSCRIPTION',
campaign: 'CAMPAIGN'
};
const EventVals = {
[Entity.SUBSCRIPTION]: {
created: 'CREATED',
latest_open: 'LATEST_OPEN',
latest_click: 'LATEST_CLICK'
},
[Entity.CAMPAIGN]: {
delivered: 'DELIVERED',
opened: 'OPENED',
clicked: 'CLICKED',
not_opened: 'NOT_OPENED',
not_clicked: 'NOT_CLICKED'
}
};
module.exports = {
Entity,
Event,
EntityVals,
EventVals
'use strict';
const Entity = {
SUBSCRIPTION: 'subscription',
CAMPAIGN: 'campaign'
};
const Event = {
[Entity.SUBSCRIPTION]: {
CREATED: 'created',
LATEST_OPEN: 'latest_open',
LATEST_CLICK: 'latest_click'
},
[Entity.CAMPAIGN]: {
DELIVERED: 'delivered',
OPENED: 'opened',
CLICKED: 'clicked',
NOT_OPENED: 'not_opened',
NOT_CLICKED: 'not_clicked'
}
};
const EntityVals = {
subscription: 'SUBSCRIPTION',
campaign: 'CAMPAIGN'
};
const EventVals = {
[Entity.SUBSCRIPTION]: {
created: 'CREATED',
latest_open: 'LATEST_OPEN',
latest_click: 'LATEST_CLICK'
},
[Entity.CAMPAIGN]: {
delivered: 'DELIVERED',
opened: 'OPENED',
clicked: 'CLICKED',
not_opened: 'NOT_OPENED',
not_clicked: 'NOT_CLICKED'
}
};
module.exports = {
Entity,
Event,
EntityVals,
EventVals
};

View file

@ -1,7 +1,7 @@
'use strict';
const anonymousRestrictedAccessToken = 'anonymous';
module.exports = {
anonymousRestrictedAccessToken
'use strict';
const anonymousRestrictedAccessToken = 'anonymous';
module.exports = {
anonymousRestrictedAccessToken
};

View file

@ -1,9 +1,9 @@
'use strict';
function getAdminId() {
return 1;
}
module.exports = {
getAdminId
'use strict';
function getAdminId() {
return 1;
}
module.exports = {
getAdminId
};

View file

@ -1,9 +1,9 @@
'use strict';
function mergeTagValid(mergeTag) {
return /^[A-Z][A-Z0-9_]*$/.test(mergeTag);
}
module.exports = {
mergeTagValid
'use strict';
function mergeTagValid(mergeTag) {
return /^[A-Z][A-Z0-9_]*$/.test(mergeTag);
}
module.exports = {
mergeTagValid
};