@luvio/model
Advanced tools
Comparing version 5.21.0 to 5.21.1-alpha.0
@@ -119,2 +119,3 @@ import amf from 'amf-client-js'; | ||
DiscriminatedDog: typeof amf.AnyShape; | ||
SelfReferencing: typeof amf.AnyShape; | ||
}, {}>; | ||
@@ -121,0 +122,0 @@ amfOneOf: TestRaml<{ |
@@ -1,2 +0,2 @@ | ||
import { type FileParserLogger } from '@luvio/utils'; | ||
import { type FileParserLogger, type LoggerService } from '@luvio/utils'; | ||
import type { AMFType } from './types'; | ||
@@ -11,2 +11,3 @@ import type { API, Server } from '../api'; | ||
private logger; | ||
private fileParserlogger; | ||
typeRegistry?: TypeRegistry<AMFType>; | ||
@@ -16,3 +17,3 @@ _endpoints?: EndPoint[]; | ||
annotationsVersion?: string; | ||
constructor(document: amf.Document, logger: FileParserLogger); | ||
constructor(document: amf.Document, logger: LoggerService, fileParserlogger: FileParserLogger); | ||
get webApi(): amf.WebApi; | ||
@@ -19,0 +20,0 @@ get endpoints(): ReadonlyArray<EndPoint>; |
import type { AuraController, AuraEndPoint, BaseEndPoint, HttpEndPoint, Parameter, Operation } from '../../api'; | ||
import type { AMFType, AMFTypeFactory } from '../types'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
import type amf from 'amf-client-js'; | ||
export type AmfEndPoint = AmfAuraEndpoint | AmfHttpEndPoint; | ||
export declare function amfEndpointFactory(amfEndpoint: amf.EndPoint, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger): AmfEndPoint | undefined; | ||
export declare function amfEndpointFactory(amfEndpoint: amf.EndPoint, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger): AmfEndPoint | undefined; | ||
export declare abstract class AmfBaseEndpoint implements BaseEndPoint { | ||
protected amfEndpoint: amf.EndPoint; | ||
operations: ReadonlyArray<Operation>; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
path: string; | ||
uriParameters: Record<string, Parameter>; | ||
abstract type: 'aura' | 'http'; | ||
constructor(amfEndpoint: amf.EndPoint, operations: ReadonlyArray<Operation>, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfEndpoint: amf.EndPoint, operations: ReadonlyArray<Operation>, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
} | ||
@@ -21,6 +22,8 @@ export declare class AmfHttpEndPoint extends AmfBaseEndpoint implements HttpEndPoint { | ||
export declare class AmfAuraEndpoint extends AmfBaseEndpoint implements AuraEndPoint { | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
readonly type = "aura"; | ||
auraController: AuraController; | ||
constructor(amfEndPoint: amf.EndPoint, operations: Operation[], amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfEndPoint: amf.EndPoint, operations: Operation[], amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildAuraController(): AuraController; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { type FileParserLogger } from '@luvio/utils'; | ||
import { type LoggerService, type FileParserLogger } from '@luvio/utils'; | ||
import type amf from 'amf-client-js'; | ||
@@ -10,3 +10,4 @@ import type { AuraOperationWithoutRequestBody, AuraOperationWithRequestBody, BaseOperation, HttpMethod, Parameter, Payload, Request, Response, HttpOperation, CacheStrategy, ConfigSchemaType, OperationType } from '../../api'; | ||
protected typeRegistry: TypeRegistry<AMFType>; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
method: HttpMethod; | ||
@@ -24,3 +25,3 @@ operationId: string; | ||
abstract readonly type: 'aura' | 'http'; | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildCacheStrategy(): CacheStrategy; | ||
@@ -41,3 +42,3 @@ buildPayloads(r: amf.Request | amf.Response): Payload[]; | ||
}; | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildAuraMethod(): { | ||
@@ -54,3 +55,3 @@ name: string; | ||
}; | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildAuraMethod(): { | ||
@@ -57,0 +58,0 @@ name: string; |
import amf from 'amf-client-js'; | ||
import { AMFAPI } from './AMFAPI'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export declare function parseAmfDocument(source: URL, logger: FileParserLogger): Promise<amf.Document>; | ||
export declare function parseUrl(source: URL, logger: FileParserLogger): Promise<AMFAPI>; | ||
export declare function parseUrl(source: URL, logger: LoggerService, fileParserLogger: FileParserLogger): Promise<AMFAPI>; |
@@ -6,3 +6,3 @@ import type { AMFTypeFactory } from './factory'; | ||
import type { AMFType } from '.'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export declare abstract class AMFBaseType<T extends Type['type'], S extends amf.AnyShape = amf.AnyShape> implements BaseType { | ||
@@ -12,7 +12,8 @@ shape: S; | ||
protected factory: AMFTypeFactory; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
resolved: boolean; | ||
inherits: AMFType[]; | ||
abstract type: T; | ||
constructor(shape: S, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: S, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
resolve(): void; | ||
@@ -19,0 +20,0 @@ typeResolve(): void; |
@@ -6,3 +6,3 @@ import { AMFBaseType } from './AMFBaseType'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export type AMFNotType = AMFTypeProps<amf.NodeShape> & NotType; | ||
@@ -13,6 +13,7 @@ export declare class AMFNotTypeImpl extends AMFBaseType<'not', amf.NodeShape> implements AMFNotType { | ||
protected factory: AMFTypeFactory; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
type: "not"; | ||
not: Type; | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
} |
@@ -6,3 +6,3 @@ import { AMFBaseType } from './AMFBaseType'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export type AMFObjectType = AMFTypeProps<amf.NodeShape> & ObjectType; | ||
@@ -13,3 +13,4 @@ export declare class AMFObjectTypeImpl extends AMFBaseType<'object', amf.NodeShape> implements AMFObjectType { | ||
protected factory: AMFTypeFactory; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
type: "object"; | ||
@@ -25,3 +26,3 @@ properties: Record<string, Property>; | ||
private discriminatorProperty; | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
typeResolve(): void; | ||
@@ -28,0 +29,0 @@ get discriminator(): Discriminator | undefined; |
@@ -6,3 +6,3 @@ import { AMFBaseType } from './AMFBaseType'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export type AMFBooleanType = AMFTypeProps & BooleanType; | ||
@@ -45,4 +45,4 @@ export type AMFDoubleType = AMFTypeProps & DoubleType; | ||
format: typeof DATE | typeof DATE_TIME; | ||
constructor(shape: amf.ScalarShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: amf.ScalarShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
} | ||
export {}; |
import amf from 'amf-client-js'; | ||
import type { AMFType } from '.'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
/** | ||
@@ -16,3 +16,3 @@ * Returns an AMFType that corresponds to a given AMF Shape. | ||
*/ | ||
export declare function amfTypeFactory(shape: amf.Shape, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger, resolve?: boolean, propertyName?: string): AMFType; | ||
export declare function amfTypeFactory(shape: amf.Shape, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserlogger: FileParserLogger, resolve?: boolean, propertyName?: string): AMFType; | ||
/** | ||
@@ -19,0 +19,0 @@ * Returns the AMF Shape ids that are equivalent to the specified Shape via |
@@ -297,3 +297,3 @@ /** | ||
class AmfBaseOperation { | ||
constructor(amfOperation, amfTypeFactory, typeRegistry, logger) { | ||
constructor(amfOperation, amfTypeFactory, typeRegistry, logger, fileParserLogger) { | ||
this.amfOperation = amfOperation; | ||
@@ -303,2 +303,3 @@ this.amfTypeFactory = amfTypeFactory; | ||
this.logger = logger; | ||
this.fileParserLogger = fileParserLogger; | ||
this.method = this.amfOperation.method.value().toUpperCase(); | ||
@@ -316,3 +317,3 @@ this.position = { | ||
if (!operationId) { | ||
this.logger.error(this.position, `operationID not found.`); | ||
this.fileParserLogger.error(this.position, `operationID not found.`); | ||
throw new Error('Operation ID not found'); | ||
@@ -345,3 +346,3 @@ } | ||
if (!['none', 'resource'].includes(cacheStrategyTypeOverride)) { | ||
this.logger.warn(this.position, `${EXTENSION_ONESTORE_OPERATION_CACHE_STRATEGY_TYPE} must be 'none' or 'resource'. Got ${cacheStrategyTypeOverride}. Defaulting to type 'none'.`); | ||
this.fileParserLogger.warn(this.position, `${EXTENSION_ONESTORE_OPERATION_CACHE_STRATEGY_TYPE} must be 'none' or 'resource'. Got ${cacheStrategyTypeOverride}. Defaulting to type 'none'.`); | ||
} | ||
@@ -353,3 +354,3 @@ else { | ||
// Seems like the extension validation should be able to enforce this as required | ||
this.logger.warn(this.position, `${EXTENSION_ONESTORE_OPERATION_CACHE_STRATEGY_MAX_AGE} must be a number. Defaulting to type 'none'`); | ||
this.fileParserLogger.warn(this.position, `${EXTENSION_ONESTORE_OPERATION_CACHE_STRATEGY_MAX_AGE} must be a number. Defaulting to type 'none'`); | ||
} | ||
@@ -367,3 +368,3 @@ else { | ||
mediaType: payload.mediaType.value(), | ||
data: this.amfTypeFactory(payload.schema, this.typeRegistry, this.logger, true), | ||
data: this.amfTypeFactory(payload.schema, this.typeRegistry, this.logger, this.fileParserLogger, true), | ||
}; | ||
@@ -377,3 +378,3 @@ }); | ||
required: param.required.value(), | ||
type: this.amfTypeFactory(param.schema, this.typeRegistry, this.logger, true), | ||
type: this.amfTypeFactory(param.schema, this.typeRegistry, this.logger, this.fileParserLogger, true), | ||
}; | ||
@@ -387,3 +388,3 @@ }); | ||
if (!['default', 'flattened'].includes(configSchemaTypeOverride)) { | ||
this.logger.warn(this.position, `${EXTENSION_ONESTORE_CONFIG_SCHEMA} must have value 'flattened' or 'default' but received ${configSchemaTypeOverride}.`); | ||
this.fileParserLogger.warn(this.position, `${EXTENSION_ONESTORE_CONFIG_SCHEMA} must have value 'flattened' or 'default' but received ${configSchemaTypeOverride}.`); | ||
} | ||
@@ -401,3 +402,3 @@ else { | ||
if (!['query', 'mutation'].includes(operationTypeOverride)) { | ||
this.logger.warn(this.position, `${EXTENSION_ONESTORE_OPERATION_TYPE} must be query or mutation. Got ${operationTypeOverride}.`); | ||
this.fileParserLogger.warn(this.position, `${EXTENSION_ONESTORE_OPERATION_TYPE} must be query or mutation. Got ${operationTypeOverride}.`); | ||
} | ||
@@ -418,4 +419,4 @@ else { | ||
class AmfAuraOperationWithoutRequestBody extends AmfBaseOperation { | ||
constructor(amfOperation, amfTypeFactory, typeRegistry, logger) { | ||
super(amfOperation, amfTypeFactory, typeRegistry, logger); | ||
constructor(amfOperation, amfTypeFactory, typeRegistry, logger, fileParserLogger) { | ||
super(amfOperation, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
this.type = 'aura'; | ||
@@ -439,4 +440,4 @@ const hasRequestBody = amfOperation.requests.some((request) => request.payloads.length > 0); | ||
class AmfAuraOperationWithRequestBody extends AmfBaseOperation { | ||
constructor(amfOperation, amfTypeFactory, typeRegistry, logger) { | ||
super(amfOperation, amfTypeFactory, typeRegistry, logger); | ||
constructor(amfOperation, amfTypeFactory, typeRegistry, logger, fileParserLogger) { | ||
super(amfOperation, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
this.type = 'aura'; | ||
@@ -463,3 +464,3 @@ const hasRequestBody = amfOperation.requests.some((request) => request.payloads.length > 0); | ||
function amfEndpointFactory(amfEndpoint, amfTypeFactory, typeRegistry, logger) { | ||
function amfEndpointFactory(amfEndpoint, amfTypeFactory, typeRegistry, logger, fileParserLogger) { | ||
const endPointType = getExtensionValue(buildExtensions(amfEndpoint.customDomainProperties), EXTENSION_ONESTORE_ENDPOINT_TYPE, 'string'); | ||
@@ -473,15 +474,15 @@ if (endPointType === undefined) { | ||
if (hasRequestBody) { | ||
return new AmfAuraOperationWithRequestBody(operation, amfTypeFactory, typeRegistry, logger); | ||
return new AmfAuraOperationWithRequestBody(operation, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
} | ||
else { | ||
return new AmfAuraOperationWithoutRequestBody(operation, amfTypeFactory, typeRegistry, logger); | ||
return new AmfAuraOperationWithoutRequestBody(operation, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
} | ||
}); | ||
return new AmfAuraEndpoint(amfEndpoint, operations, amfTypeFactory, typeRegistry, logger); | ||
return new AmfAuraEndpoint(amfEndpoint, operations, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
} | ||
if (endPointType === 'http') { | ||
const operations = amfEndpoint.operations.map((operation) => { | ||
return new AmfHttpOperation(operation, amfTypeFactory, typeRegistry, logger); | ||
return new AmfHttpOperation(operation, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
}); | ||
return new AmfHttpEndPoint(amfEndpoint, operations, amfTypeFactory, typeRegistry, logger); | ||
return new AmfHttpEndPoint(amfEndpoint, operations, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
} | ||
@@ -491,6 +492,7 @@ throw new Error(`Unknown value for 'x-onestore.command-type'. Value must be 'aura' or 'http', got ${endPointType}`); | ||
class AmfBaseEndpoint { | ||
constructor(amfEndpoint, operations, amfTypeFactory, typeRegistry, logger) { | ||
constructor(amfEndpoint, operations, amfTypeFactory, typeRegistry, logger, fileParserLogger) { | ||
this.amfEndpoint = amfEndpoint; | ||
this.operations = operations; | ||
this.logger = logger; | ||
this.fileParserLogger = fileParserLogger; | ||
this.path = this.amfEndpoint.path.value(); | ||
@@ -501,3 +503,3 @@ this.uriParameters = {}; | ||
required: param.required.value(), | ||
type: amfTypeFactory(param.schema, typeRegistry, logger, true), | ||
type: amfTypeFactory(param.schema, typeRegistry, logger, fileParserLogger, true), | ||
}; | ||
@@ -514,4 +516,6 @@ }); | ||
class AmfAuraEndpoint extends AmfBaseEndpoint { | ||
constructor(amfEndPoint, operations, amfTypeFactory, typeRegistry, logger) { | ||
super(amfEndPoint, operations, amfTypeFactory, typeRegistry, logger); | ||
constructor(amfEndPoint, operations, amfTypeFactory, typeRegistry, logger, fileParserLogger) { | ||
super(amfEndPoint, operations, amfTypeFactory, typeRegistry, logger, fileParserLogger); | ||
this.logger = logger; | ||
this.fileParserLogger = fileParserLogger; | ||
this.type = 'aura'; | ||
@@ -532,3 +536,3 @@ this.auraController = this.buildAuraController(); | ||
/* NOTE: The type registry is not guaranteed to have any named types until resolve has been called. */ | ||
typeRegistry, factory, logger) { | ||
typeRegistry, factory, logger, fileParserLogger) { | ||
this.shape = shape; | ||
@@ -538,2 +542,3 @@ this.typeRegistry = typeRegistry; | ||
this.logger = logger; | ||
this.fileParserLogger = fileParserLogger; | ||
this.resolved = false; | ||
@@ -548,10 +553,15 @@ this.inherits = []; | ||
// resolve them as well. | ||
this.resolved = true; | ||
this.logger.trace('Running resolution for inherited shapes'); | ||
this.inherits = this.shape.inherits.map((inheritedShape) => { | ||
const result = this.factory(inheritedShape, this.typeRegistry, this.logger); | ||
const result = this.factory(inheritedShape, this.typeRegistry, this.logger, this.fileParserLogger); | ||
result.resolve(); | ||
return result; | ||
}); | ||
this.resolved = true; | ||
this.logger.trace('Running this types resolution'); | ||
this.typeResolve(); | ||
} | ||
else { | ||
this.logger.trace('Type was already resolved'); | ||
} | ||
} | ||
@@ -582,5 +592,5 @@ /* | ||
/* NOTE: The type registry is not guaranteed to have any named types until resolve has been called. */ | ||
typeRegistry, factory, logger) { | ||
typeRegistry, factory, logger, fileParserLogger) { | ||
var _a; | ||
super(shape, typeRegistry, factory, logger); | ||
super(shape, typeRegistry, factory, logger, fileParserLogger); | ||
this.shape = shape; | ||
@@ -590,2 +600,3 @@ this.typeRegistry = typeRegistry; | ||
this.logger = logger; | ||
this.fileParserLogger = fileParserLogger; | ||
this.type = 'object'; | ||
@@ -605,7 +616,10 @@ this.properties = {}; | ||
if (((_a = this.shape.values) === null || _a === void 0 ? void 0 : _a.length) > 0) { | ||
this.logger.error(this.shapePosition, `Type Error (${this.shape.name.value()}). Object type may not specify enum property.`); | ||
this.fileParserLogger.error(this.shapePosition, `Type Error (${this.shape.name.value()}). Object type may not specify enum property.`); | ||
throw new Error(); | ||
} | ||
this.logger.trace('Resolving properties'); | ||
this.resolveProperties(); | ||
this.logger.trace('Resolving additional properties'); | ||
this.resolveAdditionalProperties(); | ||
this.logger.trace('Resolving discriminator'); | ||
this.resolveDiscriminator(this); | ||
@@ -636,3 +650,3 @@ } | ||
const propertyName = property.name.value(); | ||
const type = this.factory(property.range, this.typeRegistry, this.logger, true, propertyName); | ||
const type = this.factory(property.range, this.typeRegistry, this.logger, this.fileParserLogger, true, propertyName); | ||
type.resolve(); | ||
@@ -666,3 +680,3 @@ const propertyType = { | ||
else if (this.shape.additionalPropertiesSchema) { | ||
this.additionalProperties = this.factory(this.shape.additionalPropertiesSchema, this.typeRegistry, this.logger, true); | ||
this.additionalProperties = this.factory(this.shape.additionalPropertiesSchema, this.typeRegistry, this.logger, this.fileParserLogger, true); | ||
} | ||
@@ -674,3 +688,3 @@ } | ||
if (this.typeRegistry.nameOf(this) === undefined) { | ||
this.logger.error(this.shapePosition, 'Cannot use discriminator on inline types.'); | ||
this.fileParserLogger.error(this.shapePosition, 'Cannot use discriminator on inline types.'); | ||
throw new Error(); | ||
@@ -689,3 +703,3 @@ } | ||
if (discriminatedParents.length > 1) { | ||
this.logger.error(this.shapePosition, `Type ${this.typeRegistry.nameOf(t)} cannot inherit from multiple discriminated objects. Inherits from ${discriminatedParents.map((parent) => this.typeRegistry.nameOf(parent))}.`); | ||
this.fileParserLogger.error(this.shapePosition, `Type ${this.typeRegistry.nameOf(t)} cannot inherit from multiple discriminated objects. Inherits from ${discriminatedParents.map((parent) => this.typeRegistry.nameOf(parent))}.`); | ||
throw new Error(); | ||
@@ -707,3 +721,3 @@ } | ||
if (type === undefined) { | ||
this.logger.error(this.shapePosition, `Cannot find type ${typeName}`); | ||
this.fileParserLogger.error(this.shapePosition, `Cannot find type ${typeName}`); | ||
throw new Error(); | ||
@@ -725,4 +739,4 @@ } | ||
class AMFNotTypeImpl extends AMFBaseType { | ||
constructor(shape, typeRegistry, factory, logger) { | ||
super(shape, typeRegistry, factory, logger); | ||
constructor(shape, typeRegistry, factory, logger, fileParserLogger) { | ||
super(shape, typeRegistry, factory, logger, fileParserLogger); | ||
this.shape = shape; | ||
@@ -732,4 +746,5 @@ this.typeRegistry = typeRegistry; | ||
this.logger = logger; | ||
this.fileParserLogger = fileParserLogger; | ||
this.type = 'not'; | ||
this.not = this.factory(this.shape.not, this.typeRegistry, this.logger); | ||
this.not = this.factory(this.shape.not, this.typeRegistry, this.logger, this.fileParserLogger); | ||
} | ||
@@ -785,4 +800,4 @@ } | ||
class AMFDateTimeImpl extends AMFEnumerableScalarType { | ||
constructor(shape, typeRegistry, factory, logger) { | ||
super(shape, typeRegistry, factory, logger); | ||
constructor(shape, typeRegistry, factory, logger, fileParserLogger) { | ||
super(shape, typeRegistry, factory, logger, fileParserLogger); | ||
this.shape = shape; | ||
@@ -820,3 +835,3 @@ this.type = 'datetime'; | ||
this.inherits = inherits.map((inheritedShape) => { | ||
const result = this.factory(inheritedShape, this.typeRegistry, this.logger); | ||
const result = this.factory(inheritedShape, this.typeRegistry, this.logger, this.fileParserLogger); | ||
result.resolve(); | ||
@@ -828,3 +843,3 @@ return result; | ||
this.anyOf = anyOf.map((subTypeShape) => { | ||
const subType = this.factory(subTypeShape, this.typeRegistry, this.logger); | ||
const subType = this.factory(subTypeShape, this.typeRegistry, this.logger, this.fileParserLogger); | ||
subType.resolve(); | ||
@@ -851,3 +866,3 @@ return subType; | ||
*/ | ||
function amfTypeFactory(shape, typeRegistry, logger, resolve = false, propertyName) { | ||
function amfTypeFactory(shape, typeRegistry, logger, fileParserlogger, resolve = false, propertyName) { | ||
var _a; | ||
@@ -867,3 +882,3 @@ const shapeIds = resolveShapeIds(shape, propertyName); | ||
// anyOf not supported, error out | ||
logger.error({ line, column }, `type of shape ${shape.name.value()} not supported: anyOf`); | ||
fileParserlogger.error({ line, column }, `type of shape ${shape.name.value()} not supported: anyOf`); | ||
throw new Error(); | ||
@@ -873,7 +888,7 @@ } | ||
const newShape = rewriteOneOfToUnionShape(shape); | ||
return amfTypeFactory(newShape, typeRegistry, logger, resolve, propertyName); | ||
return amfTypeFactory(newShape, typeRegistry, logger, fileParserlogger, resolve, propertyName); | ||
} | ||
else if (isAllOfShape(shape)) { | ||
const newShape = rewriteAllOfToNodeShape(shape); | ||
return amfTypeFactory(newShape, typeRegistry, logger, resolve, propertyName); | ||
return amfTypeFactory(newShape, typeRegistry, logger, fileParserlogger, resolve, propertyName); | ||
} | ||
@@ -910,3 +925,3 @@ } | ||
default: | ||
logger.error({ line, column }, `type of shape ${shape.name.value()} not recognized`); | ||
fileParserlogger.error({ line, column }, `type of shape ${shape.name.value()} not recognized`); | ||
throw new Error(); | ||
@@ -931,6 +946,6 @@ } | ||
else { | ||
logger.error({ line, column }, `type of shape ${shape.name.value()} not recognized`); | ||
fileParserlogger.error({ line, column }, `type of shape ${shape.name.value()} not recognized`); | ||
throw new Error(); | ||
} | ||
const result = new ctor(shape, typeRegistry, amfTypeFactory, logger); | ||
const result = new ctor(shape, typeRegistry, amfTypeFactory, logger, fileParserlogger); | ||
if (resolve) { | ||
@@ -1004,12 +1019,12 @@ result.resolve(); | ||
if (arrayShape.inherits.length > 0 && arrayShape.items) { | ||
this.logger.error({ line, column }, `RAML Type Error (${name}). Array types cannot inherit and specify items.`); | ||
this.fileParserLogger.error({ line, column }, `RAML Type Error (${name}). Array types cannot inherit and specify items.`); | ||
} | ||
if (arrayShape.inherits.length === 0 && !arrayShape.items) { | ||
this.logger.error({ line, column }, `RAML Type Error (${name}). Array must specify items explicitly or via inheritance.`); | ||
this.fileParserLogger.error({ line, column }, `RAML Type Error (${name}). Array must specify items explicitly or via inheritance.`); | ||
} | ||
if (((_a = this.shape.values) === null || _a === void 0 ? void 0 : _a.length) > 0) { | ||
this.logger.error({ line, column }, `RAML Type Error (${name}). Array type may not specify enum property.`); | ||
this.fileParserLogger.error({ line, column }, `RAML Type Error (${name}). Array type may not specify enum property.`); | ||
} | ||
if (this.shape.items) { | ||
this.items = amfTypeFactory(this.shape.items, this.typeRegistry, this.logger); | ||
this.items = amfTypeFactory(this.shape.items, this.typeRegistry, this.logger, this.fileParserLogger); | ||
this.items.resolve(); | ||
@@ -1033,5 +1048,6 @@ } | ||
class AMFAPI { | ||
constructor(document, logger) { | ||
constructor(document, logger, fileParserlogger) { | ||
this.document = document; | ||
this.logger = logger; | ||
this.fileParserlogger = fileParserlogger; | ||
this.checkAnnotationsVersion(); | ||
@@ -1046,3 +1062,3 @@ } | ||
.map((endPoint) => { | ||
return amfEndpointFactory(endPoint, amfTypeFactory, this.types, this.logger); | ||
return amfEndpointFactory(endPoint, amfTypeFactory, this.types, this.logger, this.fileParserlogger); | ||
}) | ||
@@ -1060,3 +1076,3 @@ .filter((endpoint) => endpoint !== undefined); | ||
required: param.required.value(), | ||
type: amfTypeFactory(param.schema, this.types, this.logger), | ||
type: amfTypeFactory(param.schema, this.types, this.logger, this.fileParserlogger), | ||
}; | ||
@@ -1074,2 +1090,3 @@ }); | ||
if (!this.typeRegistry) { | ||
this.logger.debug('AMFAPI - Building the type registry'); | ||
const typeRegistry = (this.typeRegistry = new BaseTypeRegistry()); | ||
@@ -1085,7 +1102,13 @@ // AMF allows circular references within types. This means that while iterating through | ||
.forEach((shape) => { | ||
const amfType = amfTypeFactory(shape, typeRegistry, this.logger); | ||
const name = shape.name.value(); | ||
this.logger.debug(`AMFAPI - Building AMF Type for ${name}`); | ||
const amfType = amfTypeFactory(shape, typeRegistry, this.logger, this.fileParserlogger); | ||
this.logger.debug(`AMFAPI - Setting ${name} in type registry`); | ||
typeRegistry.set(shape.name.value(), amfType); | ||
}); | ||
// On the 2nd pass we iterate back through all the types in the registry and resolve them. | ||
typeRegistry.forEach((type) => type.resolve()); | ||
typeRegistry.forEach((type, name) => { | ||
this.logger.debug(`AMFAPI - Resolving type ${name}`); | ||
type.resolve(); | ||
}); | ||
} | ||
@@ -1110,4 +1133,4 @@ return this.typeRegistry; | ||
} | ||
async function parseUrl(source, logger) { | ||
return new AMFAPI(await parseAmfDocument(source, logger), logger); | ||
async function parseUrl(source, logger, fileParserLogger) { | ||
return new AMFAPI(await parseAmfDocument(source, fileParserLogger), logger, fileParserLogger); | ||
} | ||
@@ -1147,3 +1170,3 @@ function logResult(result, logger) { | ||
const ramlFilePath = 'filename' in args ? args.filename : args.url.toString(); | ||
return (this._api = await parseUrl(ramlUrl, new DefaultFileParserLogger(this.services, ramlFilePath))); | ||
return (this._api = await parseUrl(ramlUrl, this.services.logger, new DefaultFileParserLogger(this.services, ramlFilePath))); | ||
} | ||
@@ -1150,0 +1173,0 @@ } |
@@ -119,2 +119,3 @@ import amf from 'amf-client-js'; | ||
DiscriminatedDog: typeof amf.AnyShape; | ||
SelfReferencing: typeof amf.AnyShape; | ||
}, {}>; | ||
@@ -121,0 +122,0 @@ amfOneOf: TestRaml<{ |
@@ -1,2 +0,2 @@ | ||
import { type FileParserLogger } from '@luvio/utils'; | ||
import { type FileParserLogger, type LoggerService } from '@luvio/utils'; | ||
import type { AMFType } from './types'; | ||
@@ -11,2 +11,3 @@ import type { API, Server } from '../api'; | ||
private logger; | ||
private fileParserlogger; | ||
typeRegistry?: TypeRegistry<AMFType>; | ||
@@ -16,3 +17,3 @@ _endpoints?: EndPoint[]; | ||
annotationsVersion?: string; | ||
constructor(document: amf.Document, logger: FileParserLogger); | ||
constructor(document: amf.Document, logger: LoggerService, fileParserlogger: FileParserLogger); | ||
get webApi(): amf.WebApi; | ||
@@ -19,0 +20,0 @@ get endpoints(): ReadonlyArray<EndPoint>; |
import type { AuraController, AuraEndPoint, BaseEndPoint, HttpEndPoint, Parameter, Operation } from '../../api'; | ||
import type { AMFType, AMFTypeFactory } from '../types'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
import type amf from 'amf-client-js'; | ||
export type AmfEndPoint = AmfAuraEndpoint | AmfHttpEndPoint; | ||
export declare function amfEndpointFactory(amfEndpoint: amf.EndPoint, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger): AmfEndPoint | undefined; | ||
export declare function amfEndpointFactory(amfEndpoint: amf.EndPoint, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger): AmfEndPoint | undefined; | ||
export declare abstract class AmfBaseEndpoint implements BaseEndPoint { | ||
protected amfEndpoint: amf.EndPoint; | ||
operations: ReadonlyArray<Operation>; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
path: string; | ||
uriParameters: Record<string, Parameter>; | ||
abstract type: 'aura' | 'http'; | ||
constructor(amfEndpoint: amf.EndPoint, operations: ReadonlyArray<Operation>, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfEndpoint: amf.EndPoint, operations: ReadonlyArray<Operation>, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
} | ||
@@ -21,6 +22,8 @@ export declare class AmfHttpEndPoint extends AmfBaseEndpoint implements HttpEndPoint { | ||
export declare class AmfAuraEndpoint extends AmfBaseEndpoint implements AuraEndPoint { | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
readonly type = "aura"; | ||
auraController: AuraController; | ||
constructor(amfEndPoint: amf.EndPoint, operations: Operation[], amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfEndPoint: amf.EndPoint, operations: Operation[], amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildAuraController(): AuraController; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { type FileParserLogger } from '@luvio/utils'; | ||
import { type LoggerService, type FileParserLogger } from '@luvio/utils'; | ||
import type amf from 'amf-client-js'; | ||
@@ -10,3 +10,4 @@ import type { AuraOperationWithoutRequestBody, AuraOperationWithRequestBody, BaseOperation, HttpMethod, Parameter, Payload, Request, Response, HttpOperation, CacheStrategy, ConfigSchemaType, OperationType } from '../../api'; | ||
protected typeRegistry: TypeRegistry<AMFType>; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
method: HttpMethod; | ||
@@ -24,3 +25,3 @@ operationId: string; | ||
abstract readonly type: 'aura' | 'http'; | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildCacheStrategy(): CacheStrategy; | ||
@@ -41,3 +42,3 @@ buildPayloads(r: amf.Request | amf.Response): Payload[]; | ||
}; | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildAuraMethod(): { | ||
@@ -54,3 +55,3 @@ name: string; | ||
}; | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger); | ||
constructor(amfOperation: amf.Operation, amfTypeFactory: AMFTypeFactory, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
buildAuraMethod(): { | ||
@@ -57,0 +58,0 @@ name: string; |
import amf from 'amf-client-js'; | ||
import { AMFAPI } from './AMFAPI'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export declare function parseAmfDocument(source: URL, logger: FileParserLogger): Promise<amf.Document>; | ||
export declare function parseUrl(source: URL, logger: FileParserLogger): Promise<AMFAPI>; | ||
export declare function parseUrl(source: URL, logger: LoggerService, fileParserLogger: FileParserLogger): Promise<AMFAPI>; |
@@ -6,3 +6,3 @@ import type { AMFTypeFactory } from './factory'; | ||
import type { AMFType } from '.'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export declare abstract class AMFBaseType<T extends Type['type'], S extends amf.AnyShape = amf.AnyShape> implements BaseType { | ||
@@ -12,7 +12,8 @@ shape: S; | ||
protected factory: AMFTypeFactory; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
resolved: boolean; | ||
inherits: AMFType[]; | ||
abstract type: T; | ||
constructor(shape: S, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: S, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
resolve(): void; | ||
@@ -19,0 +20,0 @@ typeResolve(): void; |
@@ -6,3 +6,3 @@ import { AMFBaseType } from './AMFBaseType'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export type AMFNotType = AMFTypeProps<amf.NodeShape> & NotType; | ||
@@ -13,6 +13,7 @@ export declare class AMFNotTypeImpl extends AMFBaseType<'not', amf.NodeShape> implements AMFNotType { | ||
protected factory: AMFTypeFactory; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
type: "not"; | ||
not: Type; | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
} |
@@ -6,3 +6,3 @@ import { AMFBaseType } from './AMFBaseType'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export type AMFObjectType = AMFTypeProps<amf.NodeShape> & ObjectType; | ||
@@ -13,3 +13,4 @@ export declare class AMFObjectTypeImpl extends AMFBaseType<'object', amf.NodeShape> implements AMFObjectType { | ||
protected factory: AMFTypeFactory; | ||
protected logger: FileParserLogger; | ||
protected logger: LoggerService; | ||
protected fileParserLogger: FileParserLogger; | ||
type: "object"; | ||
@@ -25,3 +26,3 @@ properties: Record<string, Property>; | ||
private discriminatorProperty; | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: amf.NodeShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
typeResolve(): void; | ||
@@ -28,0 +29,0 @@ get discriminator(): Discriminator | undefined; |
@@ -6,3 +6,3 @@ import { AMFBaseType } from './AMFBaseType'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
export type AMFBooleanType = AMFTypeProps & BooleanType; | ||
@@ -45,4 +45,4 @@ export type AMFDoubleType = AMFTypeProps & DoubleType; | ||
format: typeof DATE | typeof DATE_TIME; | ||
constructor(shape: amf.ScalarShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: FileParserLogger); | ||
constructor(shape: amf.ScalarShape, typeRegistry: TypeRegistry<AMFType>, factory: AMFTypeFactory, logger: LoggerService, fileParserLogger: FileParserLogger); | ||
} | ||
export {}; |
import amf from 'amf-client-js'; | ||
import type { AMFType } from '.'; | ||
import type { TypeRegistry } from '../../types'; | ||
import type { FileParserLogger } from '@luvio/utils'; | ||
import type { FileParserLogger, LoggerService } from '@luvio/utils'; | ||
/** | ||
@@ -16,3 +16,3 @@ * Returns an AMFType that corresponds to a given AMF Shape. | ||
*/ | ||
export declare function amfTypeFactory(shape: amf.Shape, typeRegistry: TypeRegistry<AMFType>, logger: FileParserLogger, resolve?: boolean, propertyName?: string): AMFType; | ||
export declare function amfTypeFactory(shape: amf.Shape, typeRegistry: TypeRegistry<AMFType>, logger: LoggerService, fileParserlogger: FileParserLogger, resolve?: boolean, propertyName?: string): AMFType; | ||
/** | ||
@@ -19,0 +19,0 @@ * Returns the AMF Shape ids that are equivalent to the specified Shape via |
{ | ||
"name": "@luvio/model", | ||
"version": "5.21.0", | ||
"version": "5.21.1-alpha.0", | ||
"description": "Luvio model", | ||
@@ -35,3 +35,3 @@ "repository": { | ||
"devDependencies": { | ||
"@luvio/utils": "5.21.0" | ||
"@luvio/utils": "5.21.1-alpha.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "volta": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
295802
2680
2