@tellescope/schema 0.0.6 → 0.0.10
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 +138 -1
- package/lib/cjs/schema.d.ts.map +1 -1
- package/lib/cjs/schema.js +199 -168
- package/lib/cjs/schema.js.map +1 -1
- package/lib/esm/schema.d.ts +138 -1
- package/lib/esm/schema.d.ts.map +1 -1
- package/lib/esm/schema.js +201 -170
- package/lib/esm/schema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/schema.ts +374 -196
- 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, 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>>, session: UserSession | EnduserSession) => 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: UserSession | 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: UserSession | 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;
|
|
@@ -44,6 +166,21 @@ export declare type CustomActions = {
|
|
|
44
166
|
key: string;
|
|
45
167
|
}>;
|
|
46
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
|
+
};
|
|
47
184
|
journeys: {
|
|
48
185
|
update_state: CustomAction<{
|
|
49
186
|
updates: JourneyState;
|
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,SAA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;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,QA82BpB,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",
|
|
@@ -156,6 +59,83 @@ exports.schema = {
|
|
|
156
59
|
update: [sideEffects.trackJourneyEngagement],
|
|
157
60
|
}
|
|
158
61
|
},
|
|
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
|
+
],
|
|
74
|
+
},
|
|
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: {
|
|
81
|
+
validator: validation_1.emailValidator,
|
|
82
|
+
examples: ['test@tellescope.com'],
|
|
83
|
+
}, emailConsent: {
|
|
84
|
+
validator: validation_1.booleanValidator,
|
|
85
|
+
examples: BOOLEAN_EXAMPLES,
|
|
86
|
+
initializer: function (e) { return !!e.email; } // set by default on create when provided
|
|
87
|
+
}, phone: {
|
|
88
|
+
validator: validation_1.phoneValidator,
|
|
89
|
+
examples: ['+14155555555'],
|
|
90
|
+
}, phoneConsent: {
|
|
91
|
+
validator: validation_1.booleanValidator,
|
|
92
|
+
examples: BOOLEAN_EXAMPLES,
|
|
93
|
+
initializer: function (e) { return !!e.phone; } // set by default on create when provided
|
|
94
|
+
}, hashedPassword: {
|
|
95
|
+
validator: validation_1.stringValidator100,
|
|
96
|
+
readonly: true,
|
|
97
|
+
}, fname: {
|
|
98
|
+
validator: validation_1.nameValidator,
|
|
99
|
+
}, lname: {
|
|
100
|
+
validator: validation_1.nameValidator,
|
|
101
|
+
}, journeys: {
|
|
102
|
+
validator: validation_1.journeysValidator,
|
|
103
|
+
dependencies: [
|
|
104
|
+
{
|
|
105
|
+
dependsOn: ['journeys'],
|
|
106
|
+
dependencyField: '_id',
|
|
107
|
+
relationship: 'foreignKey',
|
|
108
|
+
onDependencyDelete: 'unset',
|
|
109
|
+
getDependentValues: function (t) { var _a; return Object.keys((_a = t.journeys) !== null && _a !== void 0 ? _a : {}); },
|
|
110
|
+
filterByDependency: function (journeyId) { return ({
|
|
111
|
+
field: "journeys." + journeyId,
|
|
112
|
+
value: 'any',
|
|
113
|
+
}); },
|
|
114
|
+
},
|
|
115
|
+
]
|
|
116
|
+
}, tags: {
|
|
117
|
+
validator: validation_1.listOfStringsValidator,
|
|
118
|
+
}, fields: {
|
|
119
|
+
validator: validation_1.fieldsValidator,
|
|
120
|
+
}, preference: {
|
|
121
|
+
validator: validation_1.preferenceValidator,
|
|
122
|
+
}, assignedTo: {
|
|
123
|
+
validator: validation_1.mongoIdStringValidator,
|
|
124
|
+
}, unread: {
|
|
125
|
+
validator: validation_1.booleanValidator,
|
|
126
|
+
}, lastCommunication: {
|
|
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
|
+
]
|
|
138
|
+
} }),
|
|
159
139
|
customActions: {
|
|
160
140
|
set_password: {
|
|
161
141
|
op: "custom", access: 'update', method: "post",
|
|
@@ -180,7 +160,7 @@ exports.schema = {
|
|
|
180
160
|
returns: {
|
|
181
161
|
isAuthenticated: { validator: validation_1.booleanValidator, required: true },
|
|
182
162
|
enduser: { validator: 'enduser' },
|
|
183
|
-
} // add enduser eventually, when validator defined
|
|
163
|
+
} // todo: add enduser eventually, when validator defined
|
|
184
164
|
},
|
|
185
165
|
refresh_session: {
|
|
186
166
|
op: "custom", access: 'update', method: "post",
|
|
@@ -188,10 +168,11 @@ exports.schema = {
|
|
|
188
168
|
path: '/refresh-enduser-session',
|
|
189
169
|
description: "When called by an authenticated enduser, generates a new session",
|
|
190
170
|
parameters: {},
|
|
171
|
+
enduserOnly: true,
|
|
191
172
|
returns: {
|
|
192
173
|
authToken: { validator: validation_1.stringValidator, required: true },
|
|
193
174
|
enduser: { validator: 'enduser' },
|
|
194
|
-
} // add enduser eventually, when validator defined
|
|
175
|
+
} // todo: add enduser eventually, when validator defined
|
|
195
176
|
},
|
|
196
177
|
logout: {
|
|
197
178
|
op: "custom", access: 'update', method: "post",
|
|
@@ -202,13 +183,13 @@ exports.schema = {
|
|
|
202
183
|
returns: {},
|
|
203
184
|
},
|
|
204
185
|
},
|
|
205
|
-
enduserActions: { logout: {}, refresh_session: {} },
|
|
206
186
|
publicActions: {
|
|
207
187
|
login: {
|
|
208
188
|
op: "custom", access: 'read', method: "post",
|
|
209
189
|
name: 'Login enduser',
|
|
210
190
|
path: '/login-enduser',
|
|
211
191
|
description: "Generates an authentication token for access to enduser-facing endpoints",
|
|
192
|
+
enduserOnly: true,
|
|
212
193
|
parameters: {
|
|
213
194
|
id: { validator: validation_1.mongoIdStringValidator },
|
|
214
195
|
password: { validator: validation_1.stringValidator100, required: true },
|
|
@@ -218,69 +199,6 @@ exports.schema = {
|
|
|
218
199
|
returns: { authToken: { validator: validation_1.stringValidator5000 } },
|
|
219
200
|
},
|
|
220
201
|
},
|
|
221
|
-
fields: __assign(__assign({}, BuiltInFields), { email: {
|
|
222
|
-
validator: validation_1.emailValidator,
|
|
223
|
-
examples: ['test@tellescope.com'],
|
|
224
|
-
}, emailConsent: {
|
|
225
|
-
validator: validation_1.booleanValidator,
|
|
226
|
-
examples: BOOLEAN_EXAMPLES,
|
|
227
|
-
initializer: function (e) { return !!e.email; } // set by default on create when provided
|
|
228
|
-
}, phone: {
|
|
229
|
-
validator: validation_1.phoneValidator,
|
|
230
|
-
examples: ['+14155555555'],
|
|
231
|
-
}, phoneConsent: {
|
|
232
|
-
validator: validation_1.booleanValidator,
|
|
233
|
-
examples: BOOLEAN_EXAMPLES,
|
|
234
|
-
initializer: function (e) { return !!e.phone; } // set by default on create when provided
|
|
235
|
-
}, hashedPassword: {
|
|
236
|
-
validator: validation_1.stringValidator100,
|
|
237
|
-
readonly: true,
|
|
238
|
-
}, fname: {
|
|
239
|
-
validator: validation_1.nameValidator,
|
|
240
|
-
}, lname: {
|
|
241
|
-
validator: validation_1.nameValidator,
|
|
242
|
-
}, journeys: {
|
|
243
|
-
validator: validation_1.journeysValidator,
|
|
244
|
-
dependencies: [
|
|
245
|
-
{
|
|
246
|
-
dependsOn: ['journeys'],
|
|
247
|
-
dependencyField: '_id',
|
|
248
|
-
relationship: 'foreignKey',
|
|
249
|
-
onDependencyDelete: 'unset',
|
|
250
|
-
getDependentValues: function (t) { var _a; return Object.keys((_a = t.journeys) !== null && _a !== void 0 ? _a : {}); },
|
|
251
|
-
filterByDependency: function (journeyId) { return ({
|
|
252
|
-
field: "journeys." + journeyId,
|
|
253
|
-
value: 'any',
|
|
254
|
-
}); },
|
|
255
|
-
},
|
|
256
|
-
]
|
|
257
|
-
}, tags: {
|
|
258
|
-
validator: validation_1.listOfStringsValidator,
|
|
259
|
-
}, fields: {
|
|
260
|
-
validator: validation_1.fieldsValidator,
|
|
261
|
-
}, preference: {
|
|
262
|
-
validator: validation_1.preferenceValidator,
|
|
263
|
-
}, assignedTo: {
|
|
264
|
-
validator: validation_1.mongoIdStringValidator,
|
|
265
|
-
}, unread: {
|
|
266
|
-
validator: validation_1.booleanValidator,
|
|
267
|
-
}, lastCommunication: {
|
|
268
|
-
validator: validation_1.dateValidator,
|
|
269
|
-
} }),
|
|
270
|
-
constraints: {
|
|
271
|
-
unique: ['email', 'phone'],
|
|
272
|
-
relationship: [
|
|
273
|
-
{
|
|
274
|
-
explanation: 'One of email or phone is required',
|
|
275
|
-
evaluate: function (_a) {
|
|
276
|
-
var email = _a.email, phone = _a.phone;
|
|
277
|
-
if (!(email || phone))
|
|
278
|
-
return 'One of email or phone is required';
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
],
|
|
282
|
-
},
|
|
283
|
-
defaultActions: constants_1.DEFAULT_OPERATIONS,
|
|
284
202
|
},
|
|
285
203
|
api_keys: {
|
|
286
204
|
info: {},
|
|
@@ -469,7 +387,7 @@ exports.schema = {
|
|
|
469
387
|
validator: validation_1.mongoIdStringValidator,
|
|
470
388
|
examples: [constants_1.PLACEHOLDER_ID],
|
|
471
389
|
readonly: true,
|
|
472
|
-
initializer: function (a, s) { return s.
|
|
390
|
+
initializer: function (a, s) { return s.id; },
|
|
473
391
|
}, subject: {
|
|
474
392
|
validator: validation_1.stringValidator,
|
|
475
393
|
required: true,
|
|
@@ -571,7 +489,7 @@ exports.schema = {
|
|
|
571
489
|
}, businessUserId: {
|
|
572
490
|
validator: validation_1.mongoIdStringValidator,
|
|
573
491
|
readonly: true,
|
|
574
|
-
initializer: function (a, s) { return s.
|
|
492
|
+
initializer: function (a, s) { return s.id; },
|
|
575
493
|
dependencies: [{
|
|
576
494
|
dependsOn: ['users'],
|
|
577
495
|
dependencyField: '_id',
|
|
@@ -602,7 +520,7 @@ exports.schema = {
|
|
|
602
520
|
chat_rooms: {
|
|
603
521
|
info: {},
|
|
604
522
|
constraints: {
|
|
605
|
-
unique: [{ array: 'userIds' }],
|
|
523
|
+
unique: [{ array: 'userIds' }, { array: 'enduserIds' }],
|
|
606
524
|
relationship: [],
|
|
607
525
|
access: [
|
|
608
526
|
{ type: 'filter', field: 'userIds' },
|
|
@@ -670,7 +588,7 @@ exports.schema = {
|
|
|
670
588
|
}, senderId: {
|
|
671
589
|
validator: validation_1.mongoIdStringValidator,
|
|
672
590
|
readonly: true,
|
|
673
|
-
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; },
|
|
674
592
|
examples: [constants_1.PLACEHOLDER_ID],
|
|
675
593
|
dependencies: [{
|
|
676
594
|
dependsOn: ['users', 'endusers'],
|
|
@@ -748,6 +666,18 @@ exports.schema = {
|
|
|
748
666
|
validator: validation_1.accountTypeValidator,
|
|
749
667
|
}, roles: {
|
|
750
668
|
validator: validation_1.listOfStringsValidator,
|
|
669
|
+
}, skills: {
|
|
670
|
+
validator: validation_1.listOfStringsValidator,
|
|
671
|
+
}, avatar: {
|
|
672
|
+
validator: validation_1.stringValidator100,
|
|
673
|
+
dependencies: [
|
|
674
|
+
{
|
|
675
|
+
dependsOn: ['files'],
|
|
676
|
+
dependencyField: 'secureName',
|
|
677
|
+
relationship: 'foreignKey',
|
|
678
|
+
onDependencyDelete: 'unset',
|
|
679
|
+
},
|
|
680
|
+
]
|
|
751
681
|
} })
|
|
752
682
|
},
|
|
753
683
|
templates: {
|
|
@@ -774,6 +704,107 @@ exports.schema = {
|
|
|
774
704
|
validator: validation_1.messageTemplateTypeValidator,
|
|
775
705
|
initializer: function () { return 'enduser'; }
|
|
776
706
|
} })
|
|
777
|
-
}
|
|
707
|
+
},
|
|
708
|
+
files: {
|
|
709
|
+
info: {},
|
|
710
|
+
constraints: { unique: [], relationship: [] },
|
|
711
|
+
defaultActions: { read: {}, readMany: {}, update: {} },
|
|
712
|
+
fields: __assign(__assign({}, BuiltInFields), { name: {
|
|
713
|
+
validator: validation_1.stringValidator250,
|
|
714
|
+
required: true,
|
|
715
|
+
}, size: {
|
|
716
|
+
validator: validation_1.fileSizeValidator,
|
|
717
|
+
required: true,
|
|
718
|
+
}, type: {
|
|
719
|
+
validator: validation_1.fileTypeValidator,
|
|
720
|
+
required: true
|
|
721
|
+
}, secureName: {
|
|
722
|
+
validator: validation_1.stringValidator250,
|
|
723
|
+
readonly: true,
|
|
724
|
+
} }),
|
|
725
|
+
enduserActions: { prepare_file_upload: {} },
|
|
726
|
+
customActions: {
|
|
727
|
+
prepare_file_upload: {
|
|
728
|
+
op: "custom", access: 'create', method: "post",
|
|
729
|
+
name: 'Prepare File Upload',
|
|
730
|
+
path: '/prepare-file-upload',
|
|
731
|
+
description: "Generates an upload link for a file, storing metadata as a File record.",
|
|
732
|
+
parameters: {
|
|
733
|
+
name: {
|
|
734
|
+
validator: validation_1.stringValidator250,
|
|
735
|
+
required: true,
|
|
736
|
+
},
|
|
737
|
+
size: {
|
|
738
|
+
validator: validation_1.fileSizeValidator,
|
|
739
|
+
required: true,
|
|
740
|
+
},
|
|
741
|
+
type: {
|
|
742
|
+
validator: validation_1.fileTypeValidator,
|
|
743
|
+
required: true
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
returns: {
|
|
747
|
+
presignedUpload: {
|
|
748
|
+
validator: validation_1.objectAnyFieldsValidator,
|
|
749
|
+
},
|
|
750
|
+
file: {
|
|
751
|
+
validator: 'file', // todo: add file validator
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
file_download_URL: {
|
|
756
|
+
op: "custom", access: 'read', method: "get",
|
|
757
|
+
name: 'Generate File Download',
|
|
758
|
+
path: '/file-download-link',
|
|
759
|
+
description: "Generates a temporary download link for a file.",
|
|
760
|
+
parameters: {
|
|
761
|
+
secureName: { validator: validation_1.stringValidator250 },
|
|
762
|
+
},
|
|
763
|
+
returns: {
|
|
764
|
+
downloadURL: { validator: validation_1.stringValidator250 },
|
|
765
|
+
},
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
tickets: {
|
|
770
|
+
info: {},
|
|
771
|
+
constraints: {
|
|
772
|
+
unique: [],
|
|
773
|
+
relationship: [
|
|
774
|
+
{
|
|
775
|
+
explanation: 'When created by an enduser, enduserId must match their id',
|
|
776
|
+
evaluate: function (_a, _, session) {
|
|
777
|
+
var enduserId = _a.enduserId;
|
|
778
|
+
if (session.type === constants_1.ENDUSER_SESSION_TYPE && session.id !== enduserId)
|
|
779
|
+
return "enduserId does not match creator id for enduser session";
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
],
|
|
783
|
+
},
|
|
784
|
+
defaultActions: constants_1.DEFAULT_OPERATIONS,
|
|
785
|
+
customActions: {},
|
|
786
|
+
enduserActions: { create: {}, read: {}, readMany: {} },
|
|
787
|
+
fields: __assign(__assign({}, BuiltInFields), { title: {
|
|
788
|
+
validator: validation_1.stringValidator100,
|
|
789
|
+
required: true,
|
|
790
|
+
examples: ["Ticket Name"],
|
|
791
|
+
}, enduserId: {
|
|
792
|
+
validator: validation_1.mongoIdStringValidator,
|
|
793
|
+
required: true,
|
|
794
|
+
examples: [constants_1.PLACEHOLDER_ID],
|
|
795
|
+
}, closed: {
|
|
796
|
+
validator: validation_1.booleanValidator,
|
|
797
|
+
initializer: function () { return false; },
|
|
798
|
+
}, owner: {
|
|
799
|
+
validator: validation_1.mongoIdStringValidator,
|
|
800
|
+
}, message: {
|
|
801
|
+
validator: validation_1.stringValidator5000,
|
|
802
|
+
examples: ["Message"],
|
|
803
|
+
}, type: {
|
|
804
|
+
validator: validation_1.stringValidator100,
|
|
805
|
+
}, skillsRequired: {
|
|
806
|
+
validator: validation_1.listOfStringsValidator,
|
|
807
|
+
} })
|
|
808
|
+
},
|
|
778
809
|
};
|
|
779
810
|
//# sourceMappingURL=schema.js.map
|