ResourceListForClient
Hierarchy
- ResourceList<IDetailedResourceItemForClient>
- ResourceListForClient
Index
Constructors
constructor
Parameters
rawResourceList: IResourceItemForClient[]
Resource list generated by Studio.
trustedUploaders: string[]
core: EpisodeCore<IDefaultAdditionalEnvVariable>
Core instance.
enableGlobalCache: boolean = true
Cache resource URL that don’t have a episode across core instances to boost preload performance.
Returns ResourceListForClient
Properties
readonlyfilesById
readonlyfilesByLabel
readonlygroupsById
readonlygroupsByLabel
readonlyitems
readonlyitemsById
readonlyitemsByLabel
publicreadonlyrawResourceList
readonlyresourceFiles
readonlyresourceGroups
Methods
add
Parameters
x: T
sync: boolean = true
Returns void
getResourceById
Get resource by resource ID.
Type parameters
- Result = string
- PostProcess: PostProcessCallback<Result, IResourceFileForClient> | PostProcessMagicWords = Url
Parameters
id: string
The ID for the resource.
envConfig: Record<string, string> = null
Environment variable, this value will be used if the resource is a group,
smart-resourcewill pick one file from the group by the configuration.optionalweights: Record<string, number>
Weight of each configuration.
optionalpostProcess: PostProcess
Post process function, will convert the resource URL to whatever you want. If the callback is not provided, this method will return a URL, otherwise it will return the result of the callback.
optionalresourceType: group | file
The resource is a group or file, if not provided, a guessing strategy will be used.
useSlowQueue: boolean = false
taskId: string = ...
Task ID for debug purpose, will only be shown in the debug log.
Returns Promise<PostProcess extends Metadata ? IDetailedResourceItemForClient : Result>
A promise that resolves to the resource URL or post processed resource.
getResourceByLabel
Get resource by resource label.
Type parameters
- Result = string
- PostProcess: PostProcessMagicWords | PostProcessCallback<Result, IResourceFileForClient> = Url
Parameters
label: string
The label for the resource.
envConfig: Record<string, string> = null
Environment variable, this value will be used if the resource is a group,
smart-resourcewill pick one file from the group by the configuration.optionalweights: Record<string, number>
Weight of each configuration.
optionalpostProcess: PostProcess
Post process function, will convert the resource URL to whatever you want. If the callback is not provided, this method will return a URL, otherwise it will return the result of the callback.
optionalresourceType: group | file
The resource is a group or file, if not provided, a guessing strategy will be used.
useSlowQueue: boolean = false
taskId: string = ...
Task ID for debug purpose, will only be shown in the debug log.
Returns Promise<PostProcess extends Metadata ? IDetailedResourceItemForClient : Result>
A promise that resolves to the resource URL or post processed resource.
getResourceByQuery
Get resource by resource query.
Type parameters
- Result = string
- PostProcess: PostProcessMagicWords | PostProcessCallback<Result, IResourceFileForClient> = Url
Parameters
query: string
queryType: id | label
envConfig: Record<string, string> = null
Environment variable, this value will be used if the resource is a group,
smart-resourcewill pick one file from the group by the configuration.optionalweights: Record<string, number>
Weight of each configuration.
optionalpostProcess: PostProcess
Post process function, will convert the resource URL to whatever you want. If the callback is not provided, this method will return a URL, otherwise it will return the result of the callback.
optionalresourceType: group | file
The resource is a group or file, if not provided, a guessing strategy will be used.
useSlowQueue: boolean = false
taskId: string = ...
Task ID for debug purpose, will only be shown in the debug log.
Returns Promise<PostProcess extends Metadata ? IDetailedResourceItemForClient : Result>
A promise that resolves to the resource URL or post processed resource.
getResourceByResourceDescription
Get resource by a resource description.
Type parameters
- Result = string
- PostProcess: PostProcessMagicWords | PostProcessCallback<Result, IResourceFileForClient> = Url
Parameters
resource: IDetailedResourceItemForClient
The resource description generated by Studio.
envConfig: Record<string, string> = null
Environment variable, this value will be used if the resource is a group,
smart-resourcewill pick one file from the group by the configuration.optionalweights: Record<string, number>
Weight of each configuration.
optionalpostProcess: PostProcess
Post process function, will convert the resource URL to whatever you want. If the callback is not provided, this method will return a URL, otherwise it will return the result of the callback.
useSlowQueue: boolean = false
taskId: string = 'client-query'
Task ID for debug purpose, will only be shown in the debug log.
Returns Promise<PostProcess extends Metadata ? IDetailedResourceItemForClient : Result>
A promise that resolves to the resource URL or post processed resource.
getResourceByUrlMap
Get resource by a URL map.
Type parameters
- Result = string
- PostProcess: PostProcessMagicWords | PostProcessCallback<Result, AdditionalData> = Url
- AdditionalData = undefined
Parameters
urlMap: Record<string, string>
The key is the ID of the CDN or data source, the value is a URL.
optionalpostProcess: PostProcess
Post process function, will convert the resource URL to whatever you want. If the callback is not provided, this method will return a URL, otherwise it will return the result of the callback.
optionaladditionalData: AdditionalData
taskId: string = 'client-side-selector-url-map'
Task ID for debug purpose, will only be shown in the debug log.
addToGlobalCache: boolean = false
useSlowQueue: boolean = false
Returns Promise<Result>
A promise that resolves to the resource URL or post processed resource.
remove
Parameters
x: T
Returns void
ResourceListForClient will handle resource query related tasks, such as query file by label or ID, query file by URL set and file description.
This class will also handle resource fallback from different CDN and resource convert related task.