Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Static Resource, Asset, CMS Backend Refactor #10304

Merged
merged 81 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
ccae33e
Remove sid field from static-resource table
HexaField Jun 3, 2024
1199c8d
move getCachedURL and getCacheDomain to storage provider interface, h…
HexaField Jun 3, 2024
6640ba2
resolve url
HexaField Jun 3, 2024
ded0117
fix avatars and tsc errors
HexaField Jun 3, 2024
bd63396
local upload changes
HexaField Jun 3, 2024
389a8e2
Merge branch 'dev' into cms-refactor
HexaField Jun 3, 2024
3f26fba
add more info to resource json and static resources
HexaField Jun 4, 2024
058df46
fixes
HexaField Jun 4, 2024
64482de
fix seeding
HexaField Jun 4, 2024
c7cdcb3
migration convert assets to static resources, fix reinit to wipe DB c…
HexaField Jun 4, 2024
b0bef50
Merge branch 'dev' into cms-refactor
HexaField Jun 4, 2024
f0babda
Merge branch 'dev' into cms-refactor
HexaField Jun 4, 2024
efaf2e1
fixes
HexaField Jun 5, 2024
2298c61
fixes to seeder, avatar install and uploading local to storage provider
HexaField Jun 6, 2024
446a63e
license
HexaField Jun 6, 2024
a32e3a2
Merge branch 'dev' into cms-refactor
HexaField Jun 6, 2024
76e4b55
use static resource service instead of asset service
HexaField Jun 6, 2024
68bc37f
bug fixes
HexaField Jun 7, 2024
40fa785
more simplification and refactoring
HexaField Jun 7, 2024
b0834a5
remove unused asset service
HexaField Jun 7, 2024
49e2998
bug fixes, simplification
HexaField Jun 7, 2024
0069e6f
bug fixes for types
HexaField Jun 7, 2024
436a161
refactoring file browser
HexaField Jun 10, 2024
85aad20
license
HexaField Jun 10, 2024
2144f74
Merge branch 'dev' into cms-refactor
HexaField Jun 10, 2024
29b03ae
dynamically handle org name in file browser ui (#10354)
aditya-mitra Jun 10, 2024
936db7b
file upload and other fixes
HexaField Jun 10, 2024
fe362f5
tsc fix
HexaField Jun 10, 2024
4a1d7f0
fix merge conflict
HexaField Jun 10, 2024
6546ae1
test fixes
HexaField Jun 10, 2024
c9fcf6f
fix project upload
HexaField Jun 11, 2024
72b9440
various fixes
HexaField Jun 11, 2024
71d68bf
file browser works with orgs
HexaField Jun 11, 2024
941035b
clean up
HexaField Jun 11, 2024
219d8ee
update resources json in hooks
HexaField Jun 11, 2024
da8f312
Merge branch 'dev' into cms-refactor
HexaField Jun 11, 2024
3c12617
Merge branch 'dev' into cms-refactor
HexaField Jun 11, 2024
972cd25
bug fixes
HexaField Jun 11, 2024
b6ead5f
fixes
HexaField Jun 11, 2024
979ddad
fixes for update method and tests
HexaField Jun 11, 2024
7b08b12
Merge branch 'dev' into cms-refactor
HexaField Jun 11, 2024
2080df2
improve file browser tests
HexaField Jun 12, 2024
7c0a6de
bug fixes
HexaField Jun 12, 2024
de17644
fix rename scene
HexaField Jun 12, 2024
e3eb963
Merge branch 'dev' into cms-refactor
HexaField Jun 12, 2024
877df44
Merge branch 'dev' into cms-refactor
HexaField Jun 12, 2024
399d925
tsc err
HexaField Jun 13, 2024
38c5187
fix rename
HexaField Jun 13, 2024
5ffdc16
Merge branch 'dev' into cms-refactor
HexaField Jun 13, 2024
6331c12
Merge branch 'dev' into cms-refactor
HexaField Jun 14, 2024
1438bd3
fix saving scenes
HexaField Jun 14, 2024
2093e28
fix thumbnail gen
HexaField Jun 14, 2024
24933d1
Merge branch 'dev' into cms-refactor
HexaField Jun 14, 2024
fd6ba2b
fix delete scene and rename scene
HexaField Jun 14, 2024
a73ff73
cleanup logs
HexaField Jun 14, 2024
6a3df40
Merge branch 'dev' into cms-refactor
HexaField Jun 14, 2024
767193a
Merge branch 'dev' into cms-refactor
HexaField Jun 14, 2024
f485257
optimize location query, improve export, add back removed delete for …
HexaField Jun 14, 2024
1cb6260
fix projectEventHooks
HexaField Jun 14, 2024
611139f
fix projectEventHooks
HexaField Jun 14, 2024
fd5eb9e
Merge branch 'dev' into cms-refactor
HexaField Jun 15, 2024
5cbc43f
remove knex transaction from migration
HexaField Jun 15, 2024
73211be
remove console log
HexaField Jun 15, 2024
63052dc
Merge branch 'dev' into cms-refactor
HexaField Jun 15, 2024
8825426
fixes
HexaField Jun 15, 2024
9c46994
trying migrations
HexaField Jun 15, 2024
63b83aa
fix bug with migrating resources
HexaField Jun 15, 2024
1242c75
optimize single static resource updates to resources.json
HexaField Jun 15, 2024
8d6ae12
Merge branch 'dev' into cms-refactor
HexaField Jun 15, 2024
15de684
Merge branch 'dev' into cms-refactor
HexaField Jun 17, 2024
fa0a473
add thumbnail key field alongside thumbnail url
HexaField Jun 17, 2024
7817ff5
fix file browser tests
HexaField Jun 17, 2024
f6110ab
Merge branch 'dev' into cms-refactor
HexaField Jun 17, 2024
6bf5d2f
dont always generate resources json
HexaField Jun 17, 2024
82617c0
fix for manifest
HexaField Jun 17, 2024
bed8ad1
Merge branch 'dev' into cms-refactor
HexaField Jun 17, 2024
6c23b25
fix bugs with updating resources json
HexaField Jun 17, 2024
cce7868
ensure new scenes have unique names and include thumbnail
HexaField Jun 18, 2024
343124b
fix pagination and reactivity
HexaField Jun 18, 2024
95e245c
type fix
HexaField Jun 18, 2024
be88424
Merge branch 'dev' into cms-refactor
HexaField Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/client-core/i18n/en/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@
"refresh": "Refresh",
"back": "Back",
"loadingFiles": "Loading files",
"loadingProjects": "Loading projects",
"compress": "Compress",
"convert": "Convert",
"downloadProject": "Download Project",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ import InputSelect, { InputMenuItem } from '@etherealengine/client-core/src/comm
import InputSwitch from '@etherealengine/client-core/src/common/components/InputSwitch'
import InputText from '@etherealengine/client-core/src/common/components/InputText'
import {
assetPath,
LocationData,
LocationID,
locationPath,
LocationType
LocationType,
staticResourcePath
} from '@etherealengine/common/src/schema.type.module'
import { AssetType } from '@etherealengine/common/src/schemas/assets/asset.schema'
import { getState, useHookstate } from '@etherealengine/hyperflux'
import { useFind, useGet, useMutation } from '@etherealengine/spatial/src/common/functions/FeathersHooks'
import Button from '@etherealengine/ui/src/primitives/mui/Button'
Expand Down Expand Up @@ -88,14 +87,14 @@ const LocationDrawer = ({ open, mode, selectedLocation, selectedScene, onClose }
const editMode = useHookstate(false)
const state = useHookstate({ ...defaultState })

const scenes = useFind(assetPath)
const scenes = useFind(staticResourcePath, { query: { type: 'scene' } })
// const locationTypes = useFind(locationTypePath).data

const locationMutation = useMutation(locationPath)

const viewMode = mode === LocationDrawerMode.ViewEdit && !editMode.value

const selectedSceneData = useGet(assetPath, selectedScene!)
const selectedSceneData = useGet(staticResourcePath, selectedScene!)

const editorState = getState(EditorState)

Expand All @@ -107,13 +106,13 @@ const LocationDrawer = ({ open, mode, selectedLocation, selectedScene, onClose }
? [
{
value: selectedSceneData.data.id,
label: selectedSceneData.data.assetURL
label: selectedSceneData.data.key
}
]
: scenes.data.map((el: AssetType) => {
: scenes.data.map((el) => {
return {
value: el.id,
label: el.assetURL
label: el.key
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { useTranslation } from 'react-i18next'

import { PopoverState } from '@etherealengine/client-core/src/common/services/PopoverState'
import {
assetPath,
LocationData,
LocationID,
locationPath,
LocationType
LocationType,
staticResourcePath
} from '@etherealengine/common/src/schema.type.module'
import { useHookstate } from '@etherealengine/hyperflux'
import { useFind, useMutation } from '@etherealengine/spatial/src/common/functions/FeathersHooks'
Expand Down Expand Up @@ -65,7 +65,7 @@ export default function AddEditLocationModal({ location }: { location?: Location
const screenSharingEnabled = useHookstate<boolean>(location?.locationSetting.screenSharingEnabled || true)
const locationType = useHookstate(location?.locationSetting.locationType || 'public')

const scenes = useFind(assetPath, {
const scenes = useFind(staticResourcePath, {
query: {
paginate: false
}
Expand Down Expand Up @@ -160,8 +160,8 @@ export default function AddEditLocationModal({ location }: { location?: Location
: [
{ value: '', label: t('admin:components.location.selectScene'), disabled: true },
...scenes.data.map((scene) => {
const project = scene.projectName
const name = scene.assetURL.split('/').pop()!.split('.').at(0)!
const project = scene.project
const name = scene.key.split('/').pop()!.split('.').at(0)!
return {
label: `${name} (${project})`,
value: scene.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ export default function LocationTable({ search }: { search: string }) {
rows.map((row) => ({
name: <a href={`/location/${transformLink(row.name)}`}>{row.name}</a>,
sceneId: (
<a href={`/studio?projectName=${row.sceneAsset.projectName}&scenePath=${row.sceneAsset.assetURL}`}>
{row.sceneId}
</a>
<a href={`/studio?projectName=${row.sceneAsset.project!}&scenePath=${row.sceneAsset.key}`}>{row.sceneId}</a>
),
maxUsersPerInstance: row.maxUsersPerInstance.toString(),
scene: row.slugifiedName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ import { computeTransformMatrix } from '@etherealengine/spatial/src/transform/sy
import React, { useEffect } from 'react'
import { Color, Euler, MathUtils, Matrix4, Quaternion, Scene, Sphere, Vector3 } from 'three'

import config from '@etherealengine/common/src/config'
import { projectResourcesPath } from '@etherealengine/common/src/schemas/media/project-resource.schema'
import { ErrorComponent } from '@etherealengine/engine/src/scene/components/ErrorComponent'
import { ShadowComponent } from '@etherealengine/engine/src/scene/components/ShadowComponent'
import { iterateEntityNode } from '@etherealengine/spatial/src/transform/components/EntityTree'
Expand Down Expand Up @@ -101,24 +99,20 @@ const drawToCanvas = (source: CanvasImageSource): Promise<HTMLCanvasElement | nu
return Promise.resolve(canvas)
}

const uploadThumbnail = async (key: string, projectName: string, staticResourceId: string, blob: Blob | null) => {
const uploadThumbnail = async (src: string, projectName: string, staticResourceId: string, blob: Blob | null) => {
if (!blob) return
const thumbnailType = 'automatic'
const thumbnailKey = `${decodeURI(key.replace(/^.*?\/projects\//, ''))
const thumbnailMode = 'automatic'
const thumbnailKey = `${decodeURI(src.replace(/^.*?\/projects\//, ''))
.replaceAll(/[^a-zA-Z0-9\.\-_\s]/g, '')
.replaceAll(/\s/g, '-')}-thumbnail.png`
const file = new File([blob], thumbnailKey)
const path = `projects/${projectName}/thumbnails`
const upload: Promise<string[]> = uploadToFeathersService(fileBrowserUploadPath, [file], {
const [thumbnailURL] = await uploadToFeathersService(fileBrowserUploadPath, [file], {
fileName: file.name,
path,
contentType: ''
project: projectName,
path: 'public/thumbnails/' + file.name,
contentType: file.type
}).promise
const thumbnailURL = (await upload)[0]
await Engine.instance.api.service(staticResourcePath).patch(staticResourceId, { thumbnailURL, thumbnailType })
const urlPrefixRegex = new RegExp(`^${config.client.fileServer}\/`)
const resourceKey = key.replace(urlPrefixRegex, '')
await Engine.instance.api.service(projectResourcesPath).patch(staticResourceId, { project: projectName })
await Engine.instance.api.service(staticResourcePath).patch(staticResourceId, { thumbnailURL, thumbnailMode })
}

const seenThumbnails = new Set<string>()
Expand Down Expand Up @@ -150,7 +144,7 @@ export const FileThumbnailJobState = defineState({
getMutableState(FileThumbnailJobState).merge([
{
key: url,
project: resource.project,
project: resource.project!,
id: resource.id
}
])
Expand Down Expand Up @@ -207,7 +201,7 @@ export const FileThumbnailJobState = defineState({
getMutableState(FileThumbnailJobState).merge([
{
key: url,
project: resource.project,
project: resource.project!,
id: resource.id
}
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { t } from 'i18next'
import { useEffect } from 'react'

import { LocationService, LocationState } from '@etherealengine/client-core/src/social/services/LocationService'
import { assetPath } from '@etherealengine/common/src/schema.type.module'
import { staticResourcePath } from '@etherealengine/common/src/schema.type.module'
import { GLTFAssetState } from '@etherealengine/engine/src/gltf/GLTFState'
import { getMutableState, useMutableState } from '@etherealengine/hyperflux'
import { useFind, useGet } from '@etherealengine/spatial/src/common/functions/FeathersHooks'
Expand All @@ -37,7 +37,7 @@ import { WarningUIService } from '../../systems/WarningUISystem'

export const useLoadLocation = (props: { locationName: string }) => {
const locationState = useMutableState(LocationState)
const scene = useGet(assetPath, locationState.currentLocation.location.sceneId.value).data
const scene = useGet(staticResourcePath, locationState.currentLocation.location.sceneId.value).data

useEffect(() => {
LocationState.setLocationName(props.locationName)
Expand Down Expand Up @@ -80,18 +80,18 @@ export const useLoadLocation = (props: { locationName: string }) => {
!scene
)
return
const sceneURL = scene.assetURL
const sceneURL = scene.url
return GLTFAssetState.loadScene(sceneURL, scene.id)
}, [locationState.currentLocation.location.sceneId, scene])
}

export const useLoadScene = (props: { projectName: string; sceneName: string }) => {
const sceneURL = `projects/${props.projectName}/${props.sceneName}`
const assetID = useFind(assetPath, { query: { assetURL: sceneURL } })
const sceneKey = `projects/${props.projectName}/${props.sceneName}`
const assetID = useFind(staticResourcePath, { query: { key: sceneKey, type: 'scene' } })
useEffect(() => {
if (!props.sceneName || !props.projectName) return
if (!assetID.data.length) return
getMutableState(LocationState).currentLocation.location.sceneId.set(assetID.data[0].id)
return GLTFAssetState.loadScene(sceneURL, assetID.data[0].id)
return GLTFAssetState.loadScene(assetID.data[0].url, assetID.data[0].id)
}, [assetID.data.length])
}
8 changes: 4 additions & 4 deletions packages/client-core/src/util/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ Ethereal Engine. All Rights Reserved.
import i18n from 'i18next'

import config from '@etherealengine/common/src/config'
import { uploadAssetPath } from '@etherealengine/common/src/schema.type.module'
import { getMutableState } from '@etherealengine/hyperflux'

import '@etherealengine/common/src/utils/jsonUtils'

import { ServiceTypes } from '@etherealengine/common/declarations'
import { AuthState } from '../user/services/AuthService'
import { RethrownError } from './errors'

export type CancelableUploadPromiseReturnType<T = any> = { cancel: () => void; promise: Promise<T | T[]> }
export type CancelableUploadPromiseArrayReturnType<T = any> = { cancel: () => void; promises: Array<Promise<T | T[]>> }

export const uploadToFeathersService = (
service = uploadAssetPath,
service: keyof ServiceTypes,
files: Array<File>,
params: any = {},
params: ServiceTypes[typeof service]['create']['params'], // todo make this type work
onUploadProgress?: (progress: number) => any
): CancelableUploadPromiseReturnType => {
): CancelableUploadPromiseReturnType<Awaited<ReturnType<ServiceTypes[typeof service]['create']['params']>>> => {
const token = getMutableState(AuthState).authUser.accessToken.value
const request = new XMLHttpRequest()
request.timeout = 10 * 60 * 1000 // 10 minutes - need to support big files on slow connections
Expand Down
5 changes: 0 additions & 5 deletions packages/common/src/interfaces/ManifestJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ export type ManifestJson = {
* @example "https://example.com/thumbnail.jpg"
*/
thumbnail?: string
/**
* project-relative path for scene GLTF files
* @example ["public/scenes/default.gltf"]
*/
scenes?: string[]
/**
* The dependencies of this project. Specify other projects that are to be installed alongside this one.
* @todo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,17 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/

export const projectResourcesPath = 'project-resources'
// key = /path/to/file.ext
export type ResourcesJson = Record<
string,
{
type: 'scene' | 'asset' | 'file' | 'thumbnail' | 'avatar' | 'recording'
tags?: string[]
dependencies?: string[] // other keys
licensing?: string
description?: string
attribution?: string
thumbnailURL?: string
thumbnailMode?: 'automatic' | 'manual'
}
>
3 changes: 1 addition & 2 deletions packages/common/src/interfaces/UploadAssetInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export type AdminAssetUploadArgumentsType = {
name?: string
project?: string
hash?: string
stats?: any
}

export type AdminAssetUploadType = {
Expand All @@ -67,6 +66,6 @@ export interface UploadFile {
originalname: string
encoding?: string
mimetype: string
buffer: Buffer | string
buffer: Buffer
size: number
}
8 changes: 2 additions & 6 deletions packages/common/src/schema.type.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Ethereal Engine. All Rights Reserved.

export type * from './schemas/analytics/analytics.schema'
export type * from './schemas/assets/asset-library.schema'
export type * from './schemas/assets/asset.schema'
export type * from './schemas/assets/model-transform.schema'
export type * from './schemas/bot/bot-command.schema'
export type * from './schemas/bot/bot.schema'
Expand Down Expand Up @@ -62,7 +61,6 @@ export type * from './schemas/projects/project-permission-type.schema'
export type * from './schemas/projects/project-permission.schema'
export type * from './schemas/projects/project.schema'
export type * from './schemas/projects/projects.schema'
export type * from './schemas/projects/scene-data.schema'
export type * from './schemas/recording/recording-resource-upload.schema'
export type * from './schemas/recording/recording-resource.schema'
export type * from './schemas/recording/recording.schema'
Expand Down Expand Up @@ -262,8 +260,6 @@ export const projectPath = 'project'

export const projectsPath = 'projects'

export const assetPath = 'asset'

export const builderInfoPath = 'builder-info'

export const projectCheckSourceDestinationMatchPath = 'project-check-source-destination-match'
Expand All @@ -276,8 +272,6 @@ export const projectPermissionTypePath = 'project-permission-type'

export const projectDestinationCheckPath = 'project-destination-check'

export const sceneDataPath = 'scene-data'

export const spawnPointPath = 'spawn-point'

export const projectCheckUnfetchedCommitPath = 'project-check-unfetched-commit'
Expand All @@ -301,3 +295,5 @@ export const migrationsInfoPath = 'knex_migrations'
export const uploadAssetPath = 'upload-asset'

export const invalidationPath = 'invalidation'

export const imageConvertPath = 'image-convert'
Loading
Loading