@opensea/sdk 13.0.5 → 13.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,8 +53,13 @@ type LowerAlphanumeric = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "
53
53
  * {@link snakeToCamel}: `"is_nsfw"` → `"isNsfw"`. Only an underscore followed
54
54
  * by a lowercase ASCII letter or digit is consumed, so `"foo__bar"` →
55
55
  * `"foo_Bar"` and `"trailing_"` stays as is.
56
+ *
57
+ * When the underscore is followed by a pattern placeholder rather than a
58
+ * literal character (`` `trait_${string}` ``, `` `slot_${number}` ``), the
59
+ * rest is capitalized, so `"trait_foo"` and `"slot_1"` fit the result just as
60
+ * their runtime forms `"traitFoo"` and `"slot1"` do.
56
61
  */
57
- type SnakeToCamel<S extends string> = S extends `${infer Head}_${infer Next}${infer Tail}` ? Next extends LowerAlphanumeric ? `${Head}${Uppercase<Next>}${SnakeToCamel<Tail>}` : `${Head}_${SnakeToCamel<`${Next}${Tail}`>}` : S;
62
+ type SnakeToCamel<S extends string> = S extends `${infer Head}_${infer Next}${infer Tail}` ? Next extends LowerAlphanumeric ? `${Head}${Uppercase<Next>}${SnakeToCamel<Tail>}` : Record<never, never> extends Record<Next, 1> ? `${Head}${Capitalize<SnakeToCamel<`${Next}${Tail}`>>}` : `${Head}_${SnakeToCamel<`${Next}${Tail}`>}` : S;
58
63
  /**
59
64
  * Recursively rewrites object keys from snake_case to camelCase. Preserves
60
65
  * arrays, primitives, and non-plain objects (Date, etc.).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensea/sdk",
3
- "version": "13.0.5",
3
+ "version": "13.0.6",
4
4
  "description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs, tokens, and our marketplace data",
5
5
  "license": "MIT",
6
6
  "author": "OpenSea Developers",
package/src/utils/case.ts CHANGED
@@ -172,12 +172,20 @@ type LowerAlphanumeric =
172
172
  * {@link snakeToCamel}: `"is_nsfw"` → `"isNsfw"`. Only an underscore followed
173
173
  * by a lowercase ASCII letter or digit is consumed, so `"foo__bar"` →
174
174
  * `"foo_Bar"` and `"trailing_"` stays as is.
175
+ *
176
+ * When the underscore is followed by a pattern placeholder rather than a
177
+ * literal character (`` `trait_${string}` ``, `` `slot_${number}` ``), the
178
+ * rest is capitalized, so `"trait_foo"` and `"slot_1"` fit the result just as
179
+ * their runtime forms `"traitFoo"` and `"slot1"` do.
175
180
  */
176
181
  type SnakeToCamel<S extends string> =
177
182
  S extends `${infer Head}_${infer Next}${infer Tail}`
178
183
  ? Next extends LowerAlphanumeric
179
184
  ? `${Head}${Uppercase<Next>}${SnakeToCamel<Tail>}`
180
- : `${Head}_${SnakeToCamel<`${Next}${Tail}`>}`
185
+ : // A pattern such as `${string}` has no required key, so an empty object fits its Record.
186
+ Record<never, never> extends Record<Next, 1>
187
+ ? `${Head}${Capitalize<SnakeToCamel<`${Next}${Tail}`>>}`
188
+ : `${Head}_${SnakeToCamel<`${Next}${Tail}`>}`
181
189
  : S
182
190
 
183
191
  /**