@wolfstar/decorators 0.1.3 → 0.1.4

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.
@@ -1,5 +1,4 @@
1
1
  import { LoaderPieceContext, PermissionResolvable, PieceOptions } from "@wolfstar/http-framework";
2
- //#region src/ApplyOptions.d.ts
3
2
  /**
4
3
  * The constructor signature shared by every `Piece` of `@wolfstar/http-framework`, such as `Command`, `Listener`, and
5
4
  * `InteractionHandler`.
@@ -38,8 +37,6 @@ export type PieceConstructor<Options extends PieceOptions = PieceOptions> = new
38
37
  * ```
39
38
  */
40
39
  export declare function ApplyOptions<Options extends PieceOptions = PieceOptions>(optionsOrFn: Options | ((context: LoaderPieceContext) => Options)): ClassDecorator;
41
- //#endregion
42
- //#region src/Enumerable.d.ts
43
40
  /**
44
41
  * Decorator that sets the `enumerable` property of a class field to the given value.
45
42
  *
@@ -84,8 +81,6 @@ export declare function Enumerable(value: boolean): (target: unknown, key: strin
84
81
  * ```
85
82
  */
86
83
  export declare function EnumerableMethod(value: boolean): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
87
- //#endregion
88
- //#region src/RequiresContext.d.ts
89
84
  /**
90
85
  * The fallback invoked when a context precondition is not met. It receives the same arguments as the decorated method.
91
86
  */
@@ -137,8 +132,6 @@ export declare function RequiresGuildContext(fallback?: ContextFallback): Method
137
132
  * ```
138
133
  */
139
134
  export declare function RequiresDMContext(fallback?: ContextFallback): MethodDecorator;
140
- //#endregion
141
- //#region src/RequiresPermissions.d.ts
142
135
  /**
143
136
  * Decorator that only runs the decorated method when the application has all of the given permissions in the channel
144
137
  * the interaction was sent from, as reported by the interaction's `app_permissions` field.
@@ -191,8 +184,6 @@ export declare function RequiresClientPermissions(...permissions: PermissionReso
191
184
  * ```
192
185
  */
193
186
  export declare function RequiresUserPermissions(...permissions: PermissionResolvable[]): MethodDecorator;
194
- //#endregion
195
- //#region src/utils.d.ts
196
187
  /**
197
188
  * Utility to make a method decorator from a function.
198
189
  *
@@ -251,5 +242,4 @@ export declare function createProxy<T extends object>(target: T, handler: Omit<P
251
242
  * ```
252
243
  */
253
244
  export declare function createFunctionPrecondition(precondition: (...args: any[]) => boolean | Promise<boolean>, fallback?: (...args: any[]) => unknown): MethodDecorator;
254
- //#endregion
255
245
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ApplyOptions.ts","../../src/Enumerable.ts","../../src/RequiresContext.ts","../../src/RequiresPermissions.ts","../../src/utils.ts"],"mappings":";;;;;;YAOY,iBAAiB,gBAAgB,eAAe,qBAAqB,SAAS,oBAAoB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkCxG,aAAa,gBAAgB,eAAe,cAC3D,aAAa,YAAY,SAAS,uBAAuB,WACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCnBa,WAAW,kBAAc,iBACjB;;;;;;;;;;;;;;;;;;;wBAiCR,iBAAiB,kBAAc,kBACtB,cAAc,YAAc;;;;;;YCrDzC,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;wBAwBlB,qBAAqB,WAAU,kBAAoC;;;;;;;;;;;;;;;;;;;;;;;;wBA2BnE,kBAAkB,WAAU,kBAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCVhE,6BAA6B,aAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgDnE,2BAA2B,aAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;wBC9EjE,sBAAsB,sBAAsB,yBAAyB,IAAI,YAAY;;;;;;;;;;;wBAcrF,qBAAqB,sBAAsB,yBAAyB,IAAI,YAAY;;;;;;;;wBAWpF,YAAY,kBAAkB,QAAQ,GAAG,SAAS,KAAK,aAAa,aAAa;;;;;;;;;;;;;;;;;;;;;wBA8BjF,2BACf,kBAAkB,0BAA0B,kBAC5C,eAAc,0BACZ"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ApplyOptions.ts","../../src/Enumerable.ts","../../src/RequiresContext.ts","../../src/RequiresPermissions.ts","../../src/utils.ts"],"mappings":";;;;;YAOY,iBAAiB,gBAAgB,eAAe,qBAAqB,SAAS,oBAAoB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkCxG,aAAa,gBAAgB,eAAe,cAC3D,aAAa,YAAY,SAAS,uBAAuB,WACvD;;;;;;;;;;;;;;;;;;;;;;;;;wBCnBa,WAAW,kBAAc,iBACjB;;;;;;;;;;;;;;;;;;;wBAiCR,iBAAiB,kBAAc,kBACtB,cAAc,YAAc;;;;YCrDzC,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;wBAwBlB,qBAAqB,WAAU,kBAAoC;;;;;;;;;;;;;;;;;;;;;;;;wBA2BnE,kBAAkB,WAAU,kBAAoC;;;;;;;;;;;;;;;;;;;;;;;;;wBCVhE,6BAA6B,aAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgDnE,2BAA2B,aAAa,yBAAyB;;;;;;;;;;;;;;;;;;wBC9EjE,sBAAsB,sBAAsB,yBAAyB,IAAI,YAAY;;;;;;;;;;;wBAcrF,qBAAqB,sBAAsB,yBAAyB,IAAI,YAAY;;;;;;;;wBAWpF,YAAY,kBAAkB,QAAQ,GAAG,SAAS,KAAK,aAAa,aAAa;;;;;;;;;;;;;;;;;;;;;wBA8BjF,2BACf,kBAAkB,0BAA0B,kBAC5C,eAAc,0BACZ"}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Identifiers, PreconditionError, getMissingPermissions, resolvePermissions, toPermissionNames } from "@wolfstar/http-framework";
2
2
 
3
- //#region src/utils.ts
3
+ // src/utils.ts
4
4
  /**
5
5
  * Utility to make a method decorator from a function.
6
6
  *
@@ -81,8 +81,7 @@ function createFunctionPrecondition(precondition, fallback = () => void 0) {
81
81
  });
82
82
  }
83
83
 
84
- //#endregion
85
- //#region src/ApplyOptions.ts
84
+ // src/ApplyOptions.ts
86
85
  /**
87
86
  * Decorator that sets the options of a `Piece`, such as a `Command`, a `Listener`, or an `InteractionHandler`.
88
87
  *
@@ -122,8 +121,7 @@ function ApplyOptions(optionsOrFn) {
122
121
  }], newTarget) }));
123
122
  }
124
123
 
125
- //#endregion
126
- //#region src/Enumerable.ts
124
+ // src/Enumerable.ts
127
125
  /**
128
126
  * Decorator that sets the `enumerable` property of a class field to the given value.
129
127
  *
@@ -187,8 +185,7 @@ function EnumerableMethod(value) {
187
185
  };
188
186
  }
189
187
 
190
- //#endregion
191
- //#region src/RequiresContext.ts
188
+ // src/RequiresContext.ts
192
189
  /**
193
190
  * Decorator that only runs the decorated method when the interaction was received from a guild.
194
191
  *
@@ -241,8 +238,7 @@ function RequiresDMContext(fallback = () => void 0) {
241
238
  return createFunctionPrecondition((interaction) => !interaction.inGuild(), fallback);
242
239
  }
243
240
 
244
- //#endregion
245
- //#region src/RequiresPermissions.ts
241
+ // src/RequiresPermissions.ts
246
242
  /**
247
243
  * Reads the permissions the invoking user has in the channel the interaction was sent from.
248
244
  *
@@ -343,6 +339,5 @@ function RequiresUserPermissions(...permissions) {
343
339
  });
344
340
  }
345
341
 
346
- //#endregion
347
342
  export { ApplyOptions, Enumerable, EnumerableMethod, RequiresClientPermissions, RequiresDMContext, RequiresGuildContext, RequiresUserPermissions, createClassDecorator, createFunctionPrecondition, createMethodDecorator, createProxy };
348
343
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/utils.ts","../../src/ApplyOptions.ts","../../src/Enumerable.ts","../../src/RequiresContext.ts","../../src/RequiresPermissions.ts"],"sourcesContent":["/**\n * Utility to make a method decorator from a function.\n *\n * @remarks The decorator is returned with the signature it was given, rather than widened to `MethodDecorator`, so a\n * decorator built on top of this keeps whatever constraint it declares on its target.\n * @param fn The method to decorate.\n * @returns The decorator.\n * @example\n * ```typescript\n * // Enumerable function that will not append the property to the prototype:\n * function enumerableMethod(value: boolean) {\n * \treturn createMethodDecorator((_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => {\n * \t\tdescriptor.enumerable = value;\n * \t});\n * }\n * ```\n */\nexport function createMethodDecorator<TFunction extends (...args: any[]) => unknown>(fn: TFunction): TFunction {\n\treturn fn;\n}\n\n/**\n * Utility to make a class decorator from a function.\n *\n * @remarks The decorator is returned with the signature it was given, rather than widened to `ClassDecorator`, so a\n * decorator built on top of this keeps whatever constraint it declares on its target, such as only accepting a\n * `Command` subclass.\n * @param fn The class to decorate.\n * @returns The decorator.\n * @see {@linkcode ApplyOptions}\n */\nexport function createClassDecorator<TFunction extends (...args: any[]) => unknown>(fn: TFunction): TFunction {\n\treturn fn;\n}\n\n/**\n * Creates a new proxy to efficiently add properties to a class without creating subclasses.\n *\n * @param target The constructor of the class to modify.\n * @param handler The handler function to modify the constructor behavior for the target.\n * @returns The proxy.\n */\nexport function createProxy<T extends object>(target: T, handler: Omit<ProxyHandler<T>, 'get'>): T {\n\treturn new Proxy(target, {\n\t\t...handler,\n\t\tget: (proxyTarget, property) => {\n\t\t\tconst value = Reflect.get(proxyTarget, property);\n\t\t\treturn typeof value === 'function' ? (...args: readonly unknown[]) => value.apply(proxyTarget, args) : value;\n\t\t}\n\t});\n}\n\n/**\n * Utility to make a method decorator with lighter syntax and inferred types.\n *\n * @remarks The decorated method is replaced by an `async` one, so it always returns a `Promise`, even when both the\n * precondition and the original method are synchronous.\n * @param precondition The predicate to run before the decorated method. It receives the same arguments as the method\n * and is called with the same `this`.\n * @param fallback The fallback to run when the precondition is not met. Defaults to a no-op returning `undefined`.\n * @returns The decorator.\n * @example\n * ```typescript\n * import { createFunctionPrecondition } from '@wolfstar/decorators';\n * import type { Command } from '@wolfstar/http-framework';\n *\n * const RequiresOwner = createFunctionPrecondition(\n * \t(interaction: Command.ChatInputInteraction) => interaction.user.id === process.env.OWNER_ID,\n * \t(interaction: Command.ChatInputInteraction) => interaction.reply({ content: 'Owner only.' })\n * );\n * ```\n */\nexport function createFunctionPrecondition(\n\tprecondition: (...args: any[]) => boolean | Promise<boolean>,\n\tfallback: (...args: any[]) => unknown = () => undefined\n): MethodDecorator {\n\treturn createMethodDecorator((_target: unknown, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n\t\tconst method = descriptor.value;\n\t\tif (!method) throw new Error('Function preconditions require a [[value]].');\n\t\tif (typeof method !== 'function') throw new Error('Function preconditions can only be applied to functions.');\n\n\t\tdescriptor.value = async function value(this: unknown, ...args: any[]) {\n\t\t\treturn (await precondition.apply(this, args)) ? method.apply(this, args) : fallback.apply(this, args);\n\t\t};\n\t}) as MethodDecorator;\n}\n","import type { LoaderPieceContext, PieceOptions } from '@wolfstar/http-framework';\nimport { createClassDecorator, createProxy } from './utils.js';\n\n/**\n * The constructor signature shared by every `Piece` of `@wolfstar/http-framework`, such as `Command`, `Listener`, and\n * `InteractionHandler`.\n */\nexport type PieceConstructor<Options extends PieceOptions = PieceOptions> = new (context: LoaderPieceContext, options?: Options) => unknown;\n\n/**\n * Decorator that sets the options of a `Piece`, such as a `Command`, a `Listener`, or an `InteractionHandler`.\n *\n * @remarks The options are merged on top of the ones the piece was constructed with, so a piece that also passes\n * options through `super(context, options)` will have the decorator's values win on conflicting keys.\n * @remarks Apply this decorator above (outside of) any other class decorator that keys metadata by class identity,\n * such as `RegisterCommand` from `@wolfstar/http-framework` — as in the example below. This decorator returns a `Proxy` wrapping the class,\n * so a decorator applied above it (running after it, and therefore registering against the proxy) would register\n * metadata that instances constructed from the exported class — whose `.constructor` still resolves to the original,\n * unproxied class — can never be looked up by.\n * @param optionsOrFn The options to pass to the piece's constructor, or a function that builds them from the loader\n * context.\n * @returns A class decorator.\n * @example\n * ```typescript\n * import { ApplyOptions } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)ApplyOptions<Command.Options>({ name: 'ping', enabled: true })\n * (at)RegisterCommand({ name: 'ping', description: 'A simple ping pong command' })\n * export class UserCommand extends Command {\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Pong!' });\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * (at)ApplyOptions<Command.Options>(({ name }) => ({ name: name.toLowerCase() }))\n * export class UserCommand extends Command {}\n * ```\n */\nexport function ApplyOptions<Options extends PieceOptions = PieceOptions>(\n\toptionsOrFn: Options | ((context: LoaderPieceContext) => Options)\n): ClassDecorator {\n\treturn createClassDecorator((target: PieceConstructor<Options>) =>\n\t\tcreateProxy(target, {\n\t\t\tconstruct: (ctor, [context, baseOptions]: [LoaderPieceContext, Options | undefined], newTarget) =>\n\t\t\t\tReflect.construct(\n\t\t\t\t\tctor,\n\t\t\t\t\t[\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...baseOptions,\n\t\t\t\t\t\t\t...(typeof optionsOrFn === 'function' ? optionsOrFn(context) : optionsOrFn)\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tnewTarget\n\t\t\t\t) as object\n\t\t})\n\t) as ClassDecorator;\n}\n","/**\n * Decorator that sets the `enumerable` property of a class field to the given value.\n *\n * @remarks The decorator installs a setter on the prototype, which is bypassed by the `Object.defineProperty` call\n * that `useDefineForClassFields` (enabled by `@sapphire/ts-config`, and the default from `ES2022` onwards) emits for\n * class fields. Mark the field as `declare` so no field definition is emitted, and assign it in the constructor.\n * @param value Whether the property should be enumerable or not.\n * @returns A property decorator.\n * @example\n * ```typescript\n * import { Enumerable } from '@wolfstar/decorators';\n * import { Command } from '@wolfstar/http-framework';\n *\n * export class UserCommand extends Command {\n * \t(at)Enumerable(false)\n * \tdeclare public cache: Map<string, string>;\n *\n * \tpublic constructor(context: Command.LoaderContext, options: Command.Options) {\n * \t\tsuper(context, options);\n * \t\tthis.cache = new Map();\n * \t}\n * }\n * ```\n */\nexport function Enumerable(value: boolean) {\n\treturn (target: unknown, key: string) => {\n\t\tReflect.defineProperty(target as object, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as object, key, {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: value,\n\t\t\t\t\tvalue: val,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Decorator that sets the `enumerable` property of a class method to the given value.\n *\n * @param value Whether the method should be enumerable or not.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { EnumerableMethod } from '@wolfstar/decorators';\n * import { Command } from '@wolfstar/http-framework';\n *\n * export class UserCommand extends Command {\n * \t(at)EnumerableMethod(true)\n * \tpublic getCacheKey(id: string) {\n * \t\treturn `user:${id}`;\n * \t}\n * }\n * ```\n */\nexport function EnumerableMethod(value: boolean) {\n\treturn (_target: unknown, _key: string, descriptor: PropertyDescriptor) => {\n\t\tdescriptor.enumerable = value;\n\t};\n}\n","import type { BaseInteraction } from '@wolfstar/http-framework';\nimport { createFunctionPrecondition } from './utils.js';\n\n/**\n * The fallback invoked when a context precondition is not met. It receives the same arguments as the decorated method.\n */\nexport type ContextFallback = (...args: any[]) => unknown;\n\n/**\n * Decorator that only runs the decorated method when the interaction was received from a guild.\n *\n * @param fallback The fallback to run when the interaction did not come from a guild. Defaults to a no-op, which\n * silently skips the method.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresGuildContext } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'kick', description: 'Kicks a member' })\n * export class UserCommand extends Command {\n * \t(at)RequiresGuildContext((interaction: Command.ChatInputInteraction) =>\n * \t\tinteraction.reply({ content: 'This command can only be used in a server.' })\n * \t)\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: `Hello from ${interaction.guildId}!` });\n * \t}\n * }\n * ```\n */\nexport function RequiresGuildContext(fallback: ContextFallback = () => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((interaction: BaseInteraction) => interaction.inGuild(), fallback);\n}\n\n/**\n * Decorator that only runs the decorated method when the interaction was **not** received from a guild, that is, from a\n * DM or from a user-installed app context.\n *\n * @param fallback The fallback to run when the interaction came from a guild. Defaults to a no-op, which silently skips\n * the method.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresDMContext } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'private', description: 'Only usable outside of servers' })\n * export class UserCommand extends Command {\n * \t(at)RequiresDMContext((interaction: Command.ChatInputInteraction) =>\n * \t\tinteraction.reply({ content: 'This command cannot be used in a server.' })\n * \t)\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Hello!' });\n * \t}\n * }\n * ```\n */\nexport function RequiresDMContext(fallback: ContextFallback = () => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((interaction: BaseInteraction) => !interaction.inGuild(), fallback);\n}\n","import {\n\tgetMissingPermissions,\n\tIdentifiers,\n\tPreconditionError,\n\tresolvePermissions,\n\ttoPermissionNames,\n\ttype BaseInteraction,\n\ttype PermissionResolvable\n} from '@wolfstar/http-framework';\nimport { createFunctionPrecondition } from './utils.js';\n\n/**\n * Reads the permissions the invoking user has in the channel the interaction was sent from.\n *\n * @param interaction The interaction to read from.\n * @returns The bitfield of the user's permissions, or `null` when the interaction did not come from a guild and there\n * are therefore no guild permissions to check.\n */\nfunction getUserPermissions(interaction: BaseInteraction): bigint | null {\n\tconst permissions = interaction.member?.permissions;\n\treturn permissions === undefined ? null : BigInt(permissions);\n}\n\n/**\n * Decorator that only runs the decorated method when the application has all of the given permissions in the channel\n * the interaction was sent from, as reported by the interaction's `app_permissions` field.\n *\n * @remarks When the fallback is omitted, a {@linkcode PreconditionError} identified by\n * {@linkcode Identifiers.PreconditionClientPermissions} is thrown, which the client emits as `chatInputCommandDenied` or\n * `contextMenuCommandDenied` (or `interactionHandlerDenied`), not as `commandError`, for a `Listener` to turn into a\n * user-facing reply.\n * @param permissions The permissions the application must have.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresClientPermissions } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'purge', description: 'Deletes messages' })\n * export class UserCommand extends Command {\n * \t(at)RequiresClientPermissions('ManageMessages')\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Purging!' });\n * \t}\n * }\n * ```\n */\nexport function RequiresClientPermissions(...permissions: PermissionResolvable[]): MethodDecorator {\n\tconst required = resolvePermissions(permissions);\n\treturn createFunctionPrecondition(\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst granted = interaction.applicationPermissions;\n\t\t\t// `app_permissions` is always sent by Discord, but the field is optional in the typings; when it is absent\n\t\t\t// there is nothing to check against, so the method is allowed to run.\n\t\t\treturn granted === undefined || getMissingPermissions(granted, required) === 0n;\n\t\t},\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst missing = getMissingPermissions(interaction.applicationPermissions ?? 0n, required);\n\t\t\tconst missingNames = toPermissionNames(missing);\n\t\t\tthrow new PreconditionError({\n\t\t\t\tprecondition: 'ClientPermissions',\n\t\t\t\tidentifier: Identifiers.PreconditionClientPermissions,\n\t\t\t\tmessage: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingNames.join(', ')}`,\n\t\t\t\tcontext: { missing, missingNames }\n\t\t\t});\n\t\t}\n\t);\n}\n\n/**\n * Decorator that only runs the decorated method when the invoking user has all of the given permissions in the channel\n * the interaction was sent from.\n *\n * @remarks Interactions received outside of a guild carry no member permissions, so the check passes for them. Pair\n * this decorator with {@linkcode RequiresGuildContext} when the method must also be guild-only.\n * @remarks When the fallback is omitted, a {@linkcode PreconditionError} identified by\n * {@linkcode Identifiers.PreconditionUserPermissions} is thrown, which the client emits as `chatInputCommandDenied` or\n * `contextMenuCommandDenied` (or `interactionHandlerDenied`), not as `commandError`, for a `Listener` to turn into a\n * user-facing reply.\n * @param permissions The permissions the invoking user must have.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresUserPermissions } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'ban', description: 'Bans a member' })\n * export class UserCommand extends Command {\n * \t(at)RequiresUserPermissions('BanMembers')\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Banned!' });\n * \t}\n * }\n * ```\n */\nexport function RequiresUserPermissions(...permissions: PermissionResolvable[]): MethodDecorator {\n\tconst required = resolvePermissions(permissions);\n\treturn createFunctionPrecondition(\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst granted = getUserPermissions(interaction);\n\t\t\treturn granted === null || getMissingPermissions(granted, required) === 0n;\n\t\t},\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst missing = getMissingPermissions(getUserPermissions(interaction) ?? 0n, required);\n\t\t\tconst missingNames = toPermissionNames(missing);\n\t\t\tthrow new PreconditionError({\n\t\t\t\tprecondition: 'UserPermissions',\n\t\t\t\tidentifier: Identifiers.PreconditionUserPermissions,\n\t\t\t\tmessage: `Sorry, but you are not allowed to do that. You are missing the permissions: ${missingNames.join(', ')}`,\n\t\t\t\tcontext: { missing, missingNames }\n\t\t\t});\n\t\t}\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBAAqE,IAA0B;CAC9G,OAAO;AACR;;;;;;;;;;;AAYA,SAAgB,qBAAoE,IAA0B;CAC7G,OAAO;AACR;;;;;;;;AASA,SAAgB,YAA8B,QAAW,SAA0C;CAClG,OAAO,IAAI,MAAM,QAAQ;EACxB,GAAG;EACH,MAAM,aAAa,aAAa;GAC/B,MAAM,QAAQ,QAAQ,IAAI,aAAa,QAAQ;GAC/C,OAAO,OAAO,UAAU,cA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,CACD;AACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils.ts","../../src/ApplyOptions.ts","../../src/Enumerable.ts","../../src/RequiresContext.ts","../../src/RequiresPermissions.ts"],"sourcesContent":["/**\n * Utility to make a method decorator from a function.\n *\n * @remarks The decorator is returned with the signature it was given, rather than widened to `MethodDecorator`, so a\n * decorator built on top of this keeps whatever constraint it declares on its target.\n * @param fn The method to decorate.\n * @returns The decorator.\n * @example\n * ```typescript\n * // Enumerable function that will not append the property to the prototype:\n * function enumerableMethod(value: boolean) {\n * \treturn createMethodDecorator((_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => {\n * \t\tdescriptor.enumerable = value;\n * \t});\n * }\n * ```\n */\nexport function createMethodDecorator<TFunction extends (...args: any[]) => unknown>(fn: TFunction): TFunction {\n\treturn fn;\n}\n\n/**\n * Utility to make a class decorator from a function.\n *\n * @remarks The decorator is returned with the signature it was given, rather than widened to `ClassDecorator`, so a\n * decorator built on top of this keeps whatever constraint it declares on its target, such as only accepting a\n * `Command` subclass.\n * @param fn The class to decorate.\n * @returns The decorator.\n * @see {@linkcode ApplyOptions}\n */\nexport function createClassDecorator<TFunction extends (...args: any[]) => unknown>(fn: TFunction): TFunction {\n\treturn fn;\n}\n\n/**\n * Creates a new proxy to efficiently add properties to a class without creating subclasses.\n *\n * @param target The constructor of the class to modify.\n * @param handler The handler function to modify the constructor behavior for the target.\n * @returns The proxy.\n */\nexport function createProxy<T extends object>(target: T, handler: Omit<ProxyHandler<T>, 'get'>): T {\n\treturn new Proxy(target, {\n\t\t...handler,\n\t\tget: (proxyTarget, property) => {\n\t\t\tconst value = Reflect.get(proxyTarget, property);\n\t\t\treturn typeof value === 'function' ? (...args: readonly unknown[]) => value.apply(proxyTarget, args) : value;\n\t\t}\n\t});\n}\n\n/**\n * Utility to make a method decorator with lighter syntax and inferred types.\n *\n * @remarks The decorated method is replaced by an `async` one, so it always returns a `Promise`, even when both the\n * precondition and the original method are synchronous.\n * @param precondition The predicate to run before the decorated method. It receives the same arguments as the method\n * and is called with the same `this`.\n * @param fallback The fallback to run when the precondition is not met. Defaults to a no-op returning `undefined`.\n * @returns The decorator.\n * @example\n * ```typescript\n * import { createFunctionPrecondition } from '@wolfstar/decorators';\n * import type { Command } from '@wolfstar/http-framework';\n *\n * const RequiresOwner = createFunctionPrecondition(\n * \t(interaction: Command.ChatInputInteraction) => interaction.user.id === process.env.OWNER_ID,\n * \t(interaction: Command.ChatInputInteraction) => interaction.reply({ content: 'Owner only.' })\n * );\n * ```\n */\nexport function createFunctionPrecondition(\n\tprecondition: (...args: any[]) => boolean | Promise<boolean>,\n\tfallback: (...args: any[]) => unknown = () => undefined\n): MethodDecorator {\n\treturn createMethodDecorator((_target: unknown, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n\t\tconst method = descriptor.value;\n\t\tif (!method) throw new Error('Function preconditions require a [[value]].');\n\t\tif (typeof method !== 'function') throw new Error('Function preconditions can only be applied to functions.');\n\n\t\tdescriptor.value = async function value(this: unknown, ...args: any[]) {\n\t\t\treturn (await precondition.apply(this, args)) ? method.apply(this, args) : fallback.apply(this, args);\n\t\t};\n\t}) as MethodDecorator;\n}\n","import type { LoaderPieceContext, PieceOptions } from '@wolfstar/http-framework';\nimport { createClassDecorator, createProxy } from './utils.js';\n\n/**\n * The constructor signature shared by every `Piece` of `@wolfstar/http-framework`, such as `Command`, `Listener`, and\n * `InteractionHandler`.\n */\nexport type PieceConstructor<Options extends PieceOptions = PieceOptions> = new (context: LoaderPieceContext, options?: Options) => unknown;\n\n/**\n * Decorator that sets the options of a `Piece`, such as a `Command`, a `Listener`, or an `InteractionHandler`.\n *\n * @remarks The options are merged on top of the ones the piece was constructed with, so a piece that also passes\n * options through `super(context, options)` will have the decorator's values win on conflicting keys.\n * @remarks Apply this decorator above (outside of) any other class decorator that keys metadata by class identity,\n * such as `RegisterCommand` from `@wolfstar/http-framework` — as in the example below. This decorator returns a `Proxy` wrapping the class,\n * so a decorator applied above it (running after it, and therefore registering against the proxy) would register\n * metadata that instances constructed from the exported class — whose `.constructor` still resolves to the original,\n * unproxied class — can never be looked up by.\n * @param optionsOrFn The options to pass to the piece's constructor, or a function that builds them from the loader\n * context.\n * @returns A class decorator.\n * @example\n * ```typescript\n * import { ApplyOptions } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)ApplyOptions<Command.Options>({ name: 'ping', enabled: true })\n * (at)RegisterCommand({ name: 'ping', description: 'A simple ping pong command' })\n * export class UserCommand extends Command {\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Pong!' });\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * (at)ApplyOptions<Command.Options>(({ name }) => ({ name: name.toLowerCase() }))\n * export class UserCommand extends Command {}\n * ```\n */\nexport function ApplyOptions<Options extends PieceOptions = PieceOptions>(\n\toptionsOrFn: Options | ((context: LoaderPieceContext) => Options)\n): ClassDecorator {\n\treturn createClassDecorator((target: PieceConstructor<Options>) =>\n\t\tcreateProxy(target, {\n\t\t\tconstruct: (ctor, [context, baseOptions]: [LoaderPieceContext, Options | undefined], newTarget) =>\n\t\t\t\tReflect.construct(\n\t\t\t\t\tctor,\n\t\t\t\t\t[\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...baseOptions,\n\t\t\t\t\t\t\t...(typeof optionsOrFn === 'function' ? optionsOrFn(context) : optionsOrFn)\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\tnewTarget\n\t\t\t\t) as object\n\t\t})\n\t) as ClassDecorator;\n}\n","/**\n * Decorator that sets the `enumerable` property of a class field to the given value.\n *\n * @remarks The decorator installs a setter on the prototype, which is bypassed by the `Object.defineProperty` call\n * that `useDefineForClassFields` (enabled by `@sapphire/ts-config`, and the default from `ES2022` onwards) emits for\n * class fields. Mark the field as `declare` so no field definition is emitted, and assign it in the constructor.\n * @param value Whether the property should be enumerable or not.\n * @returns A property decorator.\n * @example\n * ```typescript\n * import { Enumerable } from '@wolfstar/decorators';\n * import { Command } from '@wolfstar/http-framework';\n *\n * export class UserCommand extends Command {\n * \t(at)Enumerable(false)\n * \tdeclare public cache: Map<string, string>;\n *\n * \tpublic constructor(context: Command.LoaderContext, options: Command.Options) {\n * \t\tsuper(context, options);\n * \t\tthis.cache = new Map();\n * \t}\n * }\n * ```\n */\nexport function Enumerable(value: boolean) {\n\treturn (target: unknown, key: string) => {\n\t\tReflect.defineProperty(target as object, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as object, key, {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: value,\n\t\t\t\t\tvalue: val,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Decorator that sets the `enumerable` property of a class method to the given value.\n *\n * @param value Whether the method should be enumerable or not.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { EnumerableMethod } from '@wolfstar/decorators';\n * import { Command } from '@wolfstar/http-framework';\n *\n * export class UserCommand extends Command {\n * \t(at)EnumerableMethod(true)\n * \tpublic getCacheKey(id: string) {\n * \t\treturn `user:${id}`;\n * \t}\n * }\n * ```\n */\nexport function EnumerableMethod(value: boolean) {\n\treturn (_target: unknown, _key: string, descriptor: PropertyDescriptor) => {\n\t\tdescriptor.enumerable = value;\n\t};\n}\n","import type { BaseInteraction } from '@wolfstar/http-framework';\nimport { createFunctionPrecondition } from './utils.js';\n\n/**\n * The fallback invoked when a context precondition is not met. It receives the same arguments as the decorated method.\n */\nexport type ContextFallback = (...args: any[]) => unknown;\n\n/**\n * Decorator that only runs the decorated method when the interaction was received from a guild.\n *\n * @param fallback The fallback to run when the interaction did not come from a guild. Defaults to a no-op, which\n * silently skips the method.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresGuildContext } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'kick', description: 'Kicks a member' })\n * export class UserCommand extends Command {\n * \t(at)RequiresGuildContext((interaction: Command.ChatInputInteraction) =>\n * \t\tinteraction.reply({ content: 'This command can only be used in a server.' })\n * \t)\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: `Hello from ${interaction.guildId}!` });\n * \t}\n * }\n * ```\n */\nexport function RequiresGuildContext(fallback: ContextFallback = () => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((interaction: BaseInteraction) => interaction.inGuild(), fallback);\n}\n\n/**\n * Decorator that only runs the decorated method when the interaction was **not** received from a guild, that is, from a\n * DM or from a user-installed app context.\n *\n * @param fallback The fallback to run when the interaction came from a guild. Defaults to a no-op, which silently skips\n * the method.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresDMContext } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'private', description: 'Only usable outside of servers' })\n * export class UserCommand extends Command {\n * \t(at)RequiresDMContext((interaction: Command.ChatInputInteraction) =>\n * \t\tinteraction.reply({ content: 'This command cannot be used in a server.' })\n * \t)\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Hello!' });\n * \t}\n * }\n * ```\n */\nexport function RequiresDMContext(fallback: ContextFallback = () => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((interaction: BaseInteraction) => !interaction.inGuild(), fallback);\n}\n","import {\n\tgetMissingPermissions,\n\tIdentifiers,\n\tPreconditionError,\n\tresolvePermissions,\n\ttoPermissionNames,\n\ttype BaseInteraction,\n\ttype PermissionResolvable\n} from '@wolfstar/http-framework';\nimport { createFunctionPrecondition } from './utils.js';\n\n/**\n * Reads the permissions the invoking user has in the channel the interaction was sent from.\n *\n * @param interaction The interaction to read from.\n * @returns The bitfield of the user's permissions, or `null` when the interaction did not come from a guild and there\n * are therefore no guild permissions to check.\n */\nfunction getUserPermissions(interaction: BaseInteraction): bigint | null {\n\tconst permissions = interaction.member?.permissions;\n\treturn permissions === undefined ? null : BigInt(permissions);\n}\n\n/**\n * Decorator that only runs the decorated method when the application has all of the given permissions in the channel\n * the interaction was sent from, as reported by the interaction's `app_permissions` field.\n *\n * @remarks When the fallback is omitted, a {@linkcode PreconditionError} identified by\n * {@linkcode Identifiers.PreconditionClientPermissions} is thrown, which the client emits as `chatInputCommandDenied` or\n * `contextMenuCommandDenied` (or `interactionHandlerDenied`), not as `commandError`, for a `Listener` to turn into a\n * user-facing reply.\n * @param permissions The permissions the application must have.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresClientPermissions } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'purge', description: 'Deletes messages' })\n * export class UserCommand extends Command {\n * \t(at)RequiresClientPermissions('ManageMessages')\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Purging!' });\n * \t}\n * }\n * ```\n */\nexport function RequiresClientPermissions(...permissions: PermissionResolvable[]): MethodDecorator {\n\tconst required = resolvePermissions(permissions);\n\treturn createFunctionPrecondition(\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst granted = interaction.applicationPermissions;\n\t\t\t// `app_permissions` is always sent by Discord, but the field is optional in the typings; when it is absent\n\t\t\t// there is nothing to check against, so the method is allowed to run.\n\t\t\treturn granted === undefined || getMissingPermissions(granted, required) === 0n;\n\t\t},\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst missing = getMissingPermissions(interaction.applicationPermissions ?? 0n, required);\n\t\t\tconst missingNames = toPermissionNames(missing);\n\t\t\tthrow new PreconditionError({\n\t\t\t\tprecondition: 'ClientPermissions',\n\t\t\t\tidentifier: Identifiers.PreconditionClientPermissions,\n\t\t\t\tmessage: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingNames.join(', ')}`,\n\t\t\t\tcontext: { missing, missingNames }\n\t\t\t});\n\t\t}\n\t);\n}\n\n/**\n * Decorator that only runs the decorated method when the invoking user has all of the given permissions in the channel\n * the interaction was sent from.\n *\n * @remarks Interactions received outside of a guild carry no member permissions, so the check passes for them. Pair\n * this decorator with {@linkcode RequiresGuildContext} when the method must also be guild-only.\n * @remarks When the fallback is omitted, a {@linkcode PreconditionError} identified by\n * {@linkcode Identifiers.PreconditionUserPermissions} is thrown, which the client emits as `chatInputCommandDenied` or\n * `contextMenuCommandDenied` (or `interactionHandlerDenied`), not as `commandError`, for a `Listener` to turn into a\n * user-facing reply.\n * @param permissions The permissions the invoking user must have.\n * @returns A method decorator.\n * @example\n * ```typescript\n * import { RequiresUserPermissions } from '@wolfstar/decorators';\n * import { Command, RegisterCommand } from '@wolfstar/http-framework';\n *\n * (at)RegisterCommand({ name: 'ban', description: 'Bans a member' })\n * export class UserCommand extends Command {\n * \t(at)RequiresUserPermissions('BanMembers')\n * \tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n * \t\treturn interaction.reply({ content: 'Banned!' });\n * \t}\n * }\n * ```\n */\nexport function RequiresUserPermissions(...permissions: PermissionResolvable[]): MethodDecorator {\n\tconst required = resolvePermissions(permissions);\n\treturn createFunctionPrecondition(\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst granted = getUserPermissions(interaction);\n\t\t\treturn granted === null || getMissingPermissions(granted, required) === 0n;\n\t\t},\n\t\t(interaction: BaseInteraction) => {\n\t\t\tconst missing = getMissingPermissions(getUserPermissions(interaction) ?? 0n, required);\n\t\t\tconst missingNames = toPermissionNames(missing);\n\t\t\tthrow new PreconditionError({\n\t\t\t\tprecondition: 'UserPermissions',\n\t\t\t\tidentifier: Identifiers.PreconditionUserPermissions,\n\t\t\t\tmessage: `Sorry, but you are not allowed to do that. You are missing the permissions: ${missingNames.join(', ')}`,\n\t\t\t\tcontext: { missing, missingNames }\n\t\t\t});\n\t\t}\n\t);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BAAmB,WAAW;EAC9C,OAAO,YAAY,QAAQ,sBAAsB,SAAS,QAAQ,MAAM;CACzE,IACC,gBAAiC;EACjC,MAAM,UAAU,sBAAsB,mBAAmB,WAAW,KAAK,IAAI,QAAQ;EACrF,MAAM,eAAe,kBAAkB,OAAO;EAC9C,MAAM,IAAI,kBAAkB;GAC3B,cAAc;GACd,YAAY,YAAY;GACxB,SAAS,+EAA+E,aAAa,KAAK,IAAI;GAC9G,SAAS;IAAE;IAAS;GAAa;EAClC,CAAC;CACF,CACD;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolfstar/decorators",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Useful TypeScript decorators for @wolfstar/http-framework",
5
5
  "keywords": [
6
6
  "decorators",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@vitest/coverage-v8": "^5.0.3",
48
- "@wolfstar/http-framework": "^6.5.1",
48
+ "@wolfstar/http-framework": "^7.0.0",
49
49
  "discord-api-types": "^0.38.8",
50
50
  "golar": "^0.1.10",
51
51
  "tsdown": "^0.23.0",
@@ -53,7 +53,7 @@
53
53
  "vitest": "^5.0.3"
54
54
  },
55
55
  "peerDependencies": {
56
- "@wolfstar/http-framework": "^6.5.1"
56
+ "@wolfstar/http-framework": "^7.0.0"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=20"