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

feat: support rdf:LangString datatype (+test) #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/visitors/typescript/generates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ export function generateTsType(valueExpr: any, toCreate?: boolean) {
return toCreate ? 'Date | Literal' : 'Date';
} else if (valueExpr?.datatype === ns.xsd('string')) {
return toCreate ? 'string | Literal' : 'string';
} else if (valueExpr?.datatype === ns.rdf('langString')) {
return toCreate ? 'string | Literal' : 'string';
} else if (valueExpr?.datatype) {
return valueExpr?.datatype;
} else if (typeof valueExpr === 'string') {
Expand Down
6 changes: 6 additions & 0 deletions test/__snapshots__/generate.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ export type BasicContainerShapeUpdateArgs = Partial<BasicContainerShapeCreateArg

export type ResourceShape = {
id: string; // the url of a node of this shape
description: string; // Gives a description for the resource
size: number; // Size of Container
mtime: number; // Time of Container creation created
modified: Date; // Time the Container was modified
Expand All @@ -742,6 +743,7 @@ export type ResourceShape = {

export type ResourceShapeCreateArgs = {
id?: string | NamedNode; // the url to match or create the node with e.g. 'https://example.com#this', 'https://example.com/profile/card#me'
description: string | Literal; // Gives a description for the resource
size: number | Literal; // Size of Container
mtime: number | Literal; // Time of Container creation created
modified: Date | Literal; // Time the Container was modified
Expand Down Expand Up @@ -770,6 +772,7 @@ export enum BasicContainerShapeContext {

export enum ResourceShapeContext {
type = 'rdf:type',
description = 'terms:description',
size = 'st:size',
mtime = 'st:mtime',
modified = 'terms:modified',
Expand All @@ -778,6 +781,7 @@ export enum ResourceShapeContext {
export const ldpShapesShex = \`
PREFIX ldp: <http://www.w3.org/ns/ldp#>
PREFIX st: <http://www.w3.org/ns/posix/stat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX terms: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
Expand All @@ -801,6 +805,8 @@ ldp:BasicContainerShape EXTRA a {
ldp:ResourceShape EXTRA a {
a [ ldp:Resource ]
// rdfs:comment \\"Defines the node as a Resource\\" ;
terms:description rdf:langString
// rdfs:comment \\"Gives a description for the resource\\" ;
st:size xsd:integer
// rdfs:comment \\"Size of Container\\" ;
st:mtime xsd:decimal
Expand Down
3 changes: 3 additions & 0 deletions test/shapes/ldpShapes.shex
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PREFIX ldp: <http://www.w3.org/ns/ldp#>
PREFIX st: <http://www.w3.org/ns/posix/stat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX terms: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
Expand All @@ -23,6 +24,8 @@ ldp:BasicContainerShape EXTRA a {
ldp:ResourceShape EXTRA a {
a [ ldp:Resource ]
// rdfs:comment "Defines the node as a Resource" ;
terms:description rdf:langString
// rdfs:comment "Gives a description for the resource" ;
st:size xsd:integer
// rdfs:comment "Size of Container" ;
st:mtime xsd:decimal
Expand Down