Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unsupported map representation "stringpairs" #72

Open
RangerMauve opened this issue Sep 13, 2022 · 3 comments
Open

Error: Unsupported map representation "stringpairs" #72

RangerMauve opened this issue Sep 13, 2022 · 3 comments
Assignees

Comments

@RangerMauve
Copy link

I was attempting to use the stringpairs representation for a schema, but got an error when trying to pass it to the create() function in typed.js.

Here's the schema I used:

type Example {String:String} representation stringpairs {
      entryDelim ","
      innerDelim " "
}

Did I do something wrong? It appears as though typed.js just doesn't support this functionality.

@rvagg
Copy link
Member

rvagg commented Sep 13, 2022

Screenshot 2022-09-13 at 4 54 41 pm

well, it parses, thankfully!

but alas no, I obviously skipped this one as can't-be-bothered in my initial passes:

js-ipld-schema/lib/typed.js

Lines 307 to 314 in fae8a4c

let representation = 'map'
if (typeDef.map.representation !== undefined) {
if ('listpairs' in typeDef.map.representation && typeof typeDef.map.representation.listpairs === 'object') {
representation = 'listpairs'
} else if (!('map' in typeDef.map.representation) || typeof typeDef.map.representation.map !== 'object') {
throw new Error(`Unsupported map representation "${Object.keys(typeDef.map.representation).join(',')}"`)
}
}

but it would be useful, I know Eric uses this one a lot in the things he does and it's useful for representing all sorts of unixy things. Do you have a direct use for it now? It probably wouldn't be too hard to add, it'd just need some solid testing because of all the possible variations and the fixtures I wrote for stringpairs are pretty .. basic.

@rvagg rvagg self-assigned this Sep 13, 2022
@RangerMauve
Copy link
Author

I don't have a direct use for it at the moment, and don't see one any time soon. It just happened to be the first thing I tested from the representations since it looked cool. 😁

@RangerMauve
Copy link
Author

So, no rush on implenting this if there's higher priority stuff, could just leave this open as a tracking issue.

If you have time, it would be useful to document which features are unsupported in the README however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🗄️ Backlog
Development

No branches or pull requests

2 participants