import { type TokenSrcGroup, type TokenType, type TokenSrcValueInfo, type TokenInfo, type TokenData, type TokenKsExtensions } from '@knapsack/types'; import { type TokenDataSummary } from '../converters/spec-src-to-token-data/index.js'; /** * Setting values for modes */ export type SetModeValArgs = { /** * The collection ID within the "collections" key. */ collectionId: string; /** * Var IDs are the path within its collection. */ varId: string; /** * The mode ID *within the collection it's a part of* */ modeId: string; /** * Token data for the Mode. */ tokenSrcValueInfo: TokenSrcValueInfo; /** * If the tokenSrcValueInfo is a ref, this will skip the check for the ref * existing. This is useful when the ref is being set in a loop and the ref * is not yet created. */ skipRefExistsCheck?: boolean; }; /** * A helper to manipulate Token src data. * */ export declare class TokenSrcUpdater { #private; /** * This is the group key that all collections are nested under. * Convenient prop instead of `this.data.globalConfig?.collectionsParentKey` */ collectionsParentKey: string; /** * Getter for #_src. Remember: external CAN get (the whole point) */ get src(): TokenSrcGroup; /** * Calculate `TokenDataSummary` from current `src` */ get data(): TokenDataSummary; constructor({ src, prefix }: { src: TokenSrcGroup; prefix?: string; }); /** * Single Token operations */ /** * Simple token addition at dot.path */ createToken({ tokenId, tokenSrcValueInfo: info, description }: TokenInfo): void; /** * Simple token data updates (value, description, etc) */ updateToken({ tokenId, tokenSrcValueInfo, description }: TokenInfo): void; /** * Remove token at dot.path. If other things ref it, update those to original * tokens value. Note that tokenId can be a single token or an array of tokens. */ deleteToken({ tokenId }: { tokenId: string | string[]; }): TokenData[]; /** * Renaming a token simply copies it to the new path, then deletes the old one. * All references within other tokens are updated to use the new path. */ renameToken({ originalTokenId, destinationTokenId, }: { originalTokenId: string; destinationTokenId: string; }): { originalTokenId: string; destinationTokenId: string; }; /** * Create a group at dot.path, don't try and handle collisions for now. */ createGroup({ groupId, groupData, }: { groupId: string; groupData?: { description?: string; type?: TokenType; config?: TokenKsExtensions['group']; }; }): void; /** * Update token fields, like description and type */ updateGroup({ groupId, groupData, }: { groupId: string; groupData: { description?: string; type?: TokenType; config?: TokenKsExtensions['group']; }; }): void; /** * Removing a group nukes all tokens within */ deleteGroup({ groupId }: { groupId: string; }): void; /** * Renaming a group utilizes prior methods */ renameGroup({ originalGroupId, destinationGroupId, }: { originalGroupId: string; destinationGroupId: string; }): void; setCollectionsParentKey({ collectionsParentKey, }: { collectionsParentKey: string; }): void; /** * Collection operations */ collection: { /** * Collection -> Create */ create: ({ collectionId, excludeInitialMode, }: { collectionId: string; excludeInitialMode?: boolean; }) => { collectionId: string; }; /** * Collection -> Rename */ rename: ({ collectionId, newName, }: { collectionId: string; newName: string; }) => void; /** * Collection -> Delete */ delete: ({ collectionId }: { collectionId: string; }) => void; }; /** * Collection -> Mode operations */ mode: { /** * Collection -> Mode -> Create */ create: ({ collectionId, modeId, }: { collectionId: string; modeId: string; }) => void; /** * Collection -> Mode -> Rename * @TODO: ensure new Mode ID does not already exist */ rename: ({ collectionId, modeId, newModeId, }: { collectionId: string; modeId: string; newModeId: string; }) => void; /** * Collection -> Mode -> Delete */ delete: ({ collectionId, modeId, }: { collectionId: string; modeId: string; }) => void; reorder: ({ collectionId, modeId, index, }: { collectionId: string; modeId: string; index: number; }) => void; }; /** * Collection -> Collection Group operations */ collectionGroup: { /** * Collection -> Collection Group -> Create */ create: ({ collectionId, groupId, parentGroupId, }: { collectionId: string; groupId: string; parentGroupId?: string; }) => { groupId: string; }; /** * Collection -> Collection Group -> Rename */ rename: ({ collectionId, collectionGroupId, name, }: { collectionId: string; /** Original group id (without collectionID or collectionParentKey) */ collectionGroupId: string; /** this will be the final piece of ID with no `.` */ name: string; }) => void; /** * Collection -> Collection Group -> Delete */ delete: ({ collectionId, collectionGroupId, }: { collectionId: string; collectionGroupId: string; }) => void; /** * Collection -> Collection Group -> Move */ move: ({ collectionId, collectionGroupId, newParentCollectionId, newParentCollectionGroupId, }: { /** * FROM collectionId */ collectionId: string; /** * FROM collectionGroupId */ collectionGroupId: string; /** * TO collectionId * If left empty, assume moving within same collection id */ newParentCollectionId?: string; /** * TO collectionGroupId */ newParentCollectionGroupId: string; }) => void; /** * CONVERT vanilla group to collection group */ convert: ({ currentGroupId, collectionId, newParentCollectionGroupId, }: { /** * Vanilla group ID * @example `brand.bg` */ currentGroupId: string; /** * The collection ID within the "collections" key we're moving vanilla tokens TO. */ collectionId: string; /** * The collection GROUP within the "collections" key we're moving vanilla tokens TO. */ newParentCollectionGroupId: string; }) => void; }; /** * Var operations */ var: { /** * Var -> Create */ create: ({ collectionId, groupId, varId, varType, }: { /** * The collection ID within the "collections" key this var belongs to. */ collectionId: string; varId: string; varType: TokenType; groupId?: string; }) => void; /** * Var -> Rename */ rename: ({ collectionId, varId, newVarId, }: { /** * The collection ID within the "collections" key this var belongs to. */ collectionId: string; /** * Var IDs are the path within its collection. */ varId: string; /** * The new name should also be a Var ID, minus its collection and type keys. * See `varId` above for more info. */ newVarId: string; }) => void; /** * Var -> Delete */ delete: ({ collectionId, varId, }: { /** * The collection ID within the "collections" key this var belongs to. */ collectionId: string; /** * Var IDs are the path within its collection, minus the final "type" key. * So a var that technically lives at `collections.collection.brand.bg.color` * has a Var ID of just `brand.bg`. */ varId: string; }) => void; /** * Var -> Move/Rename (moving groups is the same as renaming) * @TODO: needs work around existing Var groups */ move: ({ collectionId, varId, newParentGroupId, }: { collectionId: string; varId: string; newParentGroupId: string; }) => void; /** * Var -> setDescription */ setDescription: ({ collectionId, varId, description, }: { /** * The collection ID within the "collections" key. */ collectionId: string; /** * Var IDs are the path within its collection. */ varId: string; /** * The actual description change. */ description: string; }) => void; /** * Var -> setModeValue */ /** * Set one or many var mode values */ setModeValue: (modeVals: SetModeValArgs | SetModeValArgs[]) => void; /** * Var -> unsetModeValue */ unsetModeValue: ({ collectionId, varId, modeId, }: { /** * The collection ID within the "collections" key. */ collectionId: string; /** * Var IDs are the path within its collection. */ varId: string; /** * The Mode ID within the Var to delete */ modeId: string; }) => void; }; } //# sourceMappingURL=token-src-updater.d.ts.map