Skip to content

Commit

Permalink
feat: Add AssetServiceUtils package with additional API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Quenty committed Mar 31, 2023
1 parent 89b4fcd commit 8074968
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 40 deletions.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Many of these packages represent not just useful code, but useful patterns, or w
### All packages
<!--package-list-generated-start-->

There are 230 packages in Nevermore.
There are 231 packages in Nevermore.

| Package | Description | Install | docs | source | changelog | npm |
| ------- | ----------- | ------- | ---- | ------ | --------- | --- |
Expand All @@ -69,6 +69,7 @@ There are 230 packages in Nevermore.
| [AnimationProvider](https://quenty.github.io/NevermoreEngine/api/AnimationProvider) | Provides animations for anything tagged with "AnimationContainer" and from a folder named "Animations" in ReplicatedStorage. | `npm i @quenty/animationprovider` | [docs](https://quenty.github.io/NevermoreEngine/api/AnimationProvider) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/animationprovider) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/animationprovider/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/animationprovider) |
| [AnimationTrackUtils](https://quenty.github.io/NevermoreEngine/api/AnimationTrackUtils) | Utility functions for animations | `npm i @quenty/animationtrackutils` | [docs](https://quenty.github.io/NevermoreEngine/api/AnimationTrackUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/animationtrackutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/animationtrackutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/animationtrackutils) |
| [ApplyTagToTaggedChildren](https://quenty.github.io/NevermoreEngine/api/ApplyTagToTaggedChildren) | Class that while constructed apply a tag to any children of the parent it is given, assuming that class has the required tag. This lets you bridge tag systems since CollectionService is used as an interop model between many components in scripts. | `npm i @quenty/applytagtotaggedchildren` | [docs](https://quenty.github.io/NevermoreEngine/api/ApplyTagToTaggedChildren) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/applytagtotaggedchildren) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/applytagtotaggedchildren/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/applytagtotaggedchildren) |
| [AssetServiceUtils](https://quenty.github.io/NevermoreEngine/api/AssetServiceUtils) | Provides a wrapper for AssetService&#x27;s async calls | `npm i @quenty/assetserviceutils` | [docs](https://quenty.github.io/NevermoreEngine/api/AssetServiceUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/assetserviceutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/assetserviceutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/assetserviceutils) |
| [AttributeUtils](https://quenty.github.io/NevermoreEngine/api/AttributeUtils) | Provides utility functions to work with attributes in Roblox | `npm i @quenty/attributeutils` | [docs](https://quenty.github.io/NevermoreEngine/api/AttributeUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/attributeutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/attributeutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/attributeutils) |
| [AvatarEditorUtils](https://quenty.github.io/NevermoreEngine/api/AvatarEditorUtils) | Provides utility functions to work with the Roblox AvatarEditorService | `npm i @quenty/avatareditorutils` | [docs](https://quenty.github.io/NevermoreEngine/api/AvatarEditorUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/avatareditorutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/avatareditorutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/avatareditorutils) |
| [AxisAngleUtils](https://quenty.github.io/NevermoreEngine/api/AxisAngleUtils) | Utility functions for axis angles. | `npm i @quenty/axisangleutils` | [docs](https://quenty.github.io/NevermoreEngine/api/AxisAngleUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/axisangleutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/axisangleutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/axisangleutils) |
Expand Down
23 changes: 23 additions & 0 deletions src/assetserviceutils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## AssetServiceUtils

<div align="center">
<a href="http://quenty.github.io/NevermoreEngine/">
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
</a>
<a href="https://discord.gg/mhtGUS8">
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
</a>
<a href="https://github.com/Quenty/NevermoreEngine/actions">
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
</a>
</div>

Provides a wrapper for AssetService&#x27;s async calls

<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/AssetServiceUtils">View docs →</a></div>

## Installation

```
npm install @quenty/assetserviceutils --save
```
6 changes: 6 additions & 0 deletions src/assetserviceutils/default.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "assetserviceutils",
"tree": {
"$path": "src"
}
}
35 changes: 35 additions & 0 deletions src/assetserviceutils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@quenty/assetserviceutils",
"version": "1.0.0",
"description": "Provides a wrapper for AssetService&#x27;s async calls",
"keywords": [
"Roblox",
"Nevermore",
"Lua",
"AssetService",
"Promise"
],
"bugs": {
"url": "https://github.com/Quenty/NevermoreEngine/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Quenty/NevermoreEngine.git",
"directory": "src/assetserviceutils/"
},
"funding": {
"type": "patreon",
"url": "https://www.patreon.com/quenty"
},
"license": "MIT",
"contributors": [
"Quenty"
],
"dependencies": {
"@quenty/loader": "file:../loader",
"@quenty/promise": "file:../promise"
},
"publishConfig": {
"access": "public"
}
}
114 changes: 114 additions & 0 deletions src/assetserviceutils/src/Shared/AssetServiceUtils.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
--[=[
Utility methods involving the AssetService
@class AssetServiceUtils
]=]

local require = require(script.Parent.loader).load(script)

local AssetService = game:GetService("AssetService")

local Promise = require("Promise")

local AssetServiceUtils = {}

--[=[
Retrieves the assetIds for a package
@param packageAssetId number
@return Promise<table>
]=]
function AssetServiceUtils.promiseAssetIdsForPackage(packageAssetId)
assert(type(packageAssetId) == "number", "Bad packageAssetId")

return Promise.spawn(function(resolve, reject)
local result
local ok, err = pcall(function()
result = AssetService:GetAssetIdsForPackage(packageAssetId)
end)

if not ok then
warn(err)
return reject(err)
end
if typeof(result) ~= "table" then
return reject("Result was not an table")
end

resolve(result)
end)
end

--[=[
Gets the places and their name for the current game.
@return Pages
]=]
function AssetServiceUtils.promiseGamePlaces()
return Promise.spawn(function(resolve, reject)
local pages
local ok, err = pcall(function()
pages = AssetService:GetGamePlacesAsync()
end)

if not ok then
warn(err)
return reject(err)
end
if not (typeof(pages) == "Instance" and pages:IsA("Pages")) then
return reject("pages was not an table")
end

resolve(pages)
end)
end

--[=[
Details for a specific bundle item
@interface BundleDetailsItem
.Id number -- Item's id
.Name string -- Item name
.Type string -- Item Type eg: "UserOutfit" or "Asset"
@within AssetServiceUtils
]=]

--[=[
Details for the bundle
@interface BundleDetails
.Id -- Bundle Id (passed in as an argument)
.Name string -- Bundle name
.Description string -- Bundle description
.BundleType string -- Bundle Type. eg. BodyParts or `AvatarAnimation|AvatarAnimations`
.Items { BundleDetailsItem } -- An array of ValueTable objects
@within AssetServiceUtils
]=]

--[=[
Gets the bundle details
@param bundleId number
@return BundleDetails
]=]
function AssetServiceUtils.promiseBundleDetails(bundleId)
assert(type(bundleId) == "number", "Bad bundleId")

return Promise.spawn(function(resolve, reject)
local result
local ok, err = pcall(function()
result = AssetService:GetBundleDetailsAsync(bundleId)
end)

if not ok then
warn(err)
return reject(err)
end
if typeof(result) ~= "table" then
return reject("Result was not an table")
end

resolve(result)
end)
end

return AssetServiceUtils
7 changes: 7 additions & 0 deletions src/assetserviceutils/src/node_modules.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "node_modules",
"globIgnorePaths": [ "**/.package-lock.json" ],
"tree": {
"$path": { "optional": "../node_modules" }
}
}
1 change: 1 addition & 0 deletions src/rigbuilderutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"Quenty"
],
"dependencies": {
"@quenty/assetserviceutils": "file:../assetserviceutils",
"@quenty/humanoiddescriptionutils": "file:../humanoiddescriptionutils",
"@quenty/insertserviceutils": "file:../insertserviceutils",
"@quenty/loader": "file:../loader",
Expand Down
39 changes: 0 additions & 39 deletions src/rigbuilderutils/src/Shared/AssetServiceUtils.lua

This file was deleted.

0 comments on commit 8074968

Please sign in to comment.