taon 21.0.52 → 21.0.54
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.
- package/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/icon-menu-taon.svg +15 -15
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-abstract-entity.js +19 -0
- package/lib-prod/base-classes/base-angular-service.js +84 -0
- package/lib-prod/base-classes/base-class.js +35 -0
- package/lib-prod/base-classes/{base-context.ts → base-context.js} +13 -15
- package/lib-prod/base-classes/base-controller.js +154 -0
- package/lib-prod/base-classes/base-crud-controller.js +264 -0
- package/lib-prod/base-classes/base-custom-repository.js +9 -0
- package/lib-prod/base-classes/{base-electron-service.ts → base-electron-service.js} +1 -12
- package/lib-prod/base-classes/base-entity.js +22 -0
- package/lib-prod/base-classes/base-file-upload.middleware.js +75 -0
- package/lib-prod/base-classes/base-injector.js +184 -0
- package/lib-prod/base-classes/base-middleware.js +9 -0
- package/lib-prod/base-classes/base-migration.js +20 -0
- package/lib-prod/base-classes/{base-provider.ts → base-provider.js} +2 -2
- package/lib-prod/base-classes/base-repository.js +617 -0
- package/lib-prod/base-classes/base-subscriber-for-entity.js +145 -0
- package/lib-prod/base-classes/{base.ts → base.js} +2 -15
- package/lib-prod/{build-info._auto-generated_.ts → build-info._auto-generated_.js} +1 -2
- package/lib-prod/config/controller-config.js +28 -0
- package/lib-prod/config/controller-options.js +3 -0
- package/lib-prod/config/method-config.js +7 -0
- package/lib-prod/config/param-config.js +3 -0
- package/lib-prod/constants.js +33 -0
- package/lib-prod/context-db-migrations.js +342 -0
- package/lib-prod/create-context.js +217 -0
- package/lib-prod/decorators/classes/controller-decorator.js +17 -0
- package/lib-prod/decorators/classes/entity-decorator.js +28 -0
- package/lib-prod/decorators/classes/middleware-decorator.js +16 -0
- package/lib-prod/decorators/classes/migration-decorator.js +15 -0
- package/lib-prod/decorators/classes/provider-decorator.js +15 -0
- package/lib-prod/decorators/classes/repository-decorator.js +15 -0
- package/lib-prod/decorators/classes/subscriber-decorator.js +15 -0
- package/lib-prod/decorators/decorator-abstract-opt.js +2 -0
- package/lib-prod/decorators/http/http-decorators.js +20 -0
- package/lib-prod/decorators/http/http-methods-decorators.js +102 -0
- package/lib-prod/decorators/http/http-params-decorators.js +42 -0
- package/lib-prod/dependency-injection/di-container.js +30 -0
- package/lib-prod/endpoint-context-storage.js +31 -0
- package/lib-prod/endpoint-context.js +2397 -0
- package/lib-prod/entity-process.js +225 -0
- package/lib-prod/env/{env.angular-node-app.ts → env.angular-node-app.js} +1 -1
- package/lib-prod/env/{env.docs-webapp.ts → env.docs-webapp.js} +1 -1
- package/lib-prod/env/{env.electron-app.ts → env.electron-app.js} +1 -1
- package/lib-prod/env/{env.mobile-app.ts → env.mobile-app.js} +1 -1
- package/lib-prod/env/{env.npm-lib-and-cli-tool.ts → env.npm-lib-and-cli-tool.js} +1 -1
- package/lib-prod/env/{env.vscode-plugin.ts → env.vscode-plugin.js} +1 -1
- package/lib-prod/express-types.js +1 -0
- package/lib-prod/formly/formly.models.js +1 -0
- package/lib-prod/formly/fromly.js +205 -0
- package/lib-prod/formly/type-from-entity.js +51 -0
- package/lib-prod/get-response-value.js +22 -0
- package/lib-prod/global-state/taon-global-state/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-global-state/{taon-global-state.abstract.context.ts → taon-global-state.abstract.context.js} +9 -11
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +7 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +42 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +35 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +44 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +46 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +22 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +11 -0
- package/lib-prod/global-state/taon-transaction-registry/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-transaction-registry/{taon-transaction-registry.abstract.context.ts → taon-transaction-registry.abstract.context.js} +10 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +5 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +31 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +22 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +5 -0
- package/lib-prod/helpers/class-helpers.js +228 -0
- package/lib-prod/helpers/clone-obj.js +17 -0
- package/lib-prod/helpers/taon-helpers.js +147 -0
- package/lib-prod/{index._auto-generated_.ts → index._auto-generated_.js} +1 -1
- package/lib-prod/index.js +252 -0
- package/lib-prod/{inject.ts → inject.js} +35 -57
- package/lib-prod/migrations/index.js +2 -0
- package/lib-prod/migrations/{migrations_index._auto-generated_.ts → migrations_index._auto-generated_.js} +0 -2
- package/lib-prod/models.js +78 -0
- package/lib-prod/orm/columns.js +64 -0
- package/lib-prod/orm/index.js +56 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +198 -0
- package/lib-prod/realtime/realtime-core.js +81 -0
- package/lib-prod/realtime/realtime-server.js +237 -0
- package/lib-prod/realtime/realtime-strategy/{index.ts → index.js} +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +280 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +289 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +27 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +11 -0
- package/lib-prod/realtime/realtime-subs-manager.js +88 -0
- package/lib-prod/realtime/realtime.models.js +2 -0
- package/lib-prod/symbols.js +108 -0
- package/lib-prod/ui/index.js +1 -0
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -0
- package/lib-prod/validators.js +80 -0
- package/lib-prod.split-namespaces.json +31 -91
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/lib-prod/base-classes/base-abstract-entity.ts +0 -34
- package/lib-prod/base-classes/base-angular-service.ts +0 -107
- package/lib-prod/base-classes/base-class.ts +0 -46
- package/lib-prod/base-classes/base-controller.ts +0 -240
- package/lib-prod/base-classes/base-crud-controller.ts +0 -298
- package/lib-prod/base-classes/base-custom-repository.ts +0 -10
- package/lib-prod/base-classes/base-entity.ts +0 -28
- package/lib-prod/base-classes/base-file-upload.middleware.ts +0 -92
- package/lib-prod/base-classes/base-injector.ts +0 -278
- package/lib-prod/base-classes/base-middleware.ts +0 -71
- package/lib-prod/base-classes/base-migration.ts +0 -26
- package/lib-prod/base-classes/base-repository.ts +0 -942
- package/lib-prod/base-classes/base-subscriber-for-entity.ts +0 -196
- package/lib-prod/config/controller-config.ts +0 -58
- package/lib-prod/config/controller-options.ts +0 -19
- package/lib-prod/config/method-config.ts +0 -55
- package/lib-prod/config/param-config.ts +0 -16
- package/lib-prod/constants.ts +0 -63
- package/lib-prod/context-db-migrations.ts +0 -488
- package/lib-prod/create-context.ts +0 -345
- package/lib-prod/decorators/classes/controller-decorator.ts +0 -25
- package/lib-prod/decorators/classes/entity-decorator.ts +0 -57
- package/lib-prod/decorators/classes/middleware-decorator.ts +0 -29
- package/lib-prod/decorators/classes/migration-decorator.ts +0 -27
- package/lib-prod/decorators/classes/provider-decorator.ts +0 -28
- package/lib-prod/decorators/classes/repository-decorator.ts +0 -26
- package/lib-prod/decorators/classes/subscriber-decorator.ts +0 -28
- package/lib-prod/decorators/decorator-abstract-opt.ts +0 -4
- package/lib-prod/decorators/http/http-decorators.ts +0 -26
- package/lib-prod/decorators/http/http-methods-decorators.ts +0 -275
- package/lib-prod/decorators/http/http-params-decorators.ts +0 -105
- package/lib-prod/dependency-injection/di-container.ts +0 -39
- package/lib-prod/endpoint-context-storage.ts +0 -47
- package/lib-prod/endpoint-context.ts +0 -3110
- package/lib-prod/entity-process.ts +0 -286
- package/lib-prod/express-types.ts +0 -4
- package/lib-prod/formly/formly.models.ts +0 -7
- package/lib-prod/formly/fromly.ts +0 -261
- package/lib-prod/formly/type-from-entity.ts +0 -80
- package/lib-prod/get-response-value.ts +0 -30
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.ts +0 -9
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.ts +0 -44
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.ts +0 -40
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.ts +0 -12
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.ts +0 -48
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.ts +0 -16
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.ts +0 -47
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.ts +0 -18
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.ts +0 -21
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.ts +0 -7
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.ts +0 -38
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.ts +0 -54
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.ts +0 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.ts +0 -6
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.ts +0 -16
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.ts +0 -29
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.ts +0 -20
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.ts +0 -9
- package/lib-prod/helpers/class-helpers.ts +0 -315
- package/lib-prod/helpers/clone-obj.ts +0 -24
- package/lib-prod/helpers/taon-helpers.ts +0 -181
- package/lib-prod/index.ts +0 -323
- package/lib-prod/lib-info.md +0 -8
- package/lib-prod/migrations/index.ts +0 -2
- package/lib-prod/migrations/migrations-info.md +0 -6
- package/lib-prod/models.ts +0 -427
- package/lib-prod/orm/columns.ts +0 -121
- package/lib-prod/orm/index.ts +0 -62
- package/lib-prod/realtime/realtime-client.ts +0 -288
- package/lib-prod/realtime/realtime-core.ts +0 -134
- package/lib-prod/realtime/realtime-server.ts +0 -398
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.ts +0 -344
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.ts +0 -349
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.ts +0 -30
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.ts +0 -21
- package/lib-prod/realtime/realtime-subs-manager.ts +0 -127
- package/lib-prod/realtime/realtime.models.ts +0 -33
- package/lib-prod/symbols.ts +0 -136
- package/lib-prod/ui/index.ts +0 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.ts +0 -1
- package/lib-prod/validators.ts +0 -103
- /package/lib-prod/env/{index.ts → index.js} +0 -0
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
//#region imports
|
|
2
|
-
import type { Response } from 'express';
|
|
3
|
-
import { JSON10 } from 'json10/lib-prod';
|
|
4
|
-
import { walk } from 'lodash-walk-object/lib-prod';
|
|
5
|
-
import { Mapping__NS__decode, Mapping__NS__DefaultModelWithMapping, Mapping__NS__encode, Mapping__NS__getModelsMapping, Mapping__NS__Mapping, Mapping__NS__ModelValue } from 'ng2-rest/lib-prod';
|
|
6
|
-
import { ___NS__add, ___NS__after, ___NS__ary, ___NS__assign, ___NS__assignIn, ___NS__assignInWith, ___NS__assignWith, ___NS__at, ___NS__attempt, ___NS__before, ___NS__bind, ___NS__bindAll, ___NS__bindKey, ___NS__camelCase, ___NS__capitalize, ___NS__castArray, ___NS__ceil, ___NS__chain, ___NS__chunk, ___NS__clamp, ___NS__clone, ___NS__cloneDeep, ___NS__cloneDeepWith, ___NS__cloneWith, ___NS__compact, ___NS__concat, ___NS__cond, ___NS__conforms, ___NS__conformsTo, ___NS__constant, ___NS__countBy, ___NS__create, ___NS__curry, ___NS__curryRight, ___NS__debounce, ___NS__deburr, ___NS__defaults, ___NS__defaultsDeep, ___NS__defaultTo, ___NS__defer, ___NS__delay, ___NS__difference, ___NS__differenceBy, ___NS__differenceWith, ___NS__divide, ___NS__drop, ___NS__dropRight, ___NS__dropRightWhile, ___NS__dropWhile, ___NS__each, ___NS__eachRight, ___NS__endsWith, ___NS__entries, ___NS__entriesIn, ___NS__eq, ___NS__escape, ___NS__escapeRegExp, ___NS__every, ___NS__extend, ___NS__extendWith, ___NS__fill, ___NS__filter, ___NS__find, ___NS__findIndex, ___NS__findKey, ___NS__findLast, ___NS__findLastIndex, ___NS__findLastKey, ___NS__first, ___NS__flatMap, ___NS__flatMapDeep, ___NS__flatMapDepth, ___NS__flatten, ___NS__flattenDeep, ___NS__flattenDepth, ___NS__flip, ___NS__floor, ___NS__flow, ___NS__flowRight, ___NS__forEach, ___NS__forEachRight, ___NS__forIn, ___NS__forInRight, ___NS__forOwn, ___NS__forOwnRight, ___NS__fromPairs, ___NS__functions, ___NS__functionsIn, ___NS__get, ___NS__groupBy, ___NS__gt, ___NS__gte, ___NS__has, ___NS__hasIn, ___NS__head, ___NS__identity, ___NS__includes, ___NS__indexOf, ___NS__initial, ___NS__inRange, ___NS__intersection, ___NS__intersectionBy, ___NS__intersectionWith, ___NS__invert, ___NS__invertBy, ___NS__invoke, ___NS__invokeMap, ___NS__isArguments, ___NS__isArray, ___NS__isArrayBuffer, ___NS__isArrayLike, ___NS__isArrayLikeObject, ___NS__isBoolean, ___NS__isBuffer, ___NS__isDate, ___NS__isElement, ___NS__isEmpty, ___NS__isEqual, ___NS__isEqualWith, ___NS__isError, ___NS__isFinite, ___NS__isFunction, ___NS__isInteger, ___NS__isLength, ___NS__isMap, ___NS__isMatch, ___NS__isMatchWith, ___NS__isNaN, ___NS__isNative, ___NS__isNil, ___NS__isNull, ___NS__isNumber, ___NS__isObject, ___NS__isObjectLike, ___NS__isPlainObject, ___NS__isRegExp, ___NS__isSafeInteger, ___NS__isSet, ___NS__isString, ___NS__isSymbol, ___NS__isTypedArray, ___NS__isUndefined, ___NS__isWeakMap, ___NS__isWeakSet, ___NS__iteratee, ___NS__join, ___NS__kebabCase, ___NS__keyBy, ___NS__keys, ___NS__keysIn, ___NS__last, ___NS__lastIndexOf, ___NS__lowerCase, ___NS__lowerFirst, ___NS__lt, ___NS__lte, ___NS__map, ___NS__mapKeys, ___NS__mapValues, ___NS__matches, ___NS__matchesProperty, ___NS__max, ___NS__maxBy, ___NS__mean, ___NS__meanBy, ___NS__memoize, ___NS__merge, ___NS__mergeWith, ___NS__method, ___NS__methodOf, ___NS__min, ___NS__minBy, ___NS__mixin, ___NS__multiply, ___NS__negate, ___NS__noop, ___NS__now, ___NS__nth, ___NS__nthArg, ___NS__omit, ___NS__omitBy, ___NS__once, ___NS__orderBy, ___NS__over, ___NS__overArgs, ___NS__overEvery, ___NS__overSome, ___NS__pad, ___NS__padEnd, ___NS__padStart, ___NS__parseInt, ___NS__partial, ___NS__partialRight, ___NS__partition, ___NS__pick, ___NS__pickBy, ___NS__property, ___NS__propertyOf, ___NS__pull, ___NS__pullAll, ___NS__pullAllBy, ___NS__pullAllWith, ___NS__pullAt, ___NS__random, ___NS__range, ___NS__rangeRight, ___NS__rearg, ___NS__reduce, ___NS__reduceRight, ___NS__reject, ___NS__remove, ___NS__repeat, ___NS__replace, ___NS__rest, ___NS__result, ___NS__reverse, ___NS__round, ___NS__sample, ___NS__sampleSize, ___NS__set, ___NS__setWith, ___NS__shuffle, ___NS__size, ___NS__slice, ___NS__snakeCase, ___NS__some, ___NS__sortBy, ___NS__sortedIndex, ___NS__sortedIndexBy, ___NS__sortedIndexOf, ___NS__sortedLastIndex, ___NS__sortedLastIndexBy, ___NS__sortedLastIndexOf, ___NS__sortedUniq, ___NS__sortedUniqBy, ___NS__split, ___NS__spread, ___NS__startCase, ___NS__startsWith, ___NS__stubArray, ___NS__stubFalse, ___NS__stubObject, ___NS__stubString, ___NS__stubTrue, ___NS__subtract, ___NS__sum, ___NS__sumBy, ___NS__tail, ___NS__take, ___NS__takeRight, ___NS__takeRightWhile, ___NS__takeWhile, ___NS__tap, ___NS__template, ___NS__templateSettings, ___NS__throttle, ___NS__thru, ___NS__times, ___NS__toArray, ___NS__toFinite, ___NS__toInteger, ___NS__toLength, ___NS__toLower, ___NS__toNumber, ___NS__toPairs, ___NS__toPairsIn, ___NS__toPath, ___NS__toPlainObject, ___NS__toSafeInteger, ___NS__toString, ___NS__toUpper, ___NS__transform, ___NS__trim, ___NS__trimEnd, ___NS__trimStart, ___NS__truncate, ___NS__unary, ___NS__unescape, ___NS__union, ___NS__unionBy, ___NS__unionWith, ___NS__uniq, ___NS__uniqBy, ___NS__uniqueId, ___NS__uniqWith, ___NS__unset, ___NS__unzip, ___NS__unzipWith, ___NS__update, ___NS__updateWith, ___NS__upperCase, ___NS__upperFirst, ___NS__values, ___NS__valuesIn, ___NS__without, ___NS__words, ___NS__wrap, ___NS__xor, ___NS__xorBy, ___NS__xorWith, ___NS__zip, ___NS__zipObject, ___NS__zipObjectDeep, ___NS__zipWith } from 'tnp-core/lib-prod';
|
|
7
|
-
import { config } from 'tnp-core/lib-prod';
|
|
8
|
-
|
|
9
|
-
import { ClassHelpers__NS__asyncHandler, ClassHelpers__NS__ensureClassConfig, ClassHelpers__NS__ensureMethodConfig, ClassHelpers__NS__getClassConfig, ClassHelpers__NS__getClassFnFromObject, ClassHelpers__NS__getControllerConfigs, ClassHelpers__NS__getFullInternalName, ClassHelpers__NS__getMethodsNames, ClassHelpers__NS__getName, ClassHelpers__NS__getOrginalClass, ClassHelpers__NS__getUniqueKey, ClassHelpers__NS__hasParentClassWithName, ClassHelpers__NS__isContextClassObject, ClassHelpers__NS__setName } from './helpers/class-helpers';
|
|
10
|
-
import { Symbols__NS__classMethodsNames, Symbols__NS__classNameStaticProperty, Symbols__NS__ctxInClassOrClassObj, Symbols__NS__fullClassNameStaticProperty, Symbols__NS__metadata, Symbols__NS__old, Symbols__NS__orignalClass, Symbols__NS__orignalClassClonesObj, Symbols__NS__REALTIME } from './symbols';
|
|
11
|
-
//#endregion
|
|
12
|
-
|
|
13
|
-
//#region get transform function
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated
|
|
16
|
-
*/
|
|
17
|
-
export const getTransformFunction = (target: Function) => {
|
|
18
|
-
if (!target) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// const className = ClassHelpers__NS__getName(target)
|
|
23
|
-
// target = ClassHelpers.getBy(className);
|
|
24
|
-
|
|
25
|
-
if (!target) {
|
|
26
|
-
return void 0;
|
|
27
|
-
}
|
|
28
|
-
const configs = ClassHelpers__NS__getControllerConfigs(target);
|
|
29
|
-
// console.log(`CONFIGS TO CHECK`, configs)
|
|
30
|
-
const functions = configs
|
|
31
|
-
.map(c => {
|
|
32
|
-
if (___NS__isFunction(c.browserTransformFn)) {
|
|
33
|
-
return c.browserTransformFn;
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
.filter(f => ___NS__isFunction(f));
|
|
37
|
-
return functions.length === 0
|
|
38
|
-
? void 0
|
|
39
|
-
: function (entity) {
|
|
40
|
-
for (let index = functions.length - 1; index >= 0; index--) {
|
|
41
|
-
const transformFun = functions[index];
|
|
42
|
-
transformFun(entity);
|
|
43
|
-
}
|
|
44
|
-
return entity;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
|
|
49
|
-
//#region single transform
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated
|
|
52
|
-
*/
|
|
53
|
-
export const singleTransform = (json: any) => {
|
|
54
|
-
let ptarget = ClassHelpers__NS__getClassFnFromObject(json);
|
|
55
|
-
let pbrowserTransformFn = getTransformFunction(ptarget);
|
|
56
|
-
if (pbrowserTransformFn) {
|
|
57
|
-
const newValue = pbrowserTransformFn(json);
|
|
58
|
-
if (!___NS__isObject(newValue)) {
|
|
59
|
-
console.error(
|
|
60
|
-
`Please return object in transform function for class: ` +
|
|
61
|
-
`${ClassHelpers__NS__getName(json)}`,
|
|
62
|
-
);
|
|
63
|
-
} else {
|
|
64
|
-
json = newValue;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return json;
|
|
68
|
-
};
|
|
69
|
-
//#endregion
|
|
70
|
-
|
|
71
|
-
export class EntityProcess {
|
|
72
|
-
//#region init
|
|
73
|
-
static async init(result: any, response: Response) {
|
|
74
|
-
return await new EntityProcess(result, response).run();
|
|
75
|
-
}
|
|
76
|
-
//#endregion
|
|
77
|
-
|
|
78
|
-
//#region fields
|
|
79
|
-
/**
|
|
80
|
-
* Data to send
|
|
81
|
-
*/
|
|
82
|
-
data: any;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Say yes to:
|
|
86
|
-
* - circural object
|
|
87
|
-
* - transform browser fn in decorator
|
|
88
|
-
*/
|
|
89
|
-
private advancedManipulation: boolean = false;
|
|
90
|
-
|
|
91
|
-
private entityMapping: any;
|
|
92
|
-
|
|
93
|
-
private circural = [];
|
|
94
|
-
//#endregion
|
|
95
|
-
|
|
96
|
-
//#region constructor
|
|
97
|
-
constructor(
|
|
98
|
-
/**
|
|
99
|
-
* Data from backend
|
|
100
|
-
*/
|
|
101
|
-
private result: any,
|
|
102
|
-
private response: Response,
|
|
103
|
-
) {}
|
|
104
|
-
//#endregion
|
|
105
|
-
|
|
106
|
-
//#region check advanced manipulation
|
|
107
|
-
private checkAdvancedManiupulation() {
|
|
108
|
-
if (___NS__isFunction(this.result)) {
|
|
109
|
-
this.advancedManipulation = true;
|
|
110
|
-
this.result = this.result();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
|
|
115
|
-
//#region run
|
|
116
|
-
public async run() {
|
|
117
|
-
this.checkAdvancedManiupulation();
|
|
118
|
-
this.data = this.result;
|
|
119
|
-
|
|
120
|
-
if (___NS__isObject(this.result)) {
|
|
121
|
-
if (this.advancedManipulation) {
|
|
122
|
-
this.applayTransformFn();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
this.setHeaders();
|
|
126
|
-
}
|
|
127
|
-
this.send();
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
|
|
131
|
-
//#region apply transform function
|
|
132
|
-
applayTransformFn() {
|
|
133
|
-
if (___NS__isObject(this.data) && !___NS__isArray(this.data)) {
|
|
134
|
-
this.data = singleTransform(this.data);
|
|
135
|
-
}
|
|
136
|
-
const { include } = { include: [] };
|
|
137
|
-
walk.Object(
|
|
138
|
-
this.data,
|
|
139
|
-
(value, lodashPath, changeValue, { skipObject, isCircural }) => {
|
|
140
|
-
// console.log(`${isCircural ? 'CIR' : 'NOT'} : ${lodashPath}`)
|
|
141
|
-
if (!isCircural) {
|
|
142
|
-
if (!___NS__isArray(value) && ___NS__isObject(value)) {
|
|
143
|
-
changeValue(singleTransform(value));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
{ checkCircural: true, breadthWalk: true, include },
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const { circs } = walk.Object(this.data, void 0, {
|
|
151
|
-
checkCircural: true,
|
|
152
|
-
breadthWalk: true,
|
|
153
|
-
include,
|
|
154
|
-
});
|
|
155
|
-
this.circural = circs;
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
|
|
159
|
-
//#region set headers
|
|
160
|
-
setHeaders(): void {
|
|
161
|
-
const { include } = { include: [] };
|
|
162
|
-
|
|
163
|
-
const className = ClassHelpers__NS__getName(this.data);
|
|
164
|
-
const doNothing =
|
|
165
|
-
___NS__isNil(this.data) ||
|
|
166
|
-
[
|
|
167
|
-
'Object',
|
|
168
|
-
'',
|
|
169
|
-
// void 0, null // TODO not sure about commenting this
|
|
170
|
-
].includes(className);
|
|
171
|
-
// console.log('doNothing', doNothing)
|
|
172
|
-
if (!doNothing) {
|
|
173
|
-
const cleaned = JSON10.cleaned(this.data, void 0, {
|
|
174
|
-
breadthWalk: true,
|
|
175
|
-
include,
|
|
176
|
-
});
|
|
177
|
-
this.entityMapping = Mapping__NS__decode(cleaned, !this.advancedManipulation);
|
|
178
|
-
|
|
179
|
-
this.response.set(
|
|
180
|
-
Symbols__NS__old.MAPPING_CONFIG_HEADER,
|
|
181
|
-
JSON.stringify(this.entityMapping),
|
|
182
|
-
);
|
|
183
|
-
if (this.advancedManipulation) {
|
|
184
|
-
this.response.set(
|
|
185
|
-
Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
186
|
-
JSON.stringify(this.circural),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
|
|
193
|
-
//#region send
|
|
194
|
-
send() {
|
|
195
|
-
if (this.advancedManipulation) {
|
|
196
|
-
const browserKey = config.folder.browser;
|
|
197
|
-
let toSend = ___NS__isArray(this.data) ? [] : {};
|
|
198
|
-
|
|
199
|
-
const { include = [], exclude = [] } = { include: [], exclude: [] };
|
|
200
|
-
|
|
201
|
-
walk.Object(
|
|
202
|
-
this.data,
|
|
203
|
-
(value, lodashPath, changeVAlue, { isCircural, skipObject }) => {
|
|
204
|
-
// console.log(`${isCircural ? 'CIR' : 'NOT'} ${lodashPath}`)
|
|
205
|
-
if (isCircural) {
|
|
206
|
-
___NS__set(toSend, lodashPath, null);
|
|
207
|
-
} else {
|
|
208
|
-
const fun = getTransformFunction(
|
|
209
|
-
ClassHelpers__NS__getClassFnFromObject(value),
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
if (___NS__isFunction(fun)) {
|
|
213
|
-
___NS__set(toSend, `${lodashPath}.${browserKey}`, value[browserKey]);
|
|
214
|
-
const indexProp = ClassHelpers__NS__getUniqueKey(value);
|
|
215
|
-
___NS__set(toSend, `${lodashPath}.${indexProp}`, value[indexProp]);
|
|
216
|
-
// skipObject()
|
|
217
|
-
} else {
|
|
218
|
-
___NS__set(toSend, lodashPath, value);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
{ checkCircural: true, breadthWalk: true, include },
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
if (!___NS__isArray(this.data)) {
|
|
226
|
-
let funParent = getTransformFunction(
|
|
227
|
-
ClassHelpers__NS__getClassFnFromObject(this.data),
|
|
228
|
-
);
|
|
229
|
-
// if (this.mdc && this.mdc.exclude && this.mdc.exclude.length > 0) {
|
|
230
|
-
// console.log(`funParent !!! have fun? ${!!funParent} `)
|
|
231
|
-
// }
|
|
232
|
-
if (___NS__isFunction(funParent)) {
|
|
233
|
-
toSend = {
|
|
234
|
-
[browserKey]: toSend[browserKey],
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
Object.keys(this.data).forEach(prop => {
|
|
238
|
-
if (prop !== browserKey) {
|
|
239
|
-
const v = this.data[prop];
|
|
240
|
-
if (
|
|
241
|
-
!(
|
|
242
|
-
(include.length > 0 && !include.includes(prop)) ||
|
|
243
|
-
(exclude.length > 0 && exclude.includes(prop))
|
|
244
|
-
)
|
|
245
|
-
) {
|
|
246
|
-
if (
|
|
247
|
-
ClassHelpers__NS__isContextClassObject(v) &&
|
|
248
|
-
___NS__isFunction(
|
|
249
|
-
getTransformFunction(ClassHelpers__NS__getClassFnFromObject(v)),
|
|
250
|
-
)
|
|
251
|
-
) {
|
|
252
|
-
toSend[prop] = {
|
|
253
|
-
[browserKey]: v[browserKey],
|
|
254
|
-
};
|
|
255
|
-
const indexProp = ClassHelpers__NS__getUniqueKey(v);
|
|
256
|
-
toSend[prop][indexProp] = this.data[prop][indexProp];
|
|
257
|
-
for (const key in v) {
|
|
258
|
-
if (
|
|
259
|
-
___NS__isObject(v) &&
|
|
260
|
-
v.hasOwnProperty(key) &&
|
|
261
|
-
![indexProp, config.folder.browser].includes(key) &&
|
|
262
|
-
(___NS__isString(v[key]) ||
|
|
263
|
-
___NS__isNumber(v[key]) ||
|
|
264
|
-
___NS__isDate(v[key]) ||
|
|
265
|
-
___NS__isNull(v[key]) ||
|
|
266
|
-
___NS__isBoolean(v[key]))
|
|
267
|
-
) {
|
|
268
|
-
toSend[prop][key] = v[key];
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
toSend[prop] = v;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// toSend = Helpers.JSON.cleaned(toSend, void 0, { breadthWalk: true })
|
|
280
|
-
this.response.json(toSend);
|
|
281
|
-
} else {
|
|
282
|
-
this.response.json(this.data);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
//#endregion
|
|
286
|
-
}
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { FormlyFieldConfig } from '@ngx-formly/core';
|
|
2
|
-
import { Mapping__NS__decode, Mapping__NS__DefaultModelWithMapping, Mapping__NS__encode, Mapping__NS__getModelsMapping, Mapping__NS__Mapping, Mapping__NS__ModelValue } from 'ng2-rest/lib-prod';
|
|
3
|
-
import { ___NS__add, ___NS__after, ___NS__ary, ___NS__assign, ___NS__assignIn, ___NS__assignInWith, ___NS__assignWith, ___NS__at, ___NS__attempt, ___NS__before, ___NS__bind, ___NS__bindAll, ___NS__bindKey, ___NS__camelCase, ___NS__capitalize, ___NS__castArray, ___NS__ceil, ___NS__chain, ___NS__chunk, ___NS__clamp, ___NS__clone, ___NS__cloneDeep, ___NS__cloneDeepWith, ___NS__cloneWith, ___NS__compact, ___NS__concat, ___NS__cond, ___NS__conforms, ___NS__conformsTo, ___NS__constant, ___NS__countBy, ___NS__create, ___NS__curry, ___NS__curryRight, ___NS__debounce, ___NS__deburr, ___NS__defaults, ___NS__defaultsDeep, ___NS__defaultTo, ___NS__defer, ___NS__delay, ___NS__difference, ___NS__differenceBy, ___NS__differenceWith, ___NS__divide, ___NS__drop, ___NS__dropRight, ___NS__dropRightWhile, ___NS__dropWhile, ___NS__each, ___NS__eachRight, ___NS__endsWith, ___NS__entries, ___NS__entriesIn, ___NS__eq, ___NS__escape, ___NS__escapeRegExp, ___NS__every, ___NS__extend, ___NS__extendWith, ___NS__fill, ___NS__filter, ___NS__find, ___NS__findIndex, ___NS__findKey, ___NS__findLast, ___NS__findLastIndex, ___NS__findLastKey, ___NS__first, ___NS__flatMap, ___NS__flatMapDeep, ___NS__flatMapDepth, ___NS__flatten, ___NS__flattenDeep, ___NS__flattenDepth, ___NS__flip, ___NS__floor, ___NS__flow, ___NS__flowRight, ___NS__forEach, ___NS__forEachRight, ___NS__forIn, ___NS__forInRight, ___NS__forOwn, ___NS__forOwnRight, ___NS__fromPairs, ___NS__functions, ___NS__functionsIn, ___NS__get, ___NS__groupBy, ___NS__gt, ___NS__gte, ___NS__has, ___NS__hasIn, ___NS__head, ___NS__identity, ___NS__includes, ___NS__indexOf, ___NS__initial, ___NS__inRange, ___NS__intersection, ___NS__intersectionBy, ___NS__intersectionWith, ___NS__invert, ___NS__invertBy, ___NS__invoke, ___NS__invokeMap, ___NS__isArguments, ___NS__isArray, ___NS__isArrayBuffer, ___NS__isArrayLike, ___NS__isArrayLikeObject, ___NS__isBoolean, ___NS__isBuffer, ___NS__isDate, ___NS__isElement, ___NS__isEmpty, ___NS__isEqual, ___NS__isEqualWith, ___NS__isError, ___NS__isFinite, ___NS__isFunction, ___NS__isInteger, ___NS__isLength, ___NS__isMap, ___NS__isMatch, ___NS__isMatchWith, ___NS__isNaN, ___NS__isNative, ___NS__isNil, ___NS__isNull, ___NS__isNumber, ___NS__isObject, ___NS__isObjectLike, ___NS__isPlainObject, ___NS__isRegExp, ___NS__isSafeInteger, ___NS__isSet, ___NS__isString, ___NS__isSymbol, ___NS__isTypedArray, ___NS__isUndefined, ___NS__isWeakMap, ___NS__isWeakSet, ___NS__iteratee, ___NS__join, ___NS__kebabCase, ___NS__keyBy, ___NS__keys, ___NS__keysIn, ___NS__last, ___NS__lastIndexOf, ___NS__lowerCase, ___NS__lowerFirst, ___NS__lt, ___NS__lte, ___NS__map, ___NS__mapKeys, ___NS__mapValues, ___NS__matches, ___NS__matchesProperty, ___NS__max, ___NS__maxBy, ___NS__mean, ___NS__meanBy, ___NS__memoize, ___NS__merge, ___NS__mergeWith, ___NS__method, ___NS__methodOf, ___NS__min, ___NS__minBy, ___NS__mixin, ___NS__multiply, ___NS__negate, ___NS__noop, ___NS__now, ___NS__nth, ___NS__nthArg, ___NS__omit, ___NS__omitBy, ___NS__once, ___NS__orderBy, ___NS__over, ___NS__overArgs, ___NS__overEvery, ___NS__overSome, ___NS__pad, ___NS__padEnd, ___NS__padStart, ___NS__parseInt, ___NS__partial, ___NS__partialRight, ___NS__partition, ___NS__pick, ___NS__pickBy, ___NS__property, ___NS__propertyOf, ___NS__pull, ___NS__pullAll, ___NS__pullAllBy, ___NS__pullAllWith, ___NS__pullAt, ___NS__random, ___NS__range, ___NS__rangeRight, ___NS__rearg, ___NS__reduce, ___NS__reduceRight, ___NS__reject, ___NS__remove, ___NS__repeat, ___NS__replace, ___NS__rest, ___NS__result, ___NS__reverse, ___NS__round, ___NS__sample, ___NS__sampleSize, ___NS__set, ___NS__setWith, ___NS__shuffle, ___NS__size, ___NS__slice, ___NS__snakeCase, ___NS__some, ___NS__sortBy, ___NS__sortedIndex, ___NS__sortedIndexBy, ___NS__sortedIndexOf, ___NS__sortedLastIndex, ___NS__sortedLastIndexBy, ___NS__sortedLastIndexOf, ___NS__sortedUniq, ___NS__sortedUniqBy, ___NS__split, ___NS__spread, ___NS__startCase, ___NS__startsWith, ___NS__stubArray, ___NS__stubFalse, ___NS__stubObject, ___NS__stubString, ___NS__stubTrue, ___NS__subtract, ___NS__sum, ___NS__sumBy, ___NS__tail, ___NS__take, ___NS__takeRight, ___NS__takeRightWhile, ___NS__takeWhile, ___NS__tap, ___NS__template, ___NS__templateSettings, ___NS__throttle, ___NS__thru, ___NS__times, ___NS__toArray, ___NS__toFinite, ___NS__toInteger, ___NS__toLength, ___NS__toLower, ___NS__toNumber, ___NS__toPairs, ___NS__toPairsIn, ___NS__toPath, ___NS__toPlainObject, ___NS__toSafeInteger, ___NS__toString, ___NS__toUpper, ___NS__transform, ___NS__trim, ___NS__trimEnd, ___NS__trimStart, ___NS__truncate, ___NS__unary, ___NS__unescape, ___NS__union, ___NS__unionBy, ___NS__unionWith, ___NS__uniq, ___NS__uniqBy, ___NS__uniqueId, ___NS__uniqWith, ___NS__unset, ___NS__unzip, ___NS__unzipWith, ___NS__update, ___NS__updateWith, ___NS__upperCase, ___NS__upperFirst, ___NS__values, ___NS__valuesIn, ___NS__without, ___NS__words, ___NS__wrap, ___NS__xor, ___NS__xorBy, ___NS__xorWith, ___NS__zip, ___NS__zipObject, ___NS__zipObjectDeep, ___NS__zipWith } from 'tnp-core/lib-prod';
|
|
4
|
-
import { CoreModels__NS__BaseProjectType, CoreModels__NS__BaseProjectTypeArr, CoreModels__NS__CfontAlign, CoreModels__NS__CfontStyle, CoreModels__NS__ClassNameStaticProperty, CoreModels__NS__ContentType, CoreModels__NS__ContentTypeKeys, CoreModels__NS__CoreLibCategory, CoreModels__NS__CutableFileExt, CoreModels__NS__DatabaseType, CoreModels__NS__EnvironmentName, CoreModels__NS__EnvironmentNameTaon, CoreModels__NS__ExecuteOptions, CoreModels__NS__FileEvent, CoreModels__NS__FileExtension, CoreModels__NS__FrameworkVersion, CoreModels__NS__GlobalDependencies, CoreModels__NS__HttpMethod, CoreModels__NS__ImageFileExtension, CoreModels__NS__ImageFileExtensionArr, CoreModels__NS__InstalationType, CoreModels__NS__InstalationTypeArr, CoreModels__NS__LibType, CoreModels__NS__localhostDomain, CoreModels__NS__localhostIp127, CoreModels__NS__ManifestIcon, CoreModels__NS__MediaType, CoreModels__NS__MediaTypeAllArr, CoreModels__NS__MimeType, CoreModels__NS__mimeTypes, CoreModels__NS__MimeTypesObj, CoreModels__NS__NewFactoryType, CoreModels__NS__NpmInstallOptions, CoreModels__NS__NpmSpecialVersions, CoreModels__NS__OrignalClassKey, CoreModels__NS__OutFolder, CoreModels__NS__Package, CoreModels__NS__ParamType, CoreModels__NS__parentLocation, CoreModels__NS__pathToChildren, CoreModels__NS__Position, CoreModels__NS__PreReleaseVersionTag, CoreModels__NS__PROGRESS_DATA_TYPE, CoreModels__NS__PUSHTYPE, CoreModels__NS__PwaManifest, CoreModels__NS__ReleaseVersionType, CoreModels__NS__ReleaseVersionTypeEnum, CoreModels__NS__RunOptions, CoreModels__NS__Size, CoreModels__NS__SPECIAL_APP_READY_MESSAGE, CoreModels__NS__SPECIAL_WORKER_READY_MESSAGE, CoreModels__NS__tagForTaskName, CoreModels__NS__TaonHttpErrorCustomProp, CoreModels__NS__TsUsage, CoreModels__NS__UIFramework, CoreModels__NS__UploadedBackendFile, CoreModels__NS__VSCodeSettings } from 'tnp-core/lib-prod';
|
|
5
|
-
import { CLASS } from 'typescript-class-helpers/lib-prod';
|
|
6
|
-
|
|
7
|
-
import { FormlyInputType } from './formly.models';
|
|
8
|
-
import { findTypeForEntity } from './type-from-entity';
|
|
9
|
-
|
|
10
|
-
export function getFromlyConfigFor(
|
|
11
|
-
target: Function,
|
|
12
|
-
options: {
|
|
13
|
-
formType?: CoreModels__NS__UIFramework;
|
|
14
|
-
keysPathesToInclude?: string[];
|
|
15
|
-
keysPathesToExclude?: string[];
|
|
16
|
-
parentModel?: string;
|
|
17
|
-
relativePath?: string;
|
|
18
|
-
level?: number;
|
|
19
|
-
maxLevel?: number;
|
|
20
|
-
} = {},
|
|
21
|
-
) {
|
|
22
|
-
const {
|
|
23
|
-
formType = 'material',
|
|
24
|
-
keysPathesToExclude = [],
|
|
25
|
-
keysPathesToInclude = [],
|
|
26
|
-
parentModel,
|
|
27
|
-
relativePath = '',
|
|
28
|
-
level = 0,
|
|
29
|
-
maxLevel = 4,
|
|
30
|
-
} = options;
|
|
31
|
-
|
|
32
|
-
if (level === maxLevel) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const mapping: Mapping__NS__Mapping = Mapping__NS__getModelsMapping(target);
|
|
37
|
-
// console.log('mapping', mapping)
|
|
38
|
-
const fieldNames = CLASS.describeProperites(target);
|
|
39
|
-
const checkExclude =
|
|
40
|
-
___NS__isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
|
|
41
|
-
const checkInclude =
|
|
42
|
-
___NS__isArray(keysPathesToInclude) && keysPathesToInclude.length > 0;
|
|
43
|
-
if (checkExclude && checkInclude) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`In Taon function getFromlyConfigFor(...) please use keysPathesToInclude or keysPathesToExclude, `,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
// if (checkInclude) {
|
|
49
|
-
// console.log('check include', keysPathesToExclude)
|
|
50
|
-
// }
|
|
51
|
-
|
|
52
|
-
// if (checkExclude) {
|
|
53
|
-
// console.log('check exclude', keysPathesToExclude)
|
|
54
|
-
// }
|
|
55
|
-
|
|
56
|
-
let fields: FormlyFieldConfig[] = [];
|
|
57
|
-
|
|
58
|
-
//#region input to push
|
|
59
|
-
function inputToPush(
|
|
60
|
-
key: string,
|
|
61
|
-
type: FormlyInputType,
|
|
62
|
-
model: string,
|
|
63
|
-
inptToPushOptions?: {
|
|
64
|
-
targetChild?: Function;
|
|
65
|
-
selectOptions?: any[];
|
|
66
|
-
},
|
|
67
|
-
) {
|
|
68
|
-
const { targetChild, selectOptions } = inptToPushOptions || {};
|
|
69
|
-
// console.log(`key(${key}) type: ${type} | model: ${model} targetChild: ${targetChild && targetChild.name}`)
|
|
70
|
-
let res: FormlyFieldConfig;
|
|
71
|
-
if (type === 'repeat') {
|
|
72
|
-
const fieldGroup = getFromlyConfigFor(targetChild, {
|
|
73
|
-
formType,
|
|
74
|
-
keysPathesToInclude,
|
|
75
|
-
keysPathesToExclude,
|
|
76
|
-
relativePath: `${relativePath}.${key}`,
|
|
77
|
-
level: level + 1,
|
|
78
|
-
maxLevel,
|
|
79
|
-
});
|
|
80
|
-
if (fieldGroup.length > 0) {
|
|
81
|
-
res = {
|
|
82
|
-
key,
|
|
83
|
-
type,
|
|
84
|
-
defaultValue: [],
|
|
85
|
-
fieldArray: {
|
|
86
|
-
fieldGroupClassName: 'row',
|
|
87
|
-
templateOptions: {
|
|
88
|
-
label: `Add new ${___NS__startCase(key)}`,
|
|
89
|
-
},
|
|
90
|
-
fieldGroup,
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
} else if (type === 'group') {
|
|
95
|
-
const fieldGroup = getFromlyConfigFor(targetChild, {
|
|
96
|
-
formType,
|
|
97
|
-
keysPathesToInclude,
|
|
98
|
-
keysPathesToExclude,
|
|
99
|
-
parentModel: model,
|
|
100
|
-
relativePath: `${relativePath}.${key}`,
|
|
101
|
-
level: level + 1,
|
|
102
|
-
maxLevel,
|
|
103
|
-
});
|
|
104
|
-
if (fieldGroup.length > 0) {
|
|
105
|
-
res = {
|
|
106
|
-
fieldGroupClassName: 'row',
|
|
107
|
-
templateOptions: {
|
|
108
|
-
label: `${___NS__startCase(key)}`,
|
|
109
|
-
},
|
|
110
|
-
wrappers: ['groupwrap'],
|
|
111
|
-
fieldGroup,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
} else {
|
|
115
|
-
res = {
|
|
116
|
-
key,
|
|
117
|
-
model,
|
|
118
|
-
type,
|
|
119
|
-
defaultValue: !___NS__isUndefined(target.prototype[key])
|
|
120
|
-
? target.prototype[key]
|
|
121
|
-
: undefined,
|
|
122
|
-
templateOptions: {
|
|
123
|
-
label: ___NS__isString(model)
|
|
124
|
-
? `${model
|
|
125
|
-
.split('.')
|
|
126
|
-
.map(l => ___NS__startCase(l))
|
|
127
|
-
.join(' / ')} / ${___NS__startCase(key)}`
|
|
128
|
-
: ___NS__startCase(key),
|
|
129
|
-
options: selectOptions,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
if (res) {
|
|
134
|
-
Object.keys(res).forEach(key =>
|
|
135
|
-
res[key] === undefined ? delete res[key] : '',
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
return res;
|
|
139
|
-
}
|
|
140
|
-
//#endregion
|
|
141
|
-
|
|
142
|
-
//#region is allowed path
|
|
143
|
-
function isAlowedPath(key: string) {
|
|
144
|
-
let isAlowed = true;
|
|
145
|
-
const matchPath = relativePath === '' ? key : `${relativePath}:${key}`;
|
|
146
|
-
if (checkExclude) {
|
|
147
|
-
if (keysPathesToExclude.includes(matchPath)) {
|
|
148
|
-
// console.log(`Not allowed key: ${key}`)
|
|
149
|
-
isAlowed = false;
|
|
150
|
-
} else {
|
|
151
|
-
isAlowed = true;
|
|
152
|
-
}
|
|
153
|
-
} else if (checkInclude) {
|
|
154
|
-
if (keysPathesToInclude.includes(matchPath)) {
|
|
155
|
-
// console.log(`Allowed key: ${key}`)
|
|
156
|
-
isAlowed = true;
|
|
157
|
-
} else {
|
|
158
|
-
isAlowed = false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// console.log(`Is allowed;${matchPath} `, isAlowed)
|
|
162
|
-
return isAlowed;
|
|
163
|
-
}
|
|
164
|
-
//#endregion
|
|
165
|
-
|
|
166
|
-
const simpleResolved = [];
|
|
167
|
-
|
|
168
|
-
//#region resolve simple types
|
|
169
|
-
function resolveSimpleTypes() {
|
|
170
|
-
for (const key in target.prototype) {
|
|
171
|
-
if (
|
|
172
|
-
target.prototype.hasOwnProperty(key) &&
|
|
173
|
-
!___NS__isFunction(target.prototype[key])
|
|
174
|
-
) {
|
|
175
|
-
if (!isAlowedPath(key)) {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!___NS__isUndefined(mapping[key])) {
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const element = target.prototype[key];
|
|
184
|
-
let type: FormlyInputType = 'input';
|
|
185
|
-
if (___NS__isBoolean(element)) {
|
|
186
|
-
type = 'switch';
|
|
187
|
-
} else if (___NS__isDate(element)) {
|
|
188
|
-
type = 'datepicker';
|
|
189
|
-
} else if (___NS__isFunction(target['getOptionsFor'])) {
|
|
190
|
-
var selectOptions = target['getOptionsFor'](key);
|
|
191
|
-
if (!___NS__isUndefined(selectOptions)) {
|
|
192
|
-
type = 'select';
|
|
193
|
-
}
|
|
194
|
-
} else if (___NS__isFunction(target.prototype?.getOptionsFor)) {
|
|
195
|
-
var selectOptions = target.prototype?.getOptionsFor(key);
|
|
196
|
-
if (!___NS__isUndefined(selectOptions)) {
|
|
197
|
-
type = 'select';
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
fields.push(inputToPush(key, type, parentModel, { selectOptions }));
|
|
201
|
-
simpleResolved.push(key);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
//#endregion
|
|
206
|
-
|
|
207
|
-
//#region resolve complex types
|
|
208
|
-
function resolveComplexTypes() {
|
|
209
|
-
fieldNames
|
|
210
|
-
.filter(key => !simpleResolved.includes(key))
|
|
211
|
-
.forEach(key => {
|
|
212
|
-
if (isAlowedPath(key) && !___NS__isUndefined(mapping[key])) {
|
|
213
|
-
let className = mapping[key];
|
|
214
|
-
const isArray = ___NS__isArray(className);
|
|
215
|
-
className = isArray ? ___NS__first(className) : className;
|
|
216
|
-
|
|
217
|
-
if (className === 'Date') {
|
|
218
|
-
fields.push(inputToPush(key, 'datepicker', parentModel));
|
|
219
|
-
} else {
|
|
220
|
-
const targetChild = CLASS.getBy(className);
|
|
221
|
-
|
|
222
|
-
if (targetChild) {
|
|
223
|
-
const ftype = findTypeForEntity(targetChild, isArray);
|
|
224
|
-
|
|
225
|
-
if (ftype) {
|
|
226
|
-
fields = fields.concat(
|
|
227
|
-
inputToPush(key, ftype.name as any, key),
|
|
228
|
-
);
|
|
229
|
-
} else {
|
|
230
|
-
if (isArray) {
|
|
231
|
-
fields = fields.concat(
|
|
232
|
-
inputToPush(key, 'repeat', key, { targetChild }),
|
|
233
|
-
);
|
|
234
|
-
} else {
|
|
235
|
-
fields = fields.concat(
|
|
236
|
-
inputToPush(key, 'group', key, { targetChild }),
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
//#endregion
|
|
246
|
-
|
|
247
|
-
function generate() {
|
|
248
|
-
resolveSimpleTypes();
|
|
249
|
-
// console.log('after simple', fields);
|
|
250
|
-
resolveComplexTypes();
|
|
251
|
-
// console.log('after complext', fields);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
generate();
|
|
255
|
-
return fields.filter(f => !!f);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export type FormlyArrayTransformFn = (
|
|
259
|
-
fieldsArray: FormlyFieldConfig[],
|
|
260
|
-
fieldObject?: { [propKey: string]: FormlyFieldConfig },
|
|
261
|
-
) => FormlyFieldConfig[];
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { ClassHelpers__NS__asyncHandler, ClassHelpers__NS__ensureClassConfig, ClassHelpers__NS__ensureMethodConfig, ClassHelpers__NS__getClassConfig, ClassHelpers__NS__getClassFnFromObject, ClassHelpers__NS__getControllerConfigs, ClassHelpers__NS__getFullInternalName, ClassHelpers__NS__getMethodsNames, ClassHelpers__NS__getName, ClassHelpers__NS__getOrginalClass, ClassHelpers__NS__getUniqueKey, ClassHelpers__NS__hasParentClassWithName, ClassHelpers__NS__isContextClassObject, ClassHelpers__NS__setName } from '../helpers/class-helpers';
|
|
2
|
-
import { ___NS__add, ___NS__after, ___NS__ary, ___NS__assign, ___NS__assignIn, ___NS__assignInWith, ___NS__assignWith, ___NS__at, ___NS__attempt, ___NS__before, ___NS__bind, ___NS__bindAll, ___NS__bindKey, ___NS__camelCase, ___NS__capitalize, ___NS__castArray, ___NS__ceil, ___NS__chain, ___NS__chunk, ___NS__clamp, ___NS__clone, ___NS__cloneDeep, ___NS__cloneDeepWith, ___NS__cloneWith, ___NS__compact, ___NS__concat, ___NS__cond, ___NS__conforms, ___NS__conformsTo, ___NS__constant, ___NS__countBy, ___NS__create, ___NS__curry, ___NS__curryRight, ___NS__debounce, ___NS__deburr, ___NS__defaults, ___NS__defaultsDeep, ___NS__defaultTo, ___NS__defer, ___NS__delay, ___NS__difference, ___NS__differenceBy, ___NS__differenceWith, ___NS__divide, ___NS__drop, ___NS__dropRight, ___NS__dropRightWhile, ___NS__dropWhile, ___NS__each, ___NS__eachRight, ___NS__endsWith, ___NS__entries, ___NS__entriesIn, ___NS__eq, ___NS__escape, ___NS__escapeRegExp, ___NS__every, ___NS__extend, ___NS__extendWith, ___NS__fill, ___NS__filter, ___NS__find, ___NS__findIndex, ___NS__findKey, ___NS__findLast, ___NS__findLastIndex, ___NS__findLastKey, ___NS__first, ___NS__flatMap, ___NS__flatMapDeep, ___NS__flatMapDepth, ___NS__flatten, ___NS__flattenDeep, ___NS__flattenDepth, ___NS__flip, ___NS__floor, ___NS__flow, ___NS__flowRight, ___NS__forEach, ___NS__forEachRight, ___NS__forIn, ___NS__forInRight, ___NS__forOwn, ___NS__forOwnRight, ___NS__fromPairs, ___NS__functions, ___NS__functionsIn, ___NS__get, ___NS__groupBy, ___NS__gt, ___NS__gte, ___NS__has, ___NS__hasIn, ___NS__head, ___NS__identity, ___NS__includes, ___NS__indexOf, ___NS__initial, ___NS__inRange, ___NS__intersection, ___NS__intersectionBy, ___NS__intersectionWith, ___NS__invert, ___NS__invertBy, ___NS__invoke, ___NS__invokeMap, ___NS__isArguments, ___NS__isArray, ___NS__isArrayBuffer, ___NS__isArrayLike, ___NS__isArrayLikeObject, ___NS__isBoolean, ___NS__isBuffer, ___NS__isDate, ___NS__isElement, ___NS__isEmpty, ___NS__isEqual, ___NS__isEqualWith, ___NS__isError, ___NS__isFinite, ___NS__isFunction, ___NS__isInteger, ___NS__isLength, ___NS__isMap, ___NS__isMatch, ___NS__isMatchWith, ___NS__isNaN, ___NS__isNative, ___NS__isNil, ___NS__isNull, ___NS__isNumber, ___NS__isObject, ___NS__isObjectLike, ___NS__isPlainObject, ___NS__isRegExp, ___NS__isSafeInteger, ___NS__isSet, ___NS__isString, ___NS__isSymbol, ___NS__isTypedArray, ___NS__isUndefined, ___NS__isWeakMap, ___NS__isWeakSet, ___NS__iteratee, ___NS__join, ___NS__kebabCase, ___NS__keyBy, ___NS__keys, ___NS__keysIn, ___NS__last, ___NS__lastIndexOf, ___NS__lowerCase, ___NS__lowerFirst, ___NS__lt, ___NS__lte, ___NS__map, ___NS__mapKeys, ___NS__mapValues, ___NS__matches, ___NS__matchesProperty, ___NS__max, ___NS__maxBy, ___NS__mean, ___NS__meanBy, ___NS__memoize, ___NS__merge, ___NS__mergeWith, ___NS__method, ___NS__methodOf, ___NS__min, ___NS__minBy, ___NS__mixin, ___NS__multiply, ___NS__negate, ___NS__noop, ___NS__now, ___NS__nth, ___NS__nthArg, ___NS__omit, ___NS__omitBy, ___NS__once, ___NS__orderBy, ___NS__over, ___NS__overArgs, ___NS__overEvery, ___NS__overSome, ___NS__pad, ___NS__padEnd, ___NS__padStart, ___NS__parseInt, ___NS__partial, ___NS__partialRight, ___NS__partition, ___NS__pick, ___NS__pickBy, ___NS__property, ___NS__propertyOf, ___NS__pull, ___NS__pullAll, ___NS__pullAllBy, ___NS__pullAllWith, ___NS__pullAt, ___NS__random, ___NS__range, ___NS__rangeRight, ___NS__rearg, ___NS__reduce, ___NS__reduceRight, ___NS__reject, ___NS__remove, ___NS__repeat, ___NS__replace, ___NS__rest, ___NS__result, ___NS__reverse, ___NS__round, ___NS__sample, ___NS__sampleSize, ___NS__set, ___NS__setWith, ___NS__shuffle, ___NS__size, ___NS__slice, ___NS__snakeCase, ___NS__some, ___NS__sortBy, ___NS__sortedIndex, ___NS__sortedIndexBy, ___NS__sortedIndexOf, ___NS__sortedLastIndex, ___NS__sortedLastIndexBy, ___NS__sortedLastIndexOf, ___NS__sortedUniq, ___NS__sortedUniqBy, ___NS__split, ___NS__spread, ___NS__startCase, ___NS__startsWith, ___NS__stubArray, ___NS__stubFalse, ___NS__stubObject, ___NS__stubString, ___NS__stubTrue, ___NS__subtract, ___NS__sum, ___NS__sumBy, ___NS__tail, ___NS__take, ___NS__takeRight, ___NS__takeRightWhile, ___NS__takeWhile, ___NS__tap, ___NS__template, ___NS__templateSettings, ___NS__throttle, ___NS__thru, ___NS__times, ___NS__toArray, ___NS__toFinite, ___NS__toInteger, ___NS__toLength, ___NS__toLower, ___NS__toNumber, ___NS__toPairs, ___NS__toPairsIn, ___NS__toPath, ___NS__toPlainObject, ___NS__toSafeInteger, ___NS__toString, ___NS__toUpper, ___NS__transform, ___NS__trim, ___NS__trimEnd, ___NS__trimStart, ___NS__truncate, ___NS__unary, ___NS__unescape, ___NS__union, ___NS__unionBy, ___NS__unionWith, ___NS__uniq, ___NS__uniqBy, ___NS__uniqueId, ___NS__uniqWith, ___NS__unset, ___NS__unzip, ___NS__unzipWith, ___NS__update, ___NS__updateWith, ___NS__upperCase, ___NS__upperFirst, ___NS__values, ___NS__valuesIn, ___NS__without, ___NS__words, ___NS__wrap, ___NS__xor, ___NS__xorBy, ___NS__xorWith, ___NS__zip, ___NS__zipObject, ___NS__zipObjectDeep, ___NS__zipWith } from 'tnp-core/lib-prod';
|
|
3
|
-
|
|
4
|
-
export function findTypeForEntity(entity: Function, isArray: boolean = false) {
|
|
5
|
-
if (!___NS__isArray(RegisterComponentType.prototype.types)) {
|
|
6
|
-
RegisterComponentType.prototype.types = [];
|
|
7
|
-
}
|
|
8
|
-
return getRegisteredComponents().find(
|
|
9
|
-
c => c.entity === entity && c.isArray === isArray,
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type FormlyEntityType = {
|
|
14
|
-
name: string;
|
|
15
|
-
component: Function;
|
|
16
|
-
entity?: Function;
|
|
17
|
-
isArray?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function typeFromEntity(
|
|
21
|
-
component: Function,
|
|
22
|
-
entity?: Function | Function[],
|
|
23
|
-
) {
|
|
24
|
-
const isArray = ___NS__isArray(entity);
|
|
25
|
-
if (isArray) {
|
|
26
|
-
entity = ___NS__first(entity as any);
|
|
27
|
-
}
|
|
28
|
-
let name = ClassHelpers__NS__getName(component);
|
|
29
|
-
let res = { name, component, entity, isArray };
|
|
30
|
-
// console.log(res);
|
|
31
|
-
return res;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function typeFromName(component: Function, name: string) {
|
|
35
|
-
let res = { name, component };
|
|
36
|
-
return res;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function RegisterComponentTypeForEntity(entity: Function | Function[]) {
|
|
40
|
-
if (!___NS__isArray(RegisterComponentType.prototype.types)) {
|
|
41
|
-
RegisterComponentType.prototype.types = [];
|
|
42
|
-
}
|
|
43
|
-
return function (
|
|
44
|
-
target: any,
|
|
45
|
-
propertyKey: string,
|
|
46
|
-
descriptor: PropertyDescriptor,
|
|
47
|
-
) {
|
|
48
|
-
RegisterComponentType.prototype.types.push(typeFromEntity(target, entity));
|
|
49
|
-
} as any;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function RegisterComponentType(
|
|
53
|
-
className: string,
|
|
54
|
-
...optionslNames: string[]
|
|
55
|
-
) {
|
|
56
|
-
if (!___NS__isArray(RegisterComponentType.prototype.types)) {
|
|
57
|
-
RegisterComponentType.prototype.types = [];
|
|
58
|
-
}
|
|
59
|
-
return function (
|
|
60
|
-
target: any,
|
|
61
|
-
propertyKey: string,
|
|
62
|
-
descriptor: PropertyDescriptor,
|
|
63
|
-
) {
|
|
64
|
-
ClassHelpers__NS__setName(target, className);
|
|
65
|
-
RegisterComponentType.prototype.types.push(typeFromEntity(target));
|
|
66
|
-
optionslNames.forEach(name => {
|
|
67
|
-
RegisterComponentType.prototype.types.push(typeFromName(target, name));
|
|
68
|
-
});
|
|
69
|
-
} as any;
|
|
70
|
-
}
|
|
71
|
-
// RegisterComponentType.prototype.types = []
|
|
72
|
-
|
|
73
|
-
export function getRegisteredComponents() {
|
|
74
|
-
let registered = RegisterComponentType.prototype.types as FormlyEntityType[];
|
|
75
|
-
if (!Array.isArray(registered)) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
// console.log(registered)
|
|
79
|
-
return registered;
|
|
80
|
-
}
|