@memberjunction/core
Advanced tools
Comparing version 1.5.2 to 1.5.3
@@ -34,3 +34,2 @@ import { BaseSingleton } from "@memberjunction/global"; | ||
private _contextUser; | ||
constructor(instanceKey: string); | ||
/** | ||
@@ -56,3 +55,7 @@ * Configures the engine by loading metadata from the database. | ||
get ContextUser(): UserInfo; | ||
/** | ||
* Helper method for sub-classes to have a single line of code that will make sure the data is loaded before proceeding and will throw an error if not loaded. | ||
*/ | ||
protected TryThrowIfNotLoaded(): void; | ||
} | ||
//# sourceMappingURL=baseEngine.d.ts.map |
@@ -14,4 +14,4 @@ "use strict"; | ||
class BaseEngine extends global_1.BaseSingleton { | ||
constructor(instanceKey) { | ||
super(instanceKey); | ||
constructor() { | ||
super(...arguments); | ||
this._loaded = false; | ||
@@ -81,4 +81,11 @@ this._loadingSubject = new rxjs_1.BehaviorSubject(false); | ||
} | ||
/** | ||
* Helper method for sub-classes to have a single line of code that will make sure the data is loaded before proceeding and will throw an error if not loaded. | ||
*/ | ||
TryThrowIfNotLoaded() { | ||
if (!this.Loaded) | ||
throw new Error("Data not loaded, call Config() first."); | ||
} | ||
} | ||
exports.BaseEngine = BaseEngine; | ||
//# sourceMappingURL=baseEngine.js.map |
@@ -105,2 +105,6 @@ import { EntityFieldInfo, EntityInfo, EntityFieldTSType, EntityPermissionType, RecordChange, ValidationResult, EntityRelationshipInfo } from './entityInfo'; | ||
/** | ||
* Optional, a list of structured error objects with additional information | ||
*/ | ||
Errors?: any[]; | ||
/** | ||
* A copy of the values of the entity object BEFORE the operation was performed | ||
@@ -107,0 +111,0 @@ */ |
@@ -146,4 +146,5 @@ "use strict"; | ||
this._entityFieldInfo = fieldInfo; | ||
if (Value) | ||
if (Value) { | ||
this.Value = Value; | ||
} | ||
else if (fieldInfo.DefaultValue) { | ||
@@ -643,3 +644,4 @@ if (fieldInfo.TSType === entityInfo_1.EntityFieldTSType.Boolean) { | ||
newResult.Type = this.IsSaved ? 'update' : 'create'; | ||
newResult.Message = e.message; | ||
newResult.Message = e.message || null; | ||
newResult.Errors = e.Errors || []; | ||
newResult.OriginalValues = this.Fields.map(f => { return { FieldName: f.CodeName, Value: f.OldValue }; }); | ||
@@ -810,3 +812,4 @@ newResult.EndedAt = new Date(); | ||
newResult.Type = 'delete'; | ||
newResult.Message = e.message; | ||
newResult.Message = e.message || null; | ||
newResult.Errors = e.Errors || []; | ||
newResult.OriginalValues = this.Fields.map(f => { return { FieldName: f.CodeName, Value: f.OldValue }; }); | ||
@@ -813,0 +816,0 @@ newResult.EndedAt = new Date(); |
@@ -22,4 +22,6 @@ "use strict"; | ||
// could also be something like (('Pending')) in which case we'll want to remove the SYMMETRIC parens | ||
const noParens = this.stripContainingParens(initData[keys[j]]); | ||
const finalValue = this.stripSingleQuotes(this.stripUnicodePrefix(noParens)); | ||
const initialValue = initData[keys[j]]; | ||
const noParens = this.stripContainingParens(initialValue); | ||
const unicodeStripped = this.stripUnicodePrefix(noParens); | ||
const finalValue = this.stripSingleQuotes(unicodeStripped); | ||
this[keys[j]] = finalValue; | ||
@@ -34,5 +36,6 @@ } | ||
stripUnicodePrefix(value) { | ||
if (!value) | ||
if (!value) { | ||
return value; | ||
const val = value.trim(); // trim it first | ||
} | ||
value = value.trim(); // trim it first | ||
// check to see if the first character is an N and if the character after | ||
@@ -45,2 +48,3 @@ // that as well as the last character are single quotes, if so, strip all of those out | ||
} | ||
return value; | ||
} | ||
@@ -47,0 +51,0 @@ stripSingleQuotes(value) { |
@@ -340,2 +340,3 @@ import { BaseInfo } from "./baseInfo"; | ||
EntityObjectSubclassImport: string; | ||
PreferredCommunicationField: string; | ||
CreatedAt: Date; | ||
@@ -342,0 +343,0 @@ UpdatedAt: Date; |
@@ -730,2 +730,3 @@ "use strict"; | ||
this.EntityObjectSubclassImport = null; | ||
this.PreferredCommunicationField = null; | ||
this.CreatedAt = null; | ||
@@ -732,0 +733,0 @@ this.UpdatedAt = null; |
@@ -201,3 +201,3 @@ import { BaseEntity } from "./baseEntity"; | ||
RefreshIfNeeded(): Promise<boolean>; | ||
IsRefreshNeeded(): Promise<boolean>; | ||
CheckToSeeIfRefreshNeeded(): Promise<boolean>; | ||
get LocalStorageProvider(): ILocalStorageProvider; | ||
@@ -204,0 +204,0 @@ RefreshRemoteMetadataTimestamps(): Promise<boolean>; |
@@ -52,3 +52,9 @@ import { BaseEntity } from "./baseEntity"; | ||
/******** ABSTRACT SECTION ****************************************************************** */ | ||
protected abstract AllowRefresh(): boolean; | ||
/** | ||
* Determines if a refresh is currently allowed or not | ||
*/ | ||
protected abstract get AllowRefresh(): boolean; | ||
/** | ||
* Returns the provider type for the instance | ||
*/ | ||
abstract get ProviderType(): ProviderType; | ||
@@ -80,3 +86,3 @@ abstract GetEntityRecordName(entityName: string, compositeKey: CompositeKey): Promise<string>; | ||
Refresh(): Promise<boolean>; | ||
IsRefreshNeeded(): Promise<boolean>; | ||
CheckToSeeIfRefreshNeeded(): Promise<boolean>; | ||
RefreshIfNeeded(): Promise<boolean>; | ||
@@ -83,0 +89,0 @@ GetEntityObject<T extends BaseEntity>(entityName: string, contextUser?: UserInfo): Promise<T>; |
@@ -78,3 +78,3 @@ "use strict"; | ||
this._localMetadata = new AllMetadata(); // start with fresh metadata | ||
if (this._refresh || await this.IsRefreshNeeded()) { | ||
if (this._refresh || await this.CheckToSeeIfRefreshNeeded()) { | ||
// either a hard refresh flag was set within Refresh(), or LocalMetadata is Obsolete | ||
@@ -239,3 +239,3 @@ // first, make sure we reset the flag to false so that if another call to this function happens | ||
} | ||
async IsRefreshNeeded() { | ||
async CheckToSeeIfRefreshNeeded() { | ||
if (this.AllowRefresh) { | ||
@@ -250,3 +250,3 @@ await this.RefreshRemoteMetadataTimestamps(); // get the latest timestamps from the server first | ||
async RefreshIfNeeded() { | ||
if (await this.IsRefreshNeeded()) | ||
if (await this.CheckToSeeIfRefreshNeeded()) | ||
return this.Refresh(); | ||
@@ -253,0 +253,0 @@ else |
@@ -21,2 +21,9 @@ export declare function TypeScriptTypeFromSQLType(sqlType: string): string; | ||
export declare function CodeNameFromString(input: string): string; | ||
/** | ||
* Run concurrent promises with a maximum concurrency level | ||
* @param concurrency - The number of concurrently running promises | ||
* @param funcs - An array of functions that return promises | ||
* @returns A promise that resolves to an array of the resolved values from the promises returned by funcs | ||
*/ | ||
export declare function Concurrent<V>(concurrency: number, funcs: (() => Promise<V>)[]): Promise<V[]>; | ||
//# sourceMappingURL=util.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CodeNameFromString = exports.StripStopWords = exports.CommonStopWords = exports.SQLMaxLength = exports.SQLFullType = exports.FormatValue = exports.TypeScriptTypeFromSQLType = void 0; | ||
exports.Concurrent = exports.CodeNameFromString = exports.StripStopWords = exports.CommonStopWords = exports.SQLMaxLength = exports.SQLFullType = exports.FormatValue = exports.TypeScriptTypeFromSQLType = void 0; | ||
const logging_1 = require("./logging"); | ||
@@ -165,2 +165,23 @@ function TypeScriptTypeFromSQLType(sqlType) { | ||
exports.CodeNameFromString = CodeNameFromString; | ||
/** | ||
* Run concurrent promises with a maximum concurrency level | ||
* @param concurrency - The number of concurrently running promises | ||
* @param funcs - An array of functions that return promises | ||
* @returns A promise that resolves to an array of the resolved values from the promises returned by funcs | ||
*/ | ||
function Concurrent(concurrency, funcs) { | ||
return new Promise((resolve, reject) => { | ||
let index = -1; | ||
const p = []; | ||
for (let i = 0; i < Math.max(1, Math.min(concurrency, funcs.length)); i++) | ||
runPromise(); | ||
function runPromise() { | ||
if (++index < funcs.length) | ||
(p[p.length] = funcs[index]()).then(runPromise).catch(reject); | ||
else if (index === funcs.length) | ||
Promise.all(p).then(resolve).catch(reject); | ||
} | ||
}); | ||
} | ||
exports.Concurrent = Concurrent; | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "@memberjunction/core", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "MemberJunction: Core Library including Metadata, Application, Entity Retrieval and Manipulation, and Utilities", | ||
@@ -19,8 +19,8 @@ "main": "dist/index.js", | ||
"ts-node-dev": "^2.0.0", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"@memberjunction/global": "~1.5.2", | ||
"@memberjunction/global": "1.5.3", | ||
"rxjs": "^7.8.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
491745
7137
Updated@memberjunction/global@1.5.3