@memberjunction/core 0.9.0
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/dist/generic/applicationInfo.d.ts +26 -0
- package/dist/generic/applicationInfo.js +57 -0
- package/dist/generic/applicationInfo.js.map +1 -0
- package/dist/generic/baseEntity.d.ts +88 -0
- package/dist/generic/baseEntity.js +450 -0
- package/dist/generic/baseEntity.js.map +1 -0
- package/dist/generic/baseInfo.d.ts +8 -0
- package/dist/generic/baseInfo.js +38 -0
- package/dist/generic/baseInfo.js.map +1 -0
- package/dist/generic/entityInfo.d.ts +340 -0
- package/dist/generic/entityInfo.js +647 -0
- package/dist/generic/entityInfo.js.map +1 -0
- package/dist/generic/interfaces.d.ts +235 -0
- package/dist/generic/interfaces.js +51 -0
- package/dist/generic/interfaces.js.map +1 -0
- package/dist/generic/logging.d.ts +4 -0
- package/dist/generic/logging.js +69 -0
- package/dist/generic/logging.js.map +1 -0
- package/dist/generic/metadata.d.ts +155 -0
- package/dist/generic/metadata.js +227 -0
- package/dist/generic/metadata.js.map +1 -0
- package/dist/generic/providerBase.d.ts +134 -0
- package/dist/generic/providerBase.js +517 -0
- package/dist/generic/providerBase.js.map +1 -0
- package/dist/generic/runReport.d.ts +11 -0
- package/dist/generic/runReport.js +27 -0
- package/dist/generic/runReport.js.map +1 -0
- package/dist/generic/runView.d.ts +106 -0
- package/dist/generic/runView.js +36 -0
- package/dist/generic/runView.js.map +1 -0
- package/dist/generic/securityInfo.d.ts +99 -0
- package/dist/generic/securityInfo.js +195 -0
- package/dist/generic/securityInfo.js.map +1 -0
- package/dist/generic/transactionGroup.d.ts +24 -0
- package/dist/generic/transactionGroup.js +79 -0
- package/dist/generic/transactionGroup.js.map +1 -0
- package/dist/generic/util.d.ts +4 -0
- package/dist/generic/util.js +100 -0
- package/dist/generic/util.js.map +1 -0
- package/dist/generic/viewInfo.d.ts +57 -0
- package/dist/generic/viewInfo.js +121 -0
- package/dist/generic/viewInfo.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/views/UserViewEntityBase.d.ts +171 -0
- package/dist/views/UserViewEntityBase.js +466 -0
- package/dist/views/UserViewEntityBase.js.map +1 -0
- package/dist/views/runView.d.ts +106 -0
- package/dist/views/runView.js +36 -0
- package/dist/views/runView.js.map +1 -0
- package/dist/views/viewInfo.d.ts +0 -0
- package/dist/views/viewInfo.js +118 -0
- package/dist/views/viewInfo.js.map +1 -0
- package/package.json +24 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { IRunViewProvider, RunViewResult } from './interfaces';
|
|
2
|
+
import { UserInfo } from './securityInfo';
|
|
3
|
+
import { BaseEntity } from './baseEntity';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for running either a stored or dynamic view.
|
|
6
|
+
* A stored view is a view that is saved in the database and can be run either by ID or Name.
|
|
7
|
+
* A dynamic view is one that is not stored in the database and you provide parameters to return data as
|
|
8
|
+
* desired programatically.
|
|
9
|
+
*/
|
|
10
|
+
export type RunViewParams = {
|
|
11
|
+
/**
|
|
12
|
+
* optional - ID of the UserView record to run, if provided, ViewName is ignored
|
|
13
|
+
*/
|
|
14
|
+
ViewID?: number;
|
|
15
|
+
/**
|
|
16
|
+
* optional - Name of the UserView record to run, if you are using this, make sure to use a naming convention
|
|
17
|
+
* so that your view names are unique. For example use a prefix like __Entity_View_ etc so that you're
|
|
18
|
+
* likely to have a single result. If more than one view is available that matches a provided view name an
|
|
19
|
+
* exception will be thrown.
|
|
20
|
+
*/
|
|
21
|
+
ViewName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* optional - this is the loaded instance of the BaseEntity (UserViewEntityComplete or a subclass of it).
|
|
24
|
+
* This is the preferred parameter to use IF you already have a view entity object loaded up in your code
|
|
25
|
+
* becuase by passing this in, the RunView() method doesn't have to lookup all the metadata for the view and it is faster.
|
|
26
|
+
* If you provide ViewEntity, ViewID/ViewName are ignored.
|
|
27
|
+
*/
|
|
28
|
+
ViewEntity?: BaseEntity;
|
|
29
|
+
/**
|
|
30
|
+
* optional - this is only used if ViewID/ViewName/ViewEntity are not provided, it is used for
|
|
31
|
+
* Dynamic Views in combination with the optional ExtraFilter
|
|
32
|
+
*/
|
|
33
|
+
EntityName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* An optional SQL WHERE clause that you can add to the existing filters on a stored view. For dynamic views, you can either
|
|
36
|
+
* run a view without a filter (if the entity definition allows it with AllowAllRowsAPI=1) or filter with any valid SQL WHERE clause.
|
|
37
|
+
*/
|
|
38
|
+
ExtraFilter?: string;
|
|
39
|
+
/**
|
|
40
|
+
* An optional SQL ORDER BY clause that you can use for dynamic views, as well as to OVERRIDE the stored view's sorting order.
|
|
41
|
+
*/
|
|
42
|
+
OrderBy?: string;
|
|
43
|
+
/**
|
|
44
|
+
* An optional array of field names that you want returned. The RunView() function will always return ID so you don't need to ask for that. If you leave this null then
|
|
45
|
+
* for a dynamic view all fields are returned, and for stored views, the fields stored in it view configuration are returned.
|
|
46
|
+
*/
|
|
47
|
+
Fields?: string[];
|
|
48
|
+
/**
|
|
49
|
+
* optional - string that represents a user "search" - typically from a text search option in a UI somewhere. This field is then used in the view filtering to search whichever fields are configured to be included in search in the Entity Fields definition.
|
|
50
|
+
* Search String is combined with the stored view filters as well as ExtraFilter with an AND.
|
|
51
|
+
*/
|
|
52
|
+
UserSearchString?: string;
|
|
53
|
+
/**
|
|
54
|
+
* optional - if provided, records that were returned in the specified UserViewRunID will NOT be allowed in the result set.
|
|
55
|
+
* This is useful if you want to run a particular view over time and exclude a specific prior run's resulting data set. If you
|
|
56
|
+
* want to exclude ALL data returned from ALL prior runs, use the ExcludeDataFromAllPriorViewRuns property instead.
|
|
57
|
+
*/
|
|
58
|
+
ExcludeUserViewRunID?: number;
|
|
59
|
+
/**
|
|
60
|
+
* optional - if set to true, the resulting data will filter out ANY records that were ever returned by this view, when the SaveViewResults property was set to true.
|
|
61
|
+
* This is useful if you want to run a particular view over time and make sure the results returned each time are new to the view.
|
|
62
|
+
*/
|
|
63
|
+
ExcludeDataFromAllPriorViewRuns?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* optional - if you are providing the optional ExcludeUserViewRunID property, you can also optionally provide
|
|
66
|
+
* this filter which will negate the specific list of record IDs that are excluded by the ExcludeUserViewRunID property.
|
|
67
|
+
* This can be useful if you want to ensure a certain class of data is always allowed into your view and not filtered out
|
|
68
|
+
* by a prior view run.
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
OverrideExcludeFilter?: string;
|
|
72
|
+
/**
|
|
73
|
+
* optional - if set to true, the LIST OF ID values from the view run will be stored in the User View Runs entity and the
|
|
74
|
+
* newly created UserViewRun.ID value will be returned in the RunViewResult that the RunView() function sends back to ya.
|
|
75
|
+
*/
|
|
76
|
+
SaveViewResults?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* optional - if set to true, if there IS any UserViewMaxRows property set for the entity in question, it will be IGNORED. This is useful in scenarios where you
|
|
79
|
+
* want to programmatically run a view and get ALL the data back, regardless of the MaxRows setting on the entity.
|
|
80
|
+
*/
|
|
81
|
+
IgnoreMaxRows?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* optional - if set to true, the view run will ALWAYS be logged to the Audit Log, regardless of the entity's property settings for logging view runs.
|
|
84
|
+
*/
|
|
85
|
+
ForceAuditLog?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* optional - if provided and either ForceAuditLog is set, or the entity's property settings for logging view runs are set to true, this will be used as the Audit Log Description.
|
|
88
|
+
*/
|
|
89
|
+
AuditLogDescription?: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Class for runnings views in a generic, tier-independent manner - uses a provider model for
|
|
93
|
+
* implementation transparently from the viewpoint of the consumer of the class.
|
|
94
|
+
*/
|
|
95
|
+
export declare class RunView {
|
|
96
|
+
/**
|
|
97
|
+
* Runs a view based on the provided parameters, see documentation for RunViewParams for more
|
|
98
|
+
* @param params
|
|
99
|
+
* @param contextUser if provided, this user is used for permissions and logging. For server based calls, this is generally required because there is no "Current User" since this object is shared across all requests.
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
RunView(params: RunViewParams, contextUser?: UserInfo): Promise<RunViewResult>;
|
|
103
|
+
private static _globalProviderKey;
|
|
104
|
+
static get Provider(): IRunViewProvider;
|
|
105
|
+
static set Provider(value: IRunViewProvider);
|
|
106
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunView = void 0;
|
|
4
|
+
const mj_global_1 = require("mj_global");
|
|
5
|
+
/**
|
|
6
|
+
* Class for runnings views in a generic, tier-independent manner - uses a provider model for
|
|
7
|
+
* implementation transparently from the viewpoint of the consumer of the class.
|
|
8
|
+
*/
|
|
9
|
+
class RunView {
|
|
10
|
+
/**
|
|
11
|
+
* Runs a view based on the provided parameters, see documentation for RunViewParams for more
|
|
12
|
+
* @param params
|
|
13
|
+
* @param contextUser if provided, this user is used for permissions and logging. For server based calls, this is generally required because there is no "Current User" since this object is shared across all requests.
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
async RunView(params, contextUser) {
|
|
17
|
+
return RunView.Provider.RunView(params, contextUser);
|
|
18
|
+
}
|
|
19
|
+
static get Provider() {
|
|
20
|
+
const g = mj_global_1.MJGlobal.Instance.GetGlobalObjectStore();
|
|
21
|
+
if (g)
|
|
22
|
+
return g[RunView._globalProviderKey];
|
|
23
|
+
else
|
|
24
|
+
throw new Error('No global object store, so we cant get the static provider');
|
|
25
|
+
}
|
|
26
|
+
static set Provider(value) {
|
|
27
|
+
const g = mj_global_1.MJGlobal.Instance.GetGlobalObjectStore();
|
|
28
|
+
if (g)
|
|
29
|
+
g[RunView._globalProviderKey] = value;
|
|
30
|
+
else
|
|
31
|
+
throw new Error('No global object store, so we cant set the static provider');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
RunView._globalProviderKey = 'MJ_RunViewProvider';
|
|
35
|
+
exports.RunView = RunView;
|
|
36
|
+
//# sourceMappingURL=runView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runView.js","sourceRoot":"","sources":["../../src/generic/runView.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AA6FrC;;;GAGG;AACH,MAAa,OAAO;IAChB;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAAC,MAAqB,EAAE,WAAsB;QAC9D,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzD,CAAC;IAGM,MAAM,KAAK,QAAQ;QACtB,MAAM,CAAC,GAAG,oBAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YACD,OAAO,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;;YAErC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACtF,CAAC;IACM,MAAM,KAAK,QAAQ,CAAC,KAAuB;QAC9C,MAAM,CAAC,GAAG,oBAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YACD,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC;;YAEtC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACtF,CAAC;;AAdc,0BAAkB,GAAW,oBAAoB,CAAC;AAXxD,0BAAO"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { BaseInfo } from "./baseInfo";
|
|
2
|
+
import { IMetadataProvider } from "./interfaces";
|
|
3
|
+
export declare class UserInfo extends BaseInfo {
|
|
4
|
+
Name: string;
|
|
5
|
+
FirstName: string;
|
|
6
|
+
LastName: string;
|
|
7
|
+
Title: string;
|
|
8
|
+
Email: string;
|
|
9
|
+
Type: string;
|
|
10
|
+
IsActive: boolean;
|
|
11
|
+
LinkedRecordType: 'None' | 'Employee' | 'Other';
|
|
12
|
+
EmployeeID: number;
|
|
13
|
+
LinkedEntityID: number;
|
|
14
|
+
LinkedEntityRecordID: number;
|
|
15
|
+
CreatedAt: Date;
|
|
16
|
+
UpdatedAt: Date;
|
|
17
|
+
FirstLast: string;
|
|
18
|
+
EmployeeFirstLast: string;
|
|
19
|
+
EmployeeEmail: string;
|
|
20
|
+
EmployeeTitle: string;
|
|
21
|
+
EmployeeSupervisor: string;
|
|
22
|
+
EmployeeSupervisorEmail: string;
|
|
23
|
+
private _UserRoles;
|
|
24
|
+
get UserRoles(): UserRoleInfo[];
|
|
25
|
+
constructor(md: IMetadataProvider, initData?: any);
|
|
26
|
+
SetupUserRoles(md: IMetadataProvider, userRoles: UserRoleInfo[]): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class UserRoleInfo extends BaseInfo {
|
|
29
|
+
UserID: number;
|
|
30
|
+
RoleName: string;
|
|
31
|
+
CreatedAt: Date;
|
|
32
|
+
UpdatedAt: Date;
|
|
33
|
+
User: string;
|
|
34
|
+
private _RoleInfo;
|
|
35
|
+
get RoleInfo(): RoleInfo;
|
|
36
|
+
_setRole(role: RoleInfo): void;
|
|
37
|
+
constructor(initData: any);
|
|
38
|
+
}
|
|
39
|
+
export declare class RoleInfo extends BaseInfo {
|
|
40
|
+
Name: string;
|
|
41
|
+
Description: string;
|
|
42
|
+
AzureID: string;
|
|
43
|
+
SQLName: string;
|
|
44
|
+
CreatedAt: Date;
|
|
45
|
+
UpdatedAt: Date;
|
|
46
|
+
constructor(initData: any);
|
|
47
|
+
}
|
|
48
|
+
export declare class RowLevelSecurityFilterInfo extends BaseInfo {
|
|
49
|
+
Name: string;
|
|
50
|
+
Description: string;
|
|
51
|
+
FilterText: string;
|
|
52
|
+
CreatedAt: Date;
|
|
53
|
+
UpdatedAt: Date;
|
|
54
|
+
constructor(initData: any);
|
|
55
|
+
MarkupFilterText(user: UserInfo): string;
|
|
56
|
+
}
|
|
57
|
+
export declare class AuthorizationInfo extends BaseInfo {
|
|
58
|
+
ParentID: number;
|
|
59
|
+
Name: string;
|
|
60
|
+
IsActive: boolean;
|
|
61
|
+
UseAuditLog: boolean;
|
|
62
|
+
Description: string;
|
|
63
|
+
CreatedAt: Date;
|
|
64
|
+
UpdatedAt: Date;
|
|
65
|
+
Parent: string;
|
|
66
|
+
private _AuthorizationRoles;
|
|
67
|
+
get Roles(): AuthorizationRoleInfo[];
|
|
68
|
+
constructor(md: IMetadataProvider, initData?: any);
|
|
69
|
+
SetupAuthorizationRoles(md: IMetadataProvider, authorizationRoles: AuthorizationRoleInfo[]): void;
|
|
70
|
+
UserCanExecute(user: UserInfo): boolean;
|
|
71
|
+
}
|
|
72
|
+
export declare enum AuthorizationRoleType {
|
|
73
|
+
Allow = 1,
|
|
74
|
+
Deny = 2
|
|
75
|
+
}
|
|
76
|
+
export declare class AuthorizationRoleInfo extends BaseInfo {
|
|
77
|
+
AuthorizationName: string;
|
|
78
|
+
RoleName: string;
|
|
79
|
+
Type: string;
|
|
80
|
+
CreatedAt: Date;
|
|
81
|
+
UpdatedAt: Date;
|
|
82
|
+
Authorization: string;
|
|
83
|
+
Role: string;
|
|
84
|
+
private _RoleInfo;
|
|
85
|
+
get RoleInfo(): RoleInfo;
|
|
86
|
+
AuthorizationType(): AuthorizationRoleType;
|
|
87
|
+
_setRole(role: RoleInfo): void;
|
|
88
|
+
constructor(initData: any);
|
|
89
|
+
}
|
|
90
|
+
export declare class AuditLogTypeInfo extends BaseInfo {
|
|
91
|
+
ParentID: number;
|
|
92
|
+
Name: string;
|
|
93
|
+
Description: string;
|
|
94
|
+
AuthorizationName: string;
|
|
95
|
+
CreatedAt: Date;
|
|
96
|
+
UpdatedAt: Date;
|
|
97
|
+
Parent: string;
|
|
98
|
+
constructor(initData: any);
|
|
99
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditLogTypeInfo = exports.AuthorizationRoleInfo = exports.AuthorizationRoleType = exports.AuthorizationInfo = exports.RowLevelSecurityFilterInfo = exports.RoleInfo = exports.UserRoleInfo = exports.UserInfo = void 0;
|
|
4
|
+
const baseInfo_1 = require("./baseInfo");
|
|
5
|
+
class UserInfo extends baseInfo_1.BaseInfo {
|
|
6
|
+
get UserRoles() {
|
|
7
|
+
return this._UserRoles;
|
|
8
|
+
}
|
|
9
|
+
constructor(md, initData = null) {
|
|
10
|
+
super();
|
|
11
|
+
this.Name = null;
|
|
12
|
+
this.FirstName = null;
|
|
13
|
+
this.LastName = null;
|
|
14
|
+
this.Title = null;
|
|
15
|
+
this.Email = null;
|
|
16
|
+
this.Type = null;
|
|
17
|
+
this.IsActive = null;
|
|
18
|
+
this.LinkedRecordType = null;
|
|
19
|
+
this.EmployeeID = null;
|
|
20
|
+
this.LinkedEntityID = null;
|
|
21
|
+
this.LinkedEntityRecordID = null;
|
|
22
|
+
this.CreatedAt = null;
|
|
23
|
+
this.UpdatedAt = null;
|
|
24
|
+
// virtual fields - returned by the database VIEW
|
|
25
|
+
this.FirstLast = null;
|
|
26
|
+
this.EmployeeFirstLast = null;
|
|
27
|
+
this.EmployeeEmail = null;
|
|
28
|
+
this.EmployeeTitle = null;
|
|
29
|
+
this.EmployeeSupervisor = null;
|
|
30
|
+
this.EmployeeSupervisorEmail = null;
|
|
31
|
+
this._UserRoles = [];
|
|
32
|
+
this.copyInitData(initData);
|
|
33
|
+
if (initData)
|
|
34
|
+
this.SetupUserRoles(md, initData.UserRoles || initData._UserRoles);
|
|
35
|
+
}
|
|
36
|
+
SetupUserRoles(md, userRoles) {
|
|
37
|
+
if (userRoles) {
|
|
38
|
+
const mdRoles = md.Roles;
|
|
39
|
+
this._UserRoles = [];
|
|
40
|
+
for (let i = 0; i < userRoles.length; i++) {
|
|
41
|
+
//
|
|
42
|
+
const uri = new UserRoleInfo(userRoles[i]);
|
|
43
|
+
this._UserRoles.push(uri);
|
|
44
|
+
const match = mdRoles.find(r => r.Name.trim().toLowerCase() == uri.RoleName.trim().toLowerCase());
|
|
45
|
+
if (match)
|
|
46
|
+
uri._setRole(match);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.UserInfo = UserInfo;
|
|
52
|
+
class UserRoleInfo extends baseInfo_1.BaseInfo {
|
|
53
|
+
get RoleInfo() {
|
|
54
|
+
return this._RoleInfo;
|
|
55
|
+
}
|
|
56
|
+
_setRole(role) {
|
|
57
|
+
this._RoleInfo = role;
|
|
58
|
+
}
|
|
59
|
+
constructor(initData) {
|
|
60
|
+
super();
|
|
61
|
+
this.UserID = null;
|
|
62
|
+
this.RoleName = null;
|
|
63
|
+
this.CreatedAt = null;
|
|
64
|
+
this.UpdatedAt = null;
|
|
65
|
+
// virtual fields - returned by the database VIEW
|
|
66
|
+
this.User = null;
|
|
67
|
+
this._RoleInfo = null;
|
|
68
|
+
this.copyInitData(initData);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.UserRoleInfo = UserRoleInfo;
|
|
72
|
+
class RoleInfo extends baseInfo_1.BaseInfo {
|
|
73
|
+
constructor(initData) {
|
|
74
|
+
super();
|
|
75
|
+
this.Name = null;
|
|
76
|
+
this.Description = null;
|
|
77
|
+
this.AzureID = null;
|
|
78
|
+
this.SQLName = null;
|
|
79
|
+
this.CreatedAt = null;
|
|
80
|
+
this.UpdatedAt = null;
|
|
81
|
+
this.copyInitData(initData);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.RoleInfo = RoleInfo;
|
|
85
|
+
class RowLevelSecurityFilterInfo extends baseInfo_1.BaseInfo {
|
|
86
|
+
constructor(initData) {
|
|
87
|
+
super();
|
|
88
|
+
this.Name = null;
|
|
89
|
+
this.Description = null;
|
|
90
|
+
this.FilterText = null;
|
|
91
|
+
this.CreatedAt = null;
|
|
92
|
+
this.UpdatedAt = null;
|
|
93
|
+
this.copyInitData(initData);
|
|
94
|
+
}
|
|
95
|
+
MarkupFilterText(user) {
|
|
96
|
+
let ret = this.FilterText;
|
|
97
|
+
if (user) {
|
|
98
|
+
const keys = Object.keys(user);
|
|
99
|
+
for (let i = 0; i < keys.length; i++) {
|
|
100
|
+
const key = keys[i];
|
|
101
|
+
const val = user[key];
|
|
102
|
+
if (val && typeof val == 'string') {
|
|
103
|
+
ret = ret.replace(new RegExp(`{{User${key}}}`, 'g'), val);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.RowLevelSecurityFilterInfo = RowLevelSecurityFilterInfo;
|
|
111
|
+
class AuthorizationInfo extends baseInfo_1.BaseInfo {
|
|
112
|
+
get Roles() {
|
|
113
|
+
return this._AuthorizationRoles;
|
|
114
|
+
}
|
|
115
|
+
constructor(md, initData = null) {
|
|
116
|
+
super();
|
|
117
|
+
this.ParentID = null;
|
|
118
|
+
this.Name = null;
|
|
119
|
+
this.IsActive = null;
|
|
120
|
+
this.UseAuditLog = null;
|
|
121
|
+
this.Description = null;
|
|
122
|
+
this.CreatedAt = null;
|
|
123
|
+
this.UpdatedAt = null;
|
|
124
|
+
this._AuthorizationRoles = [];
|
|
125
|
+
this.copyInitData(initData);
|
|
126
|
+
if (initData)
|
|
127
|
+
this.SetupAuthorizationRoles(md, initData.AuthorizationRoles || initData._AuthorizationRoles);
|
|
128
|
+
}
|
|
129
|
+
SetupAuthorizationRoles(md, authorizationRoles) {
|
|
130
|
+
if (authorizationRoles) {
|
|
131
|
+
const mdRoles = md.Roles;
|
|
132
|
+
this._AuthorizationRoles = [];
|
|
133
|
+
for (let i = 0; i < authorizationRoles.length; i++) {
|
|
134
|
+
//
|
|
135
|
+
const ari = new AuthorizationRoleInfo(authorizationRoles[i]);
|
|
136
|
+
this._AuthorizationRoles.push(ari);
|
|
137
|
+
const match = mdRoles.find(r => r.Name.trim().toLowerCase() == ari.RoleName.trim().toLowerCase());
|
|
138
|
+
if (match)
|
|
139
|
+
ari._setRole(match);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
UserCanExecute(user) {
|
|
144
|
+
if (this.IsActive && user && user.UserRoles) {
|
|
145
|
+
for (let i = 0; i < user.UserRoles.length; i++) {
|
|
146
|
+
const matchingRole = this.Roles.find(r => r.RoleName == user.UserRoles[i].RoleName);
|
|
147
|
+
if (matchingRole)
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.AuthorizationInfo = AuthorizationInfo;
|
|
155
|
+
var AuthorizationRoleType;
|
|
156
|
+
(function (AuthorizationRoleType) {
|
|
157
|
+
AuthorizationRoleType[AuthorizationRoleType["Allow"] = 1] = "Allow";
|
|
158
|
+
AuthorizationRoleType[AuthorizationRoleType["Deny"] = 2] = "Deny";
|
|
159
|
+
})(AuthorizationRoleType = exports.AuthorizationRoleType || (exports.AuthorizationRoleType = {}));
|
|
160
|
+
class AuthorizationRoleInfo extends baseInfo_1.BaseInfo {
|
|
161
|
+
get RoleInfo() {
|
|
162
|
+
return this._RoleInfo;
|
|
163
|
+
}
|
|
164
|
+
AuthorizationType() {
|
|
165
|
+
return this.Type.trim().toLowerCase() === 'allow' ? AuthorizationRoleType.Allow : AuthorizationRoleType.Deny;
|
|
166
|
+
}
|
|
167
|
+
_setRole(role) {
|
|
168
|
+
this._RoleInfo = role;
|
|
169
|
+
}
|
|
170
|
+
constructor(initData) {
|
|
171
|
+
super();
|
|
172
|
+
this.AuthorizationName = null;
|
|
173
|
+
this.RoleName = null;
|
|
174
|
+
this.Type = null;
|
|
175
|
+
this.CreatedAt = null;
|
|
176
|
+
this.UpdatedAt = null;
|
|
177
|
+
this._RoleInfo = null;
|
|
178
|
+
this.copyInitData(initData);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.AuthorizationRoleInfo = AuthorizationRoleInfo;
|
|
182
|
+
class AuditLogTypeInfo extends baseInfo_1.BaseInfo {
|
|
183
|
+
constructor(initData) {
|
|
184
|
+
super();
|
|
185
|
+
this.ParentID = null;
|
|
186
|
+
this.Name = null;
|
|
187
|
+
this.Description = null;
|
|
188
|
+
this.AuthorizationName = null;
|
|
189
|
+
this.CreatedAt = null;
|
|
190
|
+
this.UpdatedAt = null;
|
|
191
|
+
this.copyInitData(initData);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
exports.AuditLogTypeInfo = AuditLogTypeInfo;
|
|
195
|
+
//# sourceMappingURL=securityInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"securityInfo.js","sourceRoot":"","sources":["../../src/generic/securityInfo.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAGtC,MAAa,QAAS,SAAQ,mBAAQ;IAyBlC,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,YAAa,EAAqB,EAAE,WAAgB,IAAI;QACpD,KAAK,EAAE,CAAA;QA7BX,SAAI,GAAW,IAAI,CAAA;QACnB,cAAS,GAAW,IAAI,CAAA;QACxB,aAAQ,GAAW,IAAI,CAAA;QACvB,UAAK,GAAW,IAAI,CAAA;QACpB,UAAK,GAAW,IAAI,CAAA;QACpB,SAAI,GAAW,IAAI,CAAA;QACnB,aAAQ,GAAY,IAAI,CAAA;QACxB,qBAAgB,GAAkC,IAAI,CAAA;QACtD,eAAU,GAAW,IAAI,CAAA;QACzB,mBAAc,GAAW,IAAI,CAAA;QAC7B,yBAAoB,GAAW,IAAI,CAAA;QACnC,cAAS,GAAS,IAAI,CAAA;QACtB,cAAS,GAAS,IAAI,CAAA;QAEtB,iDAAiD;QACjD,cAAS,GAAW,IAAI,CAAA;QACxB,sBAAiB,GAAW,IAAI,CAAA;QAChC,kBAAa,GAAW,IAAI,CAAA;QAC5B,kBAAa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,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAA;IAChH,CAAC;IAED,QAAQ,CAAC,IAAc;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;IACzB,CAAC;IAED,YAAa,QAAa;QACtB,KAAK,EAAE,CAAC;QAxBZ,sBAAiB,GAAW,IAAI,CAAA;QAChC,aAAQ,GAAW,IAAI,CAAA;QACvB,SAAI,GAAW,IAAI,CAAA;QACnB,cAAS,GAAS,IAAI,CAAA;QACtB,cAAS,GAAS,IAAI,CAAA;QAMd,cAAS,GAAa,IAAI,CAAA;QAe9B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;CACJ;AA5BD,sDA4BC;AAED,MAAa,gBAAiB,SAAQ,mBAAQ;IAW1C,YAAa,QAAa;QACtB,KAAK,EAAE,CAAC;QAXZ,aAAQ,GAAW,IAAI,CAAA;QACvB,SAAI,GAAW,IAAI,CAAA;QACnB,gBAAW,GAAW,IAAI,CAAA;QAC1B,sBAAiB,GAAW,IAAI,CAAA;QAChC,cAAS,GAAS,IAAI,CAAA;QACtB,cAAS,GAAS,IAAI,CAAA;QAOlB,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;CACJ;AAfD,4CAeC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class TransactionItem {
|
|
2
|
+
private _instruction;
|
|
3
|
+
private _vars;
|
|
4
|
+
private _callBack;
|
|
5
|
+
private _extraData;
|
|
6
|
+
get Vars(): any;
|
|
7
|
+
get ExtraData(): any;
|
|
8
|
+
get Instruction(): string;
|
|
9
|
+
get CallBack(): Function;
|
|
10
|
+
constructor(instruction: string, vars: any, extraData: any, callBack: Function);
|
|
11
|
+
}
|
|
12
|
+
export declare class TransactionResult {
|
|
13
|
+
Transaction: TransactionItem;
|
|
14
|
+
Result: any;
|
|
15
|
+
Success: boolean;
|
|
16
|
+
constructor(transaction: TransactionItem, result: any, success: boolean);
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class TransactionGroupBase {
|
|
19
|
+
private _pendingTransactions;
|
|
20
|
+
protected PendingTransactions(): TransactionItem[];
|
|
21
|
+
AddTransaction(transaction: TransactionItem): void;
|
|
22
|
+
protected abstract HandleSubmit(item: TransactionItem[]): Promise<TransactionResult[]>;
|
|
23
|
+
Submit(): Promise<boolean>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* TransactionGroup is a class that handles the bundling of multiple transactions into a single request. The provider handles
|
|
3
|
+
the implementation details. If a transaction group is provided to the baseEntity object before either Save() or Delete() is called
|
|
4
|
+
instead of just immediately executing its SQL or GQL, it provides the instructions to the TransactionGroup object instead.
|
|
5
|
+
|
|
6
|
+
Then, whenever the TransactionGroup object instance has its Submit() method called, all of the requests will be bundled into a single
|
|
7
|
+
request and handled. For example in the case of the GraphQLDataProvider, we queue up all of the GQL statements for all of the
|
|
8
|
+
mutations and send them across as a single GraphQL request. The GraphQL server handles the actual DB transaction stuff.
|
|
9
|
+
|
|
10
|
+
TransactionGroup will call a callback function, if provided, after the transaction has either completed succesfully or failed.
|
|
11
|
+
If it is succesful, for Save() method calls, the latest data for that record will be provided back.
|
|
12
|
+
For Delete() method calls, the callback will be called with no data.
|
|
13
|
+
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.TransactionGroupBase = exports.TransactionResult = exports.TransactionItem = void 0;
|
|
17
|
+
class TransactionItem {
|
|
18
|
+
get Vars() {
|
|
19
|
+
return this._vars;
|
|
20
|
+
}
|
|
21
|
+
get ExtraData() {
|
|
22
|
+
return this._extraData;
|
|
23
|
+
}
|
|
24
|
+
get Instruction() {
|
|
25
|
+
return this._instruction;
|
|
26
|
+
}
|
|
27
|
+
get CallBack() {
|
|
28
|
+
return this._callBack;
|
|
29
|
+
}
|
|
30
|
+
constructor(instruction, vars, extraData, callBack) {
|
|
31
|
+
this._instruction = instruction;
|
|
32
|
+
this._vars = vars;
|
|
33
|
+
this._extraData = extraData;
|
|
34
|
+
this._callBack = callBack;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.TransactionItem = TransactionItem;
|
|
38
|
+
class TransactionResult {
|
|
39
|
+
constructor(transaction, result, success) {
|
|
40
|
+
this.Transaction = transaction;
|
|
41
|
+
this.Result = result;
|
|
42
|
+
this.Success = success;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.TransactionResult = TransactionResult;
|
|
46
|
+
class TransactionGroupBase {
|
|
47
|
+
constructor() {
|
|
48
|
+
this._pendingTransactions = [];
|
|
49
|
+
}
|
|
50
|
+
PendingTransactions() {
|
|
51
|
+
return this._pendingTransactions;
|
|
52
|
+
}
|
|
53
|
+
AddTransaction(transaction) {
|
|
54
|
+
this._pendingTransactions.push(transaction);
|
|
55
|
+
}
|
|
56
|
+
async Submit() {
|
|
57
|
+
try {
|
|
58
|
+
if (this._pendingTransactions.length > 0) {
|
|
59
|
+
// subclass handles the actual submit implementation whatever that does
|
|
60
|
+
let results = await this.HandleSubmit(this._pendingTransactions);
|
|
61
|
+
// now we have the results back, so we can call the callback functions
|
|
62
|
+
for (let i = 0; i < results.length; i++) {
|
|
63
|
+
await results[i].Transaction.CallBack(results[i].Result, results[i].Success);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
console.error(err);
|
|
70
|
+
// it failed, so we have to call the callback functions with the error
|
|
71
|
+
for (let i = 0; i < this._pendingTransactions.length; i++) {
|
|
72
|
+
await this._pendingTransactions[i].CallBack(err, false);
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.TransactionGroupBase = TransactionGroupBase;
|
|
79
|
+
//# sourceMappingURL=transactionGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionGroup.js","sourceRoot":"","sources":["../../src/generic/transactionGroup.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;EAYE;;;AAEF,MAAa,eAAe;IAMxB,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,YAAa,WAAmB,EAAE,IAAS,EAAE,SAAc,EAAE,QAAkB;QAC3E,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;CACJ;AAzBD,0CAyBC;AAED,MAAa,iBAAiB;IAK1B,YAAY,WAA4B,EAAE,MAAW,EAAE,OAAgB;QACnE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AAVD,8CAUC;AAED,MAAsB,oBAAoB;IAA1C;QACY,yBAAoB,GAAsB,EAAE,CAAC;IAmCzD,CAAC;IAjCa,mBAAmB;QACzB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAEM,cAAc,CAAC,WAA4B;QAC9C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAIM,KAAK,CAAC,MAAM;QACf,IAAI;YACA,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACtC,uEAAuE;gBACvE,IAAI,OAAO,GAAwB,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;gBAEtF,sEAAsE;gBACtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACrC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;iBAChF;aACJ;YACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,GAAG,EAAE;YACR,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,sEAAsE;YACtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACvD,MAAM,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aAC3D;YACD,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;CAEJ;AApCD,oDAoCC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function TypeScriptTypeFromSQLType(sqlType: string): string;
|
|
2
|
+
export declare function FormatValue(sqlType: string, value: any, decimals?: number, currency?: string): string;
|
|
3
|
+
export declare function SQLFullType(baseType: string, length: number, precision: number, scale: number): string;
|
|
4
|
+
export declare function SQLMaxLength(sqlBaseType: string, sqlLength: number): number;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SQLMaxLength = exports.SQLFullType = exports.FormatValue = exports.TypeScriptTypeFromSQLType = void 0;
|
|
4
|
+
const logging_1 = require("./logging");
|
|
5
|
+
function TypeScriptTypeFromSQLType(sqlType) {
|
|
6
|
+
switch (sqlType.trim().toLowerCase()) {
|
|
7
|
+
case 'text':
|
|
8
|
+
case 'char':
|
|
9
|
+
case 'varchar':
|
|
10
|
+
case 'ntext':
|
|
11
|
+
case 'nchar':
|
|
12
|
+
case 'nvarchar':
|
|
13
|
+
case 'uniqueidentifier': //treat this as a string
|
|
14
|
+
return 'string';
|
|
15
|
+
case 'datetime':
|
|
16
|
+
case 'datetime2':
|
|
17
|
+
case 'datetimeoffset':
|
|
18
|
+
case 'date':
|
|
19
|
+
case 'time':
|
|
20
|
+
return 'Date';
|
|
21
|
+
case 'bit':
|
|
22
|
+
return 'boolean';
|
|
23
|
+
default:
|
|
24
|
+
return 'number';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.TypeScriptTypeFromSQLType = TypeScriptTypeFromSQLType;
|
|
28
|
+
function FormatValue(sqlType, value, decimals = 2, currency = 'USD') {
|
|
29
|
+
if (value === null || value === undefined) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
switch (sqlType.toLowerCase()) {
|
|
34
|
+
case 'money':
|
|
35
|
+
if (isNaN(value))
|
|
36
|
+
return value;
|
|
37
|
+
else
|
|
38
|
+
return new Intl.NumberFormat(undefined, { style: 'currency',
|
|
39
|
+
currency: currency,
|
|
40
|
+
minimumFractionDigits: decimals,
|
|
41
|
+
maximumFractionDigits: decimals }).format(value);
|
|
42
|
+
case 'date':
|
|
43
|
+
case 'datetime':
|
|
44
|
+
case 'datetimeoffset':
|
|
45
|
+
let date = new Date(value);
|
|
46
|
+
return new Intl.DateTimeFormat().format(date);
|
|
47
|
+
case 'decimal':
|
|
48
|
+
case 'real':
|
|
49
|
+
case 'float':
|
|
50
|
+
return new Intl.NumberFormat(undefined, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }).format(value);
|
|
51
|
+
case 'int':
|
|
52
|
+
return new Intl.NumberFormat(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0 }).format(value);
|
|
53
|
+
case 'percent':
|
|
54
|
+
return new Intl.NumberFormat(undefined, { style: 'percent',
|
|
55
|
+
minimumFractionDigits: decimals,
|
|
56
|
+
maximumFractionDigits: decimals }).format(value);
|
|
57
|
+
default:
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
(0, logging_1.LogError)(`Error formatting value ${value} of type ${sqlType} with decimals ${decimals} and currency ${currency}`, e);
|
|
63
|
+
return value; // just return the value as is if we cant format it
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.FormatValue = FormatValue;
|
|
67
|
+
function SQLFullType(baseType, length, precision, scale) {
|
|
68
|
+
const type = baseType.trim().toLowerCase();
|
|
69
|
+
let sOutput = type;
|
|
70
|
+
if (type === 'varchar')
|
|
71
|
+
sOutput += `(${length > 0 ? length : 'MAX'})`;
|
|
72
|
+
else if (type === 'nvarchar')
|
|
73
|
+
sOutput += `(${length > 0 ? length / 2 : 'MAX'})`; // nvarchar divide the system length by 2 to get the actual length for the output
|
|
74
|
+
else if (type === 'char')
|
|
75
|
+
sOutput += `(${length})`;
|
|
76
|
+
else if (type === 'nchar')
|
|
77
|
+
sOutput += `(${length / 2})`; // nchar divide the system length by 2 to get the actual length for the output
|
|
78
|
+
else if (type === 'decimal' || type === 'numeric')
|
|
79
|
+
sOutput += `(${precision}, ${scale})`;
|
|
80
|
+
else if (type === 'float')
|
|
81
|
+
sOutput += `(${precision})`;
|
|
82
|
+
return sOutput;
|
|
83
|
+
}
|
|
84
|
+
exports.SQLFullType = SQLFullType;
|
|
85
|
+
function SQLMaxLength(sqlBaseType, sqlLength) {
|
|
86
|
+
switch (sqlBaseType.trim().toLowerCase()) {
|
|
87
|
+
case 'varchar':
|
|
88
|
+
case 'char':
|
|
89
|
+
case 'text':
|
|
90
|
+
return sqlLength;
|
|
91
|
+
case 'nvarchar':
|
|
92
|
+
case 'nchar':
|
|
93
|
+
case 'ntext':
|
|
94
|
+
return sqlLength / 2; // length in the schema is the # of bytes and on unicode fields we divide by 2 to get the # of characters a user is allowed to put in.
|
|
95
|
+
default:
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.SQLMaxLength = SQLMaxLength;
|
|
100
|
+
//# sourceMappingURL=util.js.map
|