UNPKG

@getanthill/datastore

Version:

Event-Sourced Datastore

177 lines 6.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.COMPONENTS = exports.COMPONENT_EVENT_REQUIRED_FIELDS = exports.COMPONENT_STATE_PROPERTIES = exports.COMPONENT_EVENT_PROPERTIES = exports.COMPONENT_EVENT_VERSION = exports.COMPONENT_EVENT_TYPE_VERSION = exports.COMPONENT_EVENT_TYPE = exports.COMPONENT_LOCATION = exports.COMPONENT_JSON_PATCH = exports.COMPONENT_URL = exports.COMPONENT_TIMEZONE = exports.COMPONENT_LOCALE = exports.COMPONENT_UUID_V4 = exports.COMPONENT_CORRELATION_ID = exports.COMPONENT_EMAIL = exports.COMPONENT_PHONE_NUMBER = exports.COMPONENT_DATE = exports.COMPONENT_NUMBER = exports.COMPONENT_INTEGER = exports.COMPONENT_BOOLEAN = exports.COMPONENT_TAGS_SNAKECASE = exports.COMPONENT_TAG_SNAKECASE = exports.COMPONENT_STRING = void 0; exports.COMPONENT_STRING = { type: 'string', description: 'A valid string', }; exports.COMPONENT_TAG_SNAKECASE = { type: 'string', description: 'Tag describe as `snake_case`', pattern: '^[0-9a-z_]+$', }; exports.COMPONENT_TAGS_SNAKECASE = { type: 'array', items: exports.COMPONENT_TAG_SNAKECASE, }; exports.COMPONENT_BOOLEAN = { type: 'boolean', description: 'Boolean indicating the enabling state of the entity', }; exports.COMPONENT_INTEGER = { type: 'integer', description: 'Integer value', }; exports.COMPONENT_NUMBER = { type: 'number', description: 'number value', }; exports.COMPONENT_DATE = { type: 'string', description: 'ISO 8601 date format', example: '2019-01-01T00:00:00.000Z', format: 'date-time', }; exports.COMPONENT_PHONE_NUMBER = { type: 'string', description: 'Phone number', example: '+33623344556', minLength: 2, maxLength: 50, pattern: '^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$', }; exports.COMPONENT_EMAIL = { type: 'string', description: 'Email address', example: 'john@doe.org', format: 'email', }; exports.COMPONENT_CORRELATION_ID = { type: 'string', description: 'Unique ID used as a correlation ID', example: '5fa962406a651140b5f9f4bf', }; exports.COMPONENT_UUID_V4 = { type: 'string', description: 'UUID V4', example: '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d', pattern: '^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$', }; exports.COMPONENT_LOCALE = { type: 'string', description: 'ISO 639-1 language identifier and optionaly a ISO 3166-1 alpha-2 region identifier', example: 'en', pattern: '[a-z]{2}(-[A-Z]{2})?', }; exports.COMPONENT_TIMEZONE = { type: 'string', description: 'Time zone name as defined in the tz database', example: 'Europe/Paris', }; exports.COMPONENT_URL = { type: 'string', description: 'Valid URL', example: 'https://example.com', pattern: 'https?://(www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}([-a-zA-Z0-9()@:%_+.~#?&//=]*)', }; exports.COMPONENT_JSON_PATCH = { type: 'array', items: { type: 'object', required: ['op', 'path'], properties: { op: { type: 'string', enum: ['add', 'remove', 'replace', 'copy', 'move'], description: 'JSON PATCH Operation', }, path: { type: 'string', description: 'JSON PATCH Operation path', }, }, }, }; /** * JSON Resume location schema in snake_case * @see https://jsonresume.org/schema/ */ exports.COMPONENT_LOCATION = { type: 'object', additionalProperties: false, properties: { address: { type: 'string', description: 'To add multiple address lines, use \n. For example, 1234 Glücklichkeit Straße\nHinterhaus 5. Etage li.', }, postal_code: { type: 'string', }, city: { type: 'string', }, country_code: { type: 'string', description: 'code as per ISO-3166-1 ALPHA-2, e.g. US, AU, IN', }, region: { type: 'string', description: 'The general region where you live. Can be a US state, or a province, for instance.', }, }, }; exports.COMPONENT_EVENT_TYPE = { type: 'string', description: 'Event unique type', example: 'CREATED', }; exports.COMPONENT_EVENT_TYPE_VERSION = { type: 'string', description: 'Event version following underscored semver', example: '1_0_0', // pattern: // '^(0|[1-9]\\d*)_(0|[1-9]\\d*)_(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:_(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:_[0-9a-zA-Z-]+)*))?$', }; exports.COMPONENT_EVENT_VERSION = { type: 'integer', description: 'Event history version', example: 0, minimum: 0, }; exports.COMPONENT_EVENT_PROPERTIES = { type: exports.COMPONENT_EVENT_TYPE, v: exports.COMPONENT_EVENT_TYPE_VERSION, version: exports.COMPONENT_EVENT_VERSION, created_at: exports.COMPONENT_DATE, }; exports.COMPONENT_STATE_PROPERTIES = { type: exports.COMPONENT_EVENT_TYPE, version: exports.COMPONENT_EVENT_VERSION, created_at: exports.COMPONENT_DATE, updated_at: exports.COMPONENT_DATE, }; exports.COMPONENT_EVENT_REQUIRED_FIELDS = ['type', 'v']; exports.COMPONENTS = { type: exports.COMPONENT_EVENT_TYPE, v: exports.COMPONENT_EVENT_TYPE_VERSION, version: exports.COMPONENT_EVENT_VERSION, created_at: exports.COMPONENT_DATE, updated_at: exports.COMPONENT_DATE, is_enabled: { ...exports.COMPONENT_BOOLEAN, description: 'Boolean indicating the enabling state of the entity', }, is_readonly: { ...exports.COMPONENT_BOOLEAN, description: 'Boolean indicating that the entity can not be updated anymore', }, is_archived: { ...exports.COMPONENT_BOOLEAN, description: 'Boolean indicating that the entity has been archived', }, is_deleted: { ...exports.COMPONENT_BOOLEAN, description: 'Boolean indicating that the entity has been deleted', }, }; //# sourceMappingURL=components.js.map