UNPKG

@satoshibits/cache-keys

Version:
56 lines 2.21 kB
"use strict"; import { createSimpleKeyFactory, createKeyFactory } from '../factory.mjs'; import { sanitizeKeyComponent, splitKeyComponents } from '../sanitizer.mjs'; /** * Account-related cache key factories */ export var accountKeys = { /** * Account details key * @example accountKeys.details.key('507f1f77bcf86cd799439011') * @returns 'account:details:507f1f77bcf86cd799439011' */ details: createSimpleKeyFactory('account', 'details'), /** * Account billing information key * @example accountKeys.billing.key('507f1f77bcf86cd799439011') * @returns 'account:billing:507f1f77bcf86cd799439011' */ billing: createSimpleKeyFactory('account', 'billing'), /** * Account usage by period key * @example accountKeys.usage.key('507f1f77bcf86cd799439011', '2024-01') * @returns 'account:usage:507f1f77bcf86cd799439011:2024-01' */ usage: createKeyFactory('account', 'usage', function (accountId, period) { return "".concat(sanitizeKeyComponent(String(accountId)), ":").concat(sanitizeKeyComponent(period)); }, function (suffix) { var _a, _b; var parts = splitKeyComponents(suffix, ':', true); if (parts.length !== 2) return null; return { accountId: (_a = parts[0]) !== null && _a !== void 0 ? _a : '', period: (_b = parts[1]) !== null && _b !== void 0 ? _b : '' }; }), /** * Account settings key * @example accountKeys.settings.key('507f1f77bcf86cd799439011') * @returns 'account:settings:507f1f77bcf86cd799439011' */ settings: createSimpleKeyFactory('account', 'settings'), /** * Account members list key * @example accountKeys.members.key('507f1f77bcf86cd799439011') * @returns 'account:members:507f1f77bcf86cd799439011' */ members: createSimpleKeyFactory('account', 'members'), /** * Account subscription status key * @example accountKeys.subscription.key('507f1f77bcf86cd799439011') * @returns 'account:subscription:507f1f77bcf86cd799439011' */ subscription: createSimpleKeyFactory('account', 'subscription'), }; //# sourceMappingURL=account.mjs.map