ng2-json-editor
Version:
Angular2 component for editing large json documents
57 lines (56 loc) • 2.39 kB
TypeScript
import { Map, OrderedSet, Iterable } from 'immutable';
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { Subject } from 'rxjs/Subject';
import { JSONSchema } from '../interfaces';
import { PathUtilService } from './path-util.service';
import { JsonSchemaService } from './json-schema.service';
import { AppGlobalsService } from './app-globals.service';
import { CompareKeysBySchemaService } from './compare-keys-by-schema.service';
export declare class KeysStoreService {
private appGlobalsService;
private pathUtilService;
private jsonSchemaService;
private compareKeysBySchemaService;
private keys$Map;
keysMap: {
[path: string]: OrderedSet<string>;
};
onKeysChange: Subject<{
path: string;
keys: OrderedSet<string>;
}>;
constructor(appGlobalsService: AppGlobalsService, pathUtilService: PathUtilService, jsonSchemaService: JsonSchemaService, compareKeysBySchemaService: CompareKeysBySchemaService);
forPath(path: string): ReplaySubject<OrderedSet<string>>;
/**
* Adds a key to the specified path.
*
* @param path path to add the key to
* @param key key to be added
* @param schema schema that belongs to path (schema.items for table-list)
*/
addKey(path: string, key: string, schema: JSONSchema, value?: any): string;
deletePath(path: Array<any>): void;
/**
* Sync keys in store for the given path or its parent, grand parent etc. if necessary
*
* @param path path to the (re)set field
* @param json whole json
*/
syncKeysForPath(path: Array<any>, json: Map<string, any>): void;
deleteKey(parentPath: string, key: string): void;
/**
* Swaps keys of given two indices in object list recursively
*/
swapListElementKeys(listPath: Array<any>, index1: number, index2: number): void;
buildKeysMap(json: Map<string, any>, schema: JSONSchema): void;
buildKeysMapRecursivelyForPath(mapOrList: Iterable<string | number, any>, path: string | Array<any>, schema?: JSONSchema): void;
private buildKeysForTableList(path, list, schema);
private buildkeysForObject(path, map, schema);
/**
* Filters keys, add alwaysShow fields and sorts by schema.
*/
private schemafy(keys, schema);
private isNotHidden(key, schema);
private isObjectOrArray(schema);
private setKeys(path, keys);
}