зеркало из https://github.com/microsoft/paris.git
Downgraded zonejs and systemjs
This commit is contained in:
Родитель
094df54d2a
Коммит
677444bca6
|
@ -0,0 +1,6 @@
|
|||
export interface ParisConfig {
|
||||
apiRoot?: string;
|
||||
allItemsProperty?: string;
|
||||
entityIdProperty?: string;
|
||||
}
|
||||
export declare const defaultConfig: ParisConfig;
|
|
@ -0,0 +1,9 @@
|
|||
export declare type DataSetOptionsSort = Array<DataSetOptionsSortField>;
|
||||
export interface DataSetOptionsSortField {
|
||||
field: string;
|
||||
direction: DataSetOptionsSortDirection;
|
||||
}
|
||||
export declare enum DataSetOptionsSortDirection {
|
||||
ascending = 0,
|
||||
descending = 1,
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import { DataSetOptionsSort } from "./dataset-options-sort";
|
||||
export interface DataSetOptions {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
sortBy?: DataSetOptionsSort;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export interface DataSet<T> {
|
||||
count: number;
|
||||
items: Array<T>;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { IIdentifiable } from "../models/identifiable.model";
|
||||
import { ModelEntity } from "./entity.config";
|
||||
import { ModelObjectValue } from "./object-value.config";
|
||||
export interface DataEntityConstructor<T> extends DataEntityType {
|
||||
new (data?: IIdentifiable): T;
|
||||
}
|
||||
export interface DataEntityType {
|
||||
new (data: IIdentifiable): any;
|
||||
entityConfig?: ModelEntity;
|
||||
objectValueConfig?: ModelObjectValue;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
import { EntityFields } from "./entity-fields";
|
||||
import { Field } from "./entity-field";
|
||||
export declare abstract class EntityConfigBase {
|
||||
singularName: string;
|
||||
pluralName: string;
|
||||
fields?: EntityFields;
|
||||
idProperty?: string;
|
||||
readonly fieldsArray: Array<Field>;
|
||||
constructor(config: IEntityConfigBase);
|
||||
}
|
||||
export interface IEntityConfigBase {
|
||||
singularName: string;
|
||||
pluralName: string;
|
||||
fields?: EntityFields;
|
||||
idProperty?: string;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { DataEntityType } from "./data-entity.base";
|
||||
export interface Field {
|
||||
id?: string;
|
||||
name: string;
|
||||
data?: string;
|
||||
entity?: DataEntityType;
|
||||
type?: DataEntityType;
|
||||
defaultValue?: any;
|
||||
arrayOf?: DataEntityType;
|
||||
isArray?: boolean;
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
import { Field } from "./entity-field";
|
||||
export declare function EntityField(fieldConfig: Field): PropertyDecorator;
|
|
@ -0,0 +1,2 @@
|
|||
import { Field } from "./entity-field";
|
||||
export declare type EntityFields = Map<string, Field>;
|
|
@ -0,0 +1,16 @@
|
|||
import { EntityConfigBase, IEntityConfigBase } from "./entity-config.base";
|
||||
export declare class ModelEntity extends EntityConfigBase {
|
||||
endpoint: string;
|
||||
loadAll?: boolean;
|
||||
cache?: ModelEntityCacheConfig;
|
||||
constructor(config: EntityConfig);
|
||||
}
|
||||
export interface EntityConfig extends IEntityConfigBase {
|
||||
endpoint: string;
|
||||
loadAll?: boolean;
|
||||
cache?: ModelEntityCacheConfig;
|
||||
}
|
||||
export interface ModelEntityCacheConfig {
|
||||
time?: number;
|
||||
max?: number;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import { EntityConfig } from "./entity.config";
|
||||
import { DataEntityType } from "./data-entity.base";
|
||||
export declare function Entity(config: EntityConfig): (target: DataEntityType) => void;
|
|
@ -0,0 +1,11 @@
|
|||
import { EntityConfigBase, IEntityConfigBase } from "./entity-config.base";
|
||||
import { IIdentifiable } from "../models/identifiable.model";
|
||||
export declare class ModelObjectValue extends EntityConfigBase {
|
||||
values: ReadonlyArray<IIdentifiable>;
|
||||
private _valuesMap;
|
||||
constructor(config: ObjectValueConfig);
|
||||
getValueById(valueId: string | number): IIdentifiable;
|
||||
}
|
||||
export interface ObjectValueConfig extends IEntityConfigBase {
|
||||
values: ReadonlyArray<IIdentifiable>;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import { DataEntityType } from "./data-entity.base";
|
||||
import { ObjectValueConfig } from "./object-value.config";
|
||||
export declare function ObjectValue(config: ObjectValueConfig): (target: DataEntityType) => void;
|
|
@ -0,0 +1,14 @@
|
|||
export { Repository } from "./repository/repository";
|
||||
export * from "./repository/repository-manager.service";
|
||||
export { IRepository } from "./repository/repository.interface";
|
||||
export { IIdentifiable } from "./models/identifiable.model";
|
||||
export { ParisConfig } from "./config/paris-config";
|
||||
export { DataTransformersService, DataTransformer } from "./services/data-transformers.service";
|
||||
export { ModelEntity, EntityConfig, ModelEntityCacheConfig } from "./entity/entity.config";
|
||||
export { entityFieldsService } from "./services/entity-fields.service";
|
||||
export { entitiesService } from "./services/entities.service";
|
||||
export { ModelObjectValue } from "./entity/object-value.config";
|
||||
export { EntityField } from "./entity/entity-field.decorator";
|
||||
export { ObjectValue } from "./entity/object-value.decorator";
|
||||
export { Entity } from "./entity/entity.decorator";
|
||||
export { ParisModule } from "./paris.module";
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var repository_1 = require("./repository/repository");
|
||||
exports.Repository = repository_1.Repository;
|
||||
__export(require("./repository/repository-manager.service"));
|
||||
var data_transformers_service_1 = require("./services/data-transformers.service");
|
||||
exports.DataTransformersService = data_transformers_service_1.DataTransformersService;
|
||||
var entity_config_1 = require("./entity/entity.config");
|
||||
exports.ModelEntity = entity_config_1.ModelEntity;
|
||||
var entity_fields_service_1 = require("./services/entity-fields.service");
|
||||
exports.entityFieldsService = entity_fields_service_1.entityFieldsService;
|
||||
var entities_service_1 = require("./services/entities.service");
|
||||
exports.entitiesService = entities_service_1.entitiesService;
|
||||
var object_value_config_1 = require("./entity/object-value.config");
|
||||
exports.ModelObjectValue = object_value_config_1.ModelObjectValue;
|
||||
var entity_field_decorator_1 = require("./entity/entity-field.decorator");
|
||||
exports.EntityField = entity_field_decorator_1.EntityField;
|
||||
var object_value_decorator_1 = require("./entity/object-value.decorator");
|
||||
exports.ObjectValue = object_value_decorator_1.ObjectValue;
|
||||
var entity_decorator_1 = require("./entity/entity.decorator");
|
||||
exports.Entity = entity_decorator_1.Entity;
|
||||
var paris_module_1 = require("./paris.module");
|
||||
exports.ParisModule = paris_module_1.ParisModule;
|
|
@ -0,0 +1,4 @@
|
|||
export interface IIdentifiable {
|
||||
$key: string;
|
||||
name?: string;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
export declare type Index = {
|
||||
[index: string]: any;
|
||||
};
|
|
@ -0,0 +1,13 @@
|
|||
import 'rxjs/add/observable/throw';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/of';
|
||||
import 'rxjs/add/observable/combineLatest';
|
||||
import 'rxjs/add/observable/from';
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/mergeMap';
|
||||
import 'rxjs/add/operator/share';
|
||||
import 'rxjs/add/operator/finally';
|
||||
import 'rxjs/add/operator/toPromise';
|
||||
import 'rxjs/add/observable/merge';
|
||||
import "reflect-metadata";
|
|
@ -0,0 +1,6 @@
|
|||
import "./operators";
|
||||
import { ModuleWithProviders } from "@angular/core";
|
||||
import { ParisConfig } from "./config/paris-config";
|
||||
export declare class ParisModule {
|
||||
static forRoot(config: ParisConfig): ModuleWithProviders;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
import { Repository } from "./repository";
|
||||
import { IRepository } from "./repository.interface";
|
||||
import { DataEntityConstructor } from "../entity/data-entity.base";
|
||||
import { Subject } from "rxjs/Subject";
|
||||
import { DataStoreService } from "../services/data-store/data-store.service";
|
||||
import { IIdentifiable } from "../models/identifiable.model";
|
||||
import { ParisConfig } from "../config/paris-config";
|
||||
export declare class RepositoryManagerService {
|
||||
private dataStore;
|
||||
private config;
|
||||
private repositories;
|
||||
save$: Subject<RepositoryEvent>;
|
||||
constructor(dataStore: DataStoreService, config: ParisConfig);
|
||||
getRepository<T extends IIdentifiable>(entityConstructor: DataEntityConstructor<T>): Repository<T> | null;
|
||||
}
|
||||
export interface RepositoryEvent {
|
||||
repository: IRepository;
|
||||
item: any;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
import { ModelEntity } from "../entity/entity.config";
|
||||
import { DataEntityConstructor } from "../entity/data-entity.base";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { RepositoryManagerService } from "./repository-manager.service";
|
||||
import { IRepository } from "./repository.interface";
|
||||
import { DataStoreService } from "../services/data-store/data-store.service";
|
||||
import { IIdentifiable } from "../models/identifiable.model";
|
||||
import { ParisConfig } from "../config/paris-config";
|
||||
import { DataSetOptions } from "../dataset/dataset-options";
|
||||
import { DataSet } from "../dataset/dataset";
|
||||
import { Index } from "../models/index";
|
||||
export declare class Repository<T extends IIdentifiable> implements IRepository {
|
||||
readonly entity: ModelEntity;
|
||||
private config;
|
||||
private entityConstructor;
|
||||
private dataStore;
|
||||
private repositoryManagerService;
|
||||
save$: Observable<T>;
|
||||
private _allItems$;
|
||||
private _allValues;
|
||||
private _allValuesMap;
|
||||
private _cache;
|
||||
private _allItemsSubject$;
|
||||
private _saveSubject$;
|
||||
readonly allItems$: Observable<Array<T>>;
|
||||
private readonly cache;
|
||||
constructor(entity: ModelEntity, config: ParisConfig, entityConstructor: DataEntityConstructor<T>, dataStore: DataStoreService, repositoryManagerService: RepositoryManagerService);
|
||||
createItem(itemData: any): Observable<T>;
|
||||
createNewItem(): T;
|
||||
/**
|
||||
* Populates the item dataset with any sub @model. For example, if an ID is found for a property whose type is an entity,
|
||||
* the property's value will be an instance of that entity, for the ID, not the ID.
|
||||
* @param itemData
|
||||
* @returns {Observable<ModelData>}
|
||||
*/
|
||||
private getModelData(itemData);
|
||||
private static mapToEntityFieldIndex(entityFieldId, value);
|
||||
private getEntityItem(repository, itemData);
|
||||
getItemsDataSet(options?: DataSetOptions): Observable<DataSet<T>>;
|
||||
getItemById(itemId: string | number, allowCache?: boolean): Observable<T>;
|
||||
save(item: T): Observable<T>;
|
||||
getItemSaveData(item: T): Index;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
import { Observable } from "rxjs/Observable";
|
||||
import { IIdentifiable } from "../models/identifiable.model";
|
||||
import { DataSetOptions } from "../dataset/dataset-options";
|
||||
import { DataSet } from "../dataset/dataset";
|
||||
import { ModelEntity } from "../entity/entity.config";
|
||||
export interface IRepository {
|
||||
entity: ModelEntity;
|
||||
createItem: (itemData: any) => Observable<Readonly<any>>;
|
||||
createNewItem: () => IIdentifiable;
|
||||
getItemById: (id: any) => Observable<any>;
|
||||
getItemsDataSet: (options?: DataSetOptions) => Observable<DataSet<any>>;
|
||||
getItemSaveData: (item: IIdentifiable) => Object;
|
||||
allItems$: Observable<Array<any>>;
|
||||
save: (item: IIdentifiable) => Observable<IIdentifiable>;
|
||||
save$: Observable<any>;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { Observable } from "rxjs/Observable";
|
||||
export declare class DataCache<T> {
|
||||
time: number;
|
||||
obj: number;
|
||||
getter: (_: any) => Promise<T> | Observable<T>;
|
||||
private _keys;
|
||||
private _values;
|
||||
private _timeouts;
|
||||
private _getObservable;
|
||||
constructor(settings?: DataCacheSettings<T>);
|
||||
/**
|
||||
* Gets a value from the cache collection.
|
||||
* If getter is specified, uses it to get the data.
|
||||
* @param key
|
||||
* @returns {Observable<T>}
|
||||
*/
|
||||
get(key: any): Observable<T>;
|
||||
/**
|
||||
* Adds an item to the Cached collection. If DataCache.time was specified, the item will expire after this time (in milliseconds), and will be deleted.
|
||||
* @param key {String}
|
||||
* @param value
|
||||
* @returns {Cache}
|
||||
*/
|
||||
add(key: any, value: T): DataCache<T>;
|
||||
/**
|
||||
* Removes an item from the cache collection.
|
||||
* @param key
|
||||
* @returns {*}
|
||||
*/
|
||||
remove(key: any): T;
|
||||
clearGetters(): void;
|
||||
private static validateSettings<T>(config?);
|
||||
}
|
||||
export interface DataCacheSettings<T> {
|
||||
max?: number;
|
||||
time?: number;
|
||||
getter?: (_: any) => Observable<T>;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Observable } from "rxjs/Observable";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { ParisConfig } from "../../config/paris-config";
|
||||
export declare class DataStoreService {
|
||||
private http;
|
||||
private config;
|
||||
private activeRequests;
|
||||
constructor(http: HttpClient, config: ParisConfig);
|
||||
get(endpoint: string, data?: RequestData): Observable<any>;
|
||||
post(endpoint: string, data?: RequestData): Observable<any>;
|
||||
private getEndpointUrl(endpoint);
|
||||
private setActiveRequest(obs, verb, endpoint, data?);
|
||||
private getActiveRequestId(verb, endpoint, data?);
|
||||
}
|
||||
export interface RequestData {
|
||||
[index: string]: any;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import { HttpClient } from "@angular/common/http";
|
||||
import { DataStoreService } from "./data-store.service";
|
||||
import { ParisConfig } from "../../config/paris-config";
|
||||
export declare let dataStoreServiceFactory: (http: HttpClient, dataStoreOptions: ParisConfig) => DataStoreService;
|
|
@ -0,0 +1,10 @@
|
|||
import { DataEntityType } from "../entity/data-entity.base";
|
||||
export declare class DataTransformersService {
|
||||
static parse(type: DataEntityType, value: any): any;
|
||||
static serialize(type: DataEntityType, value: any): any;
|
||||
}
|
||||
export interface DataTransformer {
|
||||
type: any;
|
||||
parse: Function;
|
||||
serialize: Function;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import { DataEntityType } from "../entity/data-entity.base";
|
||||
import { EntityConfigBase } from "../entity/entity-config.base";
|
||||
export declare abstract class EntitiesServiceBase<T extends EntityConfigBase> {
|
||||
protected _allEntities: Map<DataEntityType, T>;
|
||||
readonly allEntities: Array<T>;
|
||||
getEntityByType(dataEntityType: DataEntityType): T;
|
||||
addEntity(dataEntityType: DataEntityType, entity: T): T;
|
||||
getEntityByPluralName(pluralName: string): DataEntityType;
|
||||
private getDataEntityTypeFields(dataEntityType);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { ModelEntity } from "../entity/entity.config";
|
||||
import { EntitiesServiceBase } from "./entities.service.base";
|
||||
export declare class EntitiesService extends EntitiesServiceBase<ModelEntity> {
|
||||
}
|
||||
export declare let entitiesService: EntitiesService;
|
|
@ -0,0 +1,9 @@
|
|||
import { DataEntityType } from "../entity/data-entity.base";
|
||||
import { EntityFields } from "../entity/entity-fields";
|
||||
import { Field } from "../entity/entity-field";
|
||||
export declare class EntityFieldsService {
|
||||
protected fields: Map<DataEntityType, EntityFields>;
|
||||
addField(dataEntityType: DataEntityType, field: Field): void;
|
||||
getDataTypeFields(dataEntityType: DataEntityType): EntityFields;
|
||||
}
|
||||
export declare const entityFieldsService: EntityFieldsService;
|
|
@ -0,0 +1,4 @@
|
|||
export declare class Immutability {
|
||||
static freeze<T>(obj: T): Readonly<T>;
|
||||
static unfreeze<T>(obj: Readonly<T>): T;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { EntitiesServiceBase } from "./entities.service.base";
|
||||
import { ModelObjectValue } from "../entity/object-value.config";
|
||||
export declare class ObjectValuesService extends EntitiesServiceBase<ModelObjectValue> {
|
||||
}
|
||||
export declare let objectValuesService: ObjectValuesService;
|
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var repository_1 = require("./repository/repository");
|
||||
exports.Repository = repository_1.Repository;
|
||||
__export(require("./repository/repository-manager.service"));
|
||||
var data_transformers_service_1 = require("./services/data-transformers.service");
|
||||
exports.DataTransformersService = data_transformers_service_1.DataTransformersService;
|
||||
var entity_config_1 = require("./entity/entity.config");
|
||||
exports.ModelEntity = entity_config_1.ModelEntity;
|
||||
var entity_fields_service_1 = require("./services/entity-fields.service");
|
||||
exports.entityFieldsService = entity_fields_service_1.entityFieldsService;
|
||||
var entities_service_1 = require("./services/entities.service");
|
||||
exports.entitiesService = entities_service_1.entitiesService;
|
||||
var object_value_config_1 = require("./entity/object-value.config");
|
||||
exports.ModelObjectValue = object_value_config_1.ModelObjectValue;
|
||||
var entity_field_decorator_1 = require("./entity/entity-field.decorator");
|
||||
exports.EntityField = entity_field_decorator_1.EntityField;
|
||||
var object_value_decorator_1 = require("./entity/object-value.decorator");
|
||||
exports.ObjectValue = object_value_decorator_1.ObjectValue;
|
||||
var entity_decorator_1 = require("./entity/entity.decorator");
|
||||
exports.Entity = entity_decorator_1.Entity;
|
||||
var paris_module_1 = require("./paris.module");
|
||||
exports.ParisModule = paris_module_1.ParisModule;
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var repository_1 = require("./repository/repository");
|
||||
exports.Repository = repository_1.Repository;
|
||||
__export(require("./repository/repository-manager.service"));
|
||||
var data_transformers_service_1 = require("./services/data-transformers.service");
|
||||
exports.DataTransformersService = data_transformers_service_1.DataTransformersService;
|
||||
var entity_config_1 = require("./entity/entity.config");
|
||||
exports.ModelEntity = entity_config_1.ModelEntity;
|
||||
var entity_fields_service_1 = require("./services/entity-fields.service");
|
||||
exports.entityFieldsService = entity_fields_service_1.entityFieldsService;
|
||||
var entities_service_1 = require("./services/entities.service");
|
||||
exports.entitiesService = entities_service_1.entitiesService;
|
||||
var object_value_config_1 = require("./entity/object-value.config");
|
||||
exports.ModelObjectValue = object_value_config_1.ModelObjectValue;
|
||||
var entity_field_decorator_1 = require("./entity/entity-field.decorator");
|
||||
exports.EntityField = entity_field_decorator_1.EntityField;
|
||||
var object_value_decorator_1 = require("./entity/object-value.decorator");
|
||||
exports.ObjectValue = object_value_decorator_1.ObjectValue;
|
||||
var entity_decorator_1 = require("./entity/entity.decorator");
|
||||
exports.Entity = entity_decorator_1.Entity;
|
||||
var paris_module_1 = require("./paris.module");
|
||||
exports.ParisModule = paris_module_1.ParisModule;
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,14 @@
|
|||
export { Repository } from "./bundle/lib/repository/repository";
|
||||
export * from "./bundle/lib/repository/repository-manager.service";
|
||||
export { IRepository } from "./bundle/lib/repository/repository.interface";
|
||||
export { IIdentifiable } from "./bundle/lib/models/identifiable.model";
|
||||
export { ParisConfig } from "./bundle/lib/config/paris-config";
|
||||
export { DataTransformersService, DataTransformer } from "./bundle/lib/services/data-transformers.service";
|
||||
export { ModelEntity, EntityConfig, ModelEntityCacheConfig } from "./bundle/lib/entity/entity.config";
|
||||
export { entityFieldsService } from "./bundle/lib/services/entity-fields.service";
|
||||
export { entitiesService } from "./bundle/lib/services/entities.service";
|
||||
export { ModelObjectValue } from "./bundle/lib/entity/object-value.config";
|
||||
export { EntityField } from "./bundle/lib/entity/entity-field.decorator";
|
||||
export { ObjectValue } from "./bundle/lib/entity/object-value.decorator";
|
||||
export { Entity } from "./bundle/lib/entity/entity.decorator";
|
||||
export { ParisModule } from "./bundle/lib/paris.module";
|
2
index.ts
2
index.ts
|
@ -1 +1 @@
|
|||
export * from "./paris.umd";
|
||||
export * from "./lib/main";
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
"@angular/service-worker": "^1.0.0-beta.16",
|
||||
"core-js": "^2.4.1",
|
||||
"intl": "^1.2.5",
|
||||
"rxjs": "^5.4.2",
|
||||
"systemjs": "0.20.14",
|
||||
"zone.js": "0.8.12"
|
||||
"rxjs": "^5.2.0",
|
||||
"systemjs": "^0.20.12",
|
||||
"zone.js": "^0.8.7"
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче