Fixed problems with the generator

main
Jackson Morgan 6 months ago
parent 2b92fb47a9
commit d8a68fa829
  1. 34
      packages/schema-converter-shex/src/context/JsonLdContextBuilder.ts
  2. 2
      packages/schema-converter-shex/test/context.test.ts
  3. 1342
      packages/schema-converter-shex/test/testData/activityPub.ts
  4. 10
      packages/schema-converter-shex/test/testData/andSimple.ts
  5. 31
      packages/schema-converter-shex/test/testData/circular.ts
  6. 11
      packages/schema-converter-shex/test/testData/eachOfAndSimple.ts
  7. 8
      packages/schema-converter-shex/test/testData/extendsSimple.ts
  8. 8
      packages/schema-converter-shex/test/testData/oldExtends.ts
  9. 15
      packages/schema-converter-shex/test/testData/orSimple.ts
  10. 94
      packages/schema-converter-shex/test/testData/profile.ts
  11. 18
      packages/schema-converter-shex/test/testData/reducedProfile.ts
  12. 26
      packages/schema-converter-shex/test/testData/reusedPredicates.ts
  13. 7
      packages/schema-converter-shex/test/testData/simple.ts
  14. 2
      packages/schema-converter-shex/test/typing.test.ts
  15. 2
      packages/solid/package.json
  16. 21
      packages/solid/src/.ldo/solid.context.ts
  17. 26
      packages/solid/src/.ldo/wac.context.ts
  18. 2
      packages/solid/src/resource/wac/setWacRule.ts

@ -76,14 +76,21 @@ export class JsonLdContextBuilder {
return this.iriTypes[rdfType] as JsonLdContextBuilder;
}
addSubject(iri: string, rdfType?: string, annotations?: Annotation[]) {
private getRelevantBuilders(rdfType?: string): JsonLdContextBuilder[] {
const relevantBuilder = this.getRelevantBuilder(rdfType);
return relevantBuilder === this ? [this] : [this, relevantBuilder];
}
addSubject(iri: string, rdfType?: string, annotations?: Annotation[]) {
const relevantBuilders = this.getRelevantBuilders(rdfType);
relevantBuilders.forEach((relevantBuilder) => {
if (!relevantBuilder.iriAnnotations[iri]) {
relevantBuilder.iriAnnotations[iri] = [];
}
if (annotations && annotations.length > 0) {
relevantBuilder.iriAnnotations[iri].push(...annotations);
}
});
}
addPredicate(
@ -93,7 +100,8 @@ export class JsonLdContextBuilder {
rdfType?: string,
annotations?: Annotation[],
) {
const relevantBuilder = this.getRelevantBuilder(rdfType);
const relevantBuilders = this.getRelevantBuilders(rdfType);
relevantBuilders.forEach((relevantBuilder) => {
relevantBuilder.addSubject(iri, undefined, annotations);
if (!relevantBuilder.iriTypes[iri]) {
relevantBuilder.iriTypes[iri] = expandedTermDefinition;
@ -103,31 +111,19 @@ export class JsonLdContextBuilder {
} else {
const curDef = relevantBuilder.iriTypes[iri];
const newDef = expandedTermDefinition;
// TODO: if you reuse the same predicate with a different cardinality,
// it will overwrite the past cardinality. Perhapse we might want to
// split contexts in the various shapes.
if (isContainer) {
curDef["@isCollection"] = true;
}
// If the old and new versions both have types
if (curDef["@type"] && newDef["@type"]) {
if (
Array.isArray(curDef["@type"]) &&
!(curDef["@type"] as string[]).includes(newDef["@type"])
) {
curDef["@type"].push(newDef["@type"]);
} else if (
typeof curDef["@type"] === "string" &&
curDef["@type"] !== newDef["@type"]
) {
// The typings are incorrect. String arrays are allowed on @type
// see https://w3c.github.io/json-ld-syntax/#example-specifying-multiple-types-for-a-node
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
curDef["@type"] = [curDef["@type"], newDef["@type"]];
if (curDef["@type"] !== newDef["@type"]) {
console.warn(
`You've specified that a specific field "${iri}" can have an object of multiple literal types (${curDef["@type"]} or ${newDef["@type"]}). This is not expressable in JSON-LD context, and we will randomly select one type to use.`,
);
}
}
}
});
}
generateNames(): Record<string, string> {

@ -3,6 +3,8 @@ import { shexjToContext } from "../src/context/shexjToContext";
import parser from "@shexjs/parser";
import type { Schema } from "shexj";
console.warn = () => {};
describe("context", () => {
testData.forEach(({ name, shexc, successfulContext }) => {
it(`Creates a context for ${name}`, async () => {

File diff suppressed because one or more lines are too long

@ -24,6 +24,9 @@ export const andSimple: TestData = {
sampleTurtle: "",
baseNode: "",
successfulContext: {
type: {
"@id": "@type",
},
MediaContainer: {
"@id": "https://example.com/MediaContainer",
"@context": {
@ -36,12 +39,13 @@ export const andSimple: TestData = {
},
},
},
type: {
"@id": "@type",
videoImage: {
"@id": "https://example.com/videoImage",
"@type": "@id",
},
Video: "https://example.com/Video",
Image: "https://example.com/Image",
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface MediaContainerShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "MediaContainer";\n };\n videoImage: VideoShape & ImageShape;\n}\n\nexport interface VideoShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Video";\n };\n}\n\nexport interface ImageShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Image";\n };\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface MediaContainerShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "MediaContainer";\n };\n videoImage: VideoShape & ImageShape;\n}\n\nexport interface VideoShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Video";\n };\n}\n\nexport interface ImageShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Image";\n };\n}\n\n',
};

@ -31,21 +31,42 @@ export const circular: TestData = {
`,
baseNode: "http://example.com/SampleParent",
successfulContext: {
type: {
"@id": "@type",
},
Parent: {
"@id": "http://example.com/Parent",
"@context": {
type: { "@id": "@type" },
hasChild: { "@id": "http://example.com/hasChild", "@type": "@id" },
type: {
"@id": "@type",
},
hasChild: {
"@id": "http://example.com/hasChild",
"@type": "@id",
},
},
},
hasChild: {
"@id": "http://example.com/hasChild",
"@type": "@id",
},
Child: {
"@id": "http://example.com/Child",
"@context": {
type: { "@id": "@type" },
hasParent: { "@id": "http://example.com/hasParent", "@type": "@id" },
type: {
"@id": "@type",
},
hasParent: {
"@id": "http://example.com/hasParent",
"@type": "@id",
},
},
},
hasParent: {
"@id": "http://example.com/hasParent",
"@type": "@id",
},
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface ParentShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type?: {\n "@id": "Parent";\n };\n hasChild: ChildShape;\n}\n\nexport interface ChildShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type?: {\n "@id": "Child";\n };\n hasParent: ParentShape;\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface ParentShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type?: {\n "@id": "Parent";\n };\n hasChild: ChildShape;\n}\n\nexport interface ChildShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type?: {\n "@id": "Child";\n };\n hasParent: ParentShape;\n}\n\n',
};

@ -25,6 +25,9 @@ export const eachOfAndSimple: TestData = {
sampleTurtle: "",
baseNode: "",
successfulContext: {
type: {
"@id": "@type",
},
MediaContainer: {
"@id": "https://example.com/MediaContainer",
"@context": {
@ -38,12 +41,14 @@ export const eachOfAndSimple: TestData = {
},
},
},
type: {
"@id": "@type",
videoImage: {
"@id": "https://example.com/videoImage",
"@type": "@id",
"@isCollection": true,
},
Video: "https://example.com/Video",
Image: "https://example.com/Image",
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface MediaContainerShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "MediaContainer";\n };\n videoImage?: LdSet<VideoShape | ImageShape>;\n}\n\nexport interface VideoShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Video";\n };\n}\n\nexport interface ImageShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Image";\n };\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface MediaContainerShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "MediaContainer";\n };\n videoImage?: LdSet<VideoShape | ImageShape>;\n}\n\nexport interface VideoShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Video";\n };\n}\n\nexport interface ImageShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Image";\n };\n}\n\n',
};

@ -37,6 +37,9 @@ export const extendsSimple: TestData = {
`,
baseNode: "http://example.com/SampleParent",
successfulContext: {
type: {
"@id": "@type",
},
Entity: {
"@id": "https://example.com/Entity",
"@context": {
@ -46,6 +49,7 @@ export const extendsSimple: TestData = {
entityId: "https://example.com/entityId",
},
},
entityId: "https://example.com/entityId",
Person: {
"@id": "https://example.com/Person",
"@context": {
@ -56,6 +60,7 @@ export const extendsSimple: TestData = {
name: "http://xmlns.com/foaf/0.1/name",
},
},
name: "http://xmlns.com/foaf/0.1/name",
Employee: {
"@id": "https://example.com/Employee",
"@context": {
@ -67,7 +72,8 @@ export const extendsSimple: TestData = {
employeeNumber: "https://example.com/employeeNumber",
},
},
employeeNumber: "https://example.com/employeeNumber",
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface EntityShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Entity";\n };\n entityId: any;\n}\n\nexport interface PersonShape {\n "@id"?: LdSet<string | string>;\n "@context"?: LdSet<ContextDefinition | ContextDefinition>;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n }>;\n entityId: any;\n name: any;\n}\n\nexport interface EmployeeShape {\n "@id"?: LdSet<string | string | string>;\n "@context"?: LdSet<ContextDefinition | ContextDefinition | ContextDefinition>;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n } | {\n "@id": "Employee";\n }>;\n entityId: any;\n name: any;\n employeeNumber: any;\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface EntityShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Entity";\n };\n entityId: any;\n}\n\nexport interface PersonShape {\n "@id"?: LdSet<string | string>;\n "@context"?: LdSet<LdoJsonldContext | LdoJsonldContext>;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n }>;\n entityId: any;\n name: any;\n}\n\nexport interface EmployeeShape {\n "@id"?: LdSet<string | string | string>;\n "@context"?: LdSet<LdoJsonldContext | LdoJsonldContext | LdoJsonldContext>;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n } | {\n "@id": "Employee";\n }>;\n entityId: any;\n name: any;\n employeeNumber: any;\n}\n\n',
};

@ -42,6 +42,9 @@ export const oldExtends: TestData = {
`,
baseNode: "http://example.com/SampleParent",
successfulContext: {
type: {
"@id": "@type",
},
Entity: {
"@id": "https://example.com/Entity",
"@context": {
@ -51,6 +54,7 @@ export const oldExtends: TestData = {
entityId: "https://example.com/entityId",
},
},
entityId: "https://example.com/entityId",
Person: {
"@id": "https://example.com/Person",
"@context": {
@ -61,6 +65,7 @@ export const oldExtends: TestData = {
name: "http://xmlns.com/foaf/0.1/name",
},
},
name: "http://xmlns.com/foaf/0.1/name",
Employee: {
"@id": "https://example.com/Employee",
"@context": {
@ -72,7 +77,8 @@ export const oldExtends: TestData = {
employeeNumber: "https://example.com/employeeNumber",
},
},
employeeNumber: "https://example.com/employeeNumber",
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface EntityShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Entity";\n };\n entityId: any;\n}\n\nexport interface PersonShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n }>;\n entityId: any;\n name: any;\n}\n\nexport interface EmployeeShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n } | {\n "@id": "Employee";\n }>;\n entityId: any;\n name: any;\n employeeNumber: any;\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface EntityShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Entity";\n };\n entityId: any;\n}\n\nexport interface PersonShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n }>;\n entityId: any;\n name: any;\n}\n\nexport interface EmployeeShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: LdSet<{\n "@id": "Entity";\n } | {\n "@id": "Person";\n } | {\n "@id": "Employee";\n }>;\n entityId: any;\n name: any;\n employeeNumber: any;\n}\n\n',
};

@ -25,6 +25,9 @@ export const orSimple: TestData = {
sampleTurtle: "",
baseNode: "",
successfulContext: {
type: {
"@id": "@type",
},
MediaContainer: {
"@id": "https://example.com/MediaContainer",
"@context": {
@ -42,12 +45,18 @@ export const orSimple: TestData = {
},
},
},
type: {
"@id": "@type",
primaryMedia: {
"@id": "https://example.com/primaryMedia",
"@type": "@id",
},
Video: "https://example.com/Video",
Image: "https://example.com/Image",
media: {
"@id": "https://example.com/media",
"@type": "@id",
"@isCollection": true,
},
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface MediaContainerShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "MediaContainer";\n };\n primaryMedia: VideoShape | ImageShape;\n media?: LdSet<VideoShape | ImageShape>;\n}\n\nexport interface VideoShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Video";\n };\n}\n\nexport interface ImageShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Image";\n };\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface MediaContainerShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "MediaContainer";\n };\n primaryMedia: VideoShape | ImageShape;\n media?: LdSet<VideoShape | ImageShape>;\n}\n\nexport interface VideoShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Video";\n };\n}\n\nexport interface ImageShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Image";\n };\n}\n\n',
};

File diff suppressed because one or more lines are too long

@ -51,6 +51,9 @@ srs:EmailShape EXTRA a {
sampleTurtle: ``,
baseNode: "",
successfulContext: {
type: {
"@id": "@type",
},
Person: {
"@id": "http://schema.org/Person",
"@context": {
@ -85,6 +88,11 @@ srs:EmailShape EXTRA a {
},
},
},
hasEmail: {
"@id": "http://www.w3.org/2006/vcard/ns#hasEmail",
"@type": "@id",
"@isCollection": true,
},
Dom: {
"@id": "http://www.w3.org/2006/vcard/ns#Dom",
"@context": {
@ -217,7 +225,15 @@ srs:EmailShape EXTRA a {
},
},
},
value: {
"@id": "http://www.w3.org/2006/vcard/ns#value",
"@type": "@id",
},
name: {
"@id": "http://xmlns.com/foaf/0.1/name",
"@type": "http://www.w3.org/2001/XMLSchema#string",
},
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface SolidProfileShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n /**\n * Defines the node as a Person | Defines the node as a Person\n */\n type: LdSet<{\n "@id": "Person";\n } | {\n "@id": "Person2";\n }>;\n /**\n * The person\'s email.\n */\n hasEmail?: LdSet<EmailShape>;\n /**\n * An alternate way to define a person\'s name\n */\n name?: string;\n}\n\nexport interface EmailShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n /**\n * The type of email.\n */\n type?: {\n "@id": "Dom";\n } | {\n "@id": "Home";\n } | {\n "@id": "ISDN";\n } | {\n "@id": "Internet";\n } | {\n "@id": "Intl";\n } | {\n "@id": "Label";\n } | {\n "@id": "Parcel";\n } | {\n "@id": "Postal";\n } | {\n "@id": "Pref";\n } | {\n "@id": "Work";\n } | {\n "@id": "X400";\n };\n /**\n * The value of an email as a mailto link (Example <mailto:jane@example.com>)\n */\n value: {\n "@id": string;\n };\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface SolidProfileShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n /**\n * Defines the node as a Person | Defines the node as a Person\n */\n type: LdSet<{\n "@id": "Person";\n } | {\n "@id": "Person2";\n }>;\n /**\n * The person\'s email.\n */\n hasEmail?: LdSet<EmailShape>;\n /**\n * An alternate way to define a person\'s name\n */\n name?: string;\n}\n\nexport interface EmailShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n /**\n * The type of email.\n */\n type?: {\n "@id": "Dom";\n } | {\n "@id": "Home";\n } | {\n "@id": "ISDN";\n } | {\n "@id": "Internet";\n } | {\n "@id": "Intl";\n } | {\n "@id": "Label";\n } | {\n "@id": "Parcel";\n } | {\n "@id": "Postal";\n } | {\n "@id": "Pref";\n } | {\n "@id": "Work";\n } | {\n "@id": "X400";\n };\n /**\n * The value of an email as a mailto link (Example <mailto:jane@example.com>)\n */\n value: {\n "@id": string;\n };\n}\n\n',
};

@ -31,6 +31,9 @@ export const reusedPredicates: TestData = {
sampleTurtle: ``,
baseNode: "http://example.com/SampleParent",
successfulContext: {
type: {
"@id": "@type",
},
Document: {
"@id": "https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#Document",
"@context": {
@ -49,6 +52,12 @@ export const reusedPredicates: TestData = {
},
},
},
vocabulary: {
"@id":
"https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#vocabulary",
"@type": "@id",
"@isCollection": true,
},
Vocabulary: {
"@id":
"https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#Vocabulary",
@ -59,6 +68,7 @@ export const reusedPredicates: TestData = {
name: {
"@id": "https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#name",
"@type": "http://www.w3.org/2001/XMLSchema#string",
"@isCollection": true,
},
path: {
"@id": "https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#path",
@ -67,6 +77,20 @@ export const reusedPredicates: TestData = {
},
},
},
name: {
"@id": "https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#name",
"@type": "http://www.w3.org/2001/XMLSchema#string",
"@isCollection": true,
},
path: {
"@id": "https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#path",
"@type": "@id",
"@isCollection": true,
},
law: {
"@id": "https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#law",
"@type": "@id",
},
Law: {
"@id": "https://www.forsakringskassan.se/vocabs/fk-sem-poc.ttl#Law",
"@context": {
@ -86,5 +110,5 @@ export const reusedPredicates: TestData = {
},
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface DocumentShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Document";\n };\n vocabulary?: LdSet<VocabularyShape>;\n law: LawShape;\n}\n\nexport interface LawShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Law";\n };\n name?: LdSet<string>;\n path: {\n "@id": string;\n };\n}\n\nexport interface VocabularyShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n type: {\n "@id": "Vocabulary";\n };\n name: string;\n path?: LdSet<{\n "@id": string;\n }>;\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface DocumentShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Document";\n };\n vocabulary?: LdSet<VocabularyShape>;\n law: LawShape;\n}\n\nexport interface LawShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Law";\n };\n name?: LdSet<string>;\n path: {\n "@id": string;\n };\n}\n\nexport interface VocabularyShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n type: {\n "@id": "Vocabulary";\n };\n name: string;\n path?: LdSet<{\n "@id": string;\n }>;\n}\n\n',
};

@ -43,8 +43,11 @@ export const simple: TestData = {
"@type": "@id",
"@isCollection": true,
},
mbox: { "@id": "http://xmlns.com/foaf/0.1/mbox", "@type": "@id" },
mbox: {
"@id": "http://xmlns.com/foaf/0.1/mbox",
"@type": "@id",
},
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface EmployeeShape {\n "@id"?: string;\n "@context"?: ContextDefinition;\n givenName: LdSet<string>;\n familyName: string;\n phone?: LdSet<{\n "@id": string;\n }>;\n mbox: {\n "@id": string;\n };\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface EmployeeShape {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n givenName: LdSet<string>;\n familyName: string;\n phone?: LdSet<{\n "@id": string;\n }>;\n mbox: {\n "@id": string;\n };\n}\n\n',
};

@ -3,6 +3,8 @@ import { testData } from "./testData/testData";
import { shexjToTyping } from "../src/typing/shexjToTyping";
import type { Schema } from "shexj";
console.warn = () => {};
describe("typing", () => {
testData.forEach(({ name, shexc, successfulTypings }) => {
it(`Creates a typings for ${name}`, async () => {

@ -7,7 +7,7 @@
"example": "ts-node ./example/example.ts",
"build": "tsc --project tsconfig.build.json",
"watch": "tsc --watch",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage -t \"sets wac rules for a resource that\"",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"test:watch": "jest --watch",
"prepublishOnly": "npm run test && npm run build",
"build:ldo": "ldo build --input src/.shapes --output src/.ldo",

@ -6,6 +6,10 @@ import { LdoJsonldContext } from "@ldo/ldo";
* =============================================================================
*/
export const solidContext: LdoJsonldContext = {
type: {
"@id": "@type",
"@isCollection": true,
},
Container: {
"@id": "http://www.w3.org/ns/ldp#Container",
"@context": {
@ -58,6 +62,15 @@ export const solidContext: LdoJsonldContext = {
},
},
},
modified: {
"@id": "http://purl.org/dc/terms/modified",
"@type": "http://www.w3.org/2001/XMLSchema#string",
},
contains: {
"@id": "http://www.w3.org/ns/ldp#contains",
"@type": "@id",
"@isCollection": true,
},
Resource2: {
"@id": "http://www.w3.org/ns/iana/media-types/text/turtle#Resource",
"@context": {
@ -79,6 +92,14 @@ export const solidContext: LdoJsonldContext = {
},
},
},
mtime: {
"@id": "http://www.w3.org/ns/posix/stat#mtime",
"@type": "http://www.w3.org/2001/XMLSchema#decimal",
},
size: {
"@id": "http://www.w3.org/ns/posix/stat#size",
"@type": "http://www.w3.org/2001/XMLSchema#integer",
},
storage: {
"@id": "http://www.w3.org/ns/pim/space#storage",
"@type": "@id",

@ -43,8 +43,34 @@ export const wacContext: LdoJsonldContext = {
},
},
},
accessTo: {
"@id": "http://www.w3.org/ns/auth/acl#accessTo",
"@type": "@id",
},
default: {
"@id": "http://www.w3.org/ns/auth/acl#default",
"@type": "@id",
},
agent: {
"@id": "http://www.w3.org/ns/auth/acl#agent",
"@type": "@id",
"@isCollection": true,
},
agentGroup: {
"@id": "http://www.w3.org/ns/auth/acl#agentGroup",
"@type": "@id",
"@isCollection": true,
},
agentClass: {
"@id": "http://www.w3.org/ns/auth/acl#agentClass",
"@isCollection": true,
},
AuthenticatedAgent: "http://www.w3.org/ns/auth/acl#AuthenticatedAgent",
Agent: "http://xmlns.com/foaf/0.1/Agent",
mode: {
"@id": "http://www.w3.org/ns/auth/acl#mode",
"@isCollection": true,
},
Read: "http://www.w3.org/ns/auth/acl#Read",
Write: "http://www.w3.org/ns/auth/acl#Write",
Append: "http://www.w3.org/ns/auth/acl#Append",

@ -80,8 +80,6 @@ export async function setWacRuleForAclUri(
addRuleToDataset("agent", accessModeList, agentUri);
});
console.log(dataset.toString());
// Save to Pod
const response = await fetch(aclUri, {
method: "PUT",

Loading…
Cancel
Save