Skip to content

Commit 29c0b04

Browse files
committed
docs(changeset): fix: rename Model class to ModelDefinition to prevent naming clash in ESM generated typescript types
Signed-off-by: Timo Glastra <timo@animo.id>
1 parent 51976ce commit 29c0b04

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

.changeset/giant-yaks-build.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"dcql": patch
3+
---
4+
5+
fix: rename Model class to ModelDefinition to prevent naming clash in ESM generated typescript types
6+

dcql/src/dcql-presentation/m-dcql-credential-presentation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import * as v from 'valibot'
22
import { DcqlMdocCredential, DcqlSdJwtVcCredential, DcqlW3cVcCredential } from '../u-dcql-credential'
33
import type { InferModelTypes } from '../u-model'
4-
import { Model } from '../u-model'
4+
import { ModelDefinition } from '../u-model'
55

66
export namespace DcqlMdocPresentation {
77
export const vModel = DcqlMdocCredential.vModel
8-
export const model = new Model({ vModel })
8+
export const model = new ModelDefinition({ vModel })
99
export type Model = InferModelTypes<typeof model>
1010
}
1111
export type DcqlMdocPresentation = DcqlMdocPresentation.Model['Output']
1212

1313
export namespace DcqlSdJwtVcPresentation {
1414
export const vModel = DcqlSdJwtVcCredential.vModel
15-
export const model = new Model({ vModel })
15+
export const model = new ModelDefinition({ vModel })
1616
export type Model = InferModelTypes<typeof model>
1717
}
1818
export type DcqlSdJwtVcPresentation = DcqlSdJwtVcPresentation.Model['Output']
1919

2020
export namespace DcqlW3cVcPresentation {
2121
export const vModel = DcqlW3cVcCredential.vModel
22-
export const model = new Model({ vModel })
22+
export const model = new ModelDefinition({ vModel })
2323
export type Model = InferModelTypes<typeof model>
2424
}
2525
export type DcqlW3cVcPresentation = DcqlW3cVcPresentation.Model['Output']
2626

2727
export namespace DcqlCredentialPresentation {
28-
export const model = new Model({
28+
export const model = new ModelDefinition({
2929
vModel: v.variant('credential_format', [
3030
DcqlMdocPresentation.vModel,
3131
DcqlSdJwtVcPresentation.vModel,

dcql/src/u-dcql-credential.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as v from 'valibot'
22
import { DcqlCredentialTrustedAuthority } from './dcql-query/m-dcql-trusted-authorities.js'
33
import { vJsonRecord } from './u-dcql.js'
44
import type { InferModelTypes } from './u-model.js'
5-
import { Model } from './u-model.js'
5+
import { ModelDefinition } from './u-model.js'
66

77
const vCredentialModelBase = v.object({
88
authority: v.optional(DcqlCredentialTrustedAuthority.vModel),
@@ -32,7 +32,7 @@ export namespace DcqlMdocCredential {
3232
namespaces: vNamespaces,
3333
})
3434

35-
export const model = new Model({ vModel })
35+
export const model = new ModelDefinition({ vModel })
3636
export type Model = InferModelTypes<typeof model>
3737
export type NameSpaces = v.InferOutput<typeof vNamespaces>
3838
}
@@ -46,7 +46,7 @@ export namespace DcqlSdJwtVcCredential {
4646
vct: v.string(),
4747
claims: vClaims,
4848
})
49-
export const model = new Model({ vModel })
49+
export const model = new ModelDefinition({ vModel })
5050
export type Model = InferModelTypes<typeof model>
5151
export type Claims = Model['Output']['claims']
5252
}
@@ -61,7 +61,7 @@ export namespace DcqlW3cVcCredential {
6161
type: v.array(v.string()),
6262
})
6363

64-
export const model = new Model({ vModel })
64+
export const model = new ModelDefinition({ vModel })
6565
export type Model = InferModelTypes<typeof model>
6666
export type Claims = Model['Output']['claims']
6767
}
@@ -74,7 +74,7 @@ export namespace DcqlCredential {
7474
DcqlW3cVcCredential.vModel,
7575
])
7676

77-
export const model = new Model({ vModel })
77+
export const model = new ModelDefinition({ vModel })
7878
export type Model = InferModelTypes<typeof model>
7979
}
8080
export type DcqlCredential = DcqlCredential.Model['Output']

dcql/src/u-model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type UnknownBaseSchema = v.BaseSchema<unknown, unknown, v.BaseIssue<unkno
55

66
type EnsureOutputAssignableToInput<T extends UnknownBaseSchema> = v.InferOutput<T> extends v.InferInput<T> ? T : never
77

8-
export class Model<T extends UnknownBaseSchema> {
8+
export class ModelDefinition<T extends UnknownBaseSchema> {
99
constructor(private input: { vModel: EnsureOutputAssignableToInput<T> }) {}
1010

1111
public get v() {
@@ -47,7 +47,7 @@ export class Model<T extends UnknownBaseSchema> {
4747
}
4848

4949
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
50-
export type InferModelTypes<T extends Model<any>> = T extends Model<infer U>
50+
export type InferModelTypes<T extends ModelDefinition<any>> = T extends ModelDefinition<infer U>
5151
? {
5252
Input: v.InferInput<U>
5353
Output: v.InferOutput<U>

0 commit comments

Comments
 (0)