SudoSOS Back-end API / helpers
Helpers ​
This is the module page of the ad.
Enumerations ​
| Enumeration | Description |
|---|---|
| OrderingDirection | - |
| ReturnFileType | File type a PDF-able document can be returned as: the compiled PDF, or the raw HTML that is sent to pdf-compiler (useful for previews and debugging). |
| UserReportType | Enum for the type of user report (sales or purchases). |
Classes ​
| Class | Description |
|---|---|
| QueryFilter | - |
| ValidationError | The ValidationError combines itself by simply concatenating the string values. |
Interfaces ​
| Interface | Description |
|---|---|
| FilterMapping | Defines the mapping from properties on the parameter object, to the respective identifiers in queries. |
| FilterParameters | Defines the filtering parameters to which can be mapped. |
| ImageValidationRequirements | - |
| IReportDocumentLines | - |
| Joinable | To allow for nested errors we need the notation of traversing through errors. The abstraction is that we have a 'Joinable' such that items can be combined. |
| LDAPGroup | - |
| LDAPResponse | - |
| LDAPResult | - |
| LDAPUser | - |
| PaginationParameters | - |
| PaginationResult | - |
| RawUser | - |
| RequestWithRawBody | Extend the Express Request object with a raw body attribute, which is used by Stripe to validate incoming events |
Type Aliases ​
| Type Alias | Description |
|---|---|
| Either | - |
| Fail | - |
| ImageType | - |
| Optional | - |
| Pass | - |
| Specification | - |
| SubSpecification | - |
| ValidationRule | - |
Variables ​
| Variable | Description |
|---|---|
| ALLOWED_IMAGE_FORMATS | - |
| IMAGE_FORMAT_EXTENSIONS | File extension used to store an image, keyed by the format sharp detects from the file contents. |
| IMAGE_REQUIREMENTS | - |
| PAGINATION_DEFAULT | - |
| PAGINATION_MAX | - |
| PDF_VAT_HIGH | - |
| PDF_VAT_LOW | - |
| PDF_VAT_ZERO | - |
| PERSISTENT_TEST_DATABASES | - |
Functions ​
| Function | Description |
|---|---|
| asArrayOfDates | Converts the input to a list of dates |
| asArrayOfNumbers | Converts the input to a list of numbers |
| asArrayOfUserTypes | Converts the input to a list of UserTypes |
| asBoolean | Converts the input to a boolean |
| asDate | Converts the input to a Date object. |
| asDinero | Converts the input to a Dinero object. |
| asEventType | Converts the input to an EventType |
| asFromAndTillDate | Converts the inputs to a from and till date |
| asInvoiceState | Converts the input to a InvoiceState |
| asNumber | Converts the input to a number. |
| asOrderingDirection | Convert the given input to an OrderingDirection object or undefined if correct. Throw error otherwise |
| asReturnFileType | Converts the input to a ReturnFileType. Defaults to PDF when no input is given. |
| asShiftAvailability | Converts the input to a shift availability |
| asUserType | Converts the input to a UserType |
| asVatDeclarationPeriod | Converts the input to an VatDeclarationPeriod |
| bindUser | Function that takes a valid ADUser response and binds it to a existing User such that the AD user can authenticate as the existing user. |
| collectByKey | Function that collects items based on a given getKey function |
| collectByToId | Function that collects transaction by user ToId |
| collectProductsByCategory | Function that collects transactions by product based on their category id |
| collectProductsByRevision | Function that collects transactions by products based on their revision |
| collectProductsByVat | Function that collects transactions by product based on their Vat group |
| createArrayRule | Turn a specification for an property into a specification for an array of that property. |
| dateToUTC | Change the timezone of the given date to UTC |
| defaultPagination | - |
| extractRawBody | Put the raw, unparsed body also in the request object |
| formatTitleDate | Format a date to YYYYMMDD string format for use in PDF filenames and titles |
| getIdsAndRequests | - |
| getLDAPConnection | Makes and bind an LDAP connection. |
| getLDAPSettings | Wrapper for the LDAP environment variables. |
| hashJSON | Returns the sha256 hash of an object. |
| isDate | Returns whether a given date string is actually a date |
| isFail | - |
| isNumber | Returns whether the given object is a number |
| isPass | - |
| maxPagination | - |
| parseContainerToBaseResponse | - |
| parseFileToResponse | - |
| parseInvoiceUserToResponse | - |
| parsePOSToBasePOS | - |
| parseProductToBaseResponse | - |
| parseRawUserToResponse | Parses a raw User Entity to a UserResponse |
| parseRequestPagination | Extract possible pagination parameters from the request and put them in the take and skip variables. If one of them (or all of them) is not defined, default values are set. |
| parseUserToBaseResponse | Parses a raw user DB object to BaseUserResponse |
| parseUserToResponse | Parses a User DB entity to a UserResponse |
| parseVatGroupToResponse | - |
| reduceMapToCategoryEntries | Transforms an array of SubTransactionRows with the same product category into TransactionReportCategoryEntries |
| reduceMapToReportEntries | Transforms an array of SubTransactionRows of a single product to TransactionReportEntries |
| reduceMapToVatEntries | Transforms an array of SubTransactionRows with the same VAT group into TransactionReportVatEntries |
| reportPDFhelper | - |
| reportToDocumentLines | Map a report's products and VAT groups onto the line items, VAT specification and totals of the shared HTML document (euros, not cents). |
| sendPdfOrHtml | Send a rendered document as an attachment with the content type and extension that match its file type. |
| splitTypes | - |
| toFail | - |
| toLocalMySQLString | Print the date to a string in MySQL format (YYYY-MM-DD mm:hh:ss), but keep it in the local timezone |
| toMySQLString | Print the date to a string in MySQL format (YYYY-MM-DD mm:hh:ss) |
| toPass | - |
| toResponse | Build a paginated response from a [records, count] tuple. Use this in controllers to wrap service results into the standard paginated response format. |
| toUTCMySQLString | Print the date to a string in MySQL format (YYYY-MM-DD mm:hh:ss), but convert it to UTC |
| transactionMapper | Applies a function to all SubTransactionRows of the given transactions. |
| userFromLDAP | Wrapper for typing the untyped ldap result. |
| userTokenInOrgan | Checks if the given ID is part of the Token Organ List. |
| utcToDate | UTC to date |
| validateImageUpload | Validate an uploaded image against the requirements of the given image type. |
| validateRequestPagination | Check whether the possible take and skip query parameters are valid |
| validateSpecification | Function that validates the given param against a specification. |