Files
TheGame/packages/utils/bin/create-model.mjs
Sero f5b1a2be9f Edit Profile Style Changes (#1553)
* First pass at composedb models

* Removed patterns as they're not supported yet

* Started hooking up the edit profile page to composedb

* Got PoC working for persisting username to ComposeDB

* Some fixes after bumping urql to 3.x

* Refactored setup logic into ProfileWizardContext

* Implemented fetching from ComposeDB for first three profile wizard screens

* Refactored wizard stuff again to simplify it

* Finished upgrading profile setup components

* Added query to fetch all profile fields from composeDB

* Load profile data from composeDB on player page

* Unified composeDB models into one, updated setup flow to use new model

* Fixed a couple errors in first-time setup flow

* Added new linkProfileNode action to validate ceramic node on the backend

* Call new linkProfileNode action

* Implemented proper persistence w/ verification of a user's ceramic profile node

* Fetch profile details from ComposeDB during [username] page SSR

* Added PlayerHydrationContext for dynamically refreshing player data on player page

* Implemented player hydration from Hasura

* Slight refactor of Setup components to accept a player object

* Added ComposeDB migration modal, still need to implement image migration

* Added useImageReader, updated EditProfileModal to get the appropriate picked file data

* Implemented persisting ComposeDB profile fields from edit profile modal

* Check in composeDB graphql definition because generating it at build time may be problematic

* Merged in new setup profile image field page

* Fixed and tested image upload during setup

* Fixed background image URL form field name

* Added fallback for non-SSR player pages

* Implemented fetching file size and dimensions before persisting to ComposeDB

* Fix lint issues

* More debug logs

* Set CERAMIC_URL in deployment action

* Don't delete / recreate stuff

* Fix setup / avatar upload

* Fixed edit profile field saving, updated useUser to load from composeDB

* Fixed construction of profile payload when changing an image

* Pull in additional data in seed-db script

* Fixed white background in menus

* Updated GA4 ID

* Point to ceramic mainnet

* Bumped composedb version

* Fix ceramic API change

* Update frontend ceramic_url as well

* Only authenticate the DID for the model the compose client connects to

* Create a new model, last one got hosed

* Updated model ID in definition

* Reinstate original deployment action

* Fixed player loading

* Handle errors during DAO sync

* Handle questchain lookup errors during SSR build

* Replaced IDX cache actions / triggers with composeDB ones

* Added mainnet check to composeDB port modal

* Fixed issue where saving from the edit profile modal was wiping out fields

* Add ComposeDBPromptModal to setup pages as well

* Upgrade Hasura

* Added context to 'port data' modal

* fix bad merge

* Hasura 2.0 requires a flag for our sloppy queries to still work

* add comment to begin wokr

* refactor: 💄 Update profile UI to new design

* style: 💄 Minor style changes

* Add getPlayer import

* Make changes requested in #1559

* Delete EditAvatarImage.tsx.orig

* Delete EditBackgroundImage.tsx.orig

* Delete EditDescription.tsx.orig

* refactor: Remove commented code

---------

Co-authored-by: Alec LaLonde <alec@convergencelabs.com>
Co-authored-by: Alec LaLonde <alec@boxelderweb.com>
Co-authored-by: nitegeist <nitegeist.dev@gmail.com>
2023-08-09 09:44:10 -06:00

77 lines
2.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env -S node --experimental-json-modules
import { CeramicClient } from '@ceramicnetwork/http-client'
import { ModelManager } from '@glazed/devtools'
import { DID } from 'dids'
import { constants } from 'fs'
import JSON5 from 'json5'
import { Ed25519Provider } from 'key-did-provider-ed25519'
import { getResolver } from 'key-did-resolver'
import { access, readFile, writeFile } from 'node:fs/promises'
import { dirname } from 'path'
import { fromString } from 'uint8arrays'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
;(async () => {
let raw = process.env.DID_KEY
if(!raw) {
try {
const keyFile = `${__dirname}/../private.key`
await access(keyFile, constants.R_OK)
raw = (await readFile(keyFile, 'utf8')).trim()
} catch {}
}
if(!raw) {
console.warn('$DID_KEY must be set or `private.key` must exist.')
console.warn('Generate it with `openssl rand -hex 32 > private.key`.')
process.exit(-2)
}
const key = fromString(raw, 'base16')
const did = new DID({
provider: new Ed25519Provider(key),
resolver: getResolver(),
})
await did.authenticate()
const ceramicURL = (
process.env.CERAMIC_URL
|| 'https://ceramic.metagame.wtf'
|| 'http://localhost:7007'
)
console.debug(`Connecting to ${ceramicURL}`)
const ceramic = new CeramicClient(ceramicURL)
ceramic.did = did
const manager = new ModelManager(ceramic)
const schemaFile = `${__dirname}/../schema/extended-profile.json5`
const schema = JSON5.parse(
await readFile(schemaFile, 'utf8')
)
const schemaId = await manager.createSchema(
'ExtendedProfile', schema,
)
const schemaURI = manager.getSchemaURL(schemaId)
console.debug(`Wrote schema to "${schemaURI}".`)
await manager.createDefinition(
'extendedProfile',
{
name: 'Extended profile information',
description: 'Profile fields in addition to those found in Ceramics `basicProfile`.',
schema: schemaURI,
}
)
const model = await manager.toJSON()
const out = `${__dirname}/../src/ExtendedProfileModel.json`
await writeFile(out, JSON.stringify(model, null, 2))
console.debug(`Wrote ids to "${out}".`)
})()