@loomcore/api 0.2.39 → 0.2.41
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/LICENSE +201 -201
- package/dist/__tests__/postgres-test-migrations/postgres-test-schema.js +4 -4
- package/dist/__tests__/test-objects.js +0 -3
- package/dist/controllers/api.controller.js +7 -2
- package/dist/controllers/auth.controller.js +5 -2
- package/dist/databases/mongo-db/migrations/mongo-initial-schema.js +2 -2
- package/dist/databases/postgres/migrations/postgres-initial-schema.js +1 -1
- package/dist/models/base-api-config.interface.d.ts +3 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +1 -0
- package/dist/models/log-level.type.d.ts +1 -0
- package/dist/models/log-level.type.js +1 -0
- package/dist/services/multi-tenant-api.service.js +3 -3
- package/dist/services/organization.service.js +1 -1
- package/dist/services/tenant-query-decorator.js +8 -8
- package/dist/utils/auth/attempt-login.util.js +4 -2
- package/dist/utils/auth/log-user-in.util.js +1 -1
- package/dist/utils/auth/request-token-using-refresh-token.util.d.ts +1 -2
- package/dist/utils/auth/request-token-using-refresh-token.util.js +1 -17
- package/dist/utils/auth/reset-password.util.js +4 -1
- package/dist/utils/auth/send-reset-password-email.util.d.ts +2 -2
- package/dist/utils/auth/send-reset-password-email.util.js +1 -6
- package/dist/utils/create-public-spec.utils.d.ts +2 -0
- package/dist/utils/create-public-spec.utils.js +13 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/logger.utils.d.ts +8 -0
- package/dist/utils/logger.utils.js +43 -0
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -6,7 +6,7 @@ export const getPostgresTestSchema = (config) => {
|
|
|
6
6
|
up: async ({ context: pool }) => {
|
|
7
7
|
const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
|
|
8
8
|
await pool.query(`
|
|
9
|
-
CREATE TABLE IF NOT EXISTS "
|
|
9
|
+
CREATE TABLE IF NOT EXISTS "test_entities" (
|
|
10
10
|
"_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
11
11
|
${orgColumnDef}
|
|
12
12
|
"name" VARCHAR(255) NOT NULL,
|
|
@@ -24,7 +24,7 @@ export const getPostgresTestSchema = (config) => {
|
|
|
24
24
|
`);
|
|
25
25
|
},
|
|
26
26
|
down: async ({ context: pool }) => {
|
|
27
|
-
await pool.query('DROP TABLE IF EXISTS "
|
|
27
|
+
await pool.query('DROP TABLE IF EXISTS "test_entities"');
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
migrations.push({
|
|
@@ -74,7 +74,7 @@ export const getPostgresTestSchema = (config) => {
|
|
|
74
74
|
up: async ({ context: pool }) => {
|
|
75
75
|
const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
|
|
76
76
|
await pool.query(`
|
|
77
|
-
CREATE TABLE IF NOT EXISTS "
|
|
77
|
+
CREATE TABLE IF NOT EXISTS "test_items" (
|
|
78
78
|
"_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
79
79
|
${orgColumnDef}
|
|
80
80
|
"name" VARCHAR(255) NOT NULL,
|
|
@@ -90,7 +90,7 @@ export const getPostgresTestSchema = (config) => {
|
|
|
90
90
|
`);
|
|
91
91
|
},
|
|
92
92
|
down: async ({ context: pool }) => {
|
|
93
|
-
await pool.query('DROP TABLE IF EXISTS "
|
|
93
|
+
await pool.query('DROP TABLE IF EXISTS "test_items"');
|
|
94
94
|
},
|
|
95
95
|
});
|
|
96
96
|
migrations.push({
|
|
@@ -53,14 +53,12 @@ export function getTestMetaOrgUser() {
|
|
|
53
53
|
export function getTestMetaOrgUserContext() {
|
|
54
54
|
return {
|
|
55
55
|
user: getTestMetaOrgUser(),
|
|
56
|
-
organization: getTestMetaOrg(),
|
|
57
56
|
features: ["metaorgUser"],
|
|
58
57
|
};
|
|
59
58
|
}
|
|
60
59
|
export function getTestMetaOrgAdminUserContext() {
|
|
61
60
|
return {
|
|
62
61
|
user: getTestMetaOrgUser(),
|
|
63
|
-
organization: getTestMetaOrg(),
|
|
64
62
|
features: ["admin"],
|
|
65
63
|
};
|
|
66
64
|
}
|
|
@@ -105,7 +103,6 @@ export function getTestOrgUser() {
|
|
|
105
103
|
export function getTestOrgUserContext() {
|
|
106
104
|
return {
|
|
107
105
|
user: getTestOrgUser(),
|
|
108
|
-
organization: getTestOrg(),
|
|
109
106
|
features: ["testOrgUser"],
|
|
110
107
|
};
|
|
111
108
|
}
|
|
@@ -2,7 +2,7 @@ import { BadRequestError } from '../errors/index.js';
|
|
|
2
2
|
import { entityUtils } from '@loomcore/common/utils';
|
|
3
3
|
import { Value } from '@sinclair/typebox/value';
|
|
4
4
|
import { getIdSchema } from '@loomcore/common/validation';
|
|
5
|
-
import { apiUtils, authorizeMethod } from '../utils/index.js';
|
|
5
|
+
import { apiUtils, authorizeMethod, createPublicSpec } from '../utils/index.js';
|
|
6
6
|
export class ApiController {
|
|
7
7
|
app;
|
|
8
8
|
service;
|
|
@@ -17,9 +17,14 @@ export class ApiController {
|
|
|
17
17
|
this.service = service;
|
|
18
18
|
this.apiResourceName = resourceName;
|
|
19
19
|
this.modelSpec = modelSpec;
|
|
20
|
-
this.publicSpec = publicSpec;
|
|
21
20
|
this.idSchema = getIdSchema();
|
|
22
21
|
this.mapRoutes(app);
|
|
22
|
+
if (modelSpec && !publicSpec) {
|
|
23
|
+
this.publicSpec = createPublicSpec(modelSpec);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.publicSpec = publicSpec;
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
mapRoutes(app) {
|
|
25
30
|
const authorize = (method) => authorizeMethod(this, method);
|
|
@@ -157,13 +157,16 @@ let AuthController = (() => {
|
|
|
157
157
|
}
|
|
158
158
|
const userContext = {
|
|
159
159
|
...EmptyUserContext,
|
|
160
|
-
|
|
160
|
+
user: {
|
|
161
|
+
...EmptyUserContext.user,
|
|
162
|
+
_orgId: organization?._id,
|
|
163
|
+
},
|
|
161
164
|
};
|
|
162
165
|
const user = await this.userService.findOne(userContext, {
|
|
163
166
|
filters: { email: { eq: email.toLowerCase() } },
|
|
164
167
|
});
|
|
165
168
|
if (user) {
|
|
166
|
-
await sendResetPasswordEmail(this.database, email, referer
|
|
169
|
+
await sendResetPasswordEmail(userContext, this.database, email, referer);
|
|
167
170
|
}
|
|
168
171
|
apiUtils.apiResponse(res, 200);
|
|
169
172
|
}
|
|
@@ -253,8 +253,8 @@ export const getMongoInitialSchema = (dbConfig) => {
|
|
|
253
253
|
throw new Error(errorMessage);
|
|
254
254
|
}
|
|
255
255
|
const systemUserContext = getSystemUserContext();
|
|
256
|
-
const orgDoc = isMultiTenant && systemUserContext.
|
|
257
|
-
? { _orgId: String(systemUserContext.
|
|
256
|
+
const orgDoc = isMultiTenant && systemUserContext.user._orgId
|
|
257
|
+
? { _orgId: String(systemUserContext.user._orgId) }
|
|
258
258
|
: {};
|
|
259
259
|
const hashedPassword = await passwordUtils.hashPassword(dbConfig.adminUser.password);
|
|
260
260
|
const email = dbConfig.adminUser.email.toLowerCase();
|
|
@@ -313,7 +313,7 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
313
313
|
}
|
|
314
314
|
const systemUserContext = getSystemUserContext();
|
|
315
315
|
const orgId = isMultiTenant
|
|
316
|
-
? systemUserContext.
|
|
316
|
+
? systemUserContext.user._orgId
|
|
317
317
|
: undefined;
|
|
318
318
|
const hashedPassword = await passwordUtils.hashPassword(dbConfig.adminUser.password);
|
|
319
319
|
const email = dbConfig.adminUser.email.toLowerCase();
|
|
@@ -3,12 +3,15 @@ import type { IAuthConfig } from "./auth-config.interface.js";
|
|
|
3
3
|
import type { IDatabaseConfig } from "./database-config.interface.js";
|
|
4
4
|
import type { IEmailClient } from "./email-client.interface.js";
|
|
5
5
|
import type { IEmailConfig } from "./email-config.interface.js";
|
|
6
|
+
import { LogLevel } from "./index.js";
|
|
6
7
|
export interface IBaseApiConfig {
|
|
7
8
|
app: IAppConfig;
|
|
8
9
|
auth?: IAuthConfig;
|
|
9
10
|
database: IDatabaseConfig;
|
|
10
11
|
debug?: {
|
|
11
12
|
showErrors?: boolean;
|
|
13
|
+
logLevel: LogLevel;
|
|
14
|
+
showAuditFields: boolean;
|
|
12
15
|
};
|
|
13
16
|
email?: IEmailConfig;
|
|
14
17
|
env: string;
|
package/dist/models/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export * from './app-config.interface.js';
|
|
|
2
2
|
export * from './base-api-config.interface.js';
|
|
3
3
|
export * from './database-config.interface.js';
|
|
4
4
|
export * from './initial-database-config.interface.js';
|
|
5
|
+
export * from './log-level.type.js';
|
|
5
6
|
export * from './email-client.interface.js';
|
package/dist/models/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export * from './app-config.interface.js';
|
|
|
2
2
|
export * from './base-api-config.interface.js';
|
|
3
3
|
export * from './database-config.interface.js';
|
|
4
4
|
export * from './initial-database-config.interface.js';
|
|
5
|
+
export * from './log-level.type.js';
|
|
5
6
|
export * from './email-client.interface.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,7 +17,7 @@ export class MultiTenantApiService extends GenericApiService {
|
|
|
17
17
|
userContext?.user?._id === getSystemUserId()) {
|
|
18
18
|
return super.prepareQuery(userContext, queryOptions, operations);
|
|
19
19
|
}
|
|
20
|
-
if (!userContext?.
|
|
20
|
+
if (!userContext?.user?._orgId) {
|
|
21
21
|
throw new BadRequestError("A valid userContext was not provided to MultiTenantApiService.prepareQuery");
|
|
22
22
|
}
|
|
23
23
|
if (!this.tenantDecorator) {
|
|
@@ -30,12 +30,12 @@ export class MultiTenantApiService extends GenericApiService {
|
|
|
30
30
|
if (!config?.app?.isMultiTenant) {
|
|
31
31
|
return super.preProcessEntity(userContext, entity, isCreate, allowId);
|
|
32
32
|
}
|
|
33
|
-
if (!userContext?.
|
|
33
|
+
if (!userContext?.user?._orgId) {
|
|
34
34
|
throw new BadRequestError("A valid userContext was not provided to MultiTenantApiService.prepareEntity");
|
|
35
35
|
}
|
|
36
36
|
const preparedEntity = await super.preProcessEntity(userContext, entity, isCreate, allowId);
|
|
37
37
|
if (isCreate && userContext.user._id !== getSystemUserId()) {
|
|
38
|
-
preparedEntity._orgId = userContext.
|
|
38
|
+
preparedEntity._orgId = userContext.user._orgId;
|
|
39
39
|
}
|
|
40
40
|
return preparedEntity;
|
|
41
41
|
}
|
|
@@ -14,7 +14,7 @@ export class OrganizationService extends GenericApiService {
|
|
|
14
14
|
if (metaOrg && entity.isMetaOrg) {
|
|
15
15
|
throw new BadRequestError("Meta organization already exists");
|
|
16
16
|
}
|
|
17
|
-
if (metaOrg && userContext.
|
|
17
|
+
if (metaOrg && userContext.user._orgId !== metaOrg._id) {
|
|
18
18
|
throw new BadRequestError("User is not authorized to create an organization");
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -11,18 +11,18 @@ export class TenantQueryDecorator {
|
|
|
11
11
|
applyTenantToQuery(userContext, queryObject, collectionName) {
|
|
12
12
|
let result = queryObject;
|
|
13
13
|
const shouldApplyTenantFilter = !this.options.excludedCollections?.includes(collectionName) &&
|
|
14
|
-
userContext?.
|
|
14
|
+
userContext?.user._orgId;
|
|
15
15
|
if (shouldApplyTenantFilter) {
|
|
16
16
|
const orgIdField = this.options.orgIdField || "_orgId";
|
|
17
17
|
result = {
|
|
18
18
|
...queryObject,
|
|
19
19
|
filters: {
|
|
20
20
|
...queryObject.filters,
|
|
21
|
-
[orgIdField]: { eq: userContext.
|
|
21
|
+
[orgIdField]: { eq: userContext.user._orgId },
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
else if (!userContext?.
|
|
25
|
+
else if (!userContext?.user._orgId) {
|
|
26
26
|
if (!this.options.excludedCollections?.includes(collectionName)) {
|
|
27
27
|
throw new ServerError("No _orgId found in userContext");
|
|
28
28
|
}
|
|
@@ -33,29 +33,29 @@ export class TenantQueryDecorator {
|
|
|
33
33
|
const result = { ...queryOptions };
|
|
34
34
|
const shouldApplyTenantFilter = !this.options.excludedCollections?.includes(collectionName);
|
|
35
35
|
if (shouldApplyTenantFilter) {
|
|
36
|
-
if (!userContext?.
|
|
36
|
+
if (!userContext?.user._orgId) {
|
|
37
37
|
throw new ServerError("userContext must have an _orgId property to apply tenant filtering");
|
|
38
38
|
}
|
|
39
39
|
if (!result.filters) {
|
|
40
40
|
result.filters = {};
|
|
41
41
|
}
|
|
42
42
|
const orgIdField = this.getOrgIdField();
|
|
43
|
-
result.filters[orgIdField] = { eq: userContext.
|
|
43
|
+
result.filters[orgIdField] = { eq: userContext.user._orgId };
|
|
44
44
|
}
|
|
45
45
|
return result;
|
|
46
46
|
}
|
|
47
47
|
applyTenantToEntity(userContext, entity, collectionName) {
|
|
48
48
|
let result = entity;
|
|
49
49
|
const shouldApplyTenantFilter = !this.options.excludedCollections?.includes(collectionName) &&
|
|
50
|
-
userContext?.
|
|
50
|
+
userContext?.user._orgId;
|
|
51
51
|
if (shouldApplyTenantFilter) {
|
|
52
52
|
const orgIdField = this.options.orgIdField || "_orgId";
|
|
53
53
|
result = {
|
|
54
54
|
...entity,
|
|
55
|
-
[orgIdField]: userContext.
|
|
55
|
+
[orgIdField]: userContext.user._orgId,
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
else if (!userContext?.
|
|
58
|
+
else if (!userContext?.user._orgId) {
|
|
59
59
|
if (!this.options.excludedCollections?.includes(collectionName)) {
|
|
60
60
|
throw new ServerError("No _orgId found in userContext");
|
|
61
61
|
}
|
|
@@ -8,7 +8,10 @@ export async function attemptLogin(database, email, password, deviceId, organiza
|
|
|
8
8
|
const lowerCaseEmail = email.toLowerCase();
|
|
9
9
|
const userContext = {
|
|
10
10
|
...EmptyUserContext,
|
|
11
|
-
|
|
11
|
+
user: {
|
|
12
|
+
...EmptyUserContext.user,
|
|
13
|
+
_orgId: organization?._id,
|
|
14
|
+
},
|
|
12
15
|
};
|
|
13
16
|
const user = await userService.findOne(userContext, {
|
|
14
17
|
filters: {
|
|
@@ -25,7 +28,6 @@ export async function attemptLogin(database, email, password, deviceId, organiza
|
|
|
25
28
|
const features = await authorizationsService.getUserContextFeatures(user);
|
|
26
29
|
const authenticatedUserContext = {
|
|
27
30
|
user: user,
|
|
28
|
-
organization: organization ?? undefined,
|
|
29
31
|
features: features,
|
|
30
32
|
};
|
|
31
33
|
const tokens = await logUserIn(database, authenticatedUserContext, deviceId, userService);
|
|
@@ -6,7 +6,7 @@ import { updateLastLoggedIn } from "./update-last-logged-in.util.js";
|
|
|
6
6
|
export async function logUserIn(database, userContext, deviceId, userService) {
|
|
7
7
|
const authConfig = getAuthConfig();
|
|
8
8
|
const accessToken = generateJwt(userContext);
|
|
9
|
-
const refreshTokenObject = await createNewRefreshToken(database, userContext.user._id, deviceId, userContext.
|
|
9
|
+
const refreshTokenObject = await createNewRefreshToken(database, userContext.user._id, deviceId, userContext.user._orgId);
|
|
10
10
|
const accessTokenExpiresOn = getExpiresOnFromSeconds(authConfig.jwtExpirationInSeconds);
|
|
11
11
|
const tokenResponse = {
|
|
12
12
|
accessToken,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type ITokenResponse } from "@loomcore/common/models";
|
|
2
2
|
import type { IDatabase } from "../../databases/models/index.js";
|
|
3
3
|
import { AuthorizationsService } from "../../services/authorizations.service.js";
|
|
4
|
-
import { OrganizationService } from "../../services/organization.service.js";
|
|
5
4
|
import { UserService } from "../../services/user.service.js";
|
|
6
|
-
export declare function requestTokenUsingRefreshToken(database: IDatabase, refreshToken: string, deviceId: string, userService?: UserService,
|
|
5
|
+
export declare function requestTokenUsingRefreshToken(database: IDatabase, refreshToken: string, deviceId: string, userService?: UserService, authorizationsService?: AuthorizationsService): Promise<ITokenResponse | null>;
|
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
import { getSystemUserContext, } from "@loomcore/common/models";
|
|
2
2
|
import { AuthorizationsService } from "../../services/authorizations.service.js";
|
|
3
|
-
import { OrganizationService } from "../../services/organization.service.js";
|
|
4
3
|
import { UserService } from "../../services/user.service.js";
|
|
5
|
-
import { config } from "../../config/base-api-config.js";
|
|
6
4
|
import { createNewTokens } from "./create-new-tokens.util.js";
|
|
7
5
|
import { getActiveRefreshToken } from "./get-active-refresh-token.util.js";
|
|
8
6
|
import { BadRequestError } from "../../errors/index.js";
|
|
9
|
-
export async function requestTokenUsingRefreshToken(database, refreshToken, deviceId, userService = new UserService(database),
|
|
7
|
+
export async function requestTokenUsingRefreshToken(database, refreshToken, deviceId, userService = new UserService(database), authorizationsService = new AuthorizationsService(database)) {
|
|
10
8
|
const systemUserContext = getSystemUserContext();
|
|
11
9
|
const activeRefreshToken = await getActiveRefreshToken(database, systemUserContext, refreshToken, deviceId);
|
|
12
10
|
if (!activeRefreshToken) {
|
|
13
11
|
return null;
|
|
14
12
|
}
|
|
15
|
-
let organization = null;
|
|
16
|
-
if (config.app.isMultiTenant && activeRefreshToken._orgId) {
|
|
17
|
-
organization =
|
|
18
|
-
await organizationService.findOne(systemUserContext, {
|
|
19
|
-
filters: { _id: { eq: activeRefreshToken._orgId } },
|
|
20
|
-
});
|
|
21
|
-
if (!organization) {
|
|
22
|
-
throw new BadRequestError("Organization not found");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
13
|
let userQueryOptions = {
|
|
26
14
|
filters: { _id: { eq: activeRefreshToken.userId } },
|
|
27
15
|
};
|
|
28
|
-
if (organization) {
|
|
29
|
-
userQueryOptions.filters = { ...userQueryOptions.filters, _orgId: { eq: organization._id } };
|
|
30
|
-
}
|
|
31
16
|
const user = await userService.findOne(systemUserContext, userQueryOptions);
|
|
32
17
|
if (!user) {
|
|
33
18
|
throw new BadRequestError("User not found");
|
|
@@ -35,7 +20,6 @@ export async function requestTokenUsingRefreshToken(database, refreshToken, devi
|
|
|
35
20
|
const features = await authorizationsService.getUserContextFeatures(user);
|
|
36
21
|
const userContext = {
|
|
37
22
|
user,
|
|
38
|
-
organization: organization ?? undefined,
|
|
39
23
|
features,
|
|
40
24
|
};
|
|
41
25
|
return createNewTokens(userContext, activeRefreshToken);
|
|
@@ -11,7 +11,10 @@ export async function resetPassword(database, email, passwordResetToken, passwor
|
|
|
11
11
|
const passwordResetTokenService = new PasswordResetTokenService(database);
|
|
12
12
|
const userContext = {
|
|
13
13
|
...EmptyUserContext,
|
|
14
|
-
|
|
14
|
+
user: {
|
|
15
|
+
...EmptyUserContext.user,
|
|
16
|
+
_orgId: organization?._id,
|
|
17
|
+
},
|
|
15
18
|
};
|
|
16
19
|
const retrievedPasswordResetToken = await passwordResetTokenService.findOne(userContext, {
|
|
17
20
|
filters: { email: { eq: lowerCaseEmail } },
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type IUserContext } from "@loomcore/common/models";
|
|
2
2
|
import type { IDatabase } from "../../databases/models/index.js";
|
|
3
|
-
export declare function sendResetPasswordEmail(database: IDatabase, emailAddress: string, clientBaseUrl: string
|
|
3
|
+
export declare function sendResetPasswordEmail(userContext: IUserContext, database: IDatabase, emailAddress: string, clientBaseUrl: string): Promise<void>;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { EmptyUserContext, } from "@loomcore/common/models";
|
|
2
1
|
import { ServerError } from "../../errors/index.js";
|
|
3
2
|
import { EmailService } from "../../services/email.service.js";
|
|
4
3
|
import { PasswordResetTokenService } from "../../services/password-reset-token.service.js";
|
|
5
4
|
import { getAuthConfig } from "./get-auth-config.util.js";
|
|
6
5
|
import { getExpiresOnFromMinutes } from "./get-expires-on-from-minutes.util.js";
|
|
7
|
-
export async function sendResetPasswordEmail(database, emailAddress, clientBaseUrl
|
|
6
|
+
export async function sendResetPasswordEmail(userContext, database, emailAddress, clientBaseUrl) {
|
|
8
7
|
const authConfig = getAuthConfig();
|
|
9
8
|
const passwordResetTokenService = new PasswordResetTokenService(database);
|
|
10
9
|
const emailService = new EmailService();
|
|
11
|
-
const userContext = {
|
|
12
|
-
...EmptyUserContext,
|
|
13
|
-
organization: organization ?? undefined,
|
|
14
|
-
};
|
|
15
10
|
const expiresOn = getExpiresOnFromMinutes(authConfig.passwordResetTokenExpirationInMinutes);
|
|
16
11
|
const passwordResetToken = await passwordResetTokenService.createPasswordResetToken(userContext, emailAddress, expiresOn);
|
|
17
12
|
if (!passwordResetToken) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { entityUtils } from "@loomcore/common/utils";
|
|
2
|
+
import { config } from "../config/index.js";
|
|
3
|
+
export function createPublicSpec(spec) {
|
|
4
|
+
if (config.debug?.showAuditFields) {
|
|
5
|
+
return spec;
|
|
6
|
+
}
|
|
7
|
+
const publicSpec = entityUtils.getModelSpec(spec.fullSchema, {
|
|
8
|
+
isAuditable: spec.isAuditable,
|
|
9
|
+
isEntity: spec.isEntity,
|
|
10
|
+
addAuditableSchema: false,
|
|
11
|
+
});
|
|
12
|
+
return publicSpec;
|
|
13
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ export * from "./address.utils.js";
|
|
|
2
2
|
export * from "./api.utils.js";
|
|
3
3
|
export * from "./auth/index.js";
|
|
4
4
|
export * from "./conversion.utils.js";
|
|
5
|
+
export * from "./create-public-spec.utils.js";
|
|
5
6
|
export * from "./express.utils.js";
|
|
6
7
|
export * from "./jwt.utils.js";
|
|
8
|
+
export * from "./logger.utils.js";
|
|
7
9
|
export * from "./password.utils.js";
|
|
8
10
|
export * from "./string.utils.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -2,7 +2,9 @@ export * from "./address.utils.js";
|
|
|
2
2
|
export * from "./api.utils.js";
|
|
3
3
|
export * from "./auth/index.js";
|
|
4
4
|
export * from "./conversion.utils.js";
|
|
5
|
+
export * from "./create-public-spec.utils.js";
|
|
5
6
|
export * from "./express.utils.js";
|
|
6
7
|
export * from "./jwt.utils.js";
|
|
8
|
+
export * from "./logger.utils.js";
|
|
7
9
|
export * from "./password.utils.js";
|
|
8
10
|
export * from "./string.utils.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LogLevel } from "../models/index.js";
|
|
2
|
+
export declare const getCurrentLogLevel: () => LogLevel;
|
|
3
|
+
export declare const logger: {
|
|
4
|
+
debug: (...args: unknown[]) => void;
|
|
5
|
+
info: (...args: unknown[]) => void;
|
|
6
|
+
warn: (...args: unknown[]) => void;
|
|
7
|
+
error: (...args: unknown[]) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { config } from "../config/index.js";
|
|
2
|
+
const LOG_LEVEL_PRIORITIES = {
|
|
3
|
+
debug: 0,
|
|
4
|
+
info: 1,
|
|
5
|
+
warn: 2,
|
|
6
|
+
error: 3,
|
|
7
|
+
};
|
|
8
|
+
export const getCurrentLogLevel = () => {
|
|
9
|
+
const envLogLevel = config.debug?.logLevel?.toLowerCase();
|
|
10
|
+
if (envLogLevel === "debug" ||
|
|
11
|
+
envLogLevel === "info" ||
|
|
12
|
+
envLogLevel === "warn" ||
|
|
13
|
+
envLogLevel === "error") {
|
|
14
|
+
return envLogLevel;
|
|
15
|
+
}
|
|
16
|
+
return "info";
|
|
17
|
+
};
|
|
18
|
+
const shouldLog = (messageLevel) => {
|
|
19
|
+
const currentLevel = getCurrentLogLevel();
|
|
20
|
+
return (LOG_LEVEL_PRIORITIES[messageLevel] >= LOG_LEVEL_PRIORITIES[currentLevel]);
|
|
21
|
+
};
|
|
22
|
+
export const logger = {
|
|
23
|
+
debug: (...args) => {
|
|
24
|
+
if (shouldLog("debug")) {
|
|
25
|
+
console.debug(...args);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
info: (...args) => {
|
|
29
|
+
if (shouldLog("info")) {
|
|
30
|
+
console.info(...args);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
warn: (...args) => {
|
|
34
|
+
if (shouldLog("warn")) {
|
|
35
|
+
console.warn(...args);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
error: (...args) => {
|
|
39
|
+
if (shouldLog("error")) {
|
|
40
|
+
console.error(...args);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomcore/api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.41",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb or PostgreSQL",
|
|
6
6
|
"scripts": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"reflect-metadata": "^0.2.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@loomcore/common": "^0.0.
|
|
62
|
+
"@loomcore/common": "^0.0.84",
|
|
63
63
|
"@sinclair/typebox": "0.34.33",
|
|
64
64
|
"cookie-parser": "^1.4.6",
|
|
65
65
|
"cors": "^2.8.5",
|