@twin.org/data-json-ld 0.0.3-next.22 → 0.0.3-next.24

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.
Files changed (78) hide show
  1. package/dist/es/helpers/jsonLdAliasKey.js +4 -0
  2. package/dist/es/helpers/jsonLdAliasKey.js.map +1 -0
  3. package/dist/es/helpers/jsonLdExistingProperty.js +4 -0
  4. package/dist/es/helpers/jsonLdExistingProperty.js.map +1 -0
  5. package/dist/es/helpers/jsonLdExistingPropertyEither.js +2 -0
  6. package/dist/es/helpers/jsonLdExistingPropertyEither.js.map +1 -0
  7. package/dist/es/helpers/jsonLdKeys.js +4 -0
  8. package/dist/es/helpers/jsonLdKeys.js.map +1 -0
  9. package/dist/es/helpers/jsonLdObjectWithAliases.js +2 -0
  10. package/dist/es/helpers/jsonLdObjectWithAliases.js.map +1 -0
  11. package/dist/es/helpers/jsonLdObjectWithAtId.js +2 -0
  12. package/dist/es/helpers/jsonLdObjectWithAtId.js.map +1 -0
  13. package/dist/es/helpers/jsonLdObjectWithAtType.js +2 -0
  14. package/dist/es/helpers/jsonLdObjectWithAtType.js.map +1 -0
  15. package/dist/es/helpers/jsonLdObjectWithContext.js +2 -0
  16. package/dist/es/helpers/jsonLdObjectWithContext.js.map +1 -0
  17. package/dist/es/helpers/jsonLdObjectWithId.js +2 -0
  18. package/dist/es/helpers/jsonLdObjectWithId.js.map +1 -0
  19. package/dist/es/helpers/jsonLdObjectWithNoAtId.js +4 -0
  20. package/dist/es/helpers/jsonLdObjectWithNoAtId.js.map +1 -0
  21. package/dist/es/helpers/jsonLdObjectWithNoAtType.js +4 -0
  22. package/dist/es/helpers/jsonLdObjectWithNoAtType.js.map +1 -0
  23. package/dist/es/helpers/jsonLdObjectWithNoContext.js +4 -0
  24. package/dist/es/helpers/jsonLdObjectWithNoContext.js.map +1 -0
  25. package/dist/es/helpers/jsonLdObjectWithNoId.js +4 -0
  26. package/dist/es/helpers/jsonLdObjectWithNoId.js.map +1 -0
  27. package/dist/es/helpers/jsonLdObjectWithNoType.js +4 -0
  28. package/dist/es/helpers/jsonLdObjectWithNoType.js.map +1 -0
  29. package/dist/es/helpers/jsonLdObjectWithOptionalAtId.js +2 -0
  30. package/dist/es/helpers/jsonLdObjectWithOptionalAtId.js.map +1 -0
  31. package/dist/es/helpers/jsonLdObjectWithOptionalAtType.js +2 -0
  32. package/dist/es/helpers/jsonLdObjectWithOptionalAtType.js.map +1 -0
  33. package/dist/es/helpers/jsonLdObjectWithOptionalContext.js +2 -0
  34. package/dist/es/helpers/jsonLdObjectWithOptionalContext.js.map +1 -0
  35. package/dist/es/helpers/jsonLdObjectWithOptionalId.js +2 -0
  36. package/dist/es/helpers/jsonLdObjectWithOptionalId.js.map +1 -0
  37. package/dist/es/helpers/jsonLdObjectWithOptionalType.js +2 -0
  38. package/dist/es/helpers/jsonLdObjectWithOptionalType.js.map +1 -0
  39. package/dist/es/helpers/jsonLdObjectWithType.js +2 -0
  40. package/dist/es/helpers/jsonLdObjectWithType.js.map +1 -0
  41. package/dist/es/helpers/jsonLdOptionalKeys.js +4 -0
  42. package/dist/es/helpers/jsonLdOptionalKeys.js.map +1 -0
  43. package/dist/es/helpers/jsonLdRequiredKeys.js +2 -0
  44. package/dist/es/helpers/jsonLdRequiredKeys.js.map +1 -0
  45. package/dist/es/helpers/jsonLdWithAliases.js +2 -0
  46. package/dist/es/helpers/jsonLdWithAliases.js.map +1 -0
  47. package/dist/es/index.js +23 -1
  48. package/dist/es/index.js.map +1 -1
  49. package/dist/types/helpers/jsonLdAliasKey.d.ts +4 -0
  50. package/dist/types/helpers/jsonLdExistingProperty.d.ts +6 -0
  51. package/dist/types/helpers/jsonLdExistingPropertyEither.d.ts +6 -0
  52. package/dist/types/helpers/jsonLdKeys.d.ts +4 -0
  53. package/dist/types/helpers/jsonLdObjectWithAliases.d.ts +7 -0
  54. package/dist/types/helpers/jsonLdObjectWithAtId.d.ts +7 -0
  55. package/dist/types/helpers/jsonLdObjectWithAtType.d.ts +7 -0
  56. package/dist/types/helpers/jsonLdObjectWithContext.d.ts +7 -0
  57. package/dist/types/helpers/jsonLdObjectWithId.d.ts +7 -0
  58. package/dist/types/helpers/jsonLdObjectWithNoAtId.d.ts +4 -0
  59. package/dist/types/helpers/jsonLdObjectWithNoAtType.d.ts +4 -0
  60. package/dist/types/helpers/jsonLdObjectWithNoContext.d.ts +5 -0
  61. package/dist/types/helpers/jsonLdObjectWithNoId.d.ts +4 -0
  62. package/dist/types/helpers/jsonLdObjectWithNoType.d.ts +4 -0
  63. package/dist/types/helpers/jsonLdObjectWithOptionalAtId.d.ts +7 -0
  64. package/dist/types/helpers/jsonLdObjectWithOptionalAtType.d.ts +7 -0
  65. package/dist/types/helpers/jsonLdObjectWithOptionalContext.d.ts +9 -0
  66. package/dist/types/helpers/jsonLdObjectWithOptionalId.d.ts +7 -0
  67. package/dist/types/helpers/jsonLdObjectWithOptionalType.d.ts +7 -0
  68. package/dist/types/helpers/jsonLdObjectWithType.d.ts +7 -0
  69. package/dist/types/helpers/jsonLdOptionalKeys.d.ts +6 -0
  70. package/dist/types/helpers/jsonLdRequiredKeys.d.ts +5 -0
  71. package/dist/types/helpers/jsonLdWithAliases.d.ts +13 -0
  72. package/dist/types/index.d.ts +23 -1
  73. package/docs/changelog.md +28 -0
  74. package/docs/reference/index.md +15 -15
  75. package/package.json +2 -2
  76. package/dist/es/helpers/jsonLdHelperTypes.js +0 -2
  77. package/dist/es/helpers/jsonLdHelperTypes.js.map +0 -1
  78. package/dist/types/helpers/jsonLdHelperTypes.d.ts +0 -127
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdAliasKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdAliasKey.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdAliasKey.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Keep JSON-LD keys as-is and prefix non-JSON-LD keys.\n */\nexport type JsonLdAliasKey<K extends string, Prefix extends string> = K extends `@${string}`\n\t? K\n\t: `${Prefix}:${K}`;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdExistingProperty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdExistingProperty.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdExistingProperty.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Infer an existing property's type from a source type, or fall back to a default.\n */\nexport type JsonLdExistingProperty<T extends object, P extends PropertyKey, D> = T extends {\n\t[K in P]?: infer PropertyType;\n}\n\t? Exclude<PropertyType, undefined>\n\t: D;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdExistingPropertyEither.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdExistingPropertyEither.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdExistingPropertyEither.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingProperty } from \"./jsonLdExistingProperty.js\";\n\n/**\n * Infer an existing property's type from either of two source properties,\n * or fall back to a default when neither exists.\n */\nexport type JsonLdExistingPropertyEither<\n\tT extends object,\n\tP1 extends PropertyKey,\n\tP2 extends PropertyKey,\n\tD\n> = [JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>] extends [never]\n\t? D\n\t: JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdKeys.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdKeys.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Keep only JSON-LD keys (\"@...\") from a type.\n */\nexport type JsonLdKeys<T extends object> = Pick<T, Extract<keyof T, `@${string}`>>;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithAliases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithAliases.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithAliases.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdKeys } from \"./jsonLdKeys.js\";\nimport type { JsonLdWithAliases } from \"./jsonLdWithAliases.js\";\n\n/**\n * Create a JSON-LD object shape containing only JSON-LD keys plus aliased\n * non-JSON-LD keys.\n */\nexport type JsonLdObjectWithAliases<T extends object, Prefix extends string> = JsonLdKeys<T> &\n\tJsonLdWithAliases<T, Prefix>;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithAtId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithAtId.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithAtId.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add \"@id\" to a type.\n */\nexport type JsonLdObjectWithAtId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"@id\", \"id\", string>\n> = Omit<T, \"@id\" | \"id\"> & {\n\t\"@id\": Id;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithAtType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithAtType.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithAtType.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add \"@type\" to a type.\n */\nexport type JsonLdObjectWithAtType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"@type\", \"type\", string | string[]>\n> = Omit<T, \"@type\" | \"type\"> & {\n\t\"@type\": Ty;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithContext.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionRoot } from \"../models/IJsonLdContextDefinitionRoot.js\";\n\n/**\n * Add \"@context\" to a type.\n */\nexport type JsonLdObjectWithContext<T extends object, C = IJsonLdContextDefinitionRoot> = Omit<\n\tT,\n\t\"@context\"\n> & {\n\t\"@context\": C;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithId.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithId.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add \"id\" to a type.\n */\nexport type JsonLdObjectWithId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"id\", \"@id\", string>\n> = Omit<T, \"id\" | \"@id\"> & {\n\tid: Id;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdObjectWithNoAtId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithNoAtId.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithNoAtId.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Omit \"@id\" from a type.\n */\nexport type JsonLdObjectWithNoAtId<T extends object> = Omit<T, \"@id\">;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdObjectWithNoAtType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithNoAtType.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithNoAtType.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Omit \"@type\" from a type.\n */\nexport type JsonLdObjectWithNoAtType<T extends object> = Omit<T, \"@type\">;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdObjectWithNoContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithNoContext.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithNoContext.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Omit optional \"@context\" from a type, inferring an existing context type from\n * the source type when available, otherwise using the provided default.\n */\nexport type JsonLdObjectWithNoContext<T extends object> = Omit<T, \"@context\">;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdObjectWithNoId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithNoId.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithNoId.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Omit \"id\" from a type.\n */\nexport type JsonLdObjectWithNoId<T extends object> = Omit<T, \"id\">;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdObjectWithNoType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithNoType.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithNoType.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Omit \"type\" from a type.\n */\nexport type JsonLdObjectWithNoType<T extends object> = Omit<T, \"type\">;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithOptionalAtId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithOptionalAtId.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithOptionalAtId.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add optional \"@id\" to a type.\n */\nexport type JsonLdObjectWithOptionalAtId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"@id\", \"id\", string>\n> = Omit<T, \"@id\" | \"id\"> & {\n\t\"@id\"?: Id;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithOptionalAtType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithOptionalAtType.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithOptionalAtType.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add optional \"@type\" to a type.\n */\nexport type JsonLdObjectWithOptionalAtType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"@type\", \"type\", string | string[]>\n> = Omit<T, \"@type\" | \"type\"> & {\n\t\"@type\"?: Ty;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithOptionalContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithOptionalContext.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithOptionalContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingProperty } from \"./jsonLdExistingProperty.js\";\nimport type { IJsonLdContextDefinitionRoot } from \"../models/IJsonLdContextDefinitionRoot.js\";\n\n/**\n * Add optional \"@context\" to a type, inferring an existing context type from\n * the source type when available, otherwise using the provided default.\n */\nexport type JsonLdObjectWithOptionalContext<\n\tT extends object,\n\tC = JsonLdExistingProperty<T, \"@context\", IJsonLdContextDefinitionRoot>\n> = Omit<T, \"@context\"> & {\n\t\"@context\"?: C;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithOptionalId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithOptionalId.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithOptionalId.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add optional \"id\" to a type.\n */\nexport type JsonLdObjectWithOptionalId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"id\", \"@id\", string>\n> = Omit<T, \"id\" | \"@id\"> & {\n\tid?: Id;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithOptionalType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithOptionalType.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithOptionalType.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add optional \"type\" to a type.\n */\nexport type JsonLdObjectWithOptionalType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"type\", \"@type\", string | string[]>\n> = Omit<T, \"type\" | \"@type\"> & {\n\ttype?: Ty;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdObjectWithType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdObjectWithType.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdObjectWithType.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdExistingPropertyEither } from \"./jsonLdExistingPropertyEither.js\";\n\n/**\n * Add \"type\" to a type.\n */\nexport type JsonLdObjectWithType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"type\", \"@type\", string | string[]>\n> = Omit<T, \"type\" | \"@type\"> & {\n\ttype: Ty;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=jsonLdOptionalKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdOptionalKeys.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdOptionalKeys.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Extract the optional property names from a type.\n */\nexport type JsonLdOptionalKeys<T> = {\n\t[K in keyof T]-?: {} extends Pick<T, K> ? K : never;\n}[keyof T];\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdRequiredKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdRequiredKeys.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdRequiredKeys.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdOptionalKeys } from \"./jsonLdOptionalKeys.js\";\n\n/**\n * Extract the required property names from a type.\n */\nexport type JsonLdRequiredKeys<T> = Exclude<keyof T, JsonLdOptionalKeys<T>>;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdWithAliases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonLdWithAliases.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdWithAliases.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { JsonLdAliasKey } from \"./jsonLdAliasKey.js\";\nimport type { JsonLdOptionalKeys } from \"./jsonLdOptionalKeys.js\";\nimport type { JsonLdRequiredKeys } from \"./jsonLdRequiredKeys.js\";\n\n/**\n * Remap an object type so JSON-LD keys (\"@...\") are preserved and\n * non-JSON-LD keys are exposed as `Prefix:key` aliases, while preserving\n * each key's original required/optional status.\n */\nexport type JsonLdWithAliases<T extends object, Prefix extends string> = {\n\t[K in Extract<JsonLdRequiredKeys<T>, string> as JsonLdAliasKey<K, Prefix>]: T[K];\n} & {\n\t[K in Extract<JsonLdOptionalKeys<T>, string> as JsonLdAliasKey<K, Prefix>]?: T[K];\n};\n"]}
package/dist/es/index.js CHANGED
@@ -1,7 +1,29 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  export * from "./dataTypes/jsonLdDataTypes.js";
4
- export * from "./helpers/jsonLdHelperTypes.js";
4
+ export * from "./helpers/jsonLdAliasKey.js";
5
+ export * from "./helpers/jsonLdExistingProperty.js";
6
+ export * from "./helpers/jsonLdExistingPropertyEither.js";
7
+ export * from "./helpers/jsonLdKeys.js";
8
+ export * from "./helpers/jsonLdObjectWithAliases.js";
9
+ export * from "./helpers/jsonLdObjectWithAtId.js";
10
+ export * from "./helpers/jsonLdObjectWithAtType.js";
11
+ export * from "./helpers/jsonLdObjectWithContext.js";
12
+ export * from "./helpers/jsonLdObjectWithId.js";
13
+ export * from "./helpers/jsonLdObjectWithNoAtId.js";
14
+ export * from "./helpers/jsonLdObjectWithNoAtType.js";
15
+ export * from "./helpers/jsonLdObjectWithNoContext.js";
16
+ export * from "./helpers/jsonLdObjectWithNoId.js";
17
+ export * from "./helpers/jsonLdObjectWithNoType.js";
18
+ export * from "./helpers/jsonLdObjectWithOptionalAtId.js";
19
+ export * from "./helpers/jsonLdObjectWithOptionalAtType.js";
20
+ export * from "./helpers/jsonLdObjectWithOptionalContext.js";
21
+ export * from "./helpers/jsonLdObjectWithOptionalId.js";
22
+ export * from "./helpers/jsonLdObjectWithOptionalType.js";
23
+ export * from "./helpers/jsonLdObjectWithType.js";
24
+ export * from "./helpers/jsonLdOptionalKeys.js";
25
+ export * from "./helpers/jsonLdRequiredKeys.js";
26
+ export * from "./helpers/jsonLdWithAliases.js";
5
27
  export * from "./models/IJsonLdContainerType.js";
6
28
  export * from "./models/IJsonLdContainerTypeArray.js";
7
29
  export * from "./models/IJsonLdContextDefinition.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataTypes/jsonLdDataTypes.js\";\nexport * from \"./helpers/jsonLdHelperTypes.js\";\nexport * from \"./models/IJsonLdContainerType.js\";\nexport * from \"./models/IJsonLdContainerTypeArray.js\";\nexport * from \"./models/IJsonLdContextDefinition.js\";\nexport * from \"./models/IJsonLdContextDefinitionElement.js\";\nexport * from \"./models/IJsonLdContextDefinitionRoot.js\";\nexport * from \"./models/IJsonLdDocument.js\";\nexport * from \"./models/IJsonLdExpandedTermDefinition.js\";\nexport * from \"./models/IJsonLdGraphObject.js\";\nexport * from \"./models/IJsonLdIdMap.js\";\nexport * from \"./models/IJsonLdIncludedBlock.js\";\nexport * from \"./models/IJsonLdIndexMap.js\";\nexport * from \"./models/IJsonLdIndexMapItem.js\";\nexport * from \"./models/IJsonLdJsonArray.js\";\nexport * from \"./models/IJsonLdJsonObject.js\";\nexport * from \"./models/IJsonLdJsonPrimitive.js\";\nexport * from \"./models/IJsonLdJsonValue.js\";\nexport * from \"./models/IJsonLdLanguageMap.js\";\nexport * from \"./models/IJsonLdListObject.js\";\nexport * from \"./models/IJsonLdListOrSetItem.js\";\nexport * from \"./models/IJsonLdNodeObject.js\";\nexport * from \"./models/IJsonLdNodePrimitive.js\";\nexport * from \"./models/IJsonLdObject.js\";\nexport * from \"./models/IJsonLdSetObject.js\";\nexport * from \"./models/IJsonLdTypeMap.js\";\nexport * from \"./models/IJsonLdValueObject.js\";\nexport * from \"./models/jsonLdContexts.js\";\nexport * from \"./models/jsonLdTypes.js\";\nexport * from \"./utils/jsonLdHelper.js\";\nexport * from \"./utils/jsonLdProcessor.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataTypes/jsonLdDataTypes.js\";\nexport * from \"./helpers/jsonLdAliasKey.js\";\nexport * from \"./helpers/jsonLdExistingProperty.js\";\nexport * from \"./helpers/jsonLdExistingPropertyEither.js\";\nexport * from \"./helpers/jsonLdKeys.js\";\nexport * from \"./helpers/jsonLdObjectWithAliases.js\";\nexport * from \"./helpers/jsonLdObjectWithAtId.js\";\nexport * from \"./helpers/jsonLdObjectWithAtType.js\";\nexport * from \"./helpers/jsonLdObjectWithContext.js\";\nexport * from \"./helpers/jsonLdObjectWithId.js\";\nexport * from \"./helpers/jsonLdObjectWithNoAtId.js\";\nexport * from \"./helpers/jsonLdObjectWithNoAtType.js\";\nexport * from \"./helpers/jsonLdObjectWithNoContext.js\";\nexport * from \"./helpers/jsonLdObjectWithNoId.js\";\nexport * from \"./helpers/jsonLdObjectWithNoType.js\";\nexport * from \"./helpers/jsonLdObjectWithOptionalAtId.js\";\nexport * from \"./helpers/jsonLdObjectWithOptionalAtType.js\";\nexport * from \"./helpers/jsonLdObjectWithOptionalContext.js\";\nexport * from \"./helpers/jsonLdObjectWithOptionalId.js\";\nexport * from \"./helpers/jsonLdObjectWithOptionalType.js\";\nexport * from \"./helpers/jsonLdObjectWithType.js\";\nexport * from \"./helpers/jsonLdOptionalKeys.js\";\nexport * from \"./helpers/jsonLdRequiredKeys.js\";\nexport * from \"./helpers/jsonLdWithAliases.js\";\nexport * from \"./models/IJsonLdContainerType.js\";\nexport * from \"./models/IJsonLdContainerTypeArray.js\";\nexport * from \"./models/IJsonLdContextDefinition.js\";\nexport * from \"./models/IJsonLdContextDefinitionElement.js\";\nexport * from \"./models/IJsonLdContextDefinitionRoot.js\";\nexport * from \"./models/IJsonLdDocument.js\";\nexport * from \"./models/IJsonLdExpandedTermDefinition.js\";\nexport * from \"./models/IJsonLdGraphObject.js\";\nexport * from \"./models/IJsonLdIdMap.js\";\nexport * from \"./models/IJsonLdIncludedBlock.js\";\nexport * from \"./models/IJsonLdIndexMap.js\";\nexport * from \"./models/IJsonLdIndexMapItem.js\";\nexport * from \"./models/IJsonLdJsonArray.js\";\nexport * from \"./models/IJsonLdJsonObject.js\";\nexport * from \"./models/IJsonLdJsonPrimitive.js\";\nexport * from \"./models/IJsonLdJsonValue.js\";\nexport * from \"./models/IJsonLdLanguageMap.js\";\nexport * from \"./models/IJsonLdListObject.js\";\nexport * from \"./models/IJsonLdListOrSetItem.js\";\nexport * from \"./models/IJsonLdNodeObject.js\";\nexport * from \"./models/IJsonLdNodePrimitive.js\";\nexport * from \"./models/IJsonLdObject.js\";\nexport * from \"./models/IJsonLdSetObject.js\";\nexport * from \"./models/IJsonLdTypeMap.js\";\nexport * from \"./models/IJsonLdValueObject.js\";\nexport * from \"./models/jsonLdContexts.js\";\nexport * from \"./models/jsonLdTypes.js\";\nexport * from \"./utils/jsonLdHelper.js\";\nexport * from \"./utils/jsonLdProcessor.js\";\n"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Keep JSON-LD keys as-is and prefix non-JSON-LD keys.
3
+ */
4
+ export type JsonLdAliasKey<K extends string, Prefix extends string> = K extends `@${string}` ? K : `${Prefix}:${K}`;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Infer an existing property's type from a source type, or fall back to a default.
3
+ */
4
+ export type JsonLdExistingProperty<T extends object, P extends PropertyKey, D> = T extends {
5
+ [K in P]?: infer PropertyType;
6
+ } ? Exclude<PropertyType, undefined> : D;
@@ -0,0 +1,6 @@
1
+ import type { JsonLdExistingProperty } from "./jsonLdExistingProperty.js";
2
+ /**
3
+ * Infer an existing property's type from either of two source properties,
4
+ * or fall back to a default when neither exists.
5
+ */
6
+ export type JsonLdExistingPropertyEither<T extends object, P1 extends PropertyKey, P2 extends PropertyKey, D> = [JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>] extends [never] ? D : JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Keep only JSON-LD keys ("@...") from a type.
3
+ */
4
+ export type JsonLdKeys<T extends object> = Pick<T, Extract<keyof T, `@${string}`>>;
@@ -0,0 +1,7 @@
1
+ import type { JsonLdKeys } from "./jsonLdKeys.js";
2
+ import type { JsonLdWithAliases } from "./jsonLdWithAliases.js";
3
+ /**
4
+ * Create a JSON-LD object shape containing only JSON-LD keys plus aliased
5
+ * non-JSON-LD keys.
6
+ */
7
+ export type JsonLdObjectWithAliases<T extends object, Prefix extends string> = JsonLdKeys<T> & JsonLdWithAliases<T, Prefix>;
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add "@id" to a type.
4
+ */
5
+ export type JsonLdObjectWithAtId<T extends object, Id = JsonLdExistingPropertyEither<T, "@id", "id", string>> = Omit<T, "@id" | "id"> & {
6
+ "@id": Id;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add "@type" to a type.
4
+ */
5
+ export type JsonLdObjectWithAtType<T extends object, Ty = JsonLdExistingPropertyEither<T, "@type", "type", string | string[]>> = Omit<T, "@type" | "type"> & {
6
+ "@type": Ty;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { IJsonLdContextDefinitionRoot } from "../models/IJsonLdContextDefinitionRoot.js";
2
+ /**
3
+ * Add "@context" to a type.
4
+ */
5
+ export type JsonLdObjectWithContext<T extends object, C = IJsonLdContextDefinitionRoot> = Omit<T, "@context"> & {
6
+ "@context": C;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add "id" to a type.
4
+ */
5
+ export type JsonLdObjectWithId<T extends object, Id = JsonLdExistingPropertyEither<T, "id", "@id", string>> = Omit<T, "id" | "@id"> & {
6
+ id: Id;
7
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Omit "@id" from a type.
3
+ */
4
+ export type JsonLdObjectWithNoAtId<T extends object> = Omit<T, "@id">;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Omit "@type" from a type.
3
+ */
4
+ export type JsonLdObjectWithNoAtType<T extends object> = Omit<T, "@type">;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Omit optional "@context" from a type, inferring an existing context type from
3
+ * the source type when available, otherwise using the provided default.
4
+ */
5
+ export type JsonLdObjectWithNoContext<T extends object> = Omit<T, "@context">;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Omit "id" from a type.
3
+ */
4
+ export type JsonLdObjectWithNoId<T extends object> = Omit<T, "id">;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Omit "type" from a type.
3
+ */
4
+ export type JsonLdObjectWithNoType<T extends object> = Omit<T, "type">;
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add optional "@id" to a type.
4
+ */
5
+ export type JsonLdObjectWithOptionalAtId<T extends object, Id = JsonLdExistingPropertyEither<T, "@id", "id", string>> = Omit<T, "@id" | "id"> & {
6
+ "@id"?: Id;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add optional "@type" to a type.
4
+ */
5
+ export type JsonLdObjectWithOptionalAtType<T extends object, Ty = JsonLdExistingPropertyEither<T, "@type", "type", string | string[]>> = Omit<T, "@type" | "type"> & {
6
+ "@type"?: Ty;
7
+ };
@@ -0,0 +1,9 @@
1
+ import type { JsonLdExistingProperty } from "./jsonLdExistingProperty.js";
2
+ import type { IJsonLdContextDefinitionRoot } from "../models/IJsonLdContextDefinitionRoot.js";
3
+ /**
4
+ * Add optional "@context" to a type, inferring an existing context type from
5
+ * the source type when available, otherwise using the provided default.
6
+ */
7
+ export type JsonLdObjectWithOptionalContext<T extends object, C = JsonLdExistingProperty<T, "@context", IJsonLdContextDefinitionRoot>> = Omit<T, "@context"> & {
8
+ "@context"?: C;
9
+ };
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add optional "id" to a type.
4
+ */
5
+ export type JsonLdObjectWithOptionalId<T extends object, Id = JsonLdExistingPropertyEither<T, "id", "@id", string>> = Omit<T, "id" | "@id"> & {
6
+ id?: Id;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add optional "type" to a type.
4
+ */
5
+ export type JsonLdObjectWithOptionalType<T extends object, Ty = JsonLdExistingPropertyEither<T, "type", "@type", string | string[]>> = Omit<T, "type" | "@type"> & {
6
+ type?: Ty;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { JsonLdExistingPropertyEither } from "./jsonLdExistingPropertyEither.js";
2
+ /**
3
+ * Add "type" to a type.
4
+ */
5
+ export type JsonLdObjectWithType<T extends object, Ty = JsonLdExistingPropertyEither<T, "type", "@type", string | string[]>> = Omit<T, "type" | "@type"> & {
6
+ type: Ty;
7
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Extract the optional property names from a type.
3
+ */
4
+ export type JsonLdOptionalKeys<T> = {
5
+ [K in keyof T]-?: {} extends Pick<T, K> ? K : never;
6
+ }[keyof T];
@@ -0,0 +1,5 @@
1
+ import type { JsonLdOptionalKeys } from "./jsonLdOptionalKeys.js";
2
+ /**
3
+ * Extract the required property names from a type.
4
+ */
5
+ export type JsonLdRequiredKeys<T> = Exclude<keyof T, JsonLdOptionalKeys<T>>;
@@ -0,0 +1,13 @@
1
+ import type { JsonLdAliasKey } from "./jsonLdAliasKey.js";
2
+ import type { JsonLdOptionalKeys } from "./jsonLdOptionalKeys.js";
3
+ import type { JsonLdRequiredKeys } from "./jsonLdRequiredKeys.js";
4
+ /**
5
+ * Remap an object type so JSON-LD keys ("@...") are preserved and
6
+ * non-JSON-LD keys are exposed as `Prefix:key` aliases, while preserving
7
+ * each key's original required/optional status.
8
+ */
9
+ export type JsonLdWithAliases<T extends object, Prefix extends string> = {
10
+ [K in Extract<JsonLdRequiredKeys<T>, string> as JsonLdAliasKey<K, Prefix>]: T[K];
11
+ } & {
12
+ [K in Extract<JsonLdOptionalKeys<T>, string> as JsonLdAliasKey<K, Prefix>]?: T[K];
13
+ };
@@ -1,5 +1,27 @@
1
1
  export * from "./dataTypes/jsonLdDataTypes.js";
2
- export * from "./helpers/jsonLdHelperTypes.js";
2
+ export * from "./helpers/jsonLdAliasKey.js";
3
+ export * from "./helpers/jsonLdExistingProperty.js";
4
+ export * from "./helpers/jsonLdExistingPropertyEither.js";
5
+ export * from "./helpers/jsonLdKeys.js";
6
+ export * from "./helpers/jsonLdObjectWithAliases.js";
7
+ export * from "./helpers/jsonLdObjectWithAtId.js";
8
+ export * from "./helpers/jsonLdObjectWithAtType.js";
9
+ export * from "./helpers/jsonLdObjectWithContext.js";
10
+ export * from "./helpers/jsonLdObjectWithId.js";
11
+ export * from "./helpers/jsonLdObjectWithNoAtId.js";
12
+ export * from "./helpers/jsonLdObjectWithNoAtType.js";
13
+ export * from "./helpers/jsonLdObjectWithNoContext.js";
14
+ export * from "./helpers/jsonLdObjectWithNoId.js";
15
+ export * from "./helpers/jsonLdObjectWithNoType.js";
16
+ export * from "./helpers/jsonLdObjectWithOptionalAtId.js";
17
+ export * from "./helpers/jsonLdObjectWithOptionalAtType.js";
18
+ export * from "./helpers/jsonLdObjectWithOptionalContext.js";
19
+ export * from "./helpers/jsonLdObjectWithOptionalId.js";
20
+ export * from "./helpers/jsonLdObjectWithOptionalType.js";
21
+ export * from "./helpers/jsonLdObjectWithType.js";
22
+ export * from "./helpers/jsonLdOptionalKeys.js";
23
+ export * from "./helpers/jsonLdRequiredKeys.js";
24
+ export * from "./helpers/jsonLdWithAliases.js";
3
25
  export * from "./models/IJsonLdContainerType.js";
4
26
  export * from "./models/IJsonLdContainerTypeArray.js";
5
27
  export * from "./models/IJsonLdContextDefinition.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.24](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.23...data-json-ld-v0.0.3-next.24) (2026-05-22)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **data-json-ld:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/data-core bumped from 0.0.3-next.23 to 0.0.3-next.24
16
+
17
+ ## [0.0.3-next.23](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.22...data-json-ld-v0.0.3-next.23) (2026-05-19)
18
+
19
+
20
+ ### Features
21
+
22
+ * update dependencies ([b622475](https://github.com/iotaledger/twin-data/commit/b6224758e66ac3be563d68a670636356ce033434))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/data-core bumped from 0.0.3-next.22 to 0.0.3-next.23
30
+
3
31
  ## [0.0.3-next.22](https://github.com/iotaledger/twin-data/compare/data-json-ld-v0.0.3-next.21...data-json-ld-v0.0.3-next.22) (2026-05-13)
4
32
 
5
33
 
@@ -22,29 +22,29 @@
22
22
 
23
23
  ## Type Aliases
24
24
 
25
- - [JsonLdOptionalKeys](type-aliases/JsonLdOptionalKeys.md)
26
- - [JsonLdRequiredKeys](type-aliases/JsonLdRequiredKeys.md)
27
25
  - [JsonLdAliasKey](type-aliases/JsonLdAliasKey.md)
28
- - [JsonLdWithAliases](type-aliases/JsonLdWithAliases.md)
26
+ - [JsonLdExistingProperty](type-aliases/JsonLdExistingProperty.md)
27
+ - [JsonLdExistingPropertyEither](type-aliases/JsonLdExistingPropertyEither.md)
29
28
  - [JsonLdKeys](type-aliases/JsonLdKeys.md)
30
29
  - [JsonLdObjectWithAliases](type-aliases/JsonLdObjectWithAliases.md)
30
+ - [JsonLdObjectWithAtId](type-aliases/JsonLdObjectWithAtId.md)
31
+ - [JsonLdObjectWithAtType](type-aliases/JsonLdObjectWithAtType.md)
31
32
  - [JsonLdObjectWithContext](type-aliases/JsonLdObjectWithContext.md)
32
- - [JsonLdExistingProperty](type-aliases/JsonLdExistingProperty.md)
33
- - [JsonLdExistingPropertyEither](type-aliases/JsonLdExistingPropertyEither.md)
34
- - [JsonLdObjectWithOptionalContext](type-aliases/JsonLdObjectWithOptionalContext.md)
33
+ - [JsonLdObjectWithId](type-aliases/JsonLdObjectWithId.md)
34
+ - [JsonLdObjectWithNoAtId](type-aliases/JsonLdObjectWithNoAtId.md)
35
+ - [JsonLdObjectWithNoAtType](type-aliases/JsonLdObjectWithNoAtType.md)
35
36
  - [JsonLdObjectWithNoContext](type-aliases/JsonLdObjectWithNoContext.md)
36
- - [JsonLdObjectWithType](type-aliases/JsonLdObjectWithType.md)
37
- - [JsonLdObjectWithOptionalType](type-aliases/JsonLdObjectWithOptionalType.md)
37
+ - [JsonLdObjectWithNoId](type-aliases/JsonLdObjectWithNoId.md)
38
38
  - [JsonLdObjectWithNoType](type-aliases/JsonLdObjectWithNoType.md)
39
- - [JsonLdObjectWithAtType](type-aliases/JsonLdObjectWithAtType.md)
39
+ - [JsonLdObjectWithOptionalAtId](type-aliases/JsonLdObjectWithOptionalAtId.md)
40
40
  - [JsonLdObjectWithOptionalAtType](type-aliases/JsonLdObjectWithOptionalAtType.md)
41
- - [JsonLdObjectWithNoAtType](type-aliases/JsonLdObjectWithNoAtType.md)
42
- - [JsonLdObjectWithId](type-aliases/JsonLdObjectWithId.md)
41
+ - [JsonLdObjectWithOptionalContext](type-aliases/JsonLdObjectWithOptionalContext.md)
43
42
  - [JsonLdObjectWithOptionalId](type-aliases/JsonLdObjectWithOptionalId.md)
44
- - [JsonLdObjectWithNoId](type-aliases/JsonLdObjectWithNoId.md)
45
- - [JsonLdObjectWithAtId](type-aliases/JsonLdObjectWithAtId.md)
46
- - [JsonLdObjectWithOptionalAtId](type-aliases/JsonLdObjectWithOptionalAtId.md)
47
- - [JsonLdObjectWithNoAtId](type-aliases/JsonLdObjectWithNoAtId.md)
43
+ - [JsonLdObjectWithOptionalType](type-aliases/JsonLdObjectWithOptionalType.md)
44
+ - [JsonLdObjectWithType](type-aliases/JsonLdObjectWithType.md)
45
+ - [JsonLdOptionalKeys](type-aliases/JsonLdOptionalKeys.md)
46
+ - [JsonLdRequiredKeys](type-aliases/JsonLdRequiredKeys.md)
47
+ - [JsonLdWithAliases](type-aliases/JsonLdWithAliases.md)
48
48
  - [IJsonLdContainerType](type-aliases/IJsonLdContainerType.md)
49
49
  - [IJsonLdContainerTypeArray](type-aliases/IJsonLdContainerTypeArray.md)
50
50
  - [IJsonLdContextDefinitionElement](type-aliases/IJsonLdContextDefinitionElement.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/data-json-ld",
3
- "version": "0.0.3-next.22",
3
+ "version": "0.0.3-next.24",
4
4
  "description": "JSON-LD data models and helpers for working with linked data documents.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/core": "next",
18
- "@twin.org/data-core": "0.0.3-next.22",
18
+ "@twin.org/data-core": "0.0.3-next.24",
19
19
  "@twin.org/entity": "next",
20
20
  "@twin.org/nameof": "next",
21
21
  "@twin.org/web": "next",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=jsonLdHelperTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonLdHelperTypes.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdHelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionRoot } from \"../models/IJsonLdContextDefinitionRoot.js\";\n\n/**\n * Extract the optional property names from a type.\n */\nexport type JsonLdOptionalKeys<T> = {\n\t[K in keyof T]-?: {} extends Pick<T, K> ? K : never;\n}[keyof T];\n\n/**\n * Extract the required property names from a type.\n */\nexport type JsonLdRequiredKeys<T> = Exclude<keyof T, JsonLdOptionalKeys<T>>;\n\n/**\n * Keep JSON-LD keys as-is and prefix non-JSON-LD keys.\n */\nexport type JsonLdAliasKey<K extends string, Prefix extends string> = K extends `@${string}`\n\t? K\n\t: `${Prefix}:${K}`;\n\n/**\n * Remap an object type so JSON-LD keys (\"@...\") are preserved and\n * non-JSON-LD keys are exposed as `Prefix:key` aliases, while preserving\n * each key's original required/optional status.\n */\nexport type JsonLdWithAliases<T extends object, Prefix extends string> = {\n\t[K in Extract<JsonLdRequiredKeys<T>, string> as JsonLdAliasKey<K, Prefix>]: T[K];\n} & {\n\t[K in Extract<JsonLdOptionalKeys<T>, string> as JsonLdAliasKey<K, Prefix>]?: T[K];\n};\n\n/**\n * Keep only JSON-LD keys (\"@...\") from a type.\n */\nexport type JsonLdKeys<T extends object> = Pick<T, Extract<keyof T, `@${string}`>>;\n\n/**\n * Create a JSON-LD object shape containing only JSON-LD keys plus aliased\n * non-JSON-LD keys.\n */\nexport type JsonLdObjectWithAliases<T extends object, Prefix extends string> = JsonLdKeys<T> &\n\tJsonLdWithAliases<T, Prefix>;\n\n/**\n * Add \"@context\" to a type.\n */\nexport type JsonLdObjectWithContext<T extends object, C = IJsonLdContextDefinitionRoot> = Omit<\n\tT,\n\t\"@context\"\n> & {\n\t\"@context\": C;\n};\n\n/**\n * Infer an existing property's type from a source type, or fall back to a default.\n */\nexport type JsonLdExistingProperty<T extends object, P extends PropertyKey, D> = T extends {\n\t[K in P]?: infer PropertyType;\n}\n\t? Exclude<PropertyType, undefined>\n\t: D;\n\n/**\n * Infer an existing property's type from either of two source properties,\n * or fall back to a default when neither exists.\n */\nexport type JsonLdExistingPropertyEither<\n\tT extends object,\n\tP1 extends PropertyKey,\n\tP2 extends PropertyKey,\n\tD\n> = [JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>] extends [never]\n\t? D\n\t: JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>;\n\n/**\n * Add optional \"@context\" to a type, inferring an existing context type from\n * the source type when available, otherwise using the provided default.\n */\nexport type JsonLdObjectWithOptionalContext<\n\tT extends object,\n\tC = JsonLdExistingProperty<T, \"@context\", IJsonLdContextDefinitionRoot>\n> = Omit<T, \"@context\"> & {\n\t\"@context\"?: C;\n};\n\n/**\n * Omit optional \"@context\" from a type, inferring an existing context type from\n * the source type when available, otherwise using the provided default.\n */\nexport type JsonLdObjectWithNoContext<T extends object> = Omit<T, \"@context\">;\n\n/**\n * Add \"type\" to a type.\n */\nexport type JsonLdObjectWithType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"type\", \"@type\", string | string[]>\n> = Omit<T, \"type\" | \"@type\"> & {\n\ttype: Ty;\n};\n\n/**\n * Add optional \"type\" to a type.\n */\nexport type JsonLdObjectWithOptionalType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"type\", \"@type\", string | string[]>\n> = Omit<T, \"type\" | \"@type\"> & {\n\ttype?: Ty;\n};\n\n/**\n * Omit \"type\" from a type.\n */\nexport type JsonLdObjectWithNoType<T extends object> = Omit<T, \"type\">;\n\n/**\n * Add \"@type\" to a type.\n */\nexport type JsonLdObjectWithAtType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"@type\", \"type\", string | string[]>\n> = Omit<T, \"@type\" | \"type\"> & {\n\t\"@type\": Ty;\n};\n\n/**\n * Add optional \"@type\" to a type.\n */\nexport type JsonLdObjectWithOptionalAtType<\n\tT extends object,\n\tTy = JsonLdExistingPropertyEither<T, \"@type\", \"type\", string | string[]>\n> = Omit<T, \"@type\" | \"type\"> & {\n\t\"@type\"?: Ty;\n};\n\n/**\n * Omit \"@type\" from a type.\n */\nexport type JsonLdObjectWithNoAtType<T extends object> = Omit<T, \"@type\">;\n\n/**\n * Add \"id\" to a type.\n */\nexport type JsonLdObjectWithId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"id\", \"@id\", string>\n> = Omit<T, \"id\" | \"@id\"> & {\n\tid: Id;\n};\n\n/**\n * Add optional \"id\" to a type.\n */\nexport type JsonLdObjectWithOptionalId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"id\", \"@id\", string>\n> = Omit<T, \"id\" | \"@id\"> & {\n\tid?: Id;\n};\n\n/**\n * Omit \"id\" from a type.\n */\nexport type JsonLdObjectWithNoId<T extends object> = Omit<T, \"id\">;\n\n/**\n * Add \"@id\" to a type.\n */\nexport type JsonLdObjectWithAtId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"@id\", \"id\", string>\n> = Omit<T, \"@id\" | \"id\"> & {\n\t\"@id\": Id;\n};\n\n/**\n * Add optional \"@id\" to a type.\n */\nexport type JsonLdObjectWithOptionalAtId<\n\tT extends object,\n\tId = JsonLdExistingPropertyEither<T, \"@id\", \"id\", string>\n> = Omit<T, \"@id\" | \"id\"> & {\n\t\"@id\"?: Id;\n};\n\n/**\n * Omit \"@id\" from a type.\n */\nexport type JsonLdObjectWithNoAtId<T extends object> = Omit<T, \"@id\">;\n"]}
@@ -1,127 +0,0 @@
1
- import type { IJsonLdContextDefinitionRoot } from "../models/IJsonLdContextDefinitionRoot.js";
2
- /**
3
- * Extract the optional property names from a type.
4
- */
5
- export type JsonLdOptionalKeys<T> = {
6
- [K in keyof T]-?: {} extends Pick<T, K> ? K : never;
7
- }[keyof T];
8
- /**
9
- * Extract the required property names from a type.
10
- */
11
- export type JsonLdRequiredKeys<T> = Exclude<keyof T, JsonLdOptionalKeys<T>>;
12
- /**
13
- * Keep JSON-LD keys as-is and prefix non-JSON-LD keys.
14
- */
15
- export type JsonLdAliasKey<K extends string, Prefix extends string> = K extends `@${string}` ? K : `${Prefix}:${K}`;
16
- /**
17
- * Remap an object type so JSON-LD keys ("@...") are preserved and
18
- * non-JSON-LD keys are exposed as `Prefix:key` aliases, while preserving
19
- * each key's original required/optional status.
20
- */
21
- export type JsonLdWithAliases<T extends object, Prefix extends string> = {
22
- [K in Extract<JsonLdRequiredKeys<T>, string> as JsonLdAliasKey<K, Prefix>]: T[K];
23
- } & {
24
- [K in Extract<JsonLdOptionalKeys<T>, string> as JsonLdAliasKey<K, Prefix>]?: T[K];
25
- };
26
- /**
27
- * Keep only JSON-LD keys ("@...") from a type.
28
- */
29
- export type JsonLdKeys<T extends object> = Pick<T, Extract<keyof T, `@${string}`>>;
30
- /**
31
- * Create a JSON-LD object shape containing only JSON-LD keys plus aliased
32
- * non-JSON-LD keys.
33
- */
34
- export type JsonLdObjectWithAliases<T extends object, Prefix extends string> = JsonLdKeys<T> & JsonLdWithAliases<T, Prefix>;
35
- /**
36
- * Add "@context" to a type.
37
- */
38
- export type JsonLdObjectWithContext<T extends object, C = IJsonLdContextDefinitionRoot> = Omit<T, "@context"> & {
39
- "@context": C;
40
- };
41
- /**
42
- * Infer an existing property's type from a source type, or fall back to a default.
43
- */
44
- export type JsonLdExistingProperty<T extends object, P extends PropertyKey, D> = T extends {
45
- [K in P]?: infer PropertyType;
46
- } ? Exclude<PropertyType, undefined> : D;
47
- /**
48
- * Infer an existing property's type from either of two source properties,
49
- * or fall back to a default when neither exists.
50
- */
51
- export type JsonLdExistingPropertyEither<T extends object, P1 extends PropertyKey, P2 extends PropertyKey, D> = [JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>] extends [never] ? D : JsonLdExistingProperty<T, P1, never> | JsonLdExistingProperty<T, P2, never>;
52
- /**
53
- * Add optional "@context" to a type, inferring an existing context type from
54
- * the source type when available, otherwise using the provided default.
55
- */
56
- export type JsonLdObjectWithOptionalContext<T extends object, C = JsonLdExistingProperty<T, "@context", IJsonLdContextDefinitionRoot>> = Omit<T, "@context"> & {
57
- "@context"?: C;
58
- };
59
- /**
60
- * Omit optional "@context" from a type, inferring an existing context type from
61
- * the source type when available, otherwise using the provided default.
62
- */
63
- export type JsonLdObjectWithNoContext<T extends object> = Omit<T, "@context">;
64
- /**
65
- * Add "type" to a type.
66
- */
67
- export type JsonLdObjectWithType<T extends object, Ty = JsonLdExistingPropertyEither<T, "type", "@type", string | string[]>> = Omit<T, "type" | "@type"> & {
68
- type: Ty;
69
- };
70
- /**
71
- * Add optional "type" to a type.
72
- */
73
- export type JsonLdObjectWithOptionalType<T extends object, Ty = JsonLdExistingPropertyEither<T, "type", "@type", string | string[]>> = Omit<T, "type" | "@type"> & {
74
- type?: Ty;
75
- };
76
- /**
77
- * Omit "type" from a type.
78
- */
79
- export type JsonLdObjectWithNoType<T extends object> = Omit<T, "type">;
80
- /**
81
- * Add "@type" to a type.
82
- */
83
- export type JsonLdObjectWithAtType<T extends object, Ty = JsonLdExistingPropertyEither<T, "@type", "type", string | string[]>> = Omit<T, "@type" | "type"> & {
84
- "@type": Ty;
85
- };
86
- /**
87
- * Add optional "@type" to a type.
88
- */
89
- export type JsonLdObjectWithOptionalAtType<T extends object, Ty = JsonLdExistingPropertyEither<T, "@type", "type", string | string[]>> = Omit<T, "@type" | "type"> & {
90
- "@type"?: Ty;
91
- };
92
- /**
93
- * Omit "@type" from a type.
94
- */
95
- export type JsonLdObjectWithNoAtType<T extends object> = Omit<T, "@type">;
96
- /**
97
- * Add "id" to a type.
98
- */
99
- export type JsonLdObjectWithId<T extends object, Id = JsonLdExistingPropertyEither<T, "id", "@id", string>> = Omit<T, "id" | "@id"> & {
100
- id: Id;
101
- };
102
- /**
103
- * Add optional "id" to a type.
104
- */
105
- export type JsonLdObjectWithOptionalId<T extends object, Id = JsonLdExistingPropertyEither<T, "id", "@id", string>> = Omit<T, "id" | "@id"> & {
106
- id?: Id;
107
- };
108
- /**
109
- * Omit "id" from a type.
110
- */
111
- export type JsonLdObjectWithNoId<T extends object> = Omit<T, "id">;
112
- /**
113
- * Add "@id" to a type.
114
- */
115
- export type JsonLdObjectWithAtId<T extends object, Id = JsonLdExistingPropertyEither<T, "@id", "id", string>> = Omit<T, "@id" | "id"> & {
116
- "@id": Id;
117
- };
118
- /**
119
- * Add optional "@id" to a type.
120
- */
121
- export type JsonLdObjectWithOptionalAtId<T extends object, Id = JsonLdExistingPropertyEither<T, "@id", "id", string>> = Omit<T, "@id" | "id"> & {
122
- "@id"?: Id;
123
- };
124
- /**
125
- * Omit "@id" from a type.
126
- */
127
- export type JsonLdObjectWithNoAtId<T extends object> = Omit<T, "@id">;