Updated with changes from breeze.js master repo.

This commit is contained in:
Marcel Good
2016-06-27 10:40:24 -07:00
parent d9c8c528d8
commit 9dd59e8b12
2 changed files with 168 additions and 130 deletions

View File

@@ -883,7 +883,7 @@ function test_config() {
o = config.getAdapter("myInterfaceName", "myAdapterName");
o = config.getAdapterInstance("myInterfaceName", "myAdapterName");
config.initializeAdapterInstance("myInterfaceName", "myAdapterName", true);
config.initializeAdapterInstances({ x: 3, y: "not" });
config.initializeAdapterInstances({ ajax: "", dataService: "" });
s = config.interfaceInitialized.type;
o = config.interfaceRegistry;
o = config.objectRegistry;

296
breeze/breeze.d.ts vendored
View File

@@ -11,21 +11,22 @@
// Updated Jan 16 2015 for Breeze 1.4.17 to add support for noimplicitany - Kevin Wilson ( www.kwilson.me.uk )
// Updated Jan 20 2015 for Breeze 1.5.2 and merging changes from DefinitelyTyped
// Updated Feb 28 2015 add any/all clause on Predicate
// Updated Jun 27 2016 - Marcel Good (www.ideablade.com)
declare namespace breeze.core {
interface ErrorCallback {
export interface ErrorCallback {
(error: Error): void;
}
interface IEnum {
export interface IEnum {
contains(object: any): boolean;
fromName(name: string): EnumSymbol;
getNames(): string[];
getSymbols(): EnumSymbol[];
}
class Enum implements IEnum {
export class Enum implements IEnum {
constructor(name: string, methodObj?: any);
addSymbol(propertiesObj?: any): EnumSymbol;
@@ -37,14 +38,14 @@ declare namespace breeze.core {
resolveSymbols(): void;
}
class EnumSymbol {
export class EnumSymbol {
parentEnum: IEnum;
getName(): string;
toString(): string;
}
class Event {
export class Event {
constructor(name: string, publisher: any, defaultErrorCallback?: ErrorCallback);
static enable(eventName: string, target: any): void;
@@ -91,25 +92,27 @@ declare namespace breeze.core {
declare namespace breeze {
interface Entity {
export interface Entity {
entityAspect: EntityAspect;
entityType: EntityType;
}
interface ComplexObject {
export interface ComplexObject {
complexAspect: ComplexAspect;
complexType: ComplexType;
}
interface IProperty {
export interface IProperty {
name: string;
nameOnServer: string;
displayName: string;
parentType: IStructuralType;
validators: Validator[];
isDataProperty: boolean;
isNavigationProperty: boolean;
}
interface IStructuralType {
export interface IStructuralType {
complexProperties: DataProperty[];
dataProperties: DataProperty[];
name: string;
@@ -119,13 +122,13 @@ declare namespace breeze {
validators: Validator[];
}
class AutoGeneratedKeyType {
export class AutoGeneratedKeyType {
static Identity: AutoGeneratedKeyType;
static KeyGenerator: AutoGeneratedKeyType;
static None: AutoGeneratedKeyType;
}
class ComplexAspect {
export class ComplexAspect {
complexObject: ComplexObject;
getEntityAspect(): EntityAspect;
parent: Object;
@@ -134,7 +137,7 @@ declare namespace breeze {
originalValues: Object;
}
class ComplexType implements IStructuralType {
export class ComplexType implements IStructuralType {
complexProperties: DataProperty[];
dataProperties: DataProperty[];
name: string;
@@ -146,7 +149,7 @@ declare namespace breeze {
getProperties(): DataProperty[];
}
class DataProperty implements IProperty {
export class DataProperty implements IProperty {
complexTypeName: string;
concurrencyMode: string;
dataType: DataTypeSymbol;
@@ -162,13 +165,14 @@ declare namespace breeze {
maxLength: number;
name: string;
nameOnServer: string;
displayName: string;
parentType: IStructuralType;
relatedNavigationProperty: NavigationProperty;
validators: Validator[];
constructor(config: DataPropertyOptions);
}
interface DataPropertyOptions {
export interface DataPropertyOptions {
complexTypeName?: string;
concurrencyMode?: string;
custom?: any;
@@ -185,7 +189,7 @@ declare namespace breeze {
validators?: Validator[];
}
class DataService {
export class DataService {
adapterInstance: DataServiceAdapter;
adapterName: string;
hasServerMetadata: boolean;
@@ -197,7 +201,7 @@ declare namespace breeze {
using(config: DataServiceOptions): DataService;
}
interface DataServiceOptions {
export interface DataServiceOptions {
serviceName?: string;
adapterName?: string;
uriBuilderName?: string;
@@ -206,7 +210,7 @@ declare namespace breeze {
useJsonp?: boolean;
}
class DataServiceAdapter {
export class DataServiceAdapter {
checkForRecomposition(interfaceInitializedArgs: { interfaceName: string; isDefault: boolean }): void;
initialize(): void;
fetchMetadata(metadataStore: MetadataStore, dataService: DataService): breeze.promises.IPromise<any>;
@@ -215,7 +219,7 @@ declare namespace breeze {
JsonResultsAdapter: JsonResultsAdapter;
}
class JsonResultsAdapter {
export class JsonResultsAdapter {
name: string;
extractResults: (data: {}) => {};
visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: boolean; };
@@ -226,24 +230,24 @@ declare namespace breeze {
});
}
interface QueryContext {
export interface QueryContext {
url: string;
query: any; // how to also say it could be an EntityQuery or a string
query: EntityQuery | string;
entityManager: EntityManager;
dataService: DataService;
queryOptions: QueryOptions;
}
interface NodeContext {
export interface NodeContext {
nodeType: string;
}
class DataTypeSymbol extends breeze.core.EnumSymbol {
export class DataTypeSymbol extends breeze.core.EnumSymbol {
defaultValue: any;
isNumeric: boolean;
isDate: boolean;
}
interface DataType extends breeze.core.IEnum {
export interface DataType extends breeze.core.IEnum {
Binary: DataTypeSymbol;
Boolean: DataTypeSymbol;
Byte: DataTypeSymbol;
@@ -259,16 +263,36 @@ declare namespace breeze {
String: DataTypeSymbol;
Time: DataTypeSymbol;
Undefined: DataTypeSymbol;
toDataType(typeName: string): DataTypeSymbol;
parseDateFromServer(date: any): Date;
defaultValue: any;
isNumeric: boolean;
}
var DataType: DataType;
isInteger: boolean;
class EntityActionSymbol extends breeze.core.EnumSymbol {
/** Function to convert a value from string to this DataType. Note that this will be called each time a property is changed, so make it fast. */
parse: (val: any, sourceTypeName: string) => any;
/** Function to format this DataType for OData queries. */
fmtOData: (val: any) => any;
/** Optional function to get the next value for key generation, if this datatype is used as a key. Uses an internal table of previous values. */
getNext?: () => any;
/** Optional function to normalize a data value for comparison, if its value cannot be used directly. Note that this will be called each time a property is changed, so make it fast. */
normalize?: (val: any) => any;
/** Optional function to get the next value when the datatype is used as a concurrency property. */
getConcurrencyValue?: (val: any) => any;
/** Optional function to convert a raw (server) value from string to this DataType. */
parseRawValue?: (val: any) => any;
}
interface EntityAction extends breeze.core.IEnum {
export var DataType: DataType;
export class EntityActionSymbol extends breeze.core.EnumSymbol {
}
export interface EntityAction extends breeze.core.IEnum {
AcceptChanges: EntityActionSymbol;
Attach: EntityActionSymbol;
AttachOnImport: EntityActionSymbol;
@@ -282,9 +306,9 @@ declare namespace breeze {
PropertyChange: EntityActionSymbol;
RejectChanges: EntityActionSymbol;
}
var EntityAction: EntityAction;
export var EntityAction: EntityAction;
class EntityAspect {
export class EntityAspect {
entity: Entity;
entityManager: EntityManager;
entityState: EntityStateSymbol;
@@ -318,8 +342,6 @@ declare namespace breeze {
removeValidationError(validator: Validator, property: NavigationProperty): void;
removeValidationError(validationError: ValidationError): void;
/** Sets the entity to an EntityState of 'Added'. This is NOT the equivalent of calling {{#crossLink "EntityManager/addEntity"}}{{/crossLink}}
because no key generation will occur for autogenerated keys as a result of this operation. */
setAdded(): void;
setDeleted(): void;
setDetached(): void;
@@ -333,7 +355,7 @@ declare namespace breeze {
validateProperty(property: NavigationProperty, context?: any): boolean;
}
class PropertyChangedEventArgs {
export class PropertyChangedEventArgs {
entity: Entity;
property: IProperty;
propertyName: string;
@@ -342,21 +364,21 @@ declare namespace breeze {
parent: any;
}
class PropertyChangedEvent extends breeze.core.Event {
export class PropertyChangedEvent extends breeze.core.Event {
subscribe(callback?: (data: PropertyChangedEventArgs) => void): number;
}
class ValidationErrorsChangedEventArgs {
export class ValidationErrorsChangedEventArgs {
entity: Entity;
added: ValidationError[];
removed: ValidationError[];
}
class ValidationErrorsChangedEvent extends breeze.core.Event {
export class ValidationErrorsChangedEvent extends breeze.core.Event {
subscribe(callback?: (data: ValidationErrorsChangedEventArgs) => void): number;
}
class EntityKey {
export class EntityKey {
constructor(entityType: EntityType, keyValue: any);
constructor(entityType: EntityType, keyValues: any[]);
@@ -366,17 +388,17 @@ declare namespace breeze {
values: any[];
}
interface EntityByKeyResult {
export interface EntityByKeyResult {
entity: Entity;
entityKey: EntityKey;
fromCache: boolean;
}
interface ExportEntitiesOptions {
export interface ExportEntitiesOptions {
asString: boolean; // default true
includeMetadata: boolean; // default true
}
class EntityManager {
export class EntityManager {
dataService: DataService;
keyGeneratorCtor: Function;
metadataStore: MetadataStore;
@@ -392,7 +414,7 @@ declare namespace breeze {
constructor(config?: EntityManagerOptions);
constructor(config?: string);
acceptChanges(): void;
acceptChanges(): void;
addEntity(entity: Entity): Entity;
attachEntity(entity: Entity, entityState?: EntityStateSymbol, mergeStrategy?: MergeStrategySymbol): Entity;
clear(): void;
@@ -447,7 +469,7 @@ declare namespace breeze {
setProperties(config: EntityManagerProperties): void;
}
interface EntityManagerOptions {
export interface EntityManagerOptions {
serviceName?: string;
dataService?: DataService;
metadataStore?: MetadataStore;
@@ -457,7 +479,7 @@ declare namespace breeze {
keyGeneratorCtor?: Function;
}
interface EntityManagerProperties {
export interface EntityManagerProperties {
serviceName?: string;
dataService?: DataService;
metadataStore?: MetadataStore;
@@ -467,19 +489,19 @@ declare namespace breeze {
keyGeneratorCtor?: Function;
}
interface ExecuteQuerySuccessCallback {
export interface ExecuteQuerySuccessCallback {
(data: QueryResult): void;
}
interface ExecuteQueryErrorCallback {
export interface ExecuteQueryErrorCallback {
(error: { query: EntityQuery; httpResponse: HttpResponse; entityManager: EntityManager; message?: string; stack?:string }): void;
}
interface SaveChangesSuccessCallback {
export interface SaveChangesSuccessCallback {
(saveResult: SaveResult): void;
}
interface EntityError {
export interface EntityError {
entity: Entity;
errorMessage: string;
errorName: string;
@@ -487,7 +509,7 @@ declare namespace breeze {
propertyName: string;
}
interface SaveChangesErrorCallback {
export interface SaveChangesErrorCallback {
(error: {
entityErrors: EntityError[];
httpResponse: HttpResponse;
@@ -497,26 +519,26 @@ declare namespace breeze {
}): void;
}
class EntityChangedEventArgs {
export class EntityChangedEventArgs {
entity: Entity;
entityAction: EntityActionSymbol;
args: Object;
}
class EntityChangedEvent extends breeze.core.Event {
export class EntityChangedEvent extends breeze.core.Event {
subscribe(callback?: (data: EntityChangedEventArgs) => void): number;
}
class HasChangesChangedEventArgs {
export class HasChangesChangedEventArgs {
entityManager: EntityManager;
hasChanges: boolean;
}
class HasChangesChangedEvent extends breeze.core.Event {
export class HasChangesChangedEvent extends breeze.core.Event {
subscribe(callback?: (data: HasChangesChangedEventArgs) => void): number;
}
class EntityQuery {
export class EntityQuery {
entityManager: EntityManager;
orderByClause: OrderByClause;
parameters: Object;
@@ -573,10 +595,10 @@ declare namespace breeze {
toJSON(): string;
}
interface OrderByClause {
export interface OrderByClause {
}
class EntityStateSymbol extends breeze.core.EnumSymbol {
export class EntityStateSymbol extends breeze.core.EnumSymbol {
isAdded(): boolean;
isAddedModifiedOrDeleted(): boolean;
isDeleted(): boolean;
@@ -585,16 +607,16 @@ declare namespace breeze {
isUnchanged(): boolean;
isUnchangedOrModified(): boolean;
}
interface EntityState extends breeze.core.IEnum {
export interface EntityState extends breeze.core.IEnum {
Added: EntityStateSymbol;
Deleted: EntityStateSymbol;
Detached: EntityStateSymbol;
Modified: EntityStateSymbol;
Unchanged: EntityStateSymbol;
}
var EntityState: EntityState;
export var EntityState: EntityState;
class EntityType implements IStructuralType {
export class EntityType implements IStructuralType {
autoGeneratedKeyType: AutoGeneratedKeyType;
baseEntityType: EntityType;
complexProperties: DataProperty[];
@@ -630,7 +652,7 @@ declare namespace breeze {
toString(): string;
}
interface EntityTypeOptions {
export interface EntityTypeOptions {
shortName?: string;
namespace?: string;
autoGeneratedKeyType?: AutoGeneratedKeyType;
@@ -639,24 +661,24 @@ declare namespace breeze {
navigationProperties?: NavigationProperty[];
}
interface EntityTypeProperties {
export interface EntityTypeProperties {
autoGeneratedKeyType?: AutoGeneratedKeyType;
defaultResourceName?: string;
serializerFn?: (dataProperty: DataProperty, value: any) => any;
}
class FetchStrategySymbol extends breeze.core.EnumSymbol {
export class FetchStrategySymbol extends breeze.core.EnumSymbol {
private foo; // to distinguish this class from MergeStrategySymbol
}
interface FetchStrategy extends breeze.core.IEnum {
export interface FetchStrategy extends breeze.core.IEnum {
FromLocalCache: FetchStrategySymbol;
FromServer: FetchStrategySymbol;
}
var FetchStrategy: FetchStrategy;
export var FetchStrategy: FetchStrategy;
class FilterQueryOpSymbol extends breeze.core.EnumSymbol {
export class FilterQueryOpSymbol extends breeze.core.EnumSymbol {
}
interface FilterQueryOp extends breeze.core.IEnum {
export interface FilterQueryOp extends breeze.core.IEnum {
Contains: FilterQueryOpSymbol;
EndsWith: FilterQueryOpSymbol;
Equals: FilterQueryOpSymbol;
@@ -670,9 +692,9 @@ declare namespace breeze {
Any: FilterQueryOpSymbol;
All: FilterQueryOpSymbol;
}
var FilterQueryOp: FilterQueryOp;
export var FilterQueryOp: FilterQueryOp;
class LocalQueryComparisonOptions {
export class LocalQueryComparisonOptions {
static caseInsensitiveSQL: LocalQueryComparisonOptions;
static defaultInstance: LocalQueryComparisonOptions;
@@ -681,17 +703,17 @@ declare namespace breeze {
setAsDefault(): void;
}
class MergeStrategySymbol extends breeze.core.EnumSymbol {
export class MergeStrategySymbol extends breeze.core.EnumSymbol {
}
interface MergeStrategy extends breeze.core.IEnum {
export interface MergeStrategy extends breeze.core.IEnum {
OverwriteChanges: MergeStrategySymbol;
PreserveChanges: MergeStrategySymbol;
SkipMerge: MergeStrategySymbol;
Disallowed: MergeStrategySymbol;
}
var MergeStrategy: MergeStrategy;
export var MergeStrategy: MergeStrategy;
class MetadataStore {
export class MetadataStore {
constructor();
constructor(config?: MetadataStoreOptions);
namingConvention: NamingConvention;
@@ -707,7 +729,7 @@ declare namespace breeze {
static importMetadata(exportedString: string): MetadataStore;
importMetadata(exportedString: string, allowMerge?: boolean): MetadataStore;
isEmpty(): boolean;
registerEntityTypeCtor(entityTypeName: string, entityCtor: Function, initializationFn?: (entity: Entity) => void, noTrackingFn?: (entity: Entity) => Entity): void;
registerEntityTypeCtor(entityTypeName: string, entityCtor: Function, initializationFn?: (entity: Entity) => void, noTrackingFn?: (node: Object, entityType: EntityType) => Object): void;
trackUnmappedType(entityCtor: Function, interceptor?: Function): void;
setEntityTypeForResourceName(resourceName: string, entityType: EntityType): void;
setEntityTypeForResourceName(resourceName: string, entityTypeName: string): void;
@@ -715,12 +737,12 @@ declare namespace breeze {
setProperties(config: { name?: string; serializerFn?: Function }): void;
}
interface MetadataStoreOptions {
export interface MetadataStoreOptions {
namingConvention?: NamingConvention;
localQueryComparisonOptions?: LocalQueryComparisonOptions;
}
class NamingConvention {
export class NamingConvention {
static camelCase: NamingConvention;
static defaultInstance: NamingConvention;
static none: NamingConvention;
@@ -736,12 +758,12 @@ declare namespace breeze {
setAsDefault(): NamingConvention;
}
interface NamingConventionOptions {
export interface NamingConventionOptions {
serverPropertyNameToClient?: (name: string) => string;
clientPropertyNameToServer?: (name: string) => string;
}
class NavigationProperty implements IProperty {
export class NavigationProperty implements IProperty {
associationName: string;
entityType: EntityType;
foreignKeyNames: string[];
@@ -750,6 +772,8 @@ declare namespace breeze {
isNavigationProperty: boolean;
isScalar: boolean;
name: string;
nameOnServer: string;
displayName: string;
parentType: IStructuralType;
relatedDataProperties: DataProperty[];
validators: Validator[];
@@ -757,7 +781,7 @@ declare namespace breeze {
constructor(config: NavigationPropertyOptions);
}
interface NavigationPropertyOptions {
export interface NavigationPropertyOptions {
name?: string;
nameOnServer?: string;
entityTypeName: string;
@@ -768,15 +792,21 @@ declare namespace breeze {
validators?: Validator[];
}
class Predicate {
export interface IRecursiveArray<T> {
[i: number]: T | IRecursiveArray<T>;
}
export class Predicate {
constructor();
constructor(property: string, operator: string, value: any);
constructor(property: string, operator: FilterQueryOpSymbol, value: any);
constructor(property: string, operator: string, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType });
constructor(property: string, operator: FilterQueryOpSymbol, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType });
constructor(property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol, value: any); // for any/all clauses
constructor(property: string, filterop: string, property2: string, filterop2: string, value: any); // for any/all clauses
/** Create predicate from an expression tree */
constructor(tree: Object);
constructor(passthru: string);
constructor(predicate: Predicate);
constructor(anArray: IRecursiveArray<string | number | FilterQueryOpSymbol | Predicate>);
and: PredicateMethod;
static and: PredicateMethod;
@@ -798,7 +828,7 @@ declare namespace breeze {
toJSON(): string;
}
interface PredicateMethod {
export interface PredicateMethod {
(predicates: Predicate[]): Predicate;
(...predicates: Predicate[]): Predicate;
(property: string, operator: string, value: any, valueIsLiteral?: boolean): Predicate;
@@ -807,7 +837,7 @@ declare namespace breeze {
(property: string, filterop: string, property2: string, filterop2: string, value: any): Predicate; // for any/all clauses
}
class QueryOptions {
export class QueryOptions {
static defaultInstance: QueryOptions;
fetchStrategy: FetchStrategySymbol;
mergeStrategy: MergeStrategySymbol;
@@ -822,12 +852,12 @@ declare namespace breeze {
using(config: FetchStrategySymbol): QueryOptions;
}
interface QueryOptionsConfiguration {
export interface QueryOptionsConfiguration {
fetchStrategy?: FetchStrategySymbol;
mergeStrategy?: MergeStrategySymbol;
}
interface HttpResponse {
export interface HttpResponse {
config: any;
data: Entity[];
error?: any;
@@ -836,7 +866,7 @@ declare namespace breeze {
getHeaders(headerName: string): string
}
interface QueryResult {
export interface QueryResult {
/** Top level entities returned */
results: Entity[];
/** Query that was executed */
@@ -851,33 +881,33 @@ declare namespace breeze {
retrievedEntities?: Entity[]
}
class SaveOptions {
export class SaveOptions {
allowConcurrentSaves: boolean;
resourceName: string;
dataService: DataService;
tag: Object;
static defaultInstance: SaveOptions;
constructor(config?: { allowConcurrentSaves?: boolean; resourceName?: string; dataService?: DataService; tag?: any});
constructor(config?: { allowConcurrentSaves?: boolean; resourceName?: string; dataService?: DataService; tag?: any });
setAsDefault(): SaveOptions;
using(config: SaveOptionsConfiguration): SaveOptions;
}
interface SaveOptionsConfiguration {
export interface SaveOptionsConfiguration {
allowConcurrentSaves?: boolean;
resourceName?: string;
dataService?: DataService;
tag?: Object;
}
interface SaveResult {
export interface SaveResult {
entities: Entity[];
keyMappings: any;
XHR: XMLHttpRequest;
}
class ValidationError {
export class ValidationError {
key: string;
context: any;
errorMessage: string;
@@ -889,7 +919,7 @@ declare namespace breeze {
constructor(validator: Validator, context: any, errorMessage: string, key: string);
}
class ValidationOptions {
export class ValidationOptions {
static defaultInstance: ValidationOptions;
validateOnAttach: boolean;
validateOnPropertyChange: boolean;
@@ -902,14 +932,14 @@ declare namespace breeze {
using(config: ValidationOptionsConfiguration): ValidationOptions;
}
interface ValidationOptionsConfiguration {
export interface ValidationOptionsConfiguration {
validateOnAttach?: boolean;
validateOnSave?: boolean;
validateOnQuery?: boolean;
validateOnPropertyChange?: boolean;
}
class Validator {
export class Validator {
/** Map of standard error message templates keyed by validator name.*/
static messageTemplates: any;
context: any;
@@ -962,7 +992,7 @@ declare namespace breeze {
/** Creates a regular expression validator with a fixed expression. */
static makeRegExpValidator(validatorName: string, expression: RegExp, defaultMessage: string, context?: any): Validator;
/** Run this validator against the specified value.
/** Run this validator against the specified value.
@param value {Object} Value to validate
@param additionalContext {Object} Any additional contextual information that the Validator can make use of.
@return {ValidationError|null} A ValidationError if validation fails, null otherwise */
@@ -972,11 +1002,11 @@ declare namespace breeze {
getMessage(): string;
}
interface ValidatorFunction {
export interface ValidatorFunction {
(value: any, context: ValidatorFunctionContext): void;
}
interface ValidatorFunctionContext {
export interface ValidatorFunctionContext {
value: any;
validatorName: string;
displayName: string;
@@ -984,84 +1014,89 @@ declare namespace breeze {
message?: string;
}
var metadataVersion: string;
var remoteAccess_odata: string;
var remoteAccess_webApi: string;
var version: string;
export var metadataVersion: string;
export var remoteAccess_odata: string;
export var remoteAccess_webApi: string;
export var version: string;
}
declare namespace breeze.config {
var ajax: string;
var dataService: string;
var functionRegistry: Object;
export var ajax: string;
export var dataService: string;
export var functionRegistry: Object;
/**
Returns the ctor function used to implement a specific interface with a specific adapter name.
@method getAdapter
@param interfaceName {String} One of the following interface names "ajax", "dataService" or "modelLibrary"
@param [adapterName] {String} The name of any previously registered adapter. If this parameter is omitted then
@param adapterName {String} The name of any previously registered adapter. If this parameter is omitted then
this method returns the "default" adapter for this interface. If there is no default adapter, then a null is returned.
@return {Function|null} Returns either a ctor function or null.
@returns {Function|null} Returns either a ctor function or null.
**/
export function getAdapter(interfaceName: string, adapterName?: string): Function;
/**
Returns the adapter instance corresponding to the specified interface and adapter names.
@method getAdapterInstance
@param interfaceName {String} The name of the interface.
@param [adapterName] {String} - The name of a previously registered adapter. If this parameter is
@param adapterName {String} - The name of a previously registered adapter. If this parameter is
omitted then the default implementation of the specified interface is returned. If there is
no defaultInstance of this interface, then the first registered instance of this interface is returned.
@return {an instance of the specified adapter}
**/
export function getAdapterInstance(interfaceName: string, adapterName?: string): Object;
/**
Initializes a single adapter implementation. Initialization means either newing a instance of the
Initializes a single adapter implementation. Initialization means either newing a instance of the
specified interface and then calling "initialize" on it or simply calling "initialize" on the instance
if it already exists.
@method initializeAdapterInstance
@param interfaceName {String} The name of the interface to which the adapter to initialize belongs.
@param adapterName {String} - The name of a previously registered adapter to initialize.
@param [isDefault=true] {Boolean} - Whether to make this the default "adapter" for this interface.
@param isDefault=true {Boolean} - Whether to make this the default "adapter" for this interface.
@return {an instance of the specified adapter}
**/
export function initializeAdapterInstance(interfaceName: string, adapterName: string, isDefault?: boolean): void;
export interface AdapterInstancesConfig {
/** the name of a previously registered "ajax" adapter */
ajax?: string;
/** the name of a previously registered "dataService" adapter */
dataService?: string;
/** the name of a previously registered "modelLibrary" adapter */
modelLibary?: string;
/** the name of a previously registered "uriBuilder" adapter */
uriBuilder?: string;
}
/**
Initializes a collection of adapter implementations and makes each one the default for its corresponding interface.
@method initializeAdapterInstances
@param config {Object}
@param [config.ajax] {String} - the name of a previously registered "ajax" adapter
@param [config.dataService] {String} - the name of a previously registered "dataService" adapter
@param [config.modelLibrary] {String} - the name of a previously registered "modelLibrary" adapter
@param [config.uriBuilder] {String} - the name of a previously registered "uriBuilder" adapter
@param config {AdapterInstancesConfig}
@return [array of instances]
**/
export function initializeAdapterInstances(config: Object): Object[];
var interfaceInitialized: Event;
var interfaceRegistry: Object;
var objectRegistry: Object;
export function initializeAdapterInstances(config: AdapterInstancesConfig): Object[];
export var interfaceInitialized: Event;
export var interfaceRegistry: Object;
export var objectRegistry: Object;
/**
Method use to register implementations of standard breeze interfaces. Calls to this method are usually
made as the last step within an adapter implementation.
@method registerAdapter
made as the last step within an adapter implementation.
@param interfaceName {String} - one of the following interface names "ajax", "dataService" or "modelLibrary"
@param adapterCtor {Function} - an ctor function that returns an instance of the specified interface.
@param adapterCtor {Function} - an ctor function that returns an instance of the specified interface.
**/
export function registerAdapter(interfaceName: string, adapterCtor: Function): void;
export function registerFunction(fn: Function, fnName: string): void;
export function registerType(ctor: Function, typeName: string): void;
//static setProperties(config: Object): void; //deprecated
/**
/**
Set the promise implementation, if Q.js is not found.
@param q - implementation of promise. @see http://wiki.commonjs.org/wiki/Promises/A
*/
export function setQ(q: breeze.promises.IPromiseService): void;
var stringifyPad: string;
var typeRegistry: Object;
export var stringifyPad: string;
export var typeRegistry: Object;
}
/** Promises interface used by Breeze. Usually implemented by Q (https://github.com/kriskowal/q) or angular.$q using breeze.config.setQ(impl) */
declare namespace breeze.promises {
interface IPromise<T> {
export interface IPromise<T> {
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => U): IPromise<U>;
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason: any) => U): IPromise<U>;
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => IPromise<U>): IPromise<U>;
@@ -1071,13 +1106,13 @@ declare namespace breeze.promises {
finally(finallyCallback: () => any): IPromise<T>;
}
interface IDeferred<T> {
export interface IDeferred<T> {
promise: IPromise<T>;
resolve(value: T): void;
reject(reason: any): void;
}
interface IPromiseService {
export interface IPromiseService {
defer<T>(): IDeferred<T>;
reject(reason?: any): IPromise<any>;
resolve<T>(object: T): IPromise<T>;
@@ -1085,3 +1120,6 @@ declare namespace breeze.promises {
}
}
declare module "breeze" {
export = breeze;
}