simply-xp 2.0.0-dev.5 → 2.0.0-dev.5-fix.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.
- package/FUNDING.yml +2 -2
- package/LICENSE +201 -201
- package/README.md +69 -69
- package/lib/src/connect.js +7 -6
- package/lib/src/functions/database.d.ts +8 -8
- package/lib/src/functions/database.js +6 -6
- package/lib/src/roleSetup.d.ts +4 -3
- package/lib/src/roleSetup.js +4 -4
- package/package.json +7 -7
package/FUNDING.yml
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
github: Rahuletto
|
|
2
|
-
patreon: abadima
|
|
1
|
+
github: Rahuletto
|
|
2
|
+
patreon: abadima
|
|
3
3
|
tidelift: npm/simply-xp
|
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.
|
package/README.md
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
<div class="Heading" style="text-align: center;">
|
|
2
|
-
<img src="https://i.ibb.co/cCKJ9FS/simplyxp.png" width="320" height="125" alt="XP Logo">
|
|
3
|
-
|
|
4
|
-
<h2>We have levelling! - You handle the rest.</h2>
|
|
5
|
-
<h3>Made by Abadima</h3>
|
|
6
|
-
</div>
|
|
7
|
-
|
|
8
|
-
<br>
|
|
9
|
-
<div class="badges" style="text-align: center;">
|
|
10
|
-
|
|
11
|
-
[](https://www.npmjs.com/package/simply-xp)
|
|
12
|
-
[](https://www.npmjs.com/package/simply-xp)
|
|
13
|
-
[](https://www.codefactor.io/repository/github/abadima/simply-xp)
|
|
14
|
-
|
|
15
|
-
[](https://simplyxp.js.org/docs/next/intro/)
|
|
16
|
-
[](https://discord.gg/hjhnjYJNHX)
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
> CREDITS TO [RAHULETTO](https://github.com/rahuletto) FOR SIMPLY-XP **VERSION 1**
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
<br>
|
|
24
|
-
|
|
25
|
-
## 🖥️ <b>[DEV] Installation</b>
|
|
26
|
-
|
|
27
|
-
```shell
|
|
28
|
-
npm install simply-xp@dev
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
```shell
|
|
32
|
-
pnpm install simply-xp@dev
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
```shell
|
|
36
|
-
yarn add simply-xp@dev
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
<br>
|
|
40
|
-
|
|
41
|
-
# ✅ V2 Additions
|
|
42
|
-
|
|
43
|
-
- Added support for `SQLite` database
|
|
44
|
-
- Added `debug`, `auto_create`, `auto_purge` options for `connect()` function
|
|
45
|
-
- Added `db` class for extended database functionality
|
|
46
|
-
- Added `leaderboardCard()` function
|
|
47
|
-
- Added `convertFrom()` function
|
|
48
|
-
- Added `compareCard` function
|
|
49
|
-
- Added `migrate` class
|
|
50
|
-
|
|
51
|
-
# 🎉 V2 Changes 🎉
|
|
52
|
-
|
|
53
|
-
- Better Documentation
|
|
54
|
-
- Better Log Handling (`XpDebug`, `XpError`, `XpInfo`, `XpWarn`)
|
|
55
|
-
- Better Performance
|
|
56
|
-
- Better Code Quality (EsLint)
|
|
57
|
-
- Complete TypeScript Rewrite
|
|
58
|
-
- Deleted `chart.js` dependency
|
|
59
|
-
- `fetch()` now also returns `position`, and accepts `username` parameter
|
|
60
|
-
- `roleSetup` functions now accept roleID arrays! `["role1", "role2", "role3"]`, and will return `timestamp` as a bonus!
|
|
61
|
-
- `reset()` function now accepts `erase` and `username` as optional arguments
|
|
62
|
-
- `addLevel(), addXP(), setLevel(), setXP()` now has a `username` parameter, to automatically create the user if it doesn't exist.
|
|
63
|
-
|
|
64
|
-
# ⚠️ V2 Breaking Changes ⚠️
|
|
65
|
-
|
|
66
|
-
- `create()` Now requires `username` argument.
|
|
67
|
-
- `charts()` Requires new arguments, and is revamped.
|
|
68
|
-
- `rank()` is **deprecated**, use `rankCard()` instead. (REQUIRES NEW ARGUMENTS)
|
|
69
|
-
- `roleSetup()` functions loses `client` argument.
|
|
1
|
+
<div class="Heading" style="text-align: center;">
|
|
2
|
+
<img src="https://i.ibb.co/cCKJ9FS/simplyxp.png" width="320" height="125" alt="XP Logo">
|
|
3
|
+
|
|
4
|
+
<h2>We have levelling! - You handle the rest.</h2>
|
|
5
|
+
<h3>Made by Abadima</h3>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<br>
|
|
9
|
+
<div class="badges" style="text-align: center;">
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/simply-xp)
|
|
12
|
+
[](https://www.npmjs.com/package/simply-xp)
|
|
13
|
+
[](https://www.codefactor.io/repository/github/abadima/simply-xp)
|
|
14
|
+
|
|
15
|
+
[](https://simplyxp.js.org/docs/next/intro/)
|
|
16
|
+
[](https://discord.gg/hjhnjYJNHX)
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
> CREDITS TO [RAHULETTO](https://github.com/rahuletto) FOR SIMPLY-XP **VERSION 1**
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<br>
|
|
24
|
+
|
|
25
|
+
## 🖥️ <b>[DEV] Installation</b>
|
|
26
|
+
|
|
27
|
+
```shell
|
|
28
|
+
npm install simply-xp@dev
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
pnpm install simply-xp@dev
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
yarn add simply-xp@dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<br>
|
|
40
|
+
|
|
41
|
+
# ✅ V2 Additions
|
|
42
|
+
|
|
43
|
+
- Added support for `SQLite` database
|
|
44
|
+
- Added `debug`, `auto_create`, `auto_purge` options for `connect()` function
|
|
45
|
+
- Added `db` class for extended database functionality
|
|
46
|
+
- Added `leaderboardCard()` function
|
|
47
|
+
- Added `convertFrom()` function
|
|
48
|
+
- Added `compareCard` function
|
|
49
|
+
- Added `migrate` class
|
|
50
|
+
|
|
51
|
+
# 🎉 V2 Changes 🎉
|
|
52
|
+
|
|
53
|
+
- Better Documentation
|
|
54
|
+
- Better Log Handling (`XpDebug`, `XpError`, `XpInfo`, `XpWarn`)
|
|
55
|
+
- Better Performance
|
|
56
|
+
- Better Code Quality (EsLint)
|
|
57
|
+
- Complete TypeScript Rewrite
|
|
58
|
+
- Deleted `chart.js` dependency
|
|
59
|
+
- `fetch()` now also returns `position`, and accepts `username` parameter
|
|
60
|
+
- `roleSetup` functions now accept roleID arrays! `["role1", "role2", "role3"]`, and will return `timestamp` as a bonus!
|
|
61
|
+
- `reset()` function now accepts `erase` and `username` as optional arguments
|
|
62
|
+
- `addLevel(), addXP(), setLevel(), setXP()` now has a `username` parameter, to automatically create the user if it doesn't exist.
|
|
63
|
+
|
|
64
|
+
# ⚠️ V2 Breaking Changes ⚠️
|
|
65
|
+
|
|
66
|
+
- `create()` Now requires `username` argument.
|
|
67
|
+
- `charts()` Requires new arguments, and is revamped.
|
|
68
|
+
- `rank()` is **deprecated**, use `rankCard()` instead. (REQUIRES NEW ARGUMENTS)
|
|
69
|
+
- `roleSetup()` functions loses `client` argument.
|
|
70
70
|
- `leaderboard()` loses `client` argument, and returns `user` instead of `userID`
|
package/lib/src/connect.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/connect
|
|
9
9
|
* @returns {Promise<boolean>}
|
|
10
10
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
11
|
-
*/async function connect(uri,options={type:void 0}){var e,{type:
|
|
11
|
+
*/async function connect(uri,options={type:void 0}){var e,{type:t,auto_create:o,auto_purge:n,notify:r,debug:a}=options;if(!uri)throw new xplogs_1.XpFatal({function:"connect()",message:"No URI Provided"});switch(!1===r&&(xp_1.xp.notify=!1),o&&(xp_1.xp.auto_create=!0),n&&(xp_1.xp.auto_purge=!0),a&&(xp_1.xp.debug=!0),t||(options.type="mongodb",xplogs_1.XpLog.warn("connect()","Database type not provided, defaulting to MongoDB")),t){case"mongodb":if(e=(await Promise.resolve().then(()=>__importStar(require("mongodb")))).MongoClient,!await checkPackageVersion("mongodb",4,6))return xplogs_1.XpLog.err("connect()","MongoDB Version 4 to 6 is required");e=await e.connect(uri).catch(error=>{throw new xplogs_1.XpFatal({function:"connect()",message:error.message})}),xp_1.xp.dbType="mongodb",xp_1.xp.database=e||void 0;break;case"sqlite":try{var[i,s]=await Promise.all([Promise.resolve().then(()=>__importStar(require("better-sqlite3"))),checkPackageVersion("better-sqlite3",7,9)]);if(!s)return xplogs_1.XpLog.err("connect()","better-sqlite3 Version 7 to 9 is required");xp_1.xp.database=new i.default(uri),xp_1.xp.dbType="sqlite",xp_1.xp.database.exec(`CREATE TABLE IF NOT EXISTS "simply-xps"
|
|
12
12
|
(
|
|
13
13
|
user TEXT NOT NULL,
|
|
14
14
|
guild TEXT NOT NULL,
|
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
xp INTEGER DEFAULT 0
|
|
18
18
|
)`),xp_1.xp.database.exec(`CREATE TABLE IF NOT EXISTS "simply-xp-levelroles"
|
|
19
19
|
(
|
|
20
|
-
gid TEXT
|
|
21
|
-
lvlrole TEXT NOT NULL
|
|
22
|
-
|
|
20
|
+
gid TEXT NOT NULL,
|
|
21
|
+
lvlrole TEXT NOT NULL,
|
|
22
|
+
timestamp TEXT NOT NULL
|
|
23
|
+
)`)}catch(t){if("object"==typeof t&&null!==t&&void 0!==(e=t).code&&"MODULE_NOT_FOUND"!==e.code)throw new xplogs_1.XpFatal({function:"connect()",message:e.message})}break;default:throw new xplogs_1.XpFatal({function:"connect()",message:"DATABASE TYPE NOT PROVIDED OR INVALID"})}return!!xp_1.xp.database&&(xplogs_1.XpLog.info("connect()","Connected to database!"),!0)}
|
|
23
24
|
/**
|
|
24
25
|
* Returns the package manager used
|
|
25
26
|
* @private
|
|
26
27
|
* @returns {Promise<"yarn" | "npm" | "pnpm">}
|
|
27
|
-
*/async function getPackageManager(){const e=(await Promise.resolve().then(()=>__importStar(require("fs")))).existsSync;var
|
|
28
|
+
*/async function getPackageManager(){const e=(await Promise.resolve().then(()=>__importStar(require("fs")))).existsSync;var t=["yarn.lock","pnpm-lock.yaml","pnpm-lock.json","package-lock.json"].filter(lockfile=>e(lockfile));if(1===t.length){if("yarn.lock"===t[0])return xplogs_1.XpLog.debug("getPackageManager()","Using YARN"),"yarn";if("pnpm-lock.yaml"===t[0]||"pnpm-lock.json"===t[0])return xplogs_1.XpLog.debug("getPackageManager()","Using PNPM"),"pnpm"}return xplogs_1.XpLog.debug("getPackageManager()","Using NPM"),"npm"}
|
|
28
29
|
/**
|
|
29
30
|
* Check database package versions
|
|
30
31
|
* @private
|
|
@@ -33,4 +34,4 @@
|
|
|
33
34
|
* @param {number} max - Maximum Major Version Number (Optional)
|
|
34
35
|
* @returns {Promise<boolean>}
|
|
35
36
|
* @throws {XpFatal} If the package version is not supported
|
|
36
|
-
*/async function checkPackageVersion(type,min,max){try{var e=await Promise.resolve(type+"/package.json").then(s=>__importStar(require(s)));return parseInt(e.version.substring(0,1))>=min&&(!max||parseInt(e.version.substring(0,1))<=max)}catch(e){return xplogs_1.XpLog.info("checkPackageVersion()",`Installing ${type} [V${max||min}] | Please wait...`),(0,child_process_1.execSync)(await getPackageManager()+` add ${type}@${max||min}.x.x`),xplogs_1.XpLog.warn("checkPackageVersion()",`Installed ${type}. Please restart!`),process.exit(1)}}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,
|
|
37
|
+
*/async function checkPackageVersion(type,min,max){try{var e=await Promise.resolve(type+"/package.json").then(s=>__importStar(require(s)));return parseInt(e.version.substring(0,1))>=min&&(!max||parseInt(e.version.substring(0,1))<=max)}catch(e){return xplogs_1.XpLog.info("checkPackageVersion()",`Installing ${type} [V${max||min}] | Please wait...`),(0,child_process_1.execSync)(await getPackageManager()+` add ${type}@${max||min}.x.x`),xplogs_1.XpLog.warn("checkPackageVersion()",`Installed ${type}. Please restart!`),process.exit(1)}}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,t;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(t in mod)"default"!==t&&Object.prototype.hasOwnProperty.call(mod,t)&&__createBinding(e,mod,t);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPackageVersion=exports.connect=void 0;const xplogs_1=require("./functions/xplogs"),child_process_1=require("child_process"),xp_1=require("../xp");exports.connect=connect,exports.checkPackageVersion=checkPackageVersion;
|
|
@@ -41,24 +41,24 @@ export interface UserResult {
|
|
|
41
41
|
* @property {string} collection - The collection to create the document in.
|
|
42
42
|
* @property {object} data - The data to create the document with.
|
|
43
43
|
* @property {string} data.guild - The guild ID.
|
|
44
|
-
* @property {
|
|
45
|
-
* @property {
|
|
46
|
-
* @property {string} data.
|
|
44
|
+
* @property {object} data.lvlrole - The level role data.
|
|
45
|
+
* @property {number} data.lvlrole.lvl - The level.
|
|
46
|
+
* @property {string | Array<string>} [data.lvlrole.role] - The role ID(s).
|
|
47
47
|
*/
|
|
48
48
|
export interface LevelRoleOptions {
|
|
49
49
|
collection: "simply-xp-levelroles";
|
|
50
50
|
data: {
|
|
51
51
|
guild: string;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
lvlrole: {
|
|
53
|
+
lvl: number;
|
|
54
|
+
role?: string | Array<string>;
|
|
55
|
+
};
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
export type LevelRoleResult = {
|
|
58
59
|
_id?: string;
|
|
59
60
|
guild: string;
|
|
60
|
-
|
|
61
|
-
roles: Array<string>;
|
|
61
|
+
lvlrole: string;
|
|
62
62
|
timestamp: string;
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
@@ -22,7 +22,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
22
22
|
* @link https://simplyxp.js.org/docs/next/handlers/database#createOne Documentation
|
|
23
23
|
* @returns {Promise<UserResult | LevelRoleResult>} The created document.
|
|
24
24
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
25
|
-
*/static async createOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"createOne()",message:"No database connection"});
|
|
25
|
+
*/static async createOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"createOne()",message:"No database connection"});switch(xp_1.xp.dbType){case"mongodb":xp_1.xp.database.db().collection(query.collection).insertOne(query.data).catch(error=>handleError(error,"createOne()"));break;case"sqlite":"simply-xps"===query.collection?xp_1.xp.database.prepare('INSERT INTO "simply-xps" (user, guild, name, xp, level) VALUES (?, ?, ?, ?, ?)').run(query.data.user,query.data.guild,query.data?.name,query.data.xp,query.data.level):xp_1.xp.database.prepare('INSERT INTO "simply-xp-levelroles" (gid, lvlrole, timestamp) VALUES (?, ?, ?)').run(query.data.guild,JSON.stringify(query.data.lvlrole),(new Date).toISOString())}return db.findOne(query)}
|
|
26
26
|
/**
|
|
27
27
|
* Deletes multiple documents from the database.
|
|
28
28
|
* @async
|
|
@@ -30,7 +30,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
30
30
|
* @link https://simplyxp.js.org/docs/next/handlers/database#deleteMany Documentation
|
|
31
31
|
* @returns {Promise<boolean>} `true` if the documents were successfully deleted, otherwise `false`.
|
|
32
32
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
33
|
-
*/static async deleteMany(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"deleteMany()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).deleteMany(query.data).catch(error=>handleError(error,"deleteMany()"));break;case"sqlite":e=("simply-xps"===query.collection?xp_1.xp.database.prepare('DELETE FROM "simply-xps" WHERE guild = ?'):xp_1.xp.database.prepare('DELETE FROM "simply-xp-levelroles" WHERE
|
|
33
|
+
*/static async deleteMany(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"deleteMany()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).deleteMany(query.data).catch(error=>handleError(error,"deleteMany()"));break;case"sqlite":e=("simply-xps"===query.collection?xp_1.xp.database.prepare('DELETE FROM "simply-xps" WHERE guild = ?'):xp_1.xp.database.prepare('DELETE FROM "simply-xp-levelroles" WHERE gid = ?')).run(query.data.guild)}return!!e}
|
|
34
34
|
/**
|
|
35
35
|
* Deletes one document from the database.
|
|
36
36
|
*
|
|
@@ -39,7 +39,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
39
39
|
* @link https://simplyxp.js.org/docs/next/handlers/database#deleteOne Documentation
|
|
40
40
|
* @returns {Promise<boolean>} `true` if the document was successfully deleted, otherwise `false`.
|
|
41
41
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
42
|
-
*/static async deleteOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"deleteOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).deleteOne(query.data).catch(error=>handleError(error,"deleteOne()"));break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('DELETE FROM "simply-xps" WHERE guild = ? AND user = ?').run(query.data.guild,query.data.user):xp_1.xp.database.prepare('DELETE FROM "simply-xp-levelroles" WHERE
|
|
42
|
+
*/static async deleteOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"deleteOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).deleteOne(query.data).catch(error=>handleError(error,"deleteOne()"));break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('DELETE FROM "simply-xps" WHERE guild = ? AND user = ?').run(query.data.guild,query.data.user):(e=(e=await this.find(query)).filter(row=>JSON.parse(row.lvlrole).lvl===query.data.lvlrole.lvl)[0],xp_1.xp.database.prepare('DELETE FROM "simply-xp-levelroles" WHERE gid = ? AND lvlrole = ?').run(query.data.guild,e.lvlrole))}return!!e}
|
|
43
43
|
/**
|
|
44
44
|
* Finds one document in the database.
|
|
45
45
|
*
|
|
@@ -48,7 +48,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
48
48
|
* @link https://simplyxp.js.org/docs/next/handlers/database#findOne Documentation
|
|
49
49
|
* @returns {Promise<UserResult | LevelRoleResult>} The found document.
|
|
50
50
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
51
|
-
*/static async findOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"findOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).findOne(query.data).catch(error=>handleError(error,"findOne()"));break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('SELECT * FROM "simply-xps" WHERE guild = ? AND user = ?').get(query.data.guild,query.data.user):
|
|
51
|
+
*/static async findOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"findOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e="simply-xps"===query.collection?await xp_1.xp.database.db().collection(query.collection).findOne(query.data).catch(error=>handleError(error,"findOne()")):await xp_1.xp.database.db().collection(query.collection).findOne({guild:query.data.guild,"lvlrole.lvl":query.data.lvlrole.lvl}).catch(error=>handleError(error,"findOne()"));break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('SELECT * FROM "simply-xps" WHERE guild = ? AND user = ?').get(query.data.guild,query.data.user):(e=await this.find(query)).filter(row=>JSON.parse(row.lvlrole).lvl===query.data.lvlrole.lvl)[0]}return e}
|
|
52
52
|
/**
|
|
53
53
|
* Finds multiple documents in the database.
|
|
54
54
|
*
|
|
@@ -57,7 +57,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
57
57
|
* @link https://simplyxp.js.org/docs/next/handlers/database#find Documentation
|
|
58
58
|
* @returns {Promise<UserResult[] | LevelRoleResult[]>} An array of found documents.
|
|
59
59
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
60
|
-
*/static async find(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"find()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).find(query.data).toArray().catch(error=>handleError(error,"find()"));break;case"sqlite":e=("simply-xps"===query.collection?xp_1.xp.database.prepare('SELECT * FROM "simply-xps" WHERE guild = ?'):xp_1.xp.database.prepare('SELECT * FROM "simply-xp-levelroles" WHERE
|
|
60
|
+
*/static async find(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"find()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).find(query.data).toArray().catch(error=>handleError(error,"find()"));break;case"sqlite":e=("simply-xps"===query.collection?xp_1.xp.database.prepare('SELECT * FROM "simply-xps" WHERE guild = ?'):xp_1.xp.database.prepare('SELECT * FROM "simply-xp-levelroles" WHERE gid = ?')).all(query.data.guild)}return e}
|
|
61
61
|
/**
|
|
62
62
|
* Updates one document in the database.
|
|
63
63
|
*
|
|
@@ -68,4 +68,4 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
68
68
|
* @link https://simplyxp.js.org/docs/next/handlers/database#updateOne Documentation
|
|
69
69
|
* @returns {Promise<UserResult | LevelRoleResult>} The updated document.
|
|
70
70
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
71
|
-
*/static async updateOne(filter,update,options){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"updateOne()",message:"No database connection"});switch(xp_1.xp.dbType){case"mongodb":await xp_1.xp.database.db().collection(update.collection).updateOne(filter.data,{$set:update.data},options).catch(error=>handleError(error,"updateOne()"));break;case"sqlite":if("simply-xps"===filter.collection&&"simply-xps"===update.collection)xp_1.xp.database.prepare('UPDATE "simply-xps" SET xp = ?, level = ?'+(update.data?.name?", name = ?":"")+" WHERE guild = ? AND user = ?").run(update.data?.name?[update.data.xp,update.data.level,update.data.name,filter.data.guild,filter.data.user]:[update.data.xp,update.data.level,filter.data.guild,filter.data.user]);else{if("simply-xp-levelroles"!==filter.collection||"simply-xp-levelroles"!==update.collection)throw new xplogs_1.XpFatal({function:"updateOne()",message:"Collection mismatch, expected same collection on both filter and update."});xp_1.xp.database.prepare('UPDATE "simply-xp-levelroles" SET
|
|
71
|
+
*/static async updateOne(filter,update,options){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"updateOne()",message:"No database connection"});switch(xp_1.xp.dbType){case"mongodb":await xp_1.xp.database.db().collection(update.collection).updateOne(filter.data,{$set:update.data},options).catch(error=>handleError(error,"updateOne()"));break;case"sqlite":if("simply-xps"===filter.collection&&"simply-xps"===update.collection)xp_1.xp.database.prepare('UPDATE "simply-xps" SET xp = ?, level = ?'+(update.data?.name?", name = ?":"")+" WHERE guild = ? AND user = ?").run(update.data?.name?[update.data.xp,update.data.level,update.data.name,filter.data.guild,filter.data.user]:[update.data.xp,update.data.level,filter.data.guild,filter.data.user]);else{if("simply-xp-levelroles"!==filter.collection||"simply-xp-levelroles"!==update.collection)throw new xplogs_1.XpFatal({function:"updateOne()",message:"Collection mismatch, expected same collection on both filter and update."});xp_1.xp.database.prepare('UPDATE "simply-xp-levelroles" SET lvlrole = ? WHERE gid = ?').run(JSON.stringify(update.data.lvlrole),filter.data.guild)}}return db.findOne(update)}}exports.db=db;
|
package/lib/src/roleSetup.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LevelRoleResult } from "./functions/database";
|
|
1
2
|
/**
|
|
2
3
|
* Role setup object
|
|
3
4
|
* @property {string} guild - The guild ID
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
*/
|
|
7
8
|
export interface RoleSetupObject {
|
|
8
9
|
level: number;
|
|
9
|
-
|
|
10
|
+
role: string[] | string;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Setup roles for levels
|
|
@@ -29,10 +30,10 @@ export declare class roleSetup {
|
|
|
29
30
|
* @param {string} guildId - The guild ID
|
|
30
31
|
* @param {number} levelNumber - The level number
|
|
31
32
|
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupfind
|
|
32
|
-
* @returns {Promise<
|
|
33
|
+
* @returns {Promise<LevelRoleResult>} - The level role object
|
|
33
34
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
34
35
|
*/
|
|
35
|
-
static find(guildId: string, levelNumber: number): Promise<
|
|
36
|
+
static find(guildId: string, levelNumber: number): Promise<LevelRoleResult>;
|
|
36
37
|
/**
|
|
37
38
|
* Remove a level from the role setup
|
|
38
39
|
* @async
|
package/lib/src/roleSetup.js
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
* @returns {Promise<boolean>} - True if successful
|
|
9
9
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
10
10
|
*/
|
|
11
|
-
static async add(guildId,options){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.add()",message:"Guild ID was not provided"});if(!options)throw new xplogs_1.XpFatal({function:"roleSetup.add()",message:"Options were not provided"});if(isNaN(options?.level))throw new xplogs_1.XpFatal({function:"roleSetup.add()",message:"Level must be a number"});if(options?.
|
|
11
|
+
static async add(guildId,options){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.add()",message:"Guild ID was not provided"});if(!options)throw new xplogs_1.XpFatal({function:"roleSetup.add()",message:"Options were not provided"});if(isNaN(options?.level))throw new xplogs_1.XpFatal({function:"roleSetup.add()",message:"Level must be a number"});if(options?.role)return"string"==typeof options?.role&&(options.role=[options.role]),xp_1.db.createOne({collection:"simply-xp-levelroles",data:{guild:guildId,lvlrole:{lvl:options.level,role:options.role}}}).then(()=>!0).catch(()=>!1);throw new xplogs_1.XpFatal({function:"roleSetup.add()",message:"Role was not provided"})}
|
|
12
12
|
/**
|
|
13
13
|
* Find a role in roleSetup
|
|
14
14
|
* @async
|
|
15
15
|
* @param {string} guildId - The guild ID
|
|
16
16
|
* @param {number} levelNumber - The level number
|
|
17
17
|
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupfind
|
|
18
|
-
* @returns {Promise<
|
|
18
|
+
* @returns {Promise<LevelRoleResult>} - The level role object
|
|
19
19
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
20
|
-
*/static async find(guildId,levelNumber){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.find()",message:"Guild ID was not provided"});if(isNaN(levelNumber))throw new xplogs_1.XpFatal({function:"roleSetup.find()",message:"Level Number was not provided"});return xp_1.db.findOne({collection:"simply-xp-levelroles",data:{guild:guildId,
|
|
20
|
+
*/static async find(guildId,levelNumber){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.find()",message:"Guild ID was not provided"});if(isNaN(levelNumber))throw new xplogs_1.XpFatal({function:"roleSetup.find()",message:"Level Number was not provided"});return(guildId=await xp_1.db.findOne({collection:"simply-xp-levelroles",data:{guild:guildId,lvlrole:{lvl:levelNumber}}}))&&(guildId.lvlrole="string"==typeof guildId.lvlrole?JSON.parse(guildId.lvlrole):guildId.lvlrole,guildId)}
|
|
21
21
|
/**
|
|
22
22
|
* Remove a level from the role setup
|
|
23
23
|
* @async
|
|
@@ -26,4 +26,4 @@ static async add(guildId,options){if(!guildId)throw new xplogs_1.XpFatal({functi
|
|
|
26
26
|
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupremove
|
|
27
27
|
* @returns {Promise<boolean>} - True if successful
|
|
28
28
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
29
|
-
*/static async remove(guildId,levelNumber){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.remove()",message:"Guild ID was not provided"});if(isNaN(levelNumber))throw new xplogs_1.XpFatal({function:"roleSetup.remove()",message:"Level Number was not provided"});return xp_1.db.deleteOne({collection:"simply-xp-levelroles",data:{guild:guildId,
|
|
29
|
+
*/static async remove(guildId,levelNumber){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.remove()",message:"Guild ID was not provided"});if(isNaN(levelNumber))throw new xplogs_1.XpFatal({function:"roleSetup.remove()",message:"Level Number was not provided"});return xp_1.db.deleteOne({collection:"simply-xp-levelroles",data:{guild:guildId,lvlrole:{lvl:levelNumber}}})}}exports.roleSetup=roleSetup;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simply-xp",
|
|
3
|
-
"version": "2.0.0-dev.5",
|
|
3
|
+
"version": "2.0.0-dev.5-fix.0",
|
|
4
4
|
"description": "The easiest way to implement xp system",
|
|
5
5
|
"main": "lib/xp.js",
|
|
6
6
|
"scripts": {
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"@napi-rs/canvas": "^0.1.44"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/better-sqlite3": "^7.6.
|
|
51
|
-
"@types/node": "^20.8.
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
53
|
-
"@typescript-eslint/parser": "^6.
|
|
50
|
+
"@types/better-sqlite3": "^7.6.6",
|
|
51
|
+
"@types/node": "^20.8.10",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
53
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
54
54
|
"better-sqlite3": "^9.0.0",
|
|
55
55
|
"discord.js": "^14.13.0",
|
|
56
|
-
"eslint": "^8.
|
|
56
|
+
"eslint": "^8.53.0",
|
|
57
57
|
"jsdoc-to-markdown": "^8.0.0",
|
|
58
|
-
"mongodb": "^6.
|
|
58
|
+
"mongodb": "^6.2.0",
|
|
59
59
|
"typescript": "^5.2.2",
|
|
60
60
|
"uglify-js": "^3.17.4"
|
|
61
61
|
},
|