@elliemae/pui-scripting-object 1.7.0 → 1.9.0

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.
Files changed (73) hide show
  1. package/dist/cjs/events.js +16 -0
  2. package/dist/cjs/index.js +16 -12
  3. package/dist/cjs/objects/analytics.js +16 -0
  4. package/dist/cjs/{application.js → objects/application.js} +0 -0
  5. package/dist/cjs/{auth.js → objects/auth.js} +0 -0
  6. package/dist/cjs/{form.js → objects/form.js} +0 -0
  7. package/dist/cjs/{global.js → objects/global.js} +0 -0
  8. package/dist/cjs/{http.js → objects/http.js} +0 -0
  9. package/dist/cjs/{loan.js → objects/loan.js} +0 -0
  10. package/dist/cjs/objects/loanv2.js +38 -0
  11. package/dist/cjs/objects/memStorage.js +16 -0
  12. package/dist/cjs/{module.js → objects/module.js} +0 -0
  13. package/dist/cjs/objects/route.js +16 -0
  14. package/dist/cjs/{session.js → objects/session.js} +0 -0
  15. package/dist/cjs/{loanv2.js → objects/transaction.js} +9 -9
  16. package/dist/cjs/objects/transactionTemplate.js +16 -0
  17. package/dist/cjs/{userAccessRights.js → objects/userAccessRights.js} +0 -0
  18. package/dist/cjs/objects/view.js +16 -0
  19. package/dist/cjs/scriptingObjectTypes.js +16 -0
  20. package/dist/esm/{form.js → events.js} +0 -0
  21. package/dist/esm/index.js +16 -12
  22. package/dist/esm/{global.js → objects/analytics.js} +0 -0
  23. package/dist/esm/{application.js → objects/application.js} +0 -0
  24. package/dist/esm/{auth.js → objects/auth.js} +0 -0
  25. package/dist/esm/{http.js → objects/form.js} +0 -0
  26. package/dist/esm/{session.js → objects/global.js} +0 -0
  27. package/dist/esm/{transaction.js → objects/http.js} +0 -0
  28. package/dist/esm/{loan.js → objects/loan.js} +0 -0
  29. package/dist/esm/objects/loanv2.js +18 -0
  30. package/dist/esm/{transactiontemplate.js → objects/memStorage.js} +0 -0
  31. package/dist/esm/{module.js → objects/module.js} +0 -0
  32. package/dist/esm/{userAccessRights.js → objects/route.js} +0 -0
  33. package/dist/esm/objects/session.js +0 -0
  34. package/dist/esm/objects/transaction.js +8 -0
  35. package/dist/esm/objects/transactionTemplate.js +0 -0
  36. package/dist/esm/objects/userAccessRights.js +0 -0
  37. package/dist/esm/objects/view.js +0 -0
  38. package/dist/esm/scriptingObjectTypes.js +0 -0
  39. package/dist/types/events.d.ts +7 -0
  40. package/dist/types/index.d.ts +18 -12
  41. package/dist/types/objects/analytics.d.ts +24 -0
  42. package/dist/types/{application.d.ts → objects/application.d.ts} +98 -2
  43. package/dist/types/objects/auth.d.ts +105 -0
  44. package/dist/types/objects/form.d.ts +47 -0
  45. package/dist/types/objects/global.d.ts +47 -0
  46. package/dist/types/objects/http.d.ts +52 -0
  47. package/dist/types/{loan.d.ts → objects/loan.d.ts} +75 -11
  48. package/dist/types/objects/loanv2.d.ts +140 -0
  49. package/dist/types/objects/memStorage.d.ts +26 -0
  50. package/dist/types/objects/module.d.ts +55 -0
  51. package/dist/types/objects/route.d.ts +7 -0
  52. package/dist/types/objects/session.d.ts +18 -0
  53. package/dist/types/objects/transaction.d.ts +295 -0
  54. package/dist/types/objects/transactionTemplate.d.ts +76 -0
  55. package/dist/types/{userAccessRights.d.ts → objects/userAccessRights.d.ts} +3 -0
  56. package/dist/types/objects/view.d.ts +43 -0
  57. package/dist/types/script.d.ts +25 -1
  58. package/dist/types/scriptingObjectTypes.d.ts +30 -0
  59. package/package.json +5 -3
  60. package/dist/cjs/index.pug +0 -19
  61. package/dist/cjs/transaction.js +0 -16
  62. package/dist/cjs/transactiontemplate.js +0 -16
  63. package/dist/esm/index.pug +0 -19
  64. package/dist/esm/loanv2.js +0 -8
  65. package/dist/types/auth.d.ts +0 -43
  66. package/dist/types/form.d.ts +0 -10
  67. package/dist/types/global.d.ts +0 -5
  68. package/dist/types/http.d.ts +0 -7
  69. package/dist/types/loanv2.d.ts +0 -61
  70. package/dist/types/module.d.ts +0 -16
  71. package/dist/types/session.d.ts +0 -4
  72. package/dist/types/transaction.d.ts +0 -53
  73. package/dist/types/transactiontemplate.d.ts +0 -12
@@ -0,0 +1,47 @@
1
+ export declare type FormDescriptor = {
2
+ id: string;
3
+ name: string;
4
+ };
5
+ /**
6
+ * Methods to get information about the custom form
7
+ */
8
+ export interface IForm {
9
+ /**
10
+ * get metadata of the form
11
+ *
12
+ * @returns form metadata
13
+ */
14
+ getDescriptor(): Promise<FormDescriptor>;
15
+ /**
16
+ * get reference to the form's input control
17
+ *
18
+ * @param id form id
19
+ * @returns form input control object
20
+ */
21
+ getControl(id: string): Promise<any>;
22
+ }
23
+ /**
24
+ * event handler for form load event
25
+ *
26
+ * @param id unique id of the form that is loaded
27
+ */
28
+ export declare type FormLoadListener = (id: string) => void;
29
+ /**
30
+ * event handler for form unload event
31
+ *
32
+ * @param id unique id of the form that is unloaded
33
+ */
34
+ export declare type FormUnloadListener = (id: string) => void;
35
+ /**
36
+ * events that notifies the form's lifecycle
37
+ */
38
+ export declare type FormEvents = {
39
+ /**
40
+ * form is loaded and ready for user interaction
41
+ */
42
+ 'form.load': FormLoadListener;
43
+ /**
44
+ * form is unloaded and no longer available for user interaction
45
+ */
46
+ 'form.unload': FormUnloadListener;
47
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The Global object allows for data to be shared between custom forms/tools/plugins within a user's session.
3
+ * Unlike the Session scripting object, where data is isolated to be visible/accessible only by the form/plugin that writes the variables,
4
+ * values written to the Global store are visible to all such customizations
5
+ *
6
+ * The implementation of this object should write the global state data to the host application's sessionStore,
7
+ * but should ensure that the state is isolated away from the host application's state variables. This should be done by creating
8
+ * naming conventions for the global keyspaces, e.g. ssf.global.<key>.
9
+ *
10
+ * In order to ensure that guest applications cannot consume significant amounts of sessionStorage, restrictions should be placed on
11
+ * the number and size of the stored session state. In particular, we can start with these values:
12
+ * Each valueObj, when stringified, cannot exceed 5 KB
13
+ * Total global state should be limited to 50 values
14
+ * This will ensure that no guest can consume more than 250 KB of sessionStorage
15
+ *
16
+ */
17
+ export interface IGlobal {
18
+ /**
19
+ * set a value in the global store
20
+ *
21
+ * @param key unique key to identify the value
22
+ * @param value value to be stored
23
+ */
24
+ set(key: string, value: any): Promise<void>;
25
+ /**
26
+ * get a value from the global store
27
+ *
28
+ * @param key unique key to identify the value
29
+ * @returns value stored in the global store
30
+ */
31
+ get(key: string): Promise<any>;
32
+ }
33
+ /**
34
+ * event handler for global state change event
35
+ *
36
+ * @param key name of the key for which the value changed
37
+ */
38
+ export declare type GlobalStateChangeListener = (key: string) => void;
39
+ /**
40
+ * events fired from Global scripting object
41
+ */
42
+ export declare type GlobalEvents = {
43
+ /**
44
+ * event fired when a value changes in the global store
45
+ */
46
+ 'global.change': GlobalStateChangeListener;
47
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Provides methods to make call-outs to to external systems via HTTPS.
3
+ * By exposing this object from the host, it ensures that the call will bear the "Origin" header of the host application.
4
+ * This is critical for situations where the guest's code is running in a strict-mode sandbox (where the "allowSameOrigin" flag is false).
5
+ */
6
+ export interface IHttp {
7
+ /**
8
+ * get http request
9
+ *
10
+ * @param url url to make the call to
11
+ * @param headersOrAccessToken http headers object or access token to be used for the call
12
+ * @returns http response object
13
+ * @throws error if the http call fails with non 2xx status code
14
+ */
15
+ get(url: string, headersOrAccessToken?: HeadersInit | string): Promise<Response>;
16
+ /**
17
+ * post http request
18
+ *
19
+ * @param url url to make the call to
20
+ * @param headersOrAccessToken http headers object or access token to be used for the call
21
+ * @returns http response object
22
+ * @throws error if the http call fails with non 2xx status code
23
+ */
24
+ post(url: string, content: string | Record<string, string>, headersOrAccessToken?: HeadersInit | string): Promise<Response>;
25
+ /**
26
+ * patch http request
27
+ *
28
+ * @param url url to make the call to
29
+ * @param headersOrAccessToken http headers object or access token to be used for the call
30
+ * @returns http response object
31
+ * @throws error if the http call fails with non 2xx status code
32
+ */
33
+ patch(url: string, content: string | Record<string, string>, headersOrAccessToken?: HeadersInit | string): Promise<Response>;
34
+ /**
35
+ * put http request
36
+ *
37
+ * @param url url to make the call to
38
+ * @param headersOrAccessToken http headers object or access token to be used for the call
39
+ * @returns http response object
40
+ * @throws error if the http call fails with non 2xx status code
41
+ */
42
+ put(url: string, content: string | Record<string, string>, headersOrAccessToken?: HeadersInit | string): Promise<Response>;
43
+ /**
44
+ * delete http request
45
+ *
46
+ * @param url url to make the call to
47
+ * @param headersOrAccessToken http headers object or access token to be used for the call
48
+ * @returns http response object
49
+ * @throws error if the http call fails with non 2xx status code
50
+ */
51
+ delete(url: string, headersOrAccessToken?: HeadersInit | string): Promise<Response>;
52
+ }
@@ -11,6 +11,9 @@ export declare type FieldOptions = {
11
11
  */
12
12
  value: string;
13
13
  };
14
+ /**
15
+ * v3 loan object
16
+ */
14
17
  export declare type LoanObject = Record<string, any>;
15
18
  export declare enum LoanLevelActions {
16
19
  UPDATE_CORRESPONDENT_BALANCE = "updateCorrespondentBalance",
@@ -19,11 +22,11 @@ export declare enum LoanLevelActions {
19
22
  CALCULATE_EEM_MORTGAGE = "calculateEEMMortgage"
20
23
  }
21
24
  /**
22
- * The Loan object provides methods for interacting with an open loan in the application's editor screen(s).
25
+ * Methods for interacting with an open loan in the application
23
26
  */
24
27
  export interface ILoan {
25
28
  /**
26
- * Get entire Loan object
29
+ * Get complete Loan object
27
30
  *
28
31
  * @returns v3 Loan Object
29
32
  *
@@ -46,6 +49,12 @@ export interface ILoan {
46
49
  * | all | ✔ | ✔ | ✔ | ✖️ |
47
50
  */
48
51
  commit(): Promise<void>;
52
+ /**
53
+ * get value of the given field id
54
+ *
55
+ * @param id field id
56
+ * @returns field value
57
+ */
49
58
  getField(id: string): Promise<string>;
50
59
  /**
51
60
  * get options for list of fields
@@ -135,38 +144,93 @@ export interface ILoan {
135
144
  getLockSnapshot(): Promise<Record<string, string>>;
136
145
  }
137
146
  /**
138
- * This event is fired prior to saving and pending changes to the loan. The guest can use this event to perform custom validation and, via the feedback mechanism, prevent the loan from being saved
147
+ * event handler for loan precommit event
148
+ *
149
+ * @param cause cause of precommit event
150
+ * @returns true if precommit is allowed, false otherwise
139
151
  */
140
152
  export declare type LoanPreCommitListener = (cause: string) => boolean;
141
153
  /**
142
- * This event is fired after pending changes to the loan are committed
154
+ * event handler for loan commited event
155
+ *
156
+ * @param cause cause of commit event
143
157
  */
144
158
  export declare type LoanCommittedListener = (cause: string) => void;
145
159
  /**
146
- * This event is fired for each change made by the user in the UI
160
+ * event handler for loan data change event
147
161
  */
148
162
  export declare type LoanChangeListener = () => void;
149
163
  /**
150
- * This event is fired after the loan is sync'ed within any saved state made outside of the user's workspace. This event should fire after any call to calculate() or merge(), assuming any changes are made to the loan
164
+ * event handler for loan sync event
151
165
  */
152
166
  export declare type LoanSyncListener = () => void;
153
167
  /**
154
- * Fired after the loan is opened and ready for user interaction
168
+ * event handler for loan open event
155
169
  */
156
170
  export declare type LoanOpenListener = () => void;
157
171
  /**
158
- * Fired just prior to closing the loan in the UI
172
+ * event handler for loan close event
173
+ *
174
+ * @returns true if loan close is allowed, false otherwise
159
175
  */
160
176
  export declare type LoanCloseListener = () => boolean;
161
177
  /**
162
- * This event is fired after a milestone is completed by the user and committed to the server
178
+ * event handler for loan milestone completed event
179
+ *
180
+ * @param name milestone name
163
181
  */
164
182
  export declare type LoanMilestoneCompletedListener = (name: string) => void;
165
183
  /**
166
- * This event is fired when the user attempts to complete a milestone and allows for custom validation, and cancellation, of the process
184
+ * event handler for loan pre milestone complete event
185
+ *
186
+ * @returns true if milestone complete is allowed, false otherwise
167
187
  */
168
188
  export declare type LoanPreMilestoneCompleteListener = (name: string) => boolean;
169
189
  /**
170
- * This event is fired when a borrower pair changes
190
+ * event handler for loan application selected event
171
191
  */
172
192
  export declare type LoanApplicationSelectedListener = () => void;
193
+ /**
194
+ * events supported by Loan scripting object
195
+ */
196
+ export declare type LoanEvents = {
197
+ /**
198
+ * event is fired prior to saving any pending changes to the loan.
199
+ * The guest can use this event to perform custom validation and,
200
+ * via the feedback mechanism, prevent the loan from being saved
201
+ */
202
+ 'loan.precommit': LoanPreCommitListener;
203
+ /**
204
+ * event is fired after pending changes to the loan are committed
205
+ */
206
+ 'loan.committed': LoanCommittedListener;
207
+ /**
208
+ * event is fired for each change made by the user in the UI
209
+ */
210
+ 'loan.change': LoanChangeListener;
211
+ /**
212
+ * event is fired after the loan is sync'ed within any saved state made outside of the user's workspace.
213
+ */
214
+ 'loan.sync': LoanSyncListener;
215
+ /**
216
+ * event is fired after the loan is opened and ready for user interaction
217
+ */
218
+ 'loan.open': LoanOpenListener;
219
+ /**
220
+ * event is fired just prior to closing the loan in the UI
221
+ */
222
+ 'loan.close': LoanCloseListener;
223
+ /**
224
+ * event is fired after a milestone is completed by the user and committed to the server
225
+ */
226
+ 'loan.milestoneCompleted': LoanMilestoneCompletedListener;
227
+ /**
228
+ * event is fired when the user attempts to complete a milestone and allows for custom validation,
229
+ * and cancellation, of the process
230
+ */
231
+ 'loan.premilestoneComplete': LoanPreMilestoneCompleteListener;
232
+ /**
233
+ * event is fired when a borrower pair changes
234
+ */
235
+ 'loan.applicationselected': LoanApplicationSelectedListener;
236
+ };
@@ -0,0 +1,140 @@
1
+ import { ILoan, LoanObject } from './loan.js';
2
+ /**
3
+ * Types of field errors
4
+ */
5
+ export declare enum FieldErrorType {
6
+ /**
7
+ * access related violations
8
+ */
9
+ ACCESS = "access",
10
+ /**
11
+ * Violation of a field data entry rule.
12
+ * Thrown only when value gets applied to the loan and will remain until user fixes the value
13
+ */
14
+ VALUE = "value",
15
+ /**
16
+ * Error during de\serialization of the field value
17
+ */
18
+ SERIALIZATION = "serialization",
19
+ /**
20
+ * Error due to invalid data like valid RuleActionType is not implemented
21
+ */
22
+ DATA = "data",
23
+ /**
24
+ * Error due to invalid user data based on current state of the loan
25
+ * This does not get applied to the loan
26
+ */
27
+ CONFLICT = "conflict"
28
+ }
29
+ /**
30
+ * Field error object
31
+ */
32
+ export declare type FieldErrors = {
33
+ /**
34
+ * field id
35
+ */
36
+ id: string;
37
+ /**
38
+ * field error type
39
+ */
40
+ type: FieldErrorType;
41
+ /**
42
+ * error description
43
+ */
44
+ description: string;
45
+ };
46
+ /**
47
+ * Return type of setField method
48
+ */
49
+ export declare type SetFieldResponse = {
50
+ /**
51
+ * List of fields not meeting data, access or required rule criteria
52
+ */
53
+ errors: FieldErrors[];
54
+ };
55
+ /**
56
+ * Types of commit errors
57
+ */
58
+ export declare enum CommitErrorStatus {
59
+ /**
60
+ * Commit failed due to fields
61
+ */
62
+ FIELDERROR = "field_error",
63
+ /**
64
+ * Commit failed due to invalid lock or read only loan status
65
+ */
66
+ LOCK_INVALID_OR_REMOVED = "lock_invalid_or_removed",
67
+ /**
68
+ * Commit failed due to invalid workspace state
69
+ */
70
+ WORKSPACE_READ_ONLY = "workspace_read_only"
71
+ }
72
+ /**
73
+ * Error representing a commit failure
74
+ */
75
+ export declare type CommitError = Error & {
76
+ status: CommitErrorStatus;
77
+ /**
78
+ * List of violated rules that failed the commit
79
+ */
80
+ ruleViolations: {
81
+ /**
82
+ * fields not meeting various field rules
83
+ */
84
+ fieldErrors: FieldErrors[];
85
+ };
86
+ };
87
+ /**
88
+ * Map of field ids to their loan contract path
89
+ */
90
+ export declare type FieldIDToContractPath = {
91
+ fieldId: string;
92
+ contractPath: string;
93
+ };
94
+ /**
95
+ * All operations on a loan are stateful. This means loan changes are not committed until the loan.commit is called
96
+ */
97
+ export interface ILoanV2 extends Omit<ILoan, 'commit' | 'setFields' | 'merge'> {
98
+ /**
99
+ * Commit all pending changes on the current loan
100
+ *
101
+ * @returns {Promise<CommitResponse>}
102
+ * @throws {Error} if operation fails due to network errors
103
+ * @throws {CommitError} if operation fails due to business / functional rules
104
+ *
105
+ * #### Product Compatibility:
106
+ * | | Encompass | Encompass Web | TPO | Consumer Connect |
107
+ * :-----:|:-----: |:-----: |:-----: |:-----: |
108
+ * | commit | ✖️ | ✖️ | ✖️ | ✖️ |
109
+ */
110
+ commit(): Promise<void>;
111
+ /**
112
+ * Get the contract path for the given field ids
113
+ *
114
+ * @param fieldIds list of field ids for which loan contract path is required
115
+ * @returns list of field ids and their loan contract paths
116
+ * @throws {Error} if operation fails due to network errors
117
+ */
118
+ getContractPath(fieldIds: string[]): Promise<FieldIDToContractPath[]>;
119
+ /**
120
+ * Syncs the loan workspace with any changes made by other users
121
+ * #### Product Compatibility:
122
+ * | | Encompass | Encompass Web | TPO | Consumer Connect |
123
+ * :-----:|:-----: |:-----: |:-----: |:-----: |
124
+ * | merge | ✖️ | ✖️ | ✖️ | ✖️ |
125
+ */
126
+ merge(): Promise<LoanObject>;
127
+ /**
128
+ * Set the values of one or more fields on the Loan.
129
+ *
130
+ * @param fields list of field ids and their values
131
+ * @returns list of field ids that failed to set
132
+ * @throws {Error} if operation fails due to network error
133
+ *
134
+ * #### Product Compatibility:
135
+ * | | Encompass | Encompass Web | TPO | Consumer Connect |
136
+ * :-----:|:-----: |:-----: |:-----: |:-----: |
137
+ * | setFields | ✖️ | ✖️ | ✖️ | ✖️ |
138
+ */
139
+ setFields(fields: Record<string, string>): Promise<SetFieldResponse>;
140
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * get or set values in host application javascript memory
3
+ * values stored in memory are not persisted across sessions
4
+ *
5
+ * Host application implemeting this scripting object ensures,
6
+ * there are no collisions with keys from other microapp guest applications
7
+ * that means, two microapps can use same key to store different values. Thier values will not collide.
8
+ *
9
+ */
10
+ export interface IMemStorage {
11
+ /**
12
+ * set a value in memory for given key
13
+ *
14
+ * @param clientId unique identifier assigned to the microapp
15
+ * @param key unique key to store the value
16
+ * @param value value to be stored. value should be JSON serializable
17
+ */
18
+ set(clientId: string, key: string, value: any): Promise<void>;
19
+ /**
20
+ * get a value from memory for given key and microapp id
21
+ *
22
+ * @param key unique key to retrieve the value
23
+ * @returns value stored in memory
24
+ */
25
+ get(clientId: string, key: string): Promise<any>;
26
+ }
@@ -0,0 +1,55 @@
1
+ export declare enum LogLevel {
2
+ TRACE = "TRACE",
3
+ DEBUG = "DEBUG",
4
+ INFO = "INFO",
5
+ AUDIT = "AUDIT",
6
+ WARN = "WARN",
7
+ ERROR = "ERROR",
8
+ FATAL = "FATAL"
9
+ }
10
+ /**
11
+ * Methods to bootstraps feature modules
12
+ */
13
+ export interface IModule {
14
+ /**
15
+ * get module-specific JavaScript object that can be used to communicate additional capabilities to the module
16
+ *
17
+ * @returns key-value pairs of module-specific JavaScript objects
18
+ */
19
+ getCapabilities(): Promise<Record<string, string>>;
20
+ /**
21
+ * Get startup parameters for the module
22
+ *
23
+ * @returns startup parameters as key-value pairs
24
+ */
25
+ getParameters(): Promise<Record<string, string>>;
26
+ /**
27
+ * unload the module from the host application
28
+ */
29
+ unload(): Promise<void>;
30
+ /**
31
+ * log a message to host application's logs
32
+ *
33
+ * @param message message to log
34
+ * @param logLevel level of the log message
35
+ */
36
+ log(message: string, logLevel: LogLevel): Promise<void>;
37
+ }
38
+ /**
39
+ * event handler that handles module unload event
40
+ *
41
+ * @param id unique id of the module that is being unloaded
42
+ * @returns true if the module can be unloaded, false otherwise
43
+ */
44
+ export declare type ModuleUnLoadingListener = (id: string) => boolean;
45
+ /**
46
+ * events that notifies the module's lifecycle
47
+ */
48
+ export declare type ModuleEvents = {
49
+ /**
50
+ * event fired when the module is unloading
51
+ *
52
+ * @returns true if the module can be unloaded, false otherwise
53
+ */
54
+ 'module.unloading': ModuleUnLoadingListener;
55
+ };
@@ -0,0 +1,7 @@
1
+ import { To } from 'history';
2
+ /**
3
+ * Methods to view, modify & get notified about parent window url navigation
4
+ */
5
+ export interface IRoute {
6
+ navigate(path: To, state?: any): Promise<void>;
7
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * store and retrieves values in host application's session storage
3
+ */
4
+ export interface ISession {
5
+ /**
6
+ * set a value in the session storage
7
+ *
8
+ * @param key unique key to store the value
9
+ * @param value value to be stored
10
+ */
11
+ set(key: string, value: string): Promise<void>;
12
+ /**
13
+ * get a value from the session storage
14
+ *
15
+ * @param key unique key to retrieve the value
16
+ */
17
+ get(key: string): Promise<string>;
18
+ }