@wumx-labs/noxaeapi-sdk 0.4.2 → 0.5.1
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/README.md +12 -1
- package/dist/index.cjs +212 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +215 -33
- package/dist/index.d.ts +215 -33
- package/dist/index.js +212 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -650,26 +650,44 @@ var LuckPermsModule = class {
|
|
|
650
650
|
this.http = http;
|
|
651
651
|
}
|
|
652
652
|
http;
|
|
653
|
-
|
|
653
|
+
// ---------------------------------------------------------------
|
|
654
|
+
// Player permissions & groups
|
|
655
|
+
// ---------------------------------------------------------------
|
|
656
|
+
/** Get the names of every group a player belongs to (via inheritance nodes). */
|
|
654
657
|
getPlayerGroups(uuid) {
|
|
655
658
|
return this.http.request("GET", `luckperms/player/${encodeURIComponent(uuid)}/groups`);
|
|
656
659
|
}
|
|
657
|
-
/** Get
|
|
660
|
+
/** Get every node (permissions, inheritance, prefix/suffix, meta, ...) held directly by a player. */
|
|
658
661
|
getPlayerPermissions(uuid) {
|
|
659
662
|
return this.http.request(
|
|
660
663
|
"GET",
|
|
661
664
|
`luckperms/player/${encodeURIComponent(uuid)}/permissions`
|
|
662
665
|
);
|
|
663
666
|
}
|
|
664
|
-
/** Add a permission node to a player. */
|
|
665
|
-
addPlayerPermission(uuid, permission,
|
|
667
|
+
/** Add a permission node to a player. Defaults to a permanent, global, `true`-valued node. */
|
|
668
|
+
addPlayerPermission(uuid, permission, options = {}) {
|
|
666
669
|
return this.http.request(
|
|
667
670
|
"POST",
|
|
668
671
|
`luckperms/player/${encodeURIComponent(uuid)}/permission`,
|
|
669
|
-
{ body: { permission,
|
|
672
|
+
{ body: { permission, ...options } }
|
|
670
673
|
);
|
|
671
674
|
}
|
|
672
|
-
/**
|
|
675
|
+
/**
|
|
676
|
+
* Remove a permission node from a player by key. Note this matches on
|
|
677
|
+
* the permission string only — it does not target a specific
|
|
678
|
+
* value/expiry/context combination.
|
|
679
|
+
*/
|
|
680
|
+
removePlayerPermission(uuid, permission) {
|
|
681
|
+
return this.http.request(
|
|
682
|
+
"DELETE",
|
|
683
|
+
`luckperms/player/${encodeURIComponent(uuid)}/permission`,
|
|
684
|
+
{ body: { permission } }
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Check whether a player has a given permission, using LuckPerms'
|
|
689
|
+
* native resolution (inheritance, wildcards, contexts all apply).
|
|
690
|
+
*/
|
|
673
691
|
checkPlayerPermission(uuid, permission) {
|
|
674
692
|
return this.http.request(
|
|
675
693
|
"POST",
|
|
@@ -677,30 +695,105 @@ var LuckPermsModule = class {
|
|
|
677
695
|
{ body: { permission } }
|
|
678
696
|
);
|
|
679
697
|
}
|
|
680
|
-
/**
|
|
681
|
-
|
|
698
|
+
/** Get a player's primary group name. */
|
|
699
|
+
getPlayerPrimaryGroup(uuid) {
|
|
682
700
|
return this.http.request(
|
|
683
|
-
"
|
|
684
|
-
`luckperms/player/${encodeURIComponent(uuid)}/
|
|
685
|
-
{ body: { permission } }
|
|
701
|
+
"GET",
|
|
702
|
+
`luckperms/player/${encodeURIComponent(uuid)}/primary-group`
|
|
686
703
|
);
|
|
687
704
|
}
|
|
688
|
-
/**
|
|
689
|
-
|
|
705
|
+
/**
|
|
706
|
+
* Set a player's primary group. This both adds the corresponding
|
|
707
|
+
* inheritance node (so permissions actually resolve from the group) and
|
|
708
|
+
* updates the primary-group label — mirrors `/lp user <target> parent
|
|
709
|
+
* add <group>` plus `/lp user <target> setprimarygroup <group>`.
|
|
710
|
+
*/
|
|
711
|
+
setPlayerGroup(uuid, group, options = {}) {
|
|
690
712
|
return this.http.request(
|
|
691
713
|
"POST",
|
|
692
714
|
`luckperms/player/${encodeURIComponent(uuid)}/group`,
|
|
693
|
-
{ body: { group } }
|
|
715
|
+
{ body: { group, ...options } }
|
|
694
716
|
);
|
|
695
717
|
}
|
|
696
|
-
/**
|
|
718
|
+
/**
|
|
719
|
+
* Remove a group's inheritance node from a player. Does **not** change
|
|
720
|
+
* their primary group — call `setPlayerGroup()` with the new group
|
|
721
|
+
* afterward if you're reassigning rank rather than just removing one
|
|
722
|
+
* of several parents.
|
|
723
|
+
*/
|
|
697
724
|
removePlayerGroup(uuid, groupName) {
|
|
698
725
|
return this.http.request(
|
|
699
726
|
"DELETE",
|
|
700
727
|
`luckperms/player/${encodeURIComponent(uuid)}/group/${encodeURIComponent(groupName)}`
|
|
701
728
|
);
|
|
702
729
|
}
|
|
703
|
-
/**
|
|
730
|
+
/**
|
|
731
|
+
* Promote a player one step up a track. If the result isn't successful
|
|
732
|
+
* (e.g. `END_OF_TRACK`, `AMBIGUOUS_CALL`), the player's data is left
|
|
733
|
+
* untouched — check `.success`/`.status` on the result rather than
|
|
734
|
+
* assuming the call always moves them.
|
|
735
|
+
*/
|
|
736
|
+
promotePlayer(uuid, track, options = {}) {
|
|
737
|
+
return this.http.request(
|
|
738
|
+
"POST",
|
|
739
|
+
`luckperms/player/${encodeURIComponent(uuid)}/promote`,
|
|
740
|
+
{ body: { track, ...options } }
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
/** Demote a player one step down a track. See `promotePlayer()` for the result semantics. */
|
|
744
|
+
demotePlayer(uuid, track, options = {}) {
|
|
745
|
+
return this.http.request(
|
|
746
|
+
"POST",
|
|
747
|
+
`luckperms/player/${encodeURIComponent(uuid)}/demote`,
|
|
748
|
+
{ body: { track, ...options } }
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
// ---------------------------------------------------------------
|
|
752
|
+
// Player meta (prefix / suffix / custom meta)
|
|
753
|
+
// ---------------------------------------------------------------
|
|
754
|
+
/** Get a player's resolved prefix, suffix, and custom meta key-values. */
|
|
755
|
+
getPlayerMeta(uuid) {
|
|
756
|
+
return this.http.request("GET", `luckperms/player/${encodeURIComponent(uuid)}/meta`);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Set a player's prefix. Behaves like a "set", not an "add" — any
|
|
760
|
+
* existing prefix node (in any context) is cleared first, so a player
|
|
761
|
+
* only ever has one active prefix from this call.
|
|
762
|
+
*/
|
|
763
|
+
setPlayerPrefix(uuid, prefix, options = {}) {
|
|
764
|
+
return this.http.request(
|
|
765
|
+
"POST",
|
|
766
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta/prefix`,
|
|
767
|
+
{ body: { prefix, ...options } }
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
/** Set a player's suffix. Same "set, not add" semantics as `setPlayerPrefix()`. */
|
|
771
|
+
setPlayerSuffix(uuid, suffix, options = {}) {
|
|
772
|
+
return this.http.request(
|
|
773
|
+
"POST",
|
|
774
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta/suffix`,
|
|
775
|
+
{ body: { suffix, ...options } }
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
/** Set a custom meta key-value pair on a player, replacing any existing value(s) for that key. */
|
|
779
|
+
setPlayerMeta(uuid, key, value, options = {}) {
|
|
780
|
+
return this.http.request(
|
|
781
|
+
"POST",
|
|
782
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta`,
|
|
783
|
+
{ body: { key, value, ...options } }
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
/** Remove a custom meta key from a player (all values/contexts for that key). */
|
|
787
|
+
removePlayerMeta(uuid, key) {
|
|
788
|
+
return this.http.request(
|
|
789
|
+
"DELETE",
|
|
790
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta/${encodeURIComponent(key)}`
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
// ---------------------------------------------------------------
|
|
794
|
+
// Groups
|
|
795
|
+
// ---------------------------------------------------------------
|
|
796
|
+
/** List the names of every group registered in LuckPerms. */
|
|
704
797
|
getGroups() {
|
|
705
798
|
return this.http.request("GET", "luckperms/groups");
|
|
706
799
|
}
|
|
@@ -719,10 +812,90 @@ var LuckPermsModule = class {
|
|
|
719
812
|
deleteGroup(name) {
|
|
720
813
|
return this.http.request("DELETE", `luckperms/group/${encodeURIComponent(name)}`);
|
|
721
814
|
}
|
|
722
|
-
/** Get
|
|
815
|
+
/** Get every node held directly by a group. */
|
|
723
816
|
getGroupPermissions(name) {
|
|
724
817
|
return this.http.request("GET", `luckperms/group/${encodeURIComponent(name)}/permissions`);
|
|
725
818
|
}
|
|
819
|
+
/** Add a permission node to a group. Same options/defaults as `addPlayerPermission()`. */
|
|
820
|
+
addGroupPermission(name, permission, options = {}) {
|
|
821
|
+
return this.http.request(
|
|
822
|
+
"POST",
|
|
823
|
+
`luckperms/group/${encodeURIComponent(name)}/permission`,
|
|
824
|
+
{ body: { permission, ...options } }
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
/** Remove a permission node from a group by key (matches on permission string only). */
|
|
828
|
+
removeGroupPermission(name, permission) {
|
|
829
|
+
return this.http.request(
|
|
830
|
+
"DELETE",
|
|
831
|
+
`luckperms/group/${encodeURIComponent(name)}/permission`,
|
|
832
|
+
{ body: { permission } }
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
/** Get full info for a group: name, display name, weight, and all its nodes. */
|
|
836
|
+
getGroupInfo(name) {
|
|
837
|
+
return this.http.request("GET", `luckperms/group/${encodeURIComponent(name)}`);
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Update a group's weight and/or display name. Provide at least one of
|
|
841
|
+
* the two fields — the server 400s otherwise. Passing an empty/blank
|
|
842
|
+
* `displayName` resets it to the default rather than setting a blank one.
|
|
843
|
+
* Returns the group's full updated info.
|
|
844
|
+
*/
|
|
845
|
+
updateGroup(name, updates) {
|
|
846
|
+
return this.http.request("PUT", `luckperms/group/${encodeURIComponent(name)}`, {
|
|
847
|
+
body: updates
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
// ---------------------------------------------------------------
|
|
851
|
+
// Group meta (prefix / suffix / custom meta)
|
|
852
|
+
// ---------------------------------------------------------------
|
|
853
|
+
/** Get a group's resolved prefix, suffix, and custom meta key-values. */
|
|
854
|
+
getGroupMeta(name) {
|
|
855
|
+
return this.http.request("GET", `luckperms/group/${encodeURIComponent(name)}/meta`);
|
|
856
|
+
}
|
|
857
|
+
/** Set a group's prefix. Same "set, not add" semantics as `setPlayerPrefix()`. */
|
|
858
|
+
setGroupPrefix(name, prefix, options = {}) {
|
|
859
|
+
return this.http.request(
|
|
860
|
+
"POST",
|
|
861
|
+
`luckperms/group/${encodeURIComponent(name)}/meta/prefix`,
|
|
862
|
+
{ body: { prefix, ...options } }
|
|
863
|
+
);
|
|
864
|
+
}
|
|
865
|
+
/** Set a group's suffix. Same "set, not add" semantics as `setPlayerPrefix()`. */
|
|
866
|
+
setGroupSuffix(name, suffix, options = {}) {
|
|
867
|
+
return this.http.request(
|
|
868
|
+
"POST",
|
|
869
|
+
`luckperms/group/${encodeURIComponent(name)}/meta/suffix`,
|
|
870
|
+
{ body: { suffix, ...options } }
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
/** Set a custom meta key-value pair on a group, replacing any existing value(s) for that key. */
|
|
874
|
+
setGroupMeta(name, key, value, options = {}) {
|
|
875
|
+
return this.http.request(
|
|
876
|
+
"POST",
|
|
877
|
+
`luckperms/group/${encodeURIComponent(name)}/meta`,
|
|
878
|
+
{ body: { key, value, ...options } }
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
/** Remove a custom meta key from a group (all values/contexts for that key). */
|
|
882
|
+
removeGroupMeta(name, key) {
|
|
883
|
+
return this.http.request(
|
|
884
|
+
"DELETE",
|
|
885
|
+
`luckperms/group/${encodeURIComponent(name)}/meta/${encodeURIComponent(key)}`
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
// ---------------------------------------------------------------
|
|
889
|
+
// Tracks (rank ladders — promote/demote)
|
|
890
|
+
// ---------------------------------------------------------------
|
|
891
|
+
/** List the names of every track registered in LuckPerms. */
|
|
892
|
+
getTracks() {
|
|
893
|
+
return this.http.request("GET", "luckperms/tracks");
|
|
894
|
+
}
|
|
895
|
+
/** Get a track's name and its ordered list of groups (lowest to highest rank). */
|
|
896
|
+
getTrack(name) {
|
|
897
|
+
return this.http.request("GET", `luckperms/track/${encodeURIComponent(name)}`);
|
|
898
|
+
}
|
|
726
899
|
};
|
|
727
900
|
|
|
728
901
|
// src/modules/noxauth.ts
|
|
@@ -745,6 +918,25 @@ var NoxAuthModule = class {
|
|
|
745
918
|
}
|
|
746
919
|
};
|
|
747
920
|
|
|
921
|
+
// src/modules/identity.ts
|
|
922
|
+
var IdentityModule = class {
|
|
923
|
+
constructor(http) {
|
|
924
|
+
this.http = http;
|
|
925
|
+
}
|
|
926
|
+
http;
|
|
927
|
+
/**
|
|
928
|
+
* Resolves a player's network-wide identity and local UUID status.
|
|
929
|
+
*
|
|
930
|
+
* Unlike players.resolve(name), this does NOT throw 404 if the player
|
|
931
|
+
* has never joined this server. Instead, identityUuid is always computed
|
|
932
|
+
* deterministically from the username, and hasPlayedBefore will be false
|
|
933
|
+
* with localUuid: null.
|
|
934
|
+
*/
|
|
935
|
+
get(name) {
|
|
936
|
+
return this.http.request("GET", `identity/${encodeURIComponent(name)}`);
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
|
|
748
940
|
// src/modules/skills.ts
|
|
749
941
|
var SkillsModule = class {
|
|
750
942
|
constructor(http) {
|
|
@@ -1021,6 +1213,7 @@ function safeParse(text) {
|
|
|
1021
1213
|
// src/client.ts
|
|
1022
1214
|
var NoxAeApiClient = class _NoxAeApiClient {
|
|
1023
1215
|
players;
|
|
1216
|
+
identity;
|
|
1024
1217
|
economy;
|
|
1025
1218
|
server;
|
|
1026
1219
|
worlds;
|
|
@@ -1055,6 +1248,7 @@ var NoxAeApiClient = class _NoxAeApiClient {
|
|
|
1055
1248
|
this.baseUrl = options.baseUrl;
|
|
1056
1249
|
this.apiKey = options.apiKey;
|
|
1057
1250
|
this.players = new PlayersModule(this.http);
|
|
1251
|
+
this.identity = new IdentityModule(this.http);
|
|
1058
1252
|
this.economy = new EconomyModule(this.http);
|
|
1059
1253
|
this.server = new ServerModule(this.http);
|
|
1060
1254
|
this.worlds = new WorldsModule(this.http);
|
|
@@ -1124,6 +1318,6 @@ var NoxAeApiNetworkHubClient = class _NoxAeApiNetworkHubClient {
|
|
|
1124
1318
|
}
|
|
1125
1319
|
};
|
|
1126
1320
|
|
|
1127
|
-
export { NoxAeApiClient, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNetworkHubClient, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError };
|
|
1321
|
+
export { IdentityModule, NoxAeApiClient, NoxAeApiError, NoxAeApiForbiddenError, NoxAeApiNetworkError, NoxAeApiNetworkHubClient, NoxAeApiNotFoundError, NoxAeApiRateLimitError, NoxAeApiServerError, NoxAeApiSocket, NoxAeApiUnauthorizedError };
|
|
1128
1322
|
//# sourceMappingURL=index.js.map
|
|
1129
1323
|
//# sourceMappingURL=index.js.map
|