Skip to content

Commit

Permalink
docs: full JSDocs for all client
Browse files Browse the repository at this point in the history
  • Loading branch information
Avivbens committed Jun 6, 2024
1 parent c021c5c commit 1ffbda0
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
56 changes: 56 additions & 0 deletions src/core/fast-alfred.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,71 @@ import { EnvService } from './services/env.service'
import { IconService } from './services/icon.service'

export class FastAlfred {
/**
* @description
* Service to get Alfred's environment variables
*
* You can find all Alfred & Workflow metadata in here
*/
public readonly alfredInfo: AlfredInfoService = new AlfredInfoService()
public readonly userConfig: AlfredConfigService = new AlfredConfigService({})

/**
* @description
* Get icons from the system
*
* You can use it to get the icon path for a specific icon
*
* @example
* ```typescript
* alfredClient.output({
* items: [
* {
* title: 'Some Error',
* icon: {
* path: alfredClient.icons.getIcon('error'),
* },
* },
* ],
* })
* ```
*/
public readonly icons: IconService = new IconService()

/**
* @description
* Get and set dedicated configuration for the Workflow
*
* You can use it to store and retrieve data saved about the user
*/
public readonly config: Conf = new Conf({})

/**
* @description
* Get Environment variables
*
* All Workflow user configuration would be injected in here
*/
public readonly env = new EnvService()

/**
* @description
* Get and set dedicated cache for your Workflow
*
* You can leverage it to optimize your Workflow performance
*
* @note
* Use the `setWithTTL` in order to set a cache with a time to live
*/
public readonly cache: CacheConfigService = new CacheConfigService({
configName: 'FastAlfred',
version: this.alfredInfo.alfredVersion() ?? '',
})

/**
* @description
* Get the input passed into the script filter (by `$1` or `{query}`)
*/
public readonly input: string = argv[2]

/**
Expand Down
6 changes: 6 additions & 0 deletions src/core/services/alfred-info.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { env } from 'node:process'

/**
* @description
* Service to get Alfred's environment variables
*
* You can find all Alfred & Workflow metadata in here
*/
export class AlfredInfoService {
private getEnv(key: string): string | undefined {
return env[`alfred_${key}`]
Expand Down
9 changes: 9 additions & 0 deletions src/core/services/cache-config.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import Conf from 'conf'
import type { CacheItem } from '@models/cache-item.model'

/**
* @description
* Get and set dedicated cache for your Workflow
*
* You can leverage it to optimize your Workflow performance
*
* @note
* Use the `setWithTTL` in order to set a cache with a time to live
*/
export class CacheConfigService extends Conf {
private readonly version: string
constructor(options: { configName: string; cwd?: string; version: string }) {
Expand Down
7 changes: 7 additions & 0 deletions src/core/services/env.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
import { env } from 'node:process'
import type { GetEnvOptions } from '@models/get-env-options.model'

/**
* @description
* Get Environment variables
*
* All Workflow user configuration would be injected in here
*/

export class EnvService {
getEnv<T = unknown>(key: string): T | undefined
getEnv<T = unknown>(key: string, options: GetEnvOptions<T>): T
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/icon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ICONS = {

/**
* @description
* This service responsible to get icons from the system
* Get icons from the system
*
* You can use it to get the icon path for a specific icon
*
Expand Down

0 comments on commit 1ffbda0

Please sign in to comment.