forms-angular 0.12.0-beta.306 → 0.12.0-beta.307

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.
@@ -0,0 +1,136 @@
1
+ import { Error, FilterQuery, Model, Types } from "mongoose";
2
+ import {Express} from "express";
3
+
4
+ declare module fngServer {
5
+ export interface ISearchResult {
6
+ id: any,
7
+ text: string,
8
+ url?: string,
9
+ additional?: string,
10
+ resource?: string,
11
+ resourceText: string,
12
+ resourceTab?: string,
13
+ weighting: number,
14
+ }
15
+
16
+ interface IInternalSearchResult extends ISearchResult {
17
+ // for use in internal find - handles search result ordering etc.
18
+ searchImportance? : number;
19
+ addHits?: number;
20
+ matched: number[];
21
+ resourceCollection: string;
22
+ // the next two are only set where the resource options includes disambiguation instructions and multiple search results with the same text value are found...:
23
+ disambiguationId?: any; // this will identify the record (from another resource) that will be used to disambiguate them
24
+ disambiguationResource?: string ;// ...and this will identify that resource
25
+ }
26
+
27
+ export interface IIdIsList {
28
+ params: string;
29
+ }
30
+
31
+ export interface Path {
32
+ }
33
+
34
+ export interface Paths {
35
+ [pathName: string]: Path;
36
+ }
37
+
38
+ export type ISearchResultFormatter = () => Promise<ISearchResult>;
39
+
40
+ export type Dependency = {
41
+ resource: Resource;
42
+ keys: string[];
43
+ }
44
+
45
+ export type DependencyList = Dependency[];
46
+
47
+ export type ForeignKeys = { resourceName: string, key: string, id: Types.ObjectId};
48
+ export type ForeignKeyList = ForeignKeys[];
49
+
50
+ export interface ResourceOptions {
51
+ suppressDeprecatedMessage?: boolean;
52
+ onRemove?: (doc, req, cb) => void;
53
+ handleRemove?: 'allow' | 'cascade'; // default behaviour is to prevent deletion if record is used as a foreign key
54
+ searchImportance?: boolean | number,
55
+ onSave?: (doc, req, cb) => void,
56
+ onSaveError?: (err:Error, req: Express.Request, res: Express.Response) => void,
57
+ findFunc?: (req: Express.Request, cb: (err:Error, criteria?: FilterQuery<any>) => void) => void,
58
+ getOrgCriteria?: (userOrganisation: string) => Promise<any>
59
+ idIsList?: IIdIsList,
60
+ searchResultFormat?: ISearchResultFormatter,
61
+ searchOrder?: any,
62
+ doNotCacheSchema?: boolean, // useful if bespoke fields can be added at runtime, for instance
63
+ listOrder?: any,
64
+ onAccess?: (req, cb) => void,
65
+ searchFunc?: SearchFunc;
66
+ synonyms? : {name: string, filter?: any}[], // name must be lower case
67
+ resourceName?: string, // allows a resource to have diference modelName specified
68
+ // when performing a search, two results from this resource with the same value for .text will be disambiguated by
69
+ // appending the description of the record from disambiguation.resource whose id matches result[disambiguation.field]
70
+ disambiguation?: {
71
+ field: string;
72
+ resource: string;
73
+ }
74
+ // below here are autogenerated
75
+ listFields?: ListField[]; // added after preprocess
76
+ dependents?: DependencyList; // can be added by generateDependencyList
77
+ hide? : string[]; // added after preprocess
78
+ searchFields? : string[]; // added after preprocess
79
+ paths?: Paths;
80
+ }
81
+
82
+ type SearchFunc = (resource: Resource,
83
+ req: Express.Request,
84
+ aggregationParam: any,
85
+ findParam: any,
86
+ sortOrder: any,
87
+ limit: number | null,
88
+ skip: number | null,
89
+ callback: (err: Error, docs?: any[]) => void
90
+ ) => void;
91
+
92
+ interface ResourceExport {
93
+ model?: Model<any>; // TODO TS Get rid of the ? here
94
+ options?: ResourceOptions;
95
+ }
96
+
97
+ interface Resource extends ResourceExport {
98
+ resourceName: string;
99
+ resourceNameLower: string;
100
+ preprocessed?: {[formName: string] : any};
101
+ }
102
+
103
+ interface ListParams {
104
+ ref: Boolean; // The object is this a lookup?
105
+ }
106
+
107
+ interface ListField {
108
+ field: string;
109
+ params?: ListParams;
110
+ }
111
+
112
+ interface IFngPlugin {
113
+ plugin: (fng: any, processArgs: (options: FngOptions, array: any[]) => any[], options: any) => Partial<IFngPlugin>;
114
+ options: any;
115
+ dependencyChecks? : { [resourceName: string] : DependencyList; };
116
+ }
117
+
118
+ interface IPluginMap {
119
+ [key: string]: IFngPlugin;
120
+ }
121
+
122
+ interface FngOptions {
123
+ urlPrefix?: string,
124
+ plugins?: IPluginMap,
125
+ authentication?: (() => void)[];
126
+ modelFilter? : (p1: any, req: Request, resources: Resource[]) => Resource[]
127
+ }
128
+
129
+ type AmbiguousRecordStore<t> = { [resource: string]: t[] };
130
+
131
+ interface DisambiguatableLookupItem {
132
+ id: string;
133
+ text: string;
134
+ disambiguationId?: string;
135
+ }
136
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mark Chapman <support@forms-angular.org>",
4
4
  "description": "A form builder that sits on top of Angular.js, Twitter Bootstrap, jQuery UI, Angular-UI, Express and Mongoose. Opinionated or what?",
5
5
  "homepage": "http://forms-angular.org",
6
- "version": "0.12.0-beta.306",
6
+ "version": "0.12.0-beta.307",
7
7
  "engines": {
8
8
  "node": ">=8.x",
9
9
  "npm": ">=5.x"