Skip to content

Commit

Permalink
fix import in JsoLDSchemaResult and add a new converter
Browse files Browse the repository at this point in the history
  • Loading branch information
damianpedra committed Jan 19, 2023
1 parent 6c451d0 commit 144933d
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
92 changes: 92 additions & 0 deletions amf-cli/js/typings/amf-client-js.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,8 @@ declare module "amf-client-js" {
export class JsonSchemaConfiguration {
static JsonSchema(): ShapesConfiguration;
}


export class JsonSchemaDocument extends Document {
schemaVersion: StrField;

Expand Down Expand Up @@ -5658,6 +5660,96 @@ declare module "amf-client-js" {

withUnitCache(cache: UnitCache): SemanticJsonSchemaConfiguration;
}

export class JsonLDSchemaConfiguration extends BaseShapesConfiguration{
baseUnitClient(): JsonLDSchemaConfigurationClient;

withParsingOptions(parsingOptions: ParsingOptions): JsonLDSchemaConfiguration
withRenderOptions(renderOptions: RenderOptions): JsonLDSchemaConfiguration
withResourceLoader(rl: ResourceLoader): JsonLDSchemaConfiguration
withResourceLoaders(rl: Array<ResourceLoader>): JsonLDSchemaConfiguration
withUnitCache(cache: UnitCache): JsonLDSchemaConfiguration
withTransformationPipeline(pipeline: TransformationPipeline): JsonLDSchemaConfiguration
withErrorHandlerProvider(provider: ErrorHandlerProvider): JsonLDSchemaConfiguration
withEventListener(listener: AMFEventListener): JsonLDSchemaConfiguration
withExecutionEnvironment(executionEnv: ExecutionEnvironment): JsonLDSchemaConfiguration
withDialect(dialect: Dialect): JsonLDSchemaConfiguration
withDialect(url: string): Promise<JsonLDSchemaConfiguration>
forInstance(url:string): Promise<JsonLDSchemaConfiguration>

static JsonLDSchema(): JsonLDSchemaConfiguration;
}

export class JsonLDSchemaConfigurationClient extends BaseAMLBaseUnitClient{
getConfiguration(): JsonLDSchemaConfiguration
parseJsonLDInstance(url: string, jsonLDSchema: JsonSchemaDocument): Promise<JsonLDInstanceResult>
parseJsonLDSchema(url:string): Promise<JsonLDSchemaResult>
}

export class JsonLDSchemaResult extends AMFParseResult{
jsonDocument: JsonSchemaDocument;
}

export class JsonLDInstanceResult extends AMFParseResult{
instance: JsonLDInstanceDocument;
}

export class JsonLDInstanceDocument implements BaseUnit{
id: string;
location: string;
modelVersion: StrField;
processingData: BaseUnitProcessingData;
raw: string;
sourceInformation: BaseUnitSourceInformation;
sourceSpec: Spec;
usage: StrField;
annotations(): Annotations;
cloneUnit(): BaseUnit;
findById(id: string): DomainElement;
findByType(typeId: string): DomainElement[];
pkg(): StrField;
references(): BaseUnit[];
withId(id: string): this;
withLocation(location: string): this;
withPkg(pkg: string): this;
withProcessingData(data: BaseUnitProcessingData): this;
withRaw(raw: string): this;
withReferenceAlias(alias: string, id: string, fullUrl: string, relativeUrl: string): BaseUnit;
withReferences(references: BaseUnit[]): this;
withUsage(usage: string): this;
withEncodes(encodes: Array<JsonLDObject>): JsonLDInstanceDocument;
encodes: Array<JsonLDObject>;
}

export class JsonLDObject implements DomainElement{
customDomainProperties: DomainExtension[];
extendsNode: DomainElement[];
id: string;
isExternalLink: BoolField;
position: Range;
annotations(): Annotations;
graph(): Graph;
withCustomDomainProperties(extensions: DomainExtension[]): this;
withExtendsNode(extension: ParametrizedDeclaration[]): this;
withId(id: string): this;
withIsExternalLink(isExternalLink: boolean): DomainElement;


componentId: string
withProperty(property: string, value: string): JsonLDObject
withProperty(property: string, value: number): JsonLDObject
withProperty(property: string, value: number): JsonLDObject
withProperty(property: string, value: Boolean): JsonLDObject
withProperty(property: string, value: JsonLDObject): JsonLDObject
withStringPropertyCollection(property: string, values: Array<string>): JsonLDObject
withIntPropertyCollection(property: string, values: Array<number>): JsonLDObject
withFloatPropertyCollection(property: string, values: Array<number>): JsonLDObject
withBoolPropertyCollection(property: string, values: Array<Boolean>): JsonLDObject
withObjPropertyCollection(property: string, values: Array<JsonLDObject>): JsonLDObject

}


export class Server implements DomainElement {
bindings: ServerBindings;
customDomainProperties: Array<DomainExtension>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package amf.shapes.client.platform
import amf.core.client.platform.AMFParseResult
import amf.core.client.platform.validation.AMFValidationResult
import amf.shapes.client.platform.model.document.JsonSchemaDocument
import amf.shapes.client.scala.model.document.JsonLDInstanceDocument
import amf.shapes.client.scala.{JsonLDInstanceResult => InternalJsonLDInstanceResult, JsonLDSchemaResult => InternalJsonLDSchemaResult}
Expand All @@ -18,5 +17,7 @@ class JsonLDSchemaResult(
class JsonLDInstanceResult(
private[amf] override val _internal: InternalJsonLDInstanceResult
) extends AMFParseResult(_internal) {

val instance: JsonLDInstanceDocument = _internal.instance

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import amf.shapes.client.platform.config.{
SemanticJsonSchemaConfiguration => ClientSemanticJsonSchemaConfiguration
}
import amf.shapes.client.platform.model.document.{JsonSchemaDocument => ClientJsonSchemaDocument}
import amf.shapes.client.scala.model.document.JsonSchemaDocument
import amf.shapes.client.scala.model.document.{JsonLDInstanceDocument, JsonSchemaDocument}
import amf.shapes.client.platform.model.document.{JsonLDInstanceDocument => ClientJsonLDInstanceDocument}
import amf.shapes.client.platform.model.domain
import amf.shapes.client.platform.{
JsonLDInstanceResult,
Expand Down Expand Up @@ -72,6 +73,7 @@ trait ShapesBaseConverter
with JsonLDSchemaResultConverter
with JsonLDInstanceResultConverter
with JsonLDSchemaConfigurationClientConverter
with JsonLDInstanceDocumentConverter

trait NilShapeConverter extends PlatformSecrets {

Expand Down Expand Up @@ -310,6 +312,14 @@ trait JsonSchemaDocumentConverter extends PlatformSecrets {
}
}

trait JsonLDInstanceDocumentConverter extends PlatformSecrets {
implicit object JsonLDInstanceDocumentMatcher extends BidirectionalMatcher[JsonLDInstanceDocument, ClientJsonLDInstanceDocument] {
override def asClient(from: JsonLDInstanceDocument): ClientJsonLDInstanceDocument = new ClientJsonLDInstanceDocument(from)
override def asInternal(from: ClientJsonLDInstanceDocument): JsonLDInstanceDocument = from._internal
}
}


trait BaseIriConverter extends PlatformSecrets {
implicit object BaseIriMatcher extends BidirectionalMatcher[BaseIri, domain.BaseIri] {
override def asInternal(from: domain.BaseIri): BaseIri = from._internal
Expand Down

0 comments on commit 144933d

Please sign in to comment.