@tellescope/schema 0.0.5 → 0.0.9
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.
- package/lib/cjs/schema.d.ts +158 -1
- package/lib/cjs/schema.d.ts.map +1 -1
- package/lib/cjs/schema.js +214 -164
- package/lib/cjs/schema.js.map +1 -1
- package/lib/esm/schema.d.ts +158 -1
- package/lib/esm/schema.d.ts.map +1 -1
- package/lib/esm/schema.js +215 -165
- package/lib/esm/schema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/schema.ts +381 -183
- package/tsconfig.json +1 -1
package/lib/cjs/schema.d.ts
CHANGED
|
@@ -1,4 +1,126 @@
|
|
|
1
|
-
import "@tellescope/types";
|
|
1
|
+
import { ServerModelForName, DatabaseModel, DatabaseRecord, Enduser, ObjectId, ModelName } from "@tellescope/types-server";
|
|
2
|
+
import { ErrorInfo, Indexable, Operation, JSONType, CRUD, HTTPMethod } from "@tellescope/types-utilities";
|
|
3
|
+
import { EnduserSession, ConfiguredSession, JourneyState, UserSession } from "@tellescope/types-models";
|
|
4
|
+
import { EscapeBuilder } from "@tellescope/validation";
|
|
5
|
+
export declare type RelationshipConstraint<T> = {
|
|
6
|
+
explanation: string;
|
|
7
|
+
evaluate: (v: T, dependencies: Indexable<Partial<DatabaseModel>>) => string | void;
|
|
8
|
+
};
|
|
9
|
+
export declare type DependencyAccessConstraint<T> = {
|
|
10
|
+
type: 'dependency';
|
|
11
|
+
foreignModel: ModelName;
|
|
12
|
+
foreignField: string;
|
|
13
|
+
accessField: keyof T;
|
|
14
|
+
};
|
|
15
|
+
export declare type AccessConstraint<T> = {
|
|
16
|
+
type: 'creatorOnly';
|
|
17
|
+
} | {
|
|
18
|
+
type: 'filter';
|
|
19
|
+
field: string;
|
|
20
|
+
} | DependencyAccessConstraint<T>;
|
|
21
|
+
export declare type UniqueArrayConstraint<T> = {
|
|
22
|
+
array: keyof T;
|
|
23
|
+
itemKey?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare type Constraint<T> = {
|
|
26
|
+
unique: (keyof T & string | UniqueArrayConstraint<T>)[];
|
|
27
|
+
globalUnique?: (keyof T)[];
|
|
28
|
+
relationship: RelationshipConstraint<Partial<T>>[];
|
|
29
|
+
access?: AccessConstraint<T>[];
|
|
30
|
+
};
|
|
31
|
+
export declare type Initializer<T, R> = (a: T, s: ConfiguredSession | EnduserSession) => R;
|
|
32
|
+
export declare type EndpointOptions = {
|
|
33
|
+
parameters?: {
|
|
34
|
+
[index: string]: EscapeBuilder<any>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare type DependencyDeletionAction = 'delete' | 'unset' | 'setNull' | 'nop';
|
|
38
|
+
export declare type DependecyRelationship = 'foreignKey' | 'value';
|
|
39
|
+
export declare type Dependency<T = DatabaseRecord> = {
|
|
40
|
+
dependsOn: ModelName[];
|
|
41
|
+
dependencyField: string;
|
|
42
|
+
relationship: DependecyRelationship;
|
|
43
|
+
onDependencyDelete: DependencyDeletionAction;
|
|
44
|
+
getDependentValues?: (t: T) => JSONType[];
|
|
45
|
+
filterByDependency?: (foreignValue: JSONType, foreignModel?: DatabaseModel) => {
|
|
46
|
+
field: string;
|
|
47
|
+
value: JSONType | 'any';
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export declare type ModelFieldInfo<T, R> = {
|
|
51
|
+
validator: EscapeBuilder<R>;
|
|
52
|
+
readonly?: boolean;
|
|
53
|
+
required?: boolean;
|
|
54
|
+
updatesDisabled?: boolean;
|
|
55
|
+
examples?: JSONType[];
|
|
56
|
+
initializer?: Initializer<Partial<T>, R>;
|
|
57
|
+
dependencies?: Dependency<Partial<T>>[];
|
|
58
|
+
};
|
|
59
|
+
export declare type ModelFields<T> = {
|
|
60
|
+
[K in keyof T]: ModelFieldInfo<T, T[K]>;
|
|
61
|
+
};
|
|
62
|
+
export declare type extractFields<Type> = Type extends ModelFields<infer X> ? X : never;
|
|
63
|
+
declare type ActionInfo = {
|
|
64
|
+
name?: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
notes?: string[];
|
|
67
|
+
warnings?: string[];
|
|
68
|
+
};
|
|
69
|
+
declare type CustomAction<P = any, R = any> = {
|
|
70
|
+
op: Operation | 'custom';
|
|
71
|
+
access: CRUD;
|
|
72
|
+
parameters: ModelFields<P>;
|
|
73
|
+
returns: R extends Array<any> ? ModelFieldInfo<any, R> : ModelFields<R>;
|
|
74
|
+
path?: string;
|
|
75
|
+
method?: HTTPMethod;
|
|
76
|
+
enduserOnly?: boolean;
|
|
77
|
+
} & ActionInfo;
|
|
78
|
+
export declare type EnduserAction = {
|
|
79
|
+
field?: string;
|
|
80
|
+
} & ActionInfo;
|
|
81
|
+
declare type CustomActionsForModel = {
|
|
82
|
+
[K in ModelName]: {
|
|
83
|
+
[index: string]: CustomAction;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
declare type ReadFilter<T> = {
|
|
87
|
+
[K in keyof T]?: {
|
|
88
|
+
required: boolean;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export declare type SideEffectHandler<T, O = any> = (args: Partial<T>[], m: (Partial<T> | undefined)[] | undefined, n: (Partial<T> & {
|
|
92
|
+
_id: ObjectId;
|
|
93
|
+
})[], s: ConfiguredSession | EnduserSession, o: O) => Promise<ErrorInfo[]>;
|
|
94
|
+
declare type SideEffect = {
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
export declare type Model<T, N extends ModelName> = {
|
|
99
|
+
info: {
|
|
100
|
+
name?: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
sideEffects?: {
|
|
103
|
+
[K in Operation]?: SideEffect[];
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
fields: ModelFields<T>;
|
|
107
|
+
constraints: Constraint<T>;
|
|
108
|
+
defaultActions: {
|
|
109
|
+
[k in Operation]?: ActionInfo;
|
|
110
|
+
};
|
|
111
|
+
enduserActions?: {
|
|
112
|
+
[index: string]: EnduserAction;
|
|
113
|
+
};
|
|
114
|
+
customActions: CustomActionsForModel[N];
|
|
115
|
+
readFilter?: ReadFilter<T>;
|
|
116
|
+
options?: {
|
|
117
|
+
create?: EndpointOptions;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export declare type extractModelType<Type> = Type extends Model<infer T, infer N> ? T : never;
|
|
121
|
+
export declare type Schema = {
|
|
122
|
+
[N in keyof ServerModelForName]: Model<ServerModelForName[N], ModelName>;
|
|
123
|
+
};
|
|
2
124
|
declare const sideEffects: {
|
|
3
125
|
trackJourneyEngagement: {
|
|
4
126
|
name: string;
|
|
@@ -12,6 +134,10 @@ declare const sideEffects: {
|
|
|
12
134
|
name: string;
|
|
13
135
|
description: string;
|
|
14
136
|
};
|
|
137
|
+
updateChatroomCache: {
|
|
138
|
+
name: string;
|
|
139
|
+
description: string;
|
|
140
|
+
};
|
|
15
141
|
};
|
|
16
142
|
export declare type SideEffectNames = keyof typeof sideEffects;
|
|
17
143
|
declare const BuiltInFields: {
|
|
@@ -40,6 +166,21 @@ export declare type CustomActions = {
|
|
|
40
166
|
key: string;
|
|
41
167
|
}>;
|
|
42
168
|
};
|
|
169
|
+
files: {
|
|
170
|
+
prepare_file_upload: CustomAction<{
|
|
171
|
+
name: string;
|
|
172
|
+
size: number;
|
|
173
|
+
type: string;
|
|
174
|
+
}, {
|
|
175
|
+
presignedUpload: object;
|
|
176
|
+
file: File;
|
|
177
|
+
}>;
|
|
178
|
+
file_download_URL: CustomAction<{
|
|
179
|
+
secureName: string;
|
|
180
|
+
}, {
|
|
181
|
+
downloadURL: string;
|
|
182
|
+
}>;
|
|
183
|
+
};
|
|
43
184
|
journeys: {
|
|
44
185
|
update_state: CustomAction<{
|
|
45
186
|
updates: JourneyState;
|
|
@@ -62,6 +203,22 @@ export declare type CustomActions = {
|
|
|
62
203
|
isAuthenticated: false;
|
|
63
204
|
enduser: null;
|
|
64
205
|
}>;
|
|
206
|
+
refresh_session: CustomAction<{}, {
|
|
207
|
+
enduser: Enduser;
|
|
208
|
+
authToken: string;
|
|
209
|
+
}>;
|
|
210
|
+
logout: CustomAction<{}, {}>;
|
|
211
|
+
};
|
|
212
|
+
users: {
|
|
213
|
+
display_names: CustomAction<{}, {
|
|
214
|
+
fname: string;
|
|
215
|
+
lname: string;
|
|
216
|
+
id: string;
|
|
217
|
+
}[]>;
|
|
218
|
+
refresh_session: CustomAction<{}, {
|
|
219
|
+
user: UserSession;
|
|
220
|
+
authToken: string;
|
|
221
|
+
}>;
|
|
65
222
|
};
|
|
66
223
|
};
|
|
67
224
|
export declare type PublicActions = {
|
package/lib/cjs/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,OAAO,EACP,QAAQ,EACR,SAAS,EACV,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,UAAU,EACX,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACZ,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EACL,aAAa,EAmCd,MAAM,wBAAwB,CAAA;AAO/B,oBAAY,sBAAsB,CAAC,CAAC,IAAI;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;CACpF,CAAA;AAED,oBAAY,0BAA0B,CAAE,CAAC,IAA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,OAAO,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC3E,MAAM,EAAE,YAAY,CAAC,EAAG,EAAE,EAAG,CAAC,CAAC;KAChC,CAAC;IACF,KAAK,EAAE;QACL,aAAa,EAAE,YAAY,CAAC,EAAG,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC,CAAC;QACjF,eAAe,EAAE,YAAY,CAAC,EAAE,EAAE;YAAE,IAAI,EAAE,WAAW,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC7E,CAAA;CACF,CAAA;AAED,oBAAY,aAAa,GAAG;IAC1B,QAAQ,EAAE;QACR,KAAK,EAAE,YAAY,CAAC;YAAE,EAAE,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,EAAE;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC/G,CAAC;CACH,CAAA;AAED,oBAAY,QAAQ,GAAG,MAAM,GAAG;KAC7B,CAAC,IAAI,MAAM,aAAa,GAAG;QAC1B,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;KAChC;CACF,GAAG;KACD,CAAC,IAAI,MAAM,aAAa,GAAG;QAC1B,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;KAChC;CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QA2zBpB,CAAA"}
|
package/lib/cjs/schema.js
CHANGED
|
@@ -12,105 +12,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.schema = void 0;
|
|
15
|
-
require("@tellescope/types");
|
|
16
|
-
// import "@tellescope/types-server"
|
|
17
15
|
var validation_1 = require("@tellescope/validation");
|
|
18
16
|
var constants_1 = require("@tellescope/constants");
|
|
19
|
-
// type RelationshipConstraint<T> = {
|
|
20
|
-
// explanation: string; // human readable, for documentation purposes
|
|
21
|
-
// evaluate: (v: T, dependencies: Indexable<Partial<DatabaseModel>>) => string | void;
|
|
22
|
-
// }
|
|
23
|
-
// type DependencyAccessConstraint <T> = { type: 'dependency', foreignModel: ModelName, foreignField: string, accessField: keyof T }
|
|
24
|
-
// type AccessConstraint <T> = { type: 'creatorOnly' }
|
|
25
|
-
// | { type: 'filter', field: string }
|
|
26
|
-
// | DependencyAccessConstraint<T>
|
|
27
|
-
// type UniqueArrayConstraint <T> = { array: keyof T, itemKey?: string }
|
|
28
|
-
// type Constraint <T> = {
|
|
29
|
-
// unique: (keyof T & string | UniqueArrayConstraint<T>)[];
|
|
30
|
-
// globalUnique?: (keyof T)[];
|
|
31
|
-
// relationship: RelationshipConstraint<Partial<T>>[];
|
|
32
|
-
// access?: AccessConstraint<T>[];
|
|
33
|
-
// }
|
|
34
|
-
// type Initializer <T, R> = (a: T, s: ConfiguredSession) => R
|
|
35
|
-
// type EndpointOptions = {
|
|
36
|
-
// // parameters used for endpoint that aren't stored in the model
|
|
37
|
-
// parameters?: { [index: string]: EscapeBuilder<any> },
|
|
38
|
-
// }
|
|
39
|
-
// type DependencyDeletionAction = 'delete' | 'unset' | 'setNull' | 'nop'
|
|
40
|
-
// type DependecyRelationship = 'foreignKey' | 'value'
|
|
41
|
-
// type Dependency <T=DatabaseRecord> = {
|
|
42
|
-
// dependsOn: ModelName[], // list of => OR, multiple dependency records => AND
|
|
43
|
-
// dependencyField: string,
|
|
44
|
-
// relationship: DependecyRelationship,
|
|
45
|
-
// onDependencyDelete: DependencyDeletionAction,
|
|
46
|
-
// getDependentValues?: (t: T) => JSONType[], // for accessing the values of a Dependency
|
|
47
|
-
// filterByDependency?: (foreignValue: JSONType, foreignModel?: DatabaseModel) => { // for filtering against a Dependency
|
|
48
|
-
// field: string,
|
|
49
|
-
// value: JSONType | 'any',
|
|
50
|
-
// },
|
|
51
|
-
// }
|
|
52
|
-
// type ModelFieldInfo <T, R> = {
|
|
53
|
-
// validator: EscapeBuilder<R>,
|
|
54
|
-
// readonly?: boolean,
|
|
55
|
-
// required?: boolean,
|
|
56
|
-
// updatesDisabled?: boolean,
|
|
57
|
-
// examples?: JSONType[],
|
|
58
|
-
// initializer?: Initializer<Partial<T>, R>, // should include the required fields of T, not just partial
|
|
59
|
-
// dependencies?: Dependency<Partial<T>>[],
|
|
60
|
-
// }
|
|
61
|
-
// export type ModelFields<T> = {
|
|
62
|
-
// [K in keyof T]: ModelFieldInfo<T, T[K]>
|
|
63
|
-
// }
|
|
64
|
-
// type extractFields<Type> = Type extends ModelFields<infer X> ? X : never
|
|
65
|
-
// type ArgumentInfo = {
|
|
66
|
-
// description?: string;
|
|
67
|
-
// }
|
|
68
|
-
// type ActionInfo = {
|
|
69
|
-
// name?: string,
|
|
70
|
-
// description?: string,
|
|
71
|
-
// notes?: string[],
|
|
72
|
-
// warnings?: string[],
|
|
73
|
-
// }
|
|
74
|
-
// type CustomAction <P=any, R=any> = {
|
|
75
|
-
// op: Operation | 'custom',
|
|
76
|
-
// access: CRUD,
|
|
77
|
-
// // parameters: InputValidation<P>,
|
|
78
|
-
// parameters: ModelFields<P>,
|
|
79
|
-
// returns: ModelFields<R>,
|
|
80
|
-
// path?: string,
|
|
81
|
-
// method?: HTTPMethod,
|
|
82
|
-
// } & ActionInfo
|
|
83
|
-
// type CustomActionsForModel = {
|
|
84
|
-
// [K in ModelName]: { [index: string]: CustomAction }
|
|
85
|
-
// }
|
|
86
|
-
// type ReadFilter <T> = { [K in keyof T]?: { required: boolean } }
|
|
87
|
-
// // m is the original model (or undefined, if create)
|
|
88
|
-
// // allows for easier event handling based on specific updates (by comparing args to pre-update model)
|
|
89
|
-
// type SideEffectHandler <T, O=any> = (args: Partial<T>[], m: (Partial<T> | undefined)[] | undefined, n: (Partial<T> & { _id: ObjectId })[], s: ConfiguredSession, o: O) => Promise<ErrorInfo[]>;
|
|
90
|
-
// type SideEffect = {
|
|
91
|
-
// name: string;
|
|
92
|
-
// description: string;
|
|
93
|
-
// }
|
|
94
|
-
// export type Model<T, N extends ModelName> = {
|
|
95
|
-
// info: {
|
|
96
|
-
// name?: string,
|
|
97
|
-
// description?: string,
|
|
98
|
-
// sideEffects?: { [K in Operation]?: SideEffect[] }
|
|
99
|
-
// },
|
|
100
|
-
// fields: ModelFields<T>,
|
|
101
|
-
// constraints: Constraint<T>,
|
|
102
|
-
// defaultActions: { [K in Operation]?: ActionInfo },
|
|
103
|
-
// customActions: CustomActionsForModel[N],
|
|
104
|
-
// readFilter?: ReadFilter<T>,
|
|
105
|
-
// options?: {
|
|
106
|
-
// create?: EndpointOptions,
|
|
107
|
-
// }
|
|
108
|
-
// }
|
|
109
|
-
// type extractModelType<Type> = Type extends Model<infer T, infer N> ? T : never
|
|
110
|
-
// type DatabaseModelForName = ToServerModels<ModelForName>
|
|
111
|
-
// type Schema = {
|
|
112
|
-
// [N in keyof DatabaseModelForName]: Model<DatabaseModelForName[N], ModelName>
|
|
113
|
-
// }
|
|
114
17
|
var sideEffects = {
|
|
115
18
|
trackJourneyEngagement: {
|
|
116
19
|
name: "trackJourneyEngagement",
|
|
@@ -123,6 +26,10 @@ var sideEffects = {
|
|
|
123
26
|
sendSMSMessages: {
|
|
124
27
|
name: "sendSMSMessages",
|
|
125
28
|
description: "Sends emails if logOnly is not true"
|
|
29
|
+
},
|
|
30
|
+
updateChatroomCache: {
|
|
31
|
+
name: "updateChatroomCache",
|
|
32
|
+
description: "Updates the chatroom with a preview of the recent message and sender"
|
|
126
33
|
}
|
|
127
34
|
};
|
|
128
35
|
var BOOLEAN_EXAMPLES = [true, false];
|
|
@@ -152,49 +59,25 @@ exports.schema = {
|
|
|
152
59
|
update: [sideEffects.trackJourneyEngagement],
|
|
153
60
|
}
|
|
154
61
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
is_authenticated: {
|
|
168
|
-
op: "custom", access: 'read', method: "get",
|
|
169
|
-
name: 'Check enduser authentication',
|
|
170
|
-
path: '/enduser-is-authenticated',
|
|
171
|
-
description: "Checks the validity of an enduser's authToken",
|
|
172
|
-
parameters: {
|
|
173
|
-
id: { validator: validation_1.mongoIdStringValidator, required: true },
|
|
174
|
-
authToken: { validator: validation_1.stringValidator5000, required: true },
|
|
175
|
-
},
|
|
176
|
-
returns: {
|
|
177
|
-
isAuthenticated: { validator: validation_1.booleanValidator, required: true },
|
|
178
|
-
enduser: { validator: 'enduser' },
|
|
179
|
-
} // add enduser eventually, when validator defined
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
publicActions: {
|
|
183
|
-
login: {
|
|
184
|
-
op: "custom", access: 'read', method: "post",
|
|
185
|
-
name: 'Login enduser',
|
|
186
|
-
path: '/login-enduser',
|
|
187
|
-
description: "Generates an authentication token for access to enduser-facing endpoints",
|
|
188
|
-
parameters: {
|
|
189
|
-
id: { validator: validation_1.mongoIdStringValidator },
|
|
190
|
-
password: { validator: validation_1.stringValidator100, required: true },
|
|
191
|
-
phone: { validator: validation_1.phoneValidator },
|
|
192
|
-
email: { validator: validation_1.emailValidator },
|
|
193
|
-
},
|
|
194
|
-
returns: { authToken: { validator: validation_1.stringValidator5000 } },
|
|
195
|
-
},
|
|
62
|
+
constraints: {
|
|
63
|
+
unique: ['email', 'phone', 'externalId'],
|
|
64
|
+
relationship: [
|
|
65
|
+
{
|
|
66
|
+
explanation: 'One of email or phone is required',
|
|
67
|
+
evaluate: function (_a) {
|
|
68
|
+
var email = _a.email, phone = _a.phone;
|
|
69
|
+
if (!(email || phone))
|
|
70
|
+
return 'One of email or phone is required';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
],
|
|
196
74
|
},
|
|
197
|
-
|
|
75
|
+
defaultActions: constants_1.DEFAULT_OPERATIONS,
|
|
76
|
+
enduserActions: { logout: {}, refresh_session: {} },
|
|
77
|
+
fields: __assign(__assign({}, BuiltInFields), { externalId: {
|
|
78
|
+
validator: validation_1.stringValidator250,
|
|
79
|
+
examples: ['addfed3e-ddea-415b-b52b-df820c944dbb'],
|
|
80
|
+
}, email: {
|
|
198
81
|
validator: validation_1.emailValidator,
|
|
199
82
|
examples: ['test@tellescope.com'],
|
|
200
83
|
}, emailConsent: {
|
|
@@ -242,21 +125,80 @@ exports.schema = {
|
|
|
242
125
|
validator: validation_1.booleanValidator,
|
|
243
126
|
}, lastCommunication: {
|
|
244
127
|
validator: validation_1.dateValidator,
|
|
128
|
+
}, avatar: {
|
|
129
|
+
validator: validation_1.stringValidator100,
|
|
130
|
+
dependencies: [
|
|
131
|
+
{
|
|
132
|
+
dependsOn: ['files'],
|
|
133
|
+
dependencyField: 'secureName',
|
|
134
|
+
relationship: 'foreignKey',
|
|
135
|
+
onDependencyDelete: 'unset',
|
|
136
|
+
},
|
|
137
|
+
]
|
|
245
138
|
} }),
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
139
|
+
customActions: {
|
|
140
|
+
set_password: {
|
|
141
|
+
op: "custom", access: 'update', method: "post",
|
|
142
|
+
name: 'Set enduser password',
|
|
143
|
+
path: '/set-enduser-password',
|
|
144
|
+
description: "Sets (or resets) an enduser's password. Minimum length 8 characters.",
|
|
145
|
+
parameters: {
|
|
146
|
+
id: { validator: validation_1.mongoIdStringValidator, required: true },
|
|
147
|
+
password: { validator: validation_1.stringValidator100, required: true },
|
|
148
|
+
},
|
|
149
|
+
returns: {} //authToken: { validator: stringValidator5000 } },
|
|
150
|
+
},
|
|
151
|
+
is_authenticated: {
|
|
152
|
+
op: "custom", access: 'read', method: "get",
|
|
153
|
+
name: 'Check enduser authentication',
|
|
154
|
+
path: '/enduser-is-authenticated',
|
|
155
|
+
description: "Checks the validity of an enduser's authToken",
|
|
156
|
+
parameters: {
|
|
157
|
+
id: { validator: validation_1.mongoIdStringValidator, required: true },
|
|
158
|
+
authToken: { validator: validation_1.stringValidator5000, required: true },
|
|
159
|
+
},
|
|
160
|
+
returns: {
|
|
161
|
+
isAuthenticated: { validator: validation_1.booleanValidator, required: true },
|
|
162
|
+
enduser: { validator: 'enduser' },
|
|
163
|
+
} // todo: add enduser eventually, when validator defined
|
|
164
|
+
},
|
|
165
|
+
refresh_session: {
|
|
166
|
+
op: "custom", access: 'update', method: "post",
|
|
167
|
+
name: 'Refresh enduser authentication',
|
|
168
|
+
path: '/refresh-enduser-session',
|
|
169
|
+
description: "When called by an authenticated enduser, generates a new session",
|
|
170
|
+
parameters: {},
|
|
171
|
+
enduserOnly: true,
|
|
172
|
+
returns: {
|
|
173
|
+
authToken: { validator: validation_1.stringValidator, required: true },
|
|
174
|
+
enduser: { validator: 'enduser' },
|
|
175
|
+
} // todo: add enduser eventually, when validator defined
|
|
176
|
+
},
|
|
177
|
+
logout: {
|
|
178
|
+
op: "custom", access: 'update', method: "post",
|
|
179
|
+
name: 'Logout enduser',
|
|
180
|
+
path: '/logout-enduser',
|
|
181
|
+
description: "Logs out an enduser",
|
|
182
|
+
parameters: {},
|
|
183
|
+
returns: {},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
publicActions: {
|
|
187
|
+
login: {
|
|
188
|
+
op: "custom", access: 'read', method: "post",
|
|
189
|
+
name: 'Login enduser',
|
|
190
|
+
path: '/login-enduser',
|
|
191
|
+
description: "Generates an authentication token for access to enduser-facing endpoints",
|
|
192
|
+
enduserOnly: true,
|
|
193
|
+
parameters: {
|
|
194
|
+
id: { validator: validation_1.mongoIdStringValidator },
|
|
195
|
+
password: { validator: validation_1.stringValidator100, required: true },
|
|
196
|
+
phone: { validator: validation_1.phoneValidator },
|
|
197
|
+
email: { validator: validation_1.emailValidator },
|
|
198
|
+
},
|
|
199
|
+
returns: { authToken: { validator: validation_1.stringValidator5000 } },
|
|
200
|
+
},
|
|
258
201
|
},
|
|
259
|
-
defaultActions: constants_1.DEFAULT_OPERATIONS,
|
|
260
202
|
},
|
|
261
203
|
api_keys: {
|
|
262
204
|
info: {},
|
|
@@ -445,7 +387,7 @@ exports.schema = {
|
|
|
445
387
|
validator: validation_1.mongoIdStringValidator,
|
|
446
388
|
examples: [constants_1.PLACEHOLDER_ID],
|
|
447
389
|
readonly: true,
|
|
448
|
-
initializer: function (a, s) { return s.
|
|
390
|
+
initializer: function (a, s) { return s.id; },
|
|
449
391
|
}, subject: {
|
|
450
392
|
validator: validation_1.stringValidator,
|
|
451
393
|
required: true,
|
|
@@ -547,7 +489,7 @@ exports.schema = {
|
|
|
547
489
|
}, businessUserId: {
|
|
548
490
|
validator: validation_1.mongoIdStringValidator,
|
|
549
491
|
readonly: true,
|
|
550
|
-
initializer: function (a, s) { return s.
|
|
492
|
+
initializer: function (a, s) { return s.id; },
|
|
551
493
|
dependencies: [{
|
|
552
494
|
dependsOn: ['users'],
|
|
553
495
|
dependencyField: '_id',
|
|
@@ -585,7 +527,9 @@ exports.schema = {
|
|
|
585
527
|
{ type: 'filter', field: 'enduserIds' }
|
|
586
528
|
]
|
|
587
529
|
},
|
|
588
|
-
fields: __assign(__assign({}, BuiltInFields), {
|
|
530
|
+
fields: __assign(__assign({}, BuiltInFields), { title: {
|
|
531
|
+
validator: validation_1.stringValidator100,
|
|
532
|
+
}, type: {
|
|
589
533
|
validator: validation_1.chatRoomTypeValidator,
|
|
590
534
|
initializer: function () { return 'internal'; }
|
|
591
535
|
}, topic: {
|
|
@@ -600,18 +544,36 @@ exports.schema = {
|
|
|
600
544
|
}, enduserIds: {
|
|
601
545
|
validator: validation_1.listOfMongoIdStringValidator,
|
|
602
546
|
// add pull dependency for enduser deletion?
|
|
547
|
+
}, recentMessage: {
|
|
548
|
+
validator: validation_1.stringValidator,
|
|
549
|
+
initializer: function () { return ''; },
|
|
550
|
+
readonly: true,
|
|
551
|
+
}, recentSender: {
|
|
552
|
+
validator: validation_1.mongoIdStringValidator,
|
|
553
|
+
initializer: function () { return ''; },
|
|
554
|
+
readonly: true,
|
|
603
555
|
} }),
|
|
604
556
|
defaultActions: constants_1.DEFAULT_OPERATIONS,
|
|
605
557
|
enduserActions: { create: {}, read: {}, readMany: {} },
|
|
606
558
|
customActions: {},
|
|
607
559
|
},
|
|
608
560
|
chats: {
|
|
609
|
-
info: {
|
|
561
|
+
info: {
|
|
562
|
+
sideEffects: {
|
|
563
|
+
create: [sideEffects.updateChatroomCache]
|
|
564
|
+
}
|
|
565
|
+
},
|
|
610
566
|
constraints: {
|
|
611
567
|
unique: [],
|
|
612
568
|
relationship: [],
|
|
613
569
|
access: [{ type: 'dependency', foreignModel: 'chat_rooms', foreignField: '_id', accessField: 'roomId' }]
|
|
614
570
|
},
|
|
571
|
+
defaultActions: { create: {}, read: {}, readMany: {}, delete: {} },
|
|
572
|
+
readFilter: {
|
|
573
|
+
roomId: { required: true },
|
|
574
|
+
},
|
|
575
|
+
enduserActions: { create: {}, read: {}, readMany: {} },
|
|
576
|
+
customActions: {},
|
|
615
577
|
fields: __assign(__assign({}, BuiltInFields), { roomId: {
|
|
616
578
|
validator: validation_1.mongoIdStringValidator,
|
|
617
579
|
required: true,
|
|
@@ -626,7 +588,7 @@ exports.schema = {
|
|
|
626
588
|
}, senderId: {
|
|
627
589
|
validator: validation_1.mongoIdStringValidator,
|
|
628
590
|
readonly: true,
|
|
629
|
-
initializer: function (a, s) { var _a; return (_a = s.
|
|
591
|
+
initializer: function (a, s) { var _a; return (_a = s.id) !== null && _a !== void 0 ? _a : s.id; },
|
|
630
592
|
examples: [constants_1.PLACEHOLDER_ID],
|
|
631
593
|
dependencies: [{
|
|
632
594
|
dependsOn: ['users', 'endusers'],
|
|
@@ -650,12 +612,6 @@ exports.schema = {
|
|
|
650
612
|
}, readBy: {
|
|
651
613
|
validator: validation_1.idStringToDateValidator,
|
|
652
614
|
} }),
|
|
653
|
-
defaultActions: constants_1.DEFAULT_OPERATIONS,
|
|
654
|
-
readFilter: {
|
|
655
|
-
roomId: { required: true },
|
|
656
|
-
},
|
|
657
|
-
enduserActions: { create: {}, read: {}, readMany: {} },
|
|
658
|
-
customActions: {},
|
|
659
615
|
},
|
|
660
616
|
users: {
|
|
661
617
|
info: {},
|
|
@@ -665,7 +621,30 @@ exports.schema = {
|
|
|
665
621
|
relationship: [],
|
|
666
622
|
},
|
|
667
623
|
defaultActions: { read: {}, readMany: {} },
|
|
668
|
-
customActions: {
|
|
624
|
+
customActions: {
|
|
625
|
+
display_names: {
|
|
626
|
+
op: "custom", access: 'read', method: "get",
|
|
627
|
+
name: 'User Display Names',
|
|
628
|
+
path: '/user-display-names',
|
|
629
|
+
description: "Gets display names for users, accessible by endusers",
|
|
630
|
+
parameters: {},
|
|
631
|
+
returns: {
|
|
632
|
+
validator: validation_1.listOfDisplayNameInfo
|
|
633
|
+
},
|
|
634
|
+
},
|
|
635
|
+
refresh_session: {
|
|
636
|
+
op: "custom", access: 'update', method: "post",
|
|
637
|
+
name: 'Refresh enduser authentication',
|
|
638
|
+
path: '/refresh-session',
|
|
639
|
+
description: "When called by an authenticated user, generates a new session",
|
|
640
|
+
parameters: {},
|
|
641
|
+
returns: {
|
|
642
|
+
authToken: { validator: validation_1.stringValidator, required: true },
|
|
643
|
+
enduser: { validator: 'user' },
|
|
644
|
+
} // add enduser eventually, when validator defined
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
enduserActions: { display_names: {} },
|
|
669
648
|
fields: __assign(__assign({}, BuiltInFields), { email: {
|
|
670
649
|
validator: validation_1.emailValidator,
|
|
671
650
|
required: true,
|
|
@@ -687,6 +666,16 @@ exports.schema = {
|
|
|
687
666
|
validator: validation_1.accountTypeValidator,
|
|
688
667
|
}, roles: {
|
|
689
668
|
validator: validation_1.listOfStringsValidator,
|
|
669
|
+
}, avatar: {
|
|
670
|
+
validator: validation_1.stringValidator100,
|
|
671
|
+
dependencies: [
|
|
672
|
+
{
|
|
673
|
+
dependsOn: ['files'],
|
|
674
|
+
dependencyField: 'secureName',
|
|
675
|
+
relationship: 'foreignKey',
|
|
676
|
+
onDependencyDelete: 'unset',
|
|
677
|
+
},
|
|
678
|
+
]
|
|
690
679
|
} })
|
|
691
680
|
},
|
|
692
681
|
templates: {
|
|
@@ -713,6 +702,67 @@ exports.schema = {
|
|
|
713
702
|
validator: validation_1.messageTemplateTypeValidator,
|
|
714
703
|
initializer: function () { return 'enduser'; }
|
|
715
704
|
} })
|
|
705
|
+
},
|
|
706
|
+
files: {
|
|
707
|
+
info: {},
|
|
708
|
+
constraints: { unique: [], relationship: [] },
|
|
709
|
+
defaultActions: { read: {}, readMany: {}, update: {} },
|
|
710
|
+
fields: __assign(__assign({}, BuiltInFields), { name: {
|
|
711
|
+
validator: validation_1.stringValidator250,
|
|
712
|
+
required: true,
|
|
713
|
+
}, size: {
|
|
714
|
+
validator: validation_1.fileSizeValidator,
|
|
715
|
+
required: true,
|
|
716
|
+
}, type: {
|
|
717
|
+
validator: validation_1.fileTypeValidator,
|
|
718
|
+
required: true
|
|
719
|
+
}, secureName: {
|
|
720
|
+
validator: validation_1.stringValidator250,
|
|
721
|
+
readonly: true,
|
|
722
|
+
} }),
|
|
723
|
+
enduserActions: { prepare_file_upload: {} },
|
|
724
|
+
customActions: {
|
|
725
|
+
prepare_file_upload: {
|
|
726
|
+
op: "custom", access: 'create', method: "post",
|
|
727
|
+
name: 'Prepare File Upload',
|
|
728
|
+
path: '/prepare-file-upload',
|
|
729
|
+
description: "Generates an upload link for a file, storing metadata as a File record.",
|
|
730
|
+
parameters: {
|
|
731
|
+
name: {
|
|
732
|
+
validator: validation_1.stringValidator250,
|
|
733
|
+
required: true,
|
|
734
|
+
},
|
|
735
|
+
size: {
|
|
736
|
+
validator: validation_1.fileSizeValidator,
|
|
737
|
+
required: true,
|
|
738
|
+
},
|
|
739
|
+
type: {
|
|
740
|
+
validator: validation_1.fileTypeValidator,
|
|
741
|
+
required: true
|
|
742
|
+
},
|
|
743
|
+
},
|
|
744
|
+
returns: {
|
|
745
|
+
presignedUpload: {
|
|
746
|
+
validator: validation_1.objectAnyFieldsValidator,
|
|
747
|
+
},
|
|
748
|
+
file: {
|
|
749
|
+
validator: 'file', // todo: add file validator
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
file_download_URL: {
|
|
754
|
+
op: "custom", access: 'read', method: "get",
|
|
755
|
+
name: 'Generate File Download',
|
|
756
|
+
path: '/file-download-link',
|
|
757
|
+
description: "Generates a temporary download link for a file.",
|
|
758
|
+
parameters: {
|
|
759
|
+
secureName: { validator: validation_1.stringValidator250 },
|
|
760
|
+
},
|
|
761
|
+
returns: {
|
|
762
|
+
downloadURL: { validator: validation_1.stringValidator250 },
|
|
763
|
+
},
|
|
764
|
+
},
|
|
765
|
+
},
|
|
716
766
|
}
|
|
717
767
|
};
|
|
718
768
|
//# sourceMappingURL=schema.js.map
|