@nu-art/ts-common 0.200.141 → 0.201.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { Module } from './module';
2
2
  import { Dispatcher } from './dispatcher';
3
- import { CustomException } from './exceptions';
3
+ import { CustomException } from './exceptions/exceptions';
4
4
  export declare enum ServerErrorSeverity {
5
5
  Debug = "Debug",
6
6
  Info = "Info",
@@ -18,6 +18,6 @@ export interface OnApplicationNotification {
18
18
  }
19
19
  export declare const dispatch_onApplicationNotification: Dispatcher<OnApplicationNotification, "__processApplicationNotification", [errorLevel: ServerErrorSeverity, module: Module<any, any>, message: ErrorMessage], void>;
20
20
  export interface OnApplicationException {
21
- __processApplicationException(e: CustomException, module: Module, data: any): Promise<void>;
21
+ __processApplicationException(e: CustomException, module: Module): Promise<void>;
22
22
  }
23
- export declare const dispatch_onApplicationException: Dispatcher<OnApplicationException, "__processApplicationException", [e: CustomException, module: Module<any, any>, data: any], void>;
23
+ export declare const dispatch_onApplicationException: Dispatcher<OnApplicationException, "__processApplicationException", [e: CustomException, module: Module<any, any>], void>;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Created by TacB0sS on 3/16/17.
3
3
  */
4
- import { Constructor, UniqueId } from '../utils/types';
4
+ import { ErrorBody, ErrorResponse } from './types';
5
+ import { Constructor, TS_Object, UniqueId } from '../../utils/types';
5
6
  /**
6
7
  * # <ins>isErrorOfType</ins>
7
8
  *
@@ -132,4 +133,10 @@ export declare class WhoCallthisException extends CustomException {
132
133
  export declare class AssertionException extends CustomException {
133
134
  constructor(message: string, cause?: Error);
134
135
  }
136
+ export declare class ApiException<E extends TS_Object | void = void> extends CustomException {
137
+ readonly responseBody: ErrorResponse<E>;
138
+ readonly responseCode: number;
139
+ readonly setErrorBody: (errorBody: ErrorBody<E>) => this;
140
+ constructor(responseCode: number, debugMessage?: string, cause?: Error);
141
+ }
135
142
  export declare function isCustomException(e: Error): boolean;
@@ -20,7 +20,7 @@
20
20
  * Created by TacB0sS on 3/16/17.
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.isCustomException = exports.AssertionException = exports.WhoCallthisException = exports.DontCallthisException = exports.HasDependenciesException = exports.ThisShouldNotHappenException = exports.NotImplementedYetException = exports.MUSTNeverHappenException = exports.ImplementationMissingException = exports.BadImplementationException = exports.Exception = exports.CustomException = exports.isErrorOfType = void 0;
23
+ exports.isCustomException = exports.ApiException = exports.AssertionException = exports.WhoCallthisException = exports.DontCallthisException = exports.HasDependenciesException = exports.ThisShouldNotHappenException = exports.NotImplementedYetException = exports.MUSTNeverHappenException = exports.ImplementationMissingException = exports.BadImplementationException = exports.Exception = exports.CustomException = exports.isErrorOfType = void 0;
24
24
  /**
25
25
  * # <ins>isErrorOfType</ins>
26
26
  *
@@ -192,6 +192,19 @@ class AssertionException extends CustomException {
192
192
  }
193
193
  }
194
194
  exports.AssertionException = AssertionException;
195
+ class ApiException extends CustomException {
196
+ constructor(responseCode, debugMessage, cause) {
197
+ super(ApiException, `${responseCode}-${JSON.stringify(debugMessage)}`, cause);
198
+ this.responseBody = {};
199
+ this.setErrorBody = (errorBody) => {
200
+ this.responseBody.error = errorBody;
201
+ return this;
202
+ };
203
+ this.responseCode = responseCode;
204
+ this.responseBody.debugMessage = debugMessage;
205
+ }
206
+ }
207
+ exports.ApiException = ApiException;
195
208
  const allExceptions = [
196
209
  Exception,
197
210
  BadImplementationException,
@@ -0,0 +1,9 @@
1
+ import { TS_Object } from '../../utils/types';
2
+ export type ErrorBody<E extends TS_Object | void = void> = {
3
+ type: string;
4
+ body: E;
5
+ };
6
+ export type ErrorResponse<E extends TS_Object | void = void> = {
7
+ debugMessage?: string;
8
+ error?: ErrorBody<E>;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -19,7 +19,7 @@
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.ModuleManager = exports.moduleResolver = void 0;
21
21
  const dispatcher_1 = require("./dispatcher");
22
- const exceptions_1 = require("./exceptions");
22
+ const exceptions_1 = require("./exceptions/exceptions");
23
23
  const Logger_1 = require("./logger/Logger");
24
24
  const array_tools_1 = require("../utils/array-tools");
25
25
  const _modules = [];
package/core/module.js CHANGED
@@ -18,7 +18,7 @@
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.Module = void 0;
21
- const exceptions_1 = require("./exceptions");
21
+ const exceptions_1 = require("./exceptions/exceptions");
22
22
  const merge_tools_1 = require("../utils/merge-tools");
23
23
  const Logger_1 = require("./logger/Logger");
24
24
  const date_time_tools_1 = require("../utils/date-time-tools");
package/db/consts.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const Const_UniqueKey = "_id";
2
+ export declare const DefaultDBVersion = "1.0.0";
package/db/consts.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultDBVersion = exports.Const_UniqueKey = void 0;
4
+ exports.Const_UniqueKey = '_id';
5
+ exports.DefaultDBVersion = '1.0.0';
package/db/types.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { DB_Object, OmitDBObject } from '../utils/types';
2
+ import { ValidatorTypeResolver } from '../validator/validator-core';
3
+ export type DBIndex<T extends DB_Object> = {
4
+ id: string;
5
+ keys: keyof T | (keyof T)[];
6
+ params?: {
7
+ multiEntry: boolean;
8
+ unique: boolean;
9
+ };
10
+ };
11
+ export type Default_UniqueKey = '_id';
12
+ /**
13
+ * @field version - First item in the array is current version, Must pass all past versions with the current, default version is 1.0.0
14
+ */
15
+ export type DBDef<T extends DB_Object, Ks extends keyof T = Default_UniqueKey> = {
16
+ validator: ValidatorTypeResolver<OmitDBObject<T>>;
17
+ dbName: string;
18
+ entityName: string;
19
+ lockKeys?: (keyof T)[];
20
+ uniqueKeys?: Ks[];
21
+ /**
22
+ * First item in the array is the latest version. Last item in the array is the oldest version.
23
+ */
24
+ versions?: string[];
25
+ generatedProps?: (keyof T)[];
26
+ indices?: DBIndex<T>[];
27
+ metadata?: Metadata<OmitDBObject<T>>;
28
+ TTL?: number;
29
+ lastUpdatedTTL?: number;
30
+ };
31
+ type TypeOf<ValueType> = ValueType extends any[] ? 'array' : ValueType extends object ? 'object' : ValueType extends string ? 'string' : ValueType extends number ? 'number' : ValueType extends boolean ? 'boolean' : never;
32
+ export type MetadataProperty<ValueType> = {
33
+ valueType: TypeOf<ValueType>;
34
+ optional: boolean;
35
+ description: string;
36
+ };
37
+ export type MetadataObject<T extends any> = {
38
+ [K in keyof T]-?: MetadataNested<T[K]>;
39
+ };
40
+ export type MetadataNested<T extends any> = T extends (infer I)[] ? MetadataProperty<T> & {
41
+ metadata: Metadata<I>;
42
+ } : T extends object ? MetadataProperty<T> & {
43
+ metadata: MetadataObject<T>;
44
+ } : MetadataProperty<T>;
45
+ export type Metadata<T extends any> = T extends (infer I)[] ? MetadataProperty<T> & {
46
+ metadata: Metadata<I>;
47
+ } : T extends object ? MetadataObject<T> : MetadataProperty<T>;
48
+ export declare const DB_Object_Metadata: Metadata<DB_Object>;
49
+ export {};
package/db/types.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DB_Object_Metadata = void 0;
4
+ exports.DB_Object_Metadata = {
5
+ _id: { optional: false, valueType: 'string', description: 'unique key' },
6
+ _v: { optional: false, valueType: 'string', description: 'version' },
7
+ _originDocId: { optional: true, valueType: 'string', description: 'previous doc id' },
8
+ __hardDelete: { optional: true, valueType: 'boolean', description: 'is hard delete' },
9
+ __created: { optional: false, valueType: 'number', description: 'timestamp of creation' },
10
+ __updated: { optional: false, valueType: 'number', description: 'timestamp of last time modified' }
11
+ };
12
+ //@ts-ignore
13
+ const pah = {
14
+ a: { optional: false, description: 'aaa', valueType: 'string' },
15
+ b: { optional: true, description: 'aaa', valueType: 'number' },
16
+ c: {
17
+ optional: true,
18
+ description: 'harti barti',
19
+ valueType: 'array',
20
+ metadata: { optional: false, description: 'aaa', valueType: 'string' }
21
+ },
22
+ d: {
23
+ optional: true,
24
+ description: 'harti barti',
25
+ valueType: 'object',
26
+ metadata: {
27
+ k: { optional: false, description: 'aaa', valueType: 'string' },
28
+ l: { optional: false, description: 'aaa', valueType: 'number' }
29
+ }
30
+ },
31
+ e: {
32
+ optional: true,
33
+ description: 'harti barti',
34
+ valueType: 'object',
35
+ metadata: { ashpa: { optional: false, description: 'aaa', valueType: 'string' } }
36
+ }
37
+ };
38
+ // console.log(pah);
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './core/module';
2
2
  export * from './core/module-manager';
3
3
  export * from './core/application';
4
- export * from './core/exceptions';
4
+ export * from './core/exceptions/exceptions';
5
5
  export * from './core/dispatcher';
6
6
  export * from './core/error-handling';
7
7
  export * from './core/debug-flags';
@@ -15,6 +15,8 @@ export * from './core/logger/BeLogged';
15
15
  export * from './core/logger/Logger';
16
16
  export * from './core/logger/types';
17
17
  export * from './core/logger/LogClient';
18
+ export * from './db/consts';
19
+ export * from './db/types';
18
20
  export * from './tools/Replacer';
19
21
  export * from './tools/get-log-style';
20
22
  export * from './utils/queue';
package/index.js CHANGED
@@ -34,7 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
34
  __exportStar(require("./core/module"), exports);
35
35
  __exportStar(require("./core/module-manager"), exports);
36
36
  __exportStar(require("./core/application"), exports);
37
- __exportStar(require("./core/exceptions"), exports);
37
+ __exportStar(require("./core/exceptions/exceptions"), exports);
38
38
  __exportStar(require("./core/dispatcher"), exports);
39
39
  __exportStar(require("./core/error-handling"), exports);
40
40
  __exportStar(require("./core/debug-flags"), exports);
@@ -48,6 +48,8 @@ __exportStar(require("./core/logger/BeLogged"), exports);
48
48
  __exportStar(require("./core/logger/Logger"), exports);
49
49
  __exportStar(require("./core/logger/types"), exports);
50
50
  __exportStar(require("./core/logger/LogClient"), exports);
51
+ __exportStar(require("./db/consts"), exports);
52
+ __exportStar(require("./db/types"), exports);
51
53
  __exportStar(require("./tools/Replacer"), exports);
52
54
  __exportStar(require("./tools/get-log-style"), exports);
53
55
  __exportStar(require("./utils/queue"), exports);
@@ -0,0 +1,17 @@
1
+ export declare class MemStorage {
2
+ private readonly cache;
3
+ constructor();
4
+ init<R>(makeItContext: () => Promise<R>): Promise<R>;
5
+ private set;
6
+ private get;
7
+ }
8
+ export declare class MemKey<T> {
9
+ readonly key: string;
10
+ readonly unique: boolean;
11
+ private resolver?;
12
+ constructor(key: string, unique?: boolean);
13
+ setResolver: (resolver?: ((storage: MemStorage) => T) | undefined) => this;
14
+ resolve: (storage: MemStorage) => Promise<void>;
15
+ get: (value?: T) => T;
16
+ set: (value: T) => T;
17
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MemKey = exports.MemStorage = void 0;
13
+ const tools_1 = require("../utils/tools");
14
+ const exceptions_1 = require("../core/exceptions/exceptions");
15
+ const async_hooks_1 = require("async_hooks");
16
+ const random_tools_1 = require("../utils/random-tools");
17
+ const asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
18
+ class MemStorage {
19
+ constructor() {
20
+ // console.log(`---- ${this.cache.__myId} created`);
21
+ this.cache = { __myId: (0, random_tools_1.generateHex)(4) };
22
+ this.set = (key, value) => {
23
+ // console.log(`-- ${this.cache.__myId} set: ${key.key} -> `, value);
24
+ const currentValue = this.cache[key.key];
25
+ if ((0, tools_1.exists)(currentValue) && key.unique) {
26
+ throw new exceptions_1.BadImplementationException(`Unique storage key is being overridden for key: ${key.key}
27
+ \ncurrent: ${(0, tools_1.__stringify)(currentValue)}
28
+ \nnew: ${(0, tools_1.__stringify)(value)}`);
29
+ }
30
+ return this.cache[key.key] = value;
31
+ };
32
+ this.get = (key, defaultValue) => {
33
+ let currentValue = this.cache[key.key];
34
+ if (!(0, tools_1.exists)(currentValue))
35
+ currentValue = defaultValue;
36
+ return currentValue;
37
+ };
38
+ }
39
+ init(makeItContext) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ return asyncLocalStorage.run(this, makeItContext);
42
+ });
43
+ }
44
+ }
45
+ exports.MemStorage = MemStorage;
46
+ class MemKey {
47
+ constructor(key, unique = false) {
48
+ this.setResolver = (resolver) => {
49
+ this.resolver = resolver;
50
+ return this;
51
+ };
52
+ this.resolve = (storage) => __awaiter(this, void 0, void 0, function* () {
53
+ var _a;
54
+ const value = (_a = this.resolver) === null || _a === void 0 ? void 0 : _a.call(this, storage);
55
+ if (!(0, tools_1.exists)(value))
56
+ return;
57
+ this.set(value);
58
+ });
59
+ this.get = (value) => {
60
+ // @ts-ignore
61
+ return asyncLocalStorage.getStore().get(this, value);
62
+ };
63
+ this.set = (value) => {
64
+ // @ts-ignore
65
+ return asyncLocalStorage.getStore().set(this, value);
66
+ };
67
+ this.key = key;
68
+ this.unique = unique;
69
+ }
70
+ }
71
+ exports.MemKey = MemKey;
@@ -27,6 +27,7 @@ declare class CSVModule_Class extends Module<Config> {
27
27
  constructor();
28
28
  protected init(): void;
29
29
  static createExporter(options: Options): ExportToCsv;
30
+ updateExporterSettings(options: Options): void;
30
31
  export<T>(items: T[], returnCsv?: boolean): any;
31
32
  saveToFile<T extends TS_Object>(outputFile: string, items: T[], columnsToProps?: WritePropsMap<T>): Promise<void>;
32
33
  readCsvFromFile<T extends Partial<StringMap>>(inputFile: string, readOptions?: ReadOptions): Promise<T[]>;
@@ -59,6 +59,9 @@ class CSVModule_Class extends module_1.Module {
59
59
  static createExporter(options) {
60
60
  return new export_to_csv_1.ExportToCsv(options);
61
61
  }
62
+ updateExporterSettings(options) {
63
+ this.csvExporter = CSVModule_Class.createExporter(options);
64
+ }
62
65
  export(items, returnCsv = true) {
63
66
  return this.csvExporter.generateCsv(items, returnCsv);
64
67
  }
@@ -19,7 +19,7 @@
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.CliParamsModule = void 0;
21
21
  const module_1 = require("../core/module");
22
- const exceptions_1 = require("../core/exceptions");
22
+ const exceptions_1 = require("../core/exceptions/exceptions");
23
23
  const array_tools_1 = require("../utils/array-tools");
24
24
  class CliParamsModule_Class extends module_1.Module {
25
25
  constructor() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-common",
3
- "version": "0.200.141",
3
+ "version": "0.201.1",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -40,8 +40,7 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/minimatch": "^5.1.2",
43
- "@types/node-forge": "^1.0.0",
44
- "@types/qs": "latest"
43
+ "@types/node-forge": "^1.0.0"
45
44
  },
46
45
  "_moduleAliases": {
47
46
  "@main": "dist/main/ts",
@@ -27,7 +27,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.DateTimeFormat = exports.normalizeTimestamp = exports.parseTimeString = exports.formatTimestamp = exports.createReadableTimestampObject = exports.currentTimeMillisWithTimeZone = exports.currentLocalTimeMillis = exports.specificTimeTodayMillis = exports.currentTimeMillis = exports.auditBy = exports._clearInterval = exports._setInterval = exports._clearTimeout = exports._setTimeout = exports.sleep = exports.timeout = exports.Weekdays = exports.Format_YYYYMMDD_HHmmss = exports.Format_HHmmss_DDMMYYYY = exports.Week = exports.Day = exports.Hour = exports.Minute = exports.Second = void 0;
30
- const moment = require("moment");
30
+ const moment_1 = require("moment");
31
31
  exports.Second = 1000;
32
32
  exports.Minute = exports.Second * 60;
33
33
  exports.Hour = exports.Minute * 60;
@@ -113,13 +113,13 @@ exports.createReadableTimestampObject = createReadableTimestampObject;
113
113
  */
114
114
  function formatTimestamp(pattern = exports.Format_HHmmss_DDMMYYYY, timestamp = currentTimeMillis(), timezone = Intl.DateTimeFormat()
115
115
  .resolvedOptions().timeZone) {
116
- const m = moment.utc(timestamp);
116
+ const m = (0, moment_1.utc)(timestamp);
117
117
  m.utcOffset(-new Date().getTimezoneOffset());
118
118
  return m.format(pattern);
119
119
  }
120
120
  exports.formatTimestamp = formatTimestamp;
121
121
  function parseTimeString(timestamp, pattern = exports.Format_HHmmss_DDMMYYYY) {
122
- return moment.utc(timestamp, pattern).valueOf();
122
+ return (0, moment_1.utc)(timestamp, pattern).valueOf();
123
123
  }
124
124
  exports.parseTimeString = parseTimeString;
125
125
  function normalizeTimestamp(timestamp, pattern) {
@@ -20,7 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.merge = exports.mergeArray = exports.mergeObject = void 0;
21
21
  const object_tools_1 = require("./object-tools");
22
22
  const tools_1 = require("./tools");
23
- const exceptions_1 = require("../core/exceptions");
23
+ const exceptions_1 = require("../core/exceptions/exceptions");
24
24
  function mergeObject(original, override) {
25
25
  if (original === override) {
26
26
  return override;
@@ -18,7 +18,7 @@
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.filterKeys = exports.assert = exports.compare = exports.partialCompare = exports.cloneObj = exports.cloneArr = exports._setTypedProp = exports._values = exports._keys = exports.deepClone = void 0;
21
- const exceptions_1 = require("../core/exceptions");
21
+ const exceptions_1 = require("../core/exceptions/exceptions");
22
22
  function deepClone(obj) {
23
23
  if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'undefined' || obj === null)
24
24
  return obj;
@@ -18,7 +18,7 @@
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.compareVersions = void 0;
21
- const exceptions_1 = require("../core/exceptions");
21
+ const exceptions_1 = require("../core/exceptions/exceptions");
22
22
  /**
23
23
  *
24
24
  * @param firstVersion a version
@@ -6,7 +6,7 @@ const validator_core_1 = require("./validator-core");
6
6
  const date_time_tools_1 = require("../utils/date-time-tools");
7
7
  const array_tools_1 = require("../utils/array-tools");
8
8
  const object_tools_1 = require("../utils/object-tools");
9
- const exceptions_1 = require("../core/exceptions");
9
+ const exceptions_1 = require("../core/exceptions/exceptions");
10
10
  const tsValidateDynamicObject = (valuesValidator, keysValidator, mandatory = true) => {
11
11
  return [(0, validator_core_1.tsValidateExists)(mandatory),
12
12
  (input) => {
@@ -1,5 +1,5 @@
1
- import { CustomException } from '../core/exceptions';
2
1
  import { TS_Object } from '../utils/types';
2
+ import { CustomException } from '../core/exceptions/exceptions';
3
3
  /**
4
4
  * Should be like the following but errors in resolving...
5
5
  *
@@ -18,8 +18,8 @@
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.tsValidateObject = exports.tsValidateResult = exports.tsValidate = exports.tsValidateExists = exports.assertValidateMandatoryProperty = exports.ValidationException = void 0;
21
- const exceptions_1 = require("../core/exceptions");
22
21
  const object_tools_1 = require("../utils/object-tools");
22
+ const exceptions_1 = require("../core/exceptions/exceptions");
23
23
  class ValidationException extends exceptions_1.CustomException {
24
24
  constructor(debugMessage, input, result, e) {
25
25
  super(ValidationException, debugMessage, e);
@@ -1,7 +1,28 @@
1
1
  import { Validator, ValidatorTypeResolver } from './validator-core';
2
+ import { AuditableV2, DB_Object } from '../utils/types';
2
3
  export declare const tsValidate_OptionalArray: <T>(validator: ValidatorTypeResolver<T>) => Validator<T[]>;
3
4
  export declare const tsValidator_nonMandatoryString: Validator<string>;
4
5
  export declare const tsValidateMD5: (mandatory?: boolean) => Validator<string>;
5
6
  export declare const tsValidator_colorHex: Validator<string>;
6
7
  export declare const tsValidateMustExist: import("./validator-core").ValidatorImpl<any>;
7
8
  export declare const tsValidateOptional: import("./validator-core").ValidatorImpl<any>;
9
+ export declare const dbIdLength = 32;
10
+ export declare const tsValidateId: (length: number, mandatory?: boolean) => Validator<string>;
11
+ export declare const tsValidateEmail: Validator<string>;
12
+ export declare const tsValidateBucketUrl: (mandatory?: boolean) => Validator<string>;
13
+ export declare const tsValidateGeneralUrl: (mandatory?: boolean) => Validator<string>;
14
+ export declare const tsValidateVersion: Validator<string>;
15
+ export declare const tsValidateUniqueId: Validator<string>;
16
+ export declare const tsValidator_arrayOfUniqueIds: Validator<string[]>;
17
+ export declare const tsValidate_optionalArrayOfUniqueIds: Validator<string[]>;
18
+ export declare const tsValidateOptionalId: Validator<string>;
19
+ export declare const tsValidateStringWithDashes: Validator<string>;
20
+ export declare const tsValidateStringAndNumbersWithDashes: Validator<string>;
21
+ export declare const tsValidator_JavaObjectMemberName: Validator<string>;
22
+ export declare const tsValidateNameWithDashesAndDots: Validator<string>;
23
+ export declare const tsValidator_LowercaseStringWithDashes: Validator<string>;
24
+ export declare const tsValidator_LowerUpperStringWithSpaces: Validator<string>;
25
+ export declare const tsValidator_LowerUpperStringWithDashesAndUnderscore: Validator<string>;
26
+ export declare const tsValidator_InternationalPhoneNumber: Validator<string>;
27
+ export declare const tsValidator_AuditableV2: ValidatorTypeResolver<AuditableV2>;
28
+ export declare const DB_Object_validator: ValidatorTypeResolver<DB_Object>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tsValidateOptional = exports.tsValidateMustExist = exports.tsValidator_colorHex = exports.tsValidateMD5 = exports.tsValidator_nonMandatoryString = exports.tsValidate_OptionalArray = void 0;
3
+ exports.DB_Object_validator = exports.tsValidator_AuditableV2 = exports.tsValidator_InternationalPhoneNumber = exports.tsValidator_LowerUpperStringWithDashesAndUnderscore = exports.tsValidator_LowerUpperStringWithSpaces = exports.tsValidator_LowercaseStringWithDashes = exports.tsValidateNameWithDashesAndDots = exports.tsValidator_JavaObjectMemberName = exports.tsValidateStringAndNumbersWithDashes = exports.tsValidateStringWithDashes = exports.tsValidateOptionalId = exports.tsValidate_optionalArrayOfUniqueIds = exports.tsValidator_arrayOfUniqueIds = exports.tsValidateUniqueId = exports.tsValidateVersion = exports.tsValidateGeneralUrl = exports.tsValidateBucketUrl = exports.tsValidateEmail = exports.tsValidateId = exports.dbIdLength = exports.tsValidateOptional = exports.tsValidateMustExist = exports.tsValidator_colorHex = exports.tsValidateMD5 = exports.tsValidator_nonMandatoryString = exports.tsValidate_OptionalArray = void 0;
4
4
  const validator_core_1 = require("./validator-core");
5
5
  const type_validators_1 = require("./type-validators");
6
6
  const tsValidate_OptionalArray = (validator) => (0, type_validators_1.tsValidateArray)(validator, false);
@@ -13,3 +13,33 @@ exports.tsValidateMD5 = tsValidateMD5;
13
13
  exports.tsValidator_colorHex = (0, type_validators_1.tsValidateRegexp)(/^#(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3,4})$/);
14
14
  exports.tsValidateMustExist = (0, validator_core_1.tsValidateExists)();
15
15
  exports.tsValidateOptional = (0, validator_core_1.tsValidateExists)(false);
16
+ exports.dbIdLength = 32;
17
+ const tsValidateId = (length, mandatory = true) => (0, type_validators_1.tsValidateRegexp)(new RegExp(`^[0-9a-f]{${length}}$`), mandatory);
18
+ exports.tsValidateId = tsValidateId;
19
+ exports.tsValidateEmail = (0, type_validators_1.tsValidateRegexp)(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/);
20
+ const tsValidateBucketUrl = (mandatory) => (0, type_validators_1.tsValidateRegexp)(/gs?:\/\/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/, mandatory);
21
+ exports.tsValidateBucketUrl = tsValidateBucketUrl;
22
+ const tsValidateGeneralUrl = (mandatory) => (0, type_validators_1.tsValidateRegexp)(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/, mandatory);
23
+ exports.tsValidateGeneralUrl = tsValidateGeneralUrl;
24
+ exports.tsValidateVersion = (0, type_validators_1.tsValidateRegexp)(/\d{1,3}\.\d{1,3}\.\d{1,3}/);
25
+ exports.tsValidateUniqueId = (0, exports.tsValidateId)(exports.dbIdLength);
26
+ exports.tsValidator_arrayOfUniqueIds = (0, type_validators_1.tsValidateArray)(exports.tsValidateUniqueId);
27
+ exports.tsValidate_optionalArrayOfUniqueIds = (0, exports.tsValidate_OptionalArray)(exports.tsValidateUniqueId);
28
+ exports.tsValidateOptionalId = (0, exports.tsValidateId)(exports.dbIdLength, false);
29
+ exports.tsValidateStringWithDashes = (0, type_validators_1.tsValidateRegexp)(/^[A-Za-z-]+$/);
30
+ exports.tsValidateStringAndNumbersWithDashes = (0, type_validators_1.tsValidateRegexp)(/^[0-9A-Za-z-]+$/);
31
+ exports.tsValidator_JavaObjectMemberName = (0, type_validators_1.tsValidateRegexp)(/^[a-z][a-zA-Z0-9]+$/);
32
+ exports.tsValidateNameWithDashesAndDots = (0, type_validators_1.tsValidateRegexp)(/^[a-z-.]+$/);
33
+ exports.tsValidator_LowercaseStringWithDashes = (0, type_validators_1.tsValidateRegexp)(/^[a-z-.]+$/);
34
+ exports.tsValidator_LowerUpperStringWithSpaces = (0, type_validators_1.tsValidateRegexp)(/^[A-Za-z ]+$/);
35
+ exports.tsValidator_LowerUpperStringWithDashesAndUnderscore = (0, type_validators_1.tsValidateRegexp)(/^[A-Za-z-_]+$/);
36
+ exports.tsValidator_InternationalPhoneNumber = (0, type_validators_1.tsValidateRegexp)(/^\+(?:[0-9] ?){6,14}[0-9]$/);
37
+ exports.tsValidator_AuditableV2 = { _auditorId: (0, type_validators_1.tsValidateString)() };
38
+ exports.DB_Object_validator = {
39
+ _id: exports.tsValidateUniqueId,
40
+ _v: exports.tsValidateVersion,
41
+ _originDocId: exports.tsValidateOptionalId,
42
+ __hardDelete: (0, type_validators_1.tsValidateBoolean)(false),
43
+ __created: (0, type_validators_1.tsValidateTimestamp)(),
44
+ __updated: (0, type_validators_1.tsValidateTimestamp)(),
45
+ };