@deafwave/osrs-botmaker-config-manager 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +54 -0
  2. package/dist/data/config-scope.d.ts +31 -0
  3. package/dist/data/config-scope.js +302 -0
  4. package/dist/data/group/aliases.d.ts +4 -0
  5. package/dist/data/group/aliases.js +17 -0
  6. package/dist/data/group/booleans.d.ts +2 -0
  7. package/dist/data/group/booleans.js +5 -0
  8. package/dist/data/group/json.d.ts +2 -0
  9. package/dist/data/group/json.js +5 -0
  10. package/dist/data/group/keys.d.ts +4 -0
  11. package/dist/data/group/keys.js +10 -0
  12. package/dist/data/group/number-arrays.d.ts +2 -0
  13. package/dist/data/group/number-arrays.js +5 -0
  14. package/dist/data/group/numbers.d.ts +4 -0
  15. package/dist/data/group/numbers.js +7 -0
  16. package/dist/data/group/string-arrays.d.ts +2 -0
  17. package/dist/data/group/string-arrays.js +5 -0
  18. package/dist/data/group/strings.d.ts +4 -0
  19. package/dist/data/group/strings.js +26 -0
  20. package/dist/data/group/summary.d.ts +1 -0
  21. package/dist/data/group/summary.js +30 -0
  22. package/dist/data/profile/booleans.d.ts +5 -0
  23. package/dist/data/profile/booleans.js +11 -0
  24. package/dist/data/profile/config.d.ts +5 -0
  25. package/dist/data/profile/config.js +23 -0
  26. package/dist/data/profile/json.d.ts +2 -0
  27. package/dist/data/profile/json.js +5 -0
  28. package/dist/data/profile/keys.d.ts +5 -0
  29. package/dist/data/profile/keys.js +41 -0
  30. package/dist/data/profile/number-arrays.d.ts +2 -0
  31. package/dist/data/profile/number-arrays.js +5 -0
  32. package/dist/data/profile/numbers.d.ts +7 -0
  33. package/dist/data/profile/numbers.js +15 -0
  34. package/dist/data/profile/string-arrays.d.ts +2 -0
  35. package/dist/data/profile/string-arrays.js +5 -0
  36. package/dist/data/profile/strings.d.ts +6 -0
  37. package/dist/data/profile/strings.js +43 -0
  38. package/dist/data/shared/accessors.d.ts +35 -0
  39. package/dist/data/shared/accessors.js +95 -0
  40. package/dist/data/shared/normalize-config-value.d.ts +1 -0
  41. package/dist/data/shared/normalize-config-value.js +6 -0
  42. package/dist/data/shared/parse-boolean.d.ts +1 -0
  43. package/dist/data/shared/parse-boolean.js +13 -0
  44. package/dist/data/shared/parse-number.d.ts +3 -0
  45. package/dist/data/shared/parse-number.js +20 -0
  46. package/dist/data/shared/profile-group.d.ts +3 -0
  47. package/dist/data/shared/profile-group.js +13 -0
  48. package/dist/data/shared/set-rs-profile-configuration.d.ts +5 -0
  49. package/dist/data/shared/set-rs-profile-configuration.js +7 -0
  50. package/dist/data/shared/split-csv.d.ts +1 -0
  51. package/dist/data/shared/split-csv.js +4 -0
  52. package/dist/data/shared/storage.d.ts +10 -0
  53. package/dist/data/shared/storage.js +58 -0
  54. package/dist/data/shared/string-array-codec.d.ts +2 -0
  55. package/dist/data/shared/string-array-codec.js +19 -0
  56. package/dist/data/shared/string-array.d.ts +2 -0
  57. package/dist/data/shared/string-array.js +14 -0
  58. package/dist/data/shared/types.d.ts +4 -0
  59. package/dist/data/shared/types.js +1 -0
  60. package/dist/data/shared/write-config.d.ts +2 -0
  61. package/dist/data/shared/write-config.js +6 -0
  62. package/dist/data/storage.d.ts +14 -0
  63. package/dist/data/storage.js +62 -0
  64. package/dist/index.d.ts +42 -0
  65. package/dist/index.js +56 -0
  66. package/dist/index.npm.d.ts +41 -0
  67. package/dist/index.npm.js +10 -0
  68. package/package.json +81 -0
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @deafwave/osrs-botmaker-config-manager
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ pnpm add @deafwave/osrs-botmaker-config-manager
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ group.set('builder', 'mode', 'safe')
13
+ const mode = group.getString('builder', 'mode', 'fallback')
14
+
15
+ profile.set('builder', 'enabled', true)
16
+ profile.set('builder', 'bankitems', [1171, 1])
17
+ profile.set('builder', 'mode', 'safe')
18
+ const enabled = profile.getBoolean('builder', 'enabled', false)
19
+
20
+ const scope = createConfigScope({ group: 'builder.scope', scope: 'group' })
21
+ scope.set('runs', 7)
22
+ scope.set('drops', [526, 2])
23
+ scope.set('meta', { mode: 'safe' })
24
+
25
+ const storage: RsProfileStorage = { group: 'builder', sync: true }
26
+ setStoredString(storage, 'mode', 'safe')
27
+ const storedMode = getStoredString(storage, 'mode', 'fallback')
28
+ ```
29
+
30
+ ## Generic Setter Values
31
+
32
+ `group.set`, `profile.set`, and `scope.set` accept any JSON-serializable value.
33
+
34
+ Accepted values include:
35
+
36
+ - strings
37
+ - numbers
38
+ - booleans
39
+ - `null`
40
+ - arrays
41
+ - plain objects
42
+
43
+ Rejected values throw `TypeError("Config value must be JSON-serializable.")`:
44
+
45
+ - `undefined`
46
+ - functions
47
+ - symbols
48
+ - bigint values
49
+ - circular / non-serializable objects
50
+
51
+ ## Sync Behavior
52
+
53
+ Writes do not call `configManager.sendConfig()` unless sync is enabled.
54
+ - Manual sync: call `sendConfig()` to force sending config.
@@ -0,0 +1,31 @@
1
+ import type { ConfigWriteOptions } from './shared/types.js';
2
+ export type ConfigScopeMode = 'group' | 'profile';
3
+ export type ConfigScopeOptions = {
4
+ group: string;
5
+ scope?: ConfigScopeMode;
6
+ profileKey?: string;
7
+ syncDefault?: boolean;
8
+ };
9
+ export type LogConfigValuesOptions = {
10
+ action: string;
11
+ group: string;
12
+ getAllValues: (keyPrefix?: string) => Record<string, string>;
13
+ keyPrefix?: string;
14
+ };
15
+ export type ConfigScope = {
16
+ getKeys: (keyPrefix?: string) => string[];
17
+ getAllValues: (keyPrefix?: string) => Record<string, string>;
18
+ logAllValues: (action: string, keyPrefix?: string) => Record<string, string>;
19
+ getString: (key: string, fallback?: string) => string;
20
+ set: (key: string, value: unknown, options?: ConfigWriteOptions) => void;
21
+ getNumber: (key: string, fallback?: number) => number;
22
+ getInt: (key: string, fallback?: number) => number;
23
+ getFloat: (key: string, fallback?: number) => number;
24
+ getBoolean: (key: string, fallback?: boolean) => boolean;
25
+ getStringArray: (key: string, fallback?: string[]) => string[];
26
+ getNumberArray: (key: string, fallback?: number[]) => number[];
27
+ getJson: <T>(key: string, fallback: T) => T;
28
+ unset: (key: string, options?: ConfigWriteOptions) => void;
29
+ };
30
+ export declare const logConfigValues: ({ action, group, getAllValues, keyPrefix }: LogConfigValuesOptions) => Record<string, string>;
31
+ export declare const createConfigScope: (options: ConfigScopeOptions) => ConfigScope;
@@ -0,0 +1,302 @@
1
+ import { setGroupValue } from './group/aliases.js';
2
+ import { getGroupBoolean } from './group/booleans.js';
3
+ import { getGroupJson } from './group/json.js';
4
+ import { getGroupKeys, unsetGroupValue } from './group/keys.js';
5
+ import { getGroupNumberArray } from './group/number-arrays.js';
6
+ import { getGroupFloat, getGroupInt, getGroupNumber } from './group/numbers.js';
7
+ import { getGroupStringArray } from './group/string-arrays.js';
8
+ import { getGroupString } from './group/strings.js';
9
+ import { getProfileBoolean, getProfileBooleanForProfileKey } from './profile/booleans.js';
10
+ import { setProfileValue, unsetProfileValue } from './profile/config.js';
11
+ import { getProfileJson } from './profile/json.js';
12
+ import { getProfileConfigKeys, getProfileKey } from './profile/keys.js';
13
+ import { getProfileNumberArray } from './profile/number-arrays.js';
14
+ import { getProfileFloat, getProfileInt, getProfileIntForProfileKey, getProfileNumber } from './profile/numbers.js';
15
+ import { getProfileStringArray } from './profile/string-arrays.js';
16
+ import { getProfileString, getProfileStringForProfileKey } from './profile/strings.js';
17
+ import { parseFloatNumber, parseNumber } from './shared/parse-number.js';
18
+ import { buildProfileGroupName } from './shared/profile-group.js';
19
+ import { splitCsv } from './shared/split-csv.js';
20
+ import { isNumberArray, parseStoredData } from './shared/storage.js';
21
+ import { parseStringArrayValue } from './shared/string-array.js';
22
+ const INVALID_SCOPE_GROUP_ERROR = "Invalid ConfigScopeOptions: 'group' must be a non-empty string.";
23
+ const INVALID_SCOPE_PROFILE_KEY_ERROR = "Invalid ConfigScopeOptions: 'profileKey' must be a non-empty string when provided.";
24
+ const PROFILE_KEY_WITH_GROUP_SCOPE_ERROR = "Invalid ConfigScopeOptions: 'profileKey' cannot be used when scope is 'group'.";
25
+ const INVALID_SCOPE_MODE_ERROR = "Invalid ConfigScopeOptions: 'scope' must be either 'group' or 'profile'.";
26
+ const INVALID_SYNC_DEFAULT_ERROR = "Invalid ConfigScopeOptions: 'syncDefault' must be a boolean when provided.";
27
+ const ERROR = 'Invalid ConfigScopeOptions.';
28
+ const logAndThrowTypeError = (message) => {
29
+ log.printColor(message, java.awt.Color.RED);
30
+ throw new TypeError(ERROR);
31
+ };
32
+ const parseConfigScopeMode = (value) => {
33
+ if (value === 'group' || value === 'profile') {
34
+ return value;
35
+ }
36
+ return logAndThrowTypeError(INVALID_SCOPE_MODE_ERROR);
37
+ };
38
+ const parseOptionalProfileKey = (profileKey) => {
39
+ if (profileKey === undefined) {
40
+ return undefined;
41
+ }
42
+ if (typeof profileKey !== 'string') {
43
+ return logAndThrowTypeError(INVALID_SCOPE_PROFILE_KEY_ERROR);
44
+ }
45
+ const trimmed = profileKey.trim();
46
+ if (!trimmed) {
47
+ return logAndThrowTypeError(INVALID_SCOPE_PROFILE_KEY_ERROR);
48
+ }
49
+ return trimmed;
50
+ };
51
+ const parseGroupName = (group) => {
52
+ if (typeof group !== 'string') {
53
+ return logAndThrowTypeError(INVALID_SCOPE_GROUP_ERROR);
54
+ }
55
+ const trimmed = group.trim();
56
+ if (!trimmed) {
57
+ return logAndThrowTypeError(INVALID_SCOPE_GROUP_ERROR);
58
+ }
59
+ return trimmed;
60
+ };
61
+ const parseSyncDefault = (syncDefault) => {
62
+ if (syncDefault === undefined) {
63
+ return undefined;
64
+ }
65
+ if (typeof syncDefault !== 'boolean') {
66
+ return logAndThrowTypeError(INVALID_SYNC_DEFAULT_ERROR);
67
+ }
68
+ return syncDefault;
69
+ };
70
+ const withSyncDefault = (syncDefault, options) => {
71
+ if (options?.sync !== undefined) {
72
+ return options;
73
+ }
74
+ if (syncDefault === undefined) {
75
+ return options;
76
+ }
77
+ return { ...options, sync: syncDefault };
78
+ };
79
+ const parseNumberArrayFromString = (value, fallback) => {
80
+ const parsed = parseStoredData(value);
81
+ if (parsed.ok && isNumberArray(parsed.value)) {
82
+ return parsed.value;
83
+ }
84
+ if (!value.trim()) {
85
+ return fallback;
86
+ }
87
+ const numbers = splitCsv(value)
88
+ .map(parseNumber)
89
+ .filter((number_) => number_ !== null);
90
+ return numbers.length > 0 ? numbers : fallback;
91
+ };
92
+ const parseJsonFromString = (value, fallback) => {
93
+ if (!value.trim()) {
94
+ return fallback;
95
+ }
96
+ const parsed = parseStoredData(value);
97
+ if (!parsed.ok) {
98
+ return fallback;
99
+ }
100
+ return parsed.value;
101
+ };
102
+ const toKeyArray = (keys) => {
103
+ const list = keys;
104
+ let size = 0;
105
+ if (typeof list?.size === 'function') {
106
+ size = Number(list.size());
107
+ }
108
+ else if (typeof list?.length === 'number') {
109
+ size = list.length;
110
+ }
111
+ const values = [];
112
+ let index = 0;
113
+ while (index < size) {
114
+ const valueAtIndex = typeof list.get === 'function' ? list.get(index) : list[index];
115
+ values.push(String(valueAtIndex));
116
+ index += 1;
117
+ }
118
+ return values;
119
+ };
120
+ const normalizeKey = (fullKey, prefix) => (fullKey.indexOf(prefix) === 0 ? fullKey.slice(prefix.length) : fullKey);
121
+ export const logConfigValues = ({ action, group, getAllValues, keyPrefix = '' }) => {
122
+ try {
123
+ const valuesByKey = getAllValues(keyPrefix);
124
+ bot.printLogMessage(`${action} ${group} all values: ${JSON.stringify(valuesByKey)}`);
125
+ return valuesByKey;
126
+ }
127
+ catch (error) {
128
+ bot.printLogMessage(`${action} ${group} all values failed: ${String(error)}`);
129
+ return {};
130
+ }
131
+ };
132
+ export const createConfigScope = (options) => {
133
+ const group = parseGroupName(options.group);
134
+ const scope = parseConfigScopeMode(options.scope ?? 'profile');
135
+ const profileKey = parseOptionalProfileKey(options.profileKey);
136
+ const syncDefault = parseSyncDefault(options.syncDefault);
137
+ if (scope === 'group' && profileKey !== undefined) {
138
+ logAndThrowTypeError(PROFILE_KEY_WITH_GROUP_SCOPE_ERROR);
139
+ }
140
+ const groupKeyPrefix = `${group}.`;
141
+ const profileGroupName = profileKey ? buildProfileGroupName(group, profileKey) : null;
142
+ const profileGroupKeyPrefix = profileGroupName ? `${profileGroupName}.` : null;
143
+ const usesActiveProfile = () => Boolean(profileKey) && profileKey === getProfileKey();
144
+ const getString = (key, fallback = '') => {
145
+ if (scope === 'group') {
146
+ return getGroupString(group, key, fallback);
147
+ }
148
+ if (profileKey) {
149
+ return getProfileStringForProfileKey(group, profileKey, key, fallback);
150
+ }
151
+ return getProfileString(group, key, fallback);
152
+ };
153
+ const getKeys = (keyPrefix = '') => {
154
+ let fullKeys;
155
+ let prefixToTrim = groupKeyPrefix;
156
+ if (scope === 'group') {
157
+ fullKeys = toKeyArray(getGroupKeys(groupKeyPrefix));
158
+ }
159
+ else if (profileGroupName && profileGroupKeyPrefix) {
160
+ if (usesActiveProfile()) {
161
+ fullKeys = toKeyArray(getProfileConfigKeys(group, keyPrefix));
162
+ }
163
+ else {
164
+ fullKeys = toKeyArray(getGroupKeys(profileGroupKeyPrefix));
165
+ prefixToTrim = profileGroupKeyPrefix;
166
+ }
167
+ }
168
+ else {
169
+ fullKeys = toKeyArray(getProfileConfigKeys(group, keyPrefix));
170
+ }
171
+ const normalized = fullKeys.map((fullKey) => normalizeKey(fullKey, prefixToTrim)).filter((key) => key.length > 0);
172
+ if (!keyPrefix) {
173
+ return normalized;
174
+ }
175
+ return normalized.filter((key) => key.startsWith(keyPrefix));
176
+ };
177
+ const getAllValues = (keyPrefix = '') => {
178
+ const valuesByKey = {};
179
+ getKeys(keyPrefix).forEach((key) => {
180
+ valuesByKey[key] = getString(key, '');
181
+ });
182
+ return valuesByKey;
183
+ };
184
+ const logAllValues = (action, keyPrefix = '') => logConfigValues({ action, group, getAllValues, keyPrefix });
185
+ const set = (key, value, writeOptions) => {
186
+ const resolvedOptions = withSyncDefault(syncDefault, writeOptions);
187
+ if (scope === 'group') {
188
+ setGroupValue(group, key, value, resolvedOptions);
189
+ return;
190
+ }
191
+ if (profileKey) {
192
+ if (usesActiveProfile()) {
193
+ setProfileValue(group, key, value, resolvedOptions);
194
+ return;
195
+ }
196
+ setGroupValue(buildProfileGroupName(group, profileKey), key, value, resolvedOptions);
197
+ return;
198
+ }
199
+ setProfileValue(group, key, value, resolvedOptions);
200
+ };
201
+ const getNumber = (key, fallback = 0) => {
202
+ if (scope === 'group') {
203
+ return getGroupNumber(group, key, fallback);
204
+ }
205
+ if (profileKey) {
206
+ const parsed = parseNumber(getString(key, ''));
207
+ return parsed === null ? fallback : parsed;
208
+ }
209
+ return getProfileNumber(group, key, fallback);
210
+ };
211
+ const getInt = (key, fallback = 0) => {
212
+ if (scope === 'group') {
213
+ return getGroupInt(group, key, fallback);
214
+ }
215
+ if (profileKey) {
216
+ return getProfileIntForProfileKey(group, profileKey, key, fallback);
217
+ }
218
+ return getProfileInt(group, key, fallback);
219
+ };
220
+ const getFloat = (key, fallback = 0) => {
221
+ if (scope === 'group') {
222
+ return getGroupFloat(group, key, fallback);
223
+ }
224
+ if (profileKey) {
225
+ const parsed = parseFloatNumber(getString(key, ''));
226
+ return parsed === null ? fallback : parsed;
227
+ }
228
+ return getProfileFloat(group, key, fallback);
229
+ };
230
+ const getBoolean = (key, fallback = false) => {
231
+ if (scope === 'group') {
232
+ return getGroupBoolean(group, key, fallback);
233
+ }
234
+ if (profileKey) {
235
+ return getProfileBooleanForProfileKey(group, profileKey, key, fallback);
236
+ }
237
+ return getProfileBoolean(group, key, fallback);
238
+ };
239
+ const getStringArray = (key, fallback = []) => {
240
+ if (scope === 'group') {
241
+ return getGroupStringArray(group, key, fallback);
242
+ }
243
+ if (profileKey) {
244
+ const rawValue = getString(key, '');
245
+ if (!rawValue.trim()) {
246
+ return fallback;
247
+ }
248
+ const entries = parseStringArrayValue(rawValue);
249
+ return entries.length > 0 ? entries : fallback;
250
+ }
251
+ return getProfileStringArray(group, key, fallback);
252
+ };
253
+ const getNumberArray = (key, fallback = []) => {
254
+ if (scope === 'group') {
255
+ return getGroupNumberArray(group, key, fallback);
256
+ }
257
+ if (profileKey) {
258
+ return parseNumberArrayFromString(getString(key, ''), fallback);
259
+ }
260
+ return getProfileNumberArray(group, key, fallback);
261
+ };
262
+ const getJson = (key, fallback) => {
263
+ if (scope === 'group') {
264
+ return getGroupJson(group, key, fallback);
265
+ }
266
+ if (profileKey) {
267
+ return parseJsonFromString(getString(key, ''), fallback);
268
+ }
269
+ return getProfileJson(group, key, fallback);
270
+ };
271
+ const unset = (key, writeOptions) => {
272
+ const resolvedOptions = withSyncDefault(syncDefault, writeOptions);
273
+ if (scope === 'group') {
274
+ unsetGroupValue(group, key, resolvedOptions);
275
+ return;
276
+ }
277
+ if (profileKey) {
278
+ if (usesActiveProfile()) {
279
+ unsetProfileValue(group, key, resolvedOptions);
280
+ return;
281
+ }
282
+ unsetGroupValue(buildProfileGroupName(group, profileKey), key, resolvedOptions);
283
+ return;
284
+ }
285
+ unsetProfileValue(group, key, resolvedOptions);
286
+ };
287
+ return {
288
+ getKeys,
289
+ getAllValues,
290
+ logAllValues,
291
+ getString,
292
+ set,
293
+ getNumber,
294
+ getInt,
295
+ getFloat,
296
+ getBoolean,
297
+ getStringArray,
298
+ getNumberArray,
299
+ getJson,
300
+ unset,
301
+ };
302
+ };
@@ -0,0 +1,4 @@
1
+ import type { ConfigWriteOptions } from '../shared/types.js';
2
+ export type ConfigAliasValue = number[] | string;
3
+ export declare const getGroupValue: (groupName: string, key: string) => ConfigAliasValue;
4
+ export declare const setGroupValue: (groupName: string, key: string, value: unknown, options?: ConfigWriteOptions) => void;
@@ -0,0 +1,17 @@
1
+ import { isNumberArray, parseStoredData, toStoredJson } from '../shared/storage.js';
2
+ import { getGroupString, setGroupString } from './strings.js';
3
+ const parseAliasValue = (rawValue) => {
4
+ if (!rawValue.trim()) {
5
+ return [];
6
+ }
7
+ const parsed = parseStoredData(rawValue);
8
+ if (parsed.ok && typeof parsed.value === 'string') {
9
+ return parsed.value;
10
+ }
11
+ if (parsed.ok && isNumberArray(parsed.value)) {
12
+ return parsed.value;
13
+ }
14
+ return rawValue;
15
+ };
16
+ export const getGroupValue = (groupName, key) => parseAliasValue(getGroupString(groupName, key, ''));
17
+ export const setGroupValue = (groupName, key, value, options) => setGroupString(groupName, key, toStoredJson(value), options);
@@ -0,0 +1,2 @@
1
+ export declare const getGroupBoolean: (groupName: string, key: string, fallback?: boolean | undefined) => boolean;
2
+ export declare const setGroupBoolean: (groupName: string, key: string, value: boolean, options?: import("../shared/types.js").ConfigWriteOptions | undefined) => void;
@@ -0,0 +1,5 @@
1
+ import { createBooleanAccessors } from '../shared/accessors.js';
2
+ import { getGroupString, setGroupString } from './strings.js';
3
+ const booleanAccessors = createBooleanAccessors(getGroupString, setGroupString);
4
+ export const getGroupBoolean = booleanAccessors.getBoolean;
5
+ export const setGroupBoolean = booleanAccessors.setBoolean;
@@ -0,0 +1,2 @@
1
+ export declare const getGroupJson: <T>(groupName: string, key: string, fallback: T) => T;
2
+ export declare const setGroupJson: <T>(groupName: string, key: string, value: T, options?: import("../shared/types.js").ConfigWriteOptions | undefined) => void;
@@ -0,0 +1,5 @@
1
+ import { createJsonAccessors } from '../shared/accessors.js';
2
+ import { getGroupRawValue, setGroupString } from './strings.js';
3
+ const jsonAccessors = createJsonAccessors(getGroupRawValue, setGroupString);
4
+ export const getGroupJson = jsonAccessors.getJson;
5
+ export const setGroupJson = jsonAccessors.setJson;
@@ -0,0 +1,4 @@
1
+ import type { ConfigWriteOptions } from '../shared/types.js';
2
+ export declare const unsetGroupValue: (groupName: string, key: string, options?: ConfigWriteOptions) => void;
3
+ export declare const getGroupKeys: (prefix: string) => string[];
4
+ export declare const sendConfig: () => void;
@@ -0,0 +1,10 @@
1
+ import { writeConfig } from '../shared/write-config.js';
2
+ export const unsetGroupValue = (groupName, key, options) => {
3
+ writeConfig(() => {
4
+ configManager.unsetConfiguration(groupName, key);
5
+ }, options);
6
+ };
7
+ export const getGroupKeys = (prefix) => configManager.getConfigurationKeys(prefix);
8
+ export const sendConfig = () => {
9
+ configManager.sendConfig();
10
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getGroupNumberArray: (groupName: string, key: string, fallback?: number[] | undefined) => number[];
2
+ export declare const setGroupNumberArray: (groupName: string, key: string, values: number[], options?: import("../shared/types.js").ConfigWriteOptions | undefined) => void;
@@ -0,0 +1,5 @@
1
+ import { createNumberArrayAccessors } from '../shared/accessors.js';
2
+ import { getGroupString, setGroupString } from './strings.js';
3
+ const numberArrayAccessors = createNumberArrayAccessors(getGroupString, setGroupString);
4
+ export const getGroupNumberArray = numberArrayAccessors.getNumberArray;
5
+ export const setGroupNumberArray = numberArrayAccessors.setNumberArray;
@@ -0,0 +1,4 @@
1
+ export declare const getGroupNumber: (groupName: string, key: string, fallback?: number | undefined) => number;
2
+ export declare const getGroupInt: (groupName: string, key: string, fallback?: number | undefined) => number;
3
+ export declare const getGroupFloat: (groupName: string, key: string, fallback?: number | undefined) => number;
4
+ export declare const setGroupNumber: (groupName: string, key: string, value: number, options?: import("../shared/types.js").ConfigWriteOptions | undefined) => void;
@@ -0,0 +1,7 @@
1
+ import { createNumberAccessors } from '../shared/accessors.js';
2
+ import { getGroupString, setGroupString } from './strings.js';
3
+ const numberAccessors = createNumberAccessors(getGroupString, setGroupString);
4
+ export const getGroupNumber = numberAccessors.getNumber;
5
+ export const getGroupInt = numberAccessors.getInt;
6
+ export const getGroupFloat = numberAccessors.getFloat;
7
+ export const setGroupNumber = numberAccessors.setNumber;
@@ -0,0 +1,2 @@
1
+ export declare const getGroupStringArray: (groupName: string, key: string, fallback?: string[] | undefined) => string[];
2
+ export declare const setGroupStringArray: (groupName: string, key: string, values: string[], options?: import("../shared/types.js").ConfigWriteOptions | undefined) => void;
@@ -0,0 +1,5 @@
1
+ import { createStringArrayAccessors } from '../shared/accessors.js';
2
+ import { getGroupString, setGroupString } from './strings.js';
3
+ const stringArrayAccessors = createStringArrayAccessors(getGroupString, setGroupString);
4
+ export const getGroupStringArray = stringArrayAccessors.getStringArray;
5
+ export const setGroupStringArray = stringArrayAccessors.setStringArray;
@@ -0,0 +1,4 @@
1
+ import type { ConfigWriteOptions } from '../shared/types.js';
2
+ export declare const getGroupRawValue: (groupName: string, key: string) => string | null;
3
+ export declare const getGroupString: (groupName: string, key: string, fallback?: string) => string;
4
+ export declare const setGroupString: (groupName: string, key: string, value: string, options?: ConfigWriteOptions) => void;
@@ -0,0 +1,26 @@
1
+ import { normalizeConfigValue } from '../shared/normalize-config-value.js';
2
+ import { parseStoredData } from '../shared/storage.js';
3
+ import { writeConfig } from '../shared/write-config.js';
4
+ export const getGroupRawValue = (groupName, key) => {
5
+ const rawValue = normalizeConfigValue(configManager.getConfiguration(groupName, key));
6
+ if (rawValue === null || rawValue === undefined) {
7
+ return null;
8
+ }
9
+ return rawValue;
10
+ };
11
+ export const getGroupString = (groupName, key, fallback = '') => {
12
+ const rawValue = getGroupRawValue(groupName, key);
13
+ if (rawValue === null) {
14
+ return fallback;
15
+ }
16
+ const parsed = parseStoredData(rawValue);
17
+ if (parsed.ok && typeof parsed.value === 'string') {
18
+ return parsed.value;
19
+ }
20
+ return rawValue;
21
+ };
22
+ export const setGroupString = (groupName, key, value, options) => {
23
+ writeConfig(() => {
24
+ configManager.setConfiguration(groupName, key, value);
25
+ }, options);
26
+ };
@@ -0,0 +1 @@
1
+ export declare const logGroupConfigSummary: (groupName: string) => void;
@@ -0,0 +1,30 @@
1
+ import { RS_PROFILE_GROUP_SEGMENT } from '../shared/profile-group.js';
2
+ import { getGroupKeys } from './keys.js';
3
+ export const logGroupConfigSummary = (groupName) => {
4
+ const keys = getGroupKeys(`${groupName}.`);
5
+ if (keys.length === 0) {
6
+ log.printGameMessage(`No config keys found for group '${groupName}'.`);
7
+ return;
8
+ }
9
+ const profilePrefix = `${groupName}${RS_PROFILE_GROUP_SEGMENT}`;
10
+ const groupScoped = [];
11
+ let profileScopedCount = 0;
12
+ keys.forEach((key) => {
13
+ if (key.startsWith(profilePrefix)) {
14
+ profileScopedCount += 1;
15
+ }
16
+ else {
17
+ groupScoped.push(key);
18
+ }
19
+ });
20
+ log.printGameMessage(`Config summary for group '${groupName}': ${keys.length} total key(s), ${groupScoped.length} group-level, ${profileScopedCount} profile-scoped.`);
21
+ if (groupScoped.length > 0) {
22
+ const sortedKeys = groupScoped.slice().sort((a, b) => a.localeCompare(b));
23
+ sortedKeys.forEach((key) => {
24
+ log.printGameMessage(`Group-level key: ${key}`);
25
+ });
26
+ }
27
+ if (profileScopedCount > 0) {
28
+ log.printGameMessage(`Profile-scoped keys detected for '${groupName}'. Use profile.logSummary('${groupName}') for details.`);
29
+ }
30
+ };
@@ -0,0 +1,5 @@
1
+ import type { ConfigWriteOptions } from '../shared/types.js';
2
+ export declare const getProfileBoolean: (groupName: string, key: string, fallback?: boolean | undefined) => boolean;
3
+ export declare const setProfileBoolean: (groupName: string, key: string, value: boolean, options?: ConfigWriteOptions | undefined) => void;
4
+ export declare const getProfileBooleanForProfileKey: (groupName: string, profileKey: string, key: string, fallback?: boolean) => boolean;
5
+ export declare const setProfileBooleanForProfileKey: (groupName: string, profileKey: string, key: string, value: boolean, options?: ConfigWriteOptions) => void;
@@ -0,0 +1,11 @@
1
+ import { createBooleanAccessors, parseStoredBoolean } from '../shared/accessors.js';
2
+ import { getProfileString, getProfileStringForProfileKey, setProfileString, setProfileStringForProfileKey } from './strings.js';
3
+ const booleanAccessors = createBooleanAccessors(getProfileString, setProfileString);
4
+ export const getProfileBoolean = booleanAccessors.getBoolean;
5
+ export const setProfileBoolean = booleanAccessors.setBoolean;
6
+ export const getProfileBooleanForProfileKey = (groupName, profileKey, key, fallback = false) => {
7
+ return parseStoredBoolean(getProfileStringForProfileKey(groupName, profileKey, key, ''), fallback);
8
+ };
9
+ export const setProfileBooleanForProfileKey = (groupName, profileKey, key, value, options) => {
10
+ setProfileStringForProfileKey(groupName, profileKey, key, value ? 'true' : 'false', options);
11
+ };
@@ -0,0 +1,5 @@
1
+ import type { ConfigWriteOptions } from '../shared/types.js';
2
+ export declare const unsetProfileValue: (groupName: string, key: string, options?: ConfigWriteOptions) => void;
3
+ export type ProfileConfigAliasValue = number[] | string;
4
+ export declare const getProfileValue: (groupName: string, key: string) => ProfileConfigAliasValue;
5
+ export declare const setProfileValue: (groupName: string, key: string, value: unknown, options?: ConfigWriteOptions) => void;
@@ -0,0 +1,23 @@
1
+ import { isNumberArray, parseStoredData, toStoredJson } from '../shared/storage.js';
2
+ import { writeConfig } from '../shared/write-config.js';
3
+ import { getProfileString, setProfileString } from './strings.js';
4
+ export const unsetProfileValue = (groupName, key, options) => {
5
+ writeConfig(() => {
6
+ configManager.unsetRSProfileConfiguration(groupName, key);
7
+ }, options);
8
+ };
9
+ const parseAliasValue = (rawValue) => {
10
+ if (!rawValue.trim()) {
11
+ return [];
12
+ }
13
+ const parsed = parseStoredData(rawValue);
14
+ if (parsed.ok && typeof parsed.value === 'string') {
15
+ return parsed.value;
16
+ }
17
+ if (parsed.ok && isNumberArray(parsed.value)) {
18
+ return parsed.value;
19
+ }
20
+ return rawValue;
21
+ };
22
+ export const getProfileValue = (groupName, key) => parseAliasValue(getProfileString(groupName, key, ''));
23
+ export const setProfileValue = (groupName, key, value, options) => setProfileString(groupName, key, toStoredJson(value), options);
@@ -0,0 +1,2 @@
1
+ export declare const getProfileJson: <T>(groupName: string, key: string, fallback: T) => T;
2
+ export declare const setProfileJson: <T>(groupName: string, key: string, value: T, options?: import("../shared/types.js").ConfigWriteOptions | undefined) => void;
@@ -0,0 +1,5 @@
1
+ import { createJsonAccessors } from '../shared/accessors.js';
2
+ import { getProfileRawValue, setProfileString } from './strings.js';
3
+ const jsonAccessors = createJsonAccessors(getProfileRawValue, setProfileString);
4
+ export const getProfileJson = jsonAccessors.getJson;
5
+ export const setProfileJson = jsonAccessors.setJson;
@@ -0,0 +1,5 @@
1
+ export declare const getProfileKey: () => string;
2
+ export declare const getProfileGroupName: (groupName: string, profileKey: string) => string;
3
+ export declare const getProfileKeysForGroup: (groupName: string) => string[];
4
+ export declare const logProfileConfigSummary: (groupName: string) => void;
5
+ export declare const getProfileConfigKeys: (groupName: string, keyPrefix?: string) => string[];