@api-client/core 0.14.2 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/ApiFile.d.ts +23 -0
- package/build/src/modeling/ApiFile.d.ts.map +1 -0
- package/build/src/modeling/ApiFile.js +44 -0
- package/build/src/modeling/ApiFile.js.map +1 -0
- package/build/src/modeling/ApiModel.d.ts +159 -0
- package/build/src/modeling/ApiModel.d.ts.map +1 -0
- package/build/src/modeling/ApiModel.js +237 -0
- package/build/src/modeling/ApiModel.js.map +1 -0
- package/build/src/modeling/DataDomain.d.ts +1 -1
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js +1 -3
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainEntity.js +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +1 -2
- package/build/src/modeling/DomainFile.d.ts.map +1 -1
- package/build/src/modeling/DomainFile.js +3 -41
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +55 -8
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +62 -8
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
- package/build/src/modeling/types.d.ts +491 -0
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/models/kinds.d.ts +2 -0
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +2 -0
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/File.d.ts +19 -2
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +100 -13
- package/build/src/models/store/File.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +19 -19
- package/package.json +2 -3
- package/src/modeling/ApiFile.ts +53 -0
- package/src/modeling/ApiModel.ts +327 -0
- package/src/modeling/DataDomain.ts +1 -1
- package/src/modeling/DomainEntity.ts +1 -1
- package/src/modeling/DomainFile.ts +3 -40
- package/src/modeling/Semantics.ts +63 -8
- package/src/modeling/amf/ShapeGenerator.ts +1 -1
- package/src/modeling/types.ts +545 -0
- package/src/models/kinds.ts +2 -0
- package/src/models/store/File.ts +100 -13
- package/tests/unit/modeling/api_model.spec.ts +291 -0
- package/tests/unit/modeling/domain_entity.spec.ts +15 -15
- package/tests/unit/modeling/domain_file.spec.ts +1 -11
- package/tests/unit/modeling/domain_model_entities.spec.ts +2 -2
- package/tests/unit/modeling/semantics.spec.ts +8 -11
- package/tests/unit/models/File/constructor.spec.ts +3 -2
- package/tests/unit/models/File/shortcutTo.spec.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeGenerator.js","sourceRoot":"","sources":["../../../../src/modeling/amf/ShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EAYT,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG5E,MAAM,iBAAi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pC,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,KAAwD,EAAE,MAAiB;QACxG,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAA;QAC7B,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAA;QAC3C,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAA;QAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YACtC,MAAM,CAAC,UAAU,GAAI,KAAwB,CAAC,UAAU,CAAA;QAC1D,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC3C,MAAM,CAAC,UAAU,GAAI,KAAsB,CAAC,UAAU,CAAA;QACxD,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,KAAmB;QAChD,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;;OAOG;IACO,oBAAoB,CAAC,EAAU,EAAE,KAAkB;QAC3D,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { type AssociationBindings, type PropertyWebBindings } from '../Bindings.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainProperty } from '../DomainProperty.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { IAmfExampleTypes, modelTypeToAmfDataType } from '../../amf/AmfTypes.js'\nimport { AmfNamespace } from '../../amf/definitions/Namespace.js'\nimport {\n anyShape,\n arrayShape,\n fileShape,\n IApiAnyShape,\n IApiArrayShape,\n IApiDataExample,\n IApiFileShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiRecursiveShape,\n IApiScalarShape,\n IApiShape,\n IApiUnionShape,\n IShapeUnion,\n nodeShape,\n propertyShape,\n recursiveShape,\n scalarShape,\n unionShape,\n} from '../../amf/definitions/Shapes.js'\nimport { AmfDataNode } from '../../amf/models/AmfDataNode.js'\nimport { DataValueGenerator } from '../../amf/DataValueGenerator.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DomainEntityKind, DomainPropertyKind } from '../../models/kinds.js'\nimport type { PropertySchema } from '../types.js'\n\nconst UNION_TYPE_ANY_OF = 'anyOf'\nconst UNION_TYPE_ALL_OF = 'allOf'\nconst UNION_TYPE_ONE_OF = 'oneOf'\nconst UNION_TYPE_NOT = 'not'\nconst DATA_TYPE_STRING = 'string'\nconst DATA_TYPE_BINARY = 'binary'\n\n/**\n * Serializes Data Domain elements (DomainEntity, DomainProperty, DomainAssociation)\n * to AMF shapes.\n *\n * This class provides a mechanism to translate a data domain model, defined using\n * custom classes like `DomainEntity`, `DomainProperty`, and `DomainAssociation`,\n * into AMF (API Modeling Framework) shapes. AMF shapes are a standardized way\n * to represent API structures and data models, enabling interoperability and tooling.\n *\n * This is particularly useful when you have a custom data model and need to\n * generate API definitions (e.g., RAML or OAS) from it.\n *\n * **Key Features:**\n *\n * - **Data Domain to AMF Translation:** Converts data domain elements into\n * their corresponding AMF shape representations.\n * - **Recursive Shape Handling:** Detects and handles recursive relationships\n * within the data model to prevent infinite loops during shape generation.\n * - **Union Type Support:** Supports the creation of union types in AMF\n * to represent associations that can point to multiple different entity types.\n * - **Binding Integration:** Leverages binding information (e.g., web bindings)\n * to customize the generated AMF shapes based on the target API format.\n * - **Example and Default Value Generation:** Integrates with a `DataValueGenerator`\n * to automatically generate example values and default values for properties\n * within the AMF shapes.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `ShapeGenerator`.\n * 2. Call the appropriate method (e.g., `entity()`, `property()`, `associationShape()`)\n * to generate the AMF shape for a specific data domain element.\n * 3. The returned AMF shape can then be used with other AMF tools to generate\n * API definitions or perform other API-related tasks.\n */\nexport class ShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n // we need a new instance of the generator for each shape generation\n // as the generator is stateful and we need to reset it for each shape.\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes a `DomainEntity` to an AMF node shape.\n *\n * This method is the entry point for converting a `DomainEntity` into its\n * AMF representation. It handles recursive relationships, property serialization,\n * and inheritance from parent entities.\n *\n * @param input The `DomainEntity` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiNodeShape` or `IApiRecursiveShape` representing the entity in AMF.\n * Returns a `IApiRecursiveShape` if a recursive loop is detected.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.entity(myDomainEntity);\n * ```\n */\n entity(input: DomainEntity, visited: Set<string> = new Set<string>()): IApiNodeShape | IApiRecursiveShape {\n if (visited.has(input.key)) {\n // create a recursive shape.\n return this.createRecursiveShape(input)\n }\n visited.add(input.key)\n const result = nodeShape(input.key)\n result.id = input.key\n this.updateBaseProperties(input, result)\n result.properties = []\n for (const item of input.listProperties()) {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const shape = this.property(item)\n result.properties.push(shape)\n }\n for (const assoc of input.listAssociations()) {\n const wb = assoc.readBinding('web') as AssociationBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const prop = this.associationProperty(assoc, visited)\n result.properties.push(prop)\n }\n for (const parent of input.listParents()) {\n const shape = this.entity(parent, visited)\n result.inherits.push(shape)\n }\n return result\n }\n\n /**\n * Serializes a `DomainProperty` to an AMF property shape.\n *\n * This method converts a `DomainProperty` into an `IApiPropertyShape`,\n * defining its characteristics such as data type, required status, and\n * range (the shape of the property's value).\n *\n * @param input The `DomainProperty` to serialize.\n * @returns An `IApiPropertyShape` representing the property in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.property(myDomainProperty);\n * ```\n */\n property(input: DomainProperty): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.getRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this.updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes a `DomainAssociation` to an AMF property shape, handling the\n * association's target entity or entities.\n *\n * This method is similar to `property()`, but it specifically handles\n * associations between entities. It determines the range of the property\n * based on the association's target(s) and generates the appropriate\n * AMF shape (e.g., a scalar shape for a linked schema, a union shape for\n * multiple targets).\n *\n * @param input The `DomainAssociation` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiPropertyShape` representing the association in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.associationProperty(myDomainAssociation);\n * ```\n */\n associationProperty(input: DomainAssociation, visited: Set<string> = new Set<string>()): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, visited)\n\n this.updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DomainAssociation, visited: Set<string> = new Set<string>()): IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n return this.createLinkedShape(input)\n }\n const items = this.associationUnion(input, visited)\n if (!items) {\n return\n }\n if (Array.isArray(items)) {\n return this.createUnionShape(input, items)\n }\n const unionType = (schema && schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_NOT) {\n // Need to investigate more about \"not\" union type.\n // AMF supports it, but I am not sure how to handle it.\n const wrapper = anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * @param input The data association instance.\n * @returns An AMF API scalar shape with the link to the schema.\n */\n protected createLinkedShape(input: DomainAssociation): IApiScalarShape {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType(DATA_TYPE_STRING)\n return range\n }\n\n protected createUnionShape(input: DomainAssociation, items: IShapeUnion[]): IApiUnionShape | IApiArrayShape {\n const range = unionShape(input.key)\n this.updateBaseProperties(input, range)\n range.anyOf = []\n const unionType = (input.schema && input.schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_ANY_OF) {\n range.anyOf = items\n } else if (unionType === UNION_TYPE_ALL_OF) {\n range.and = items\n } else if (unionType === UNION_TYPE_ONE_OF) {\n range.xone = items\n } else {\n // the \"not\" union type only supports a single schema.\n // I am not sure how this should be handled. Will take the first one\n // for now.\n range.not = items[0]\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(\n input: DomainAssociation,\n visited: Set<string> = new Set<string>()\n ): IShapeUnion | IShapeUnion[] | undefined {\n const result: IShapeUnion[] = []\n for (const item of input.listTargets()) {\n result.push(this.entity(item, visited))\n }\n if (!result.length) {\n return undefined\n }\n if (result.length > 1) {\n return result\n }\n return result[0]\n }\n\n /**\n * The DomainProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n */\n protected getRange(input: DomainProperty): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: PropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n const { multiple, type } = input\n if (multiple) {\n return this.createArrayShape(input, schema, bindings)\n }\n if (type === DATA_TYPE_BINARY) {\n return this.createFileShape(input, bindings)\n }\n return this.createScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DomainProperty is multiple\n */\n protected setShapeSchema(\n input: DomainProperty,\n result: IApiAnyShape,\n schema: PropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.noValue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this.createArrayExamples(schema.examples, type)\n } else {\n result.examples = this.createExamples(schema.examples, type)\n }\n }\n }\n\n protected createArrayShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape {\n const result = arrayShape(input.key)\n const { type } = input\n if (type === DATA_TYPE_BINARY) {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this.createFileShape(input, bindings)\n } else {\n result.items = this.createScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as IApiScalarShape).dataType as string\n this.setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected createScalarShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiScalarShape {\n const result = scalarShape(input.key)\n this.updateBaseProperties(input, result)\n this.setScalarCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this.setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected createExamples(examples: string[], type: string): IApiDataExample[] {\n const result: IApiDataExample[] = []\n for (const current of examples) {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n structuredValue: AmfDataNode.scalar(current, type).toJSON(),\n }\n result.push(item)\n }\n return result\n }\n\n protected createArrayExamples(examples: string[], type: string): IApiDataExample[] {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n }\n const value = new AmfDataNode('array')\n for (const item of examples) {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n }\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): IApiFileShape {\n const result = fileShape(input.key)\n this.updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this.setScalarCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected setScalarCommonProperties(\n result: IApiFileShape | IApiScalarShape,\n input: DomainProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n if (bindings?.pattern) {\n result.pattern = bindings.pattern\n }\n const { schema, type } = input\n if (schema) {\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected updateBaseProperties(input: DomainProperty | DomainAssociation | DomainEntity, target: IApiShape): void {\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DomainPropertyKind) {\n target.deprecated = (input as DomainProperty).deprecated\n } else if (input.kind === DomainEntityKind) {\n target.deprecated = (input as DomainEntity).deprecated\n }\n }\n\n protected createRecursiveShape(input: DomainEntity): IApiRecursiveShape {\n return recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n protected refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape {\n const result = arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ShapeGenerator.js","sourceRoot":"","sources":["../../../../src/modeling/amf/ShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EAYT,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG5E,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,cAAc,GAAG,KAAK,CAAA;AAC5B,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AACjC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,cAAc;IACzB,eAAe,CAAqB;IAEpC;;;;OAIG;IACH,IAAI,cAAc;QAChB,oEAAoE;QACpE,uEAAuE;QACvE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,kBAAkB,EAAE,CAAA;QACjD,CAAC;QACD,O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AA;QACxD,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,KAAmB;QAChD,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;;OAOG;IACO,oBAAoB,CAAC,EAAU,EAAE,KAAkB;QAC3D,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { type AssociationBindings, type PropertyWebBindings } from '../Bindings.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainProperty } from '../DomainProperty.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { IAmfExampleTypes, modelTypeToAmfDataType } from '../../amf/AmfTypes.js'\nimport { AmfNamespace } from '../../amf/definitions/Namespace.js'\nimport {\n anyShape,\n arrayShape,\n fileShape,\n IApiAnyShape,\n IApiArrayShape,\n IApiDataExample,\n IApiFileShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiRecursiveShape,\n IApiScalarShape,\n IApiShape,\n IApiUnionShape,\n IShapeUnion,\n nodeShape,\n propertyShape,\n recursiveShape,\n scalarShape,\n unionShape,\n} from '../../amf/definitions/Shapes.js'\nimport { AmfDataNode } from '../../amf/models/AmfDataNode.js'\nimport { DataValueGenerator } from '../../amf/DataValueGenerator.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DomainEntityKind, DomainPropertyKind } from '../../models/kinds.js'\nimport type { PropertySchema } from '../types.js'\n\nconst UNION_TYPE_ANY_OF = 'anyOf'\nconst UNION_TYPE_ALL_OF = 'allOf'\nconst UNION_TYPE_ONE_OF = 'oneOf'\nconst UNION_TYPE_NOT = 'not'\nconst DATA_TYPE_STRING = 'string'\nconst DATA_TYPE_BINARY = 'binary'\n\n/**\n * Serializes Data Domain elements (DomainEntity, DomainProperty, DomainAssociation)\n * to AMF shapes.\n *\n * This class provides a mechanism to translate a data domain model, defined using\n * custom classes like `DomainEntity`, `DomainProperty`, and `DomainAssociation`,\n * into AMF (API Modeling Framework) shapes. AMF shapes are a standardized way\n * to represent API structures and data models, enabling interoperability and tooling.\n *\n * This is particularly useful when you have a custom data model and need to\n * generate API definitions (e.g., RAML or OAS) from it.\n *\n * **Key Features:**\n *\n * - **Data Domain to AMF Translation:** Converts data domain elements into\n * their corresponding AMF shape representations.\n * - **Recursive Shape Handling:** Detects and handles recursive relationships\n * within the data model to prevent infinite loops during shape generation.\n * - **Union Type Support:** Supports the creation of union types in AMF\n * to represent associations that can point to multiple different entity types.\n * - **Binding Integration:** Leverages binding information (e.g., web bindings)\n * to customize the generated AMF shapes based on the target API format.\n * - **Example and Default Value Generation:** Integrates with a `DataValueGenerator`\n * to automatically generate example values and default values for properties\n * within the AMF shapes.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `ShapeGenerator`.\n * 2. Call the appropriate method (e.g., `entity()`, `property()`, `associationShape()`)\n * to generate the AMF shape for a specific data domain element.\n * 3. The returned AMF shape can then be used with other AMF tools to generate\n * API definitions or perform other API-related tasks.\n */\nexport class ShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n // we need a new instance of the generator for each shape generation\n // as the generator is stateful and we need to reset it for each shape.\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes a `DomainEntity` to an AMF node shape.\n *\n * This method is the entry point for converting a `DomainEntity` into its\n * AMF representation. It handles recursive relationships, property serialization,\n * and inheritance from parent entities.\n *\n * @param input The `DomainEntity` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiNodeShape` or `IApiRecursiveShape` representing the entity in AMF.\n * Returns a `IApiRecursiveShape` if a recursive loop is detected.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.entity(myDomainEntity);\n * ```\n */\n entity(input: DomainEntity, visited = new Set<string>()): IApiNodeShape | IApiRecursiveShape {\n if (visited.has(input.key)) {\n // create a recursive shape.\n return this.createRecursiveShape(input)\n }\n visited.add(input.key)\n const result = nodeShape(input.key)\n result.id = input.key\n this.updateBaseProperties(input, result)\n result.properties = []\n for (const item of input.listProperties()) {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const shape = this.property(item)\n result.properties.push(shape)\n }\n for (const assoc of input.listAssociations()) {\n const wb = assoc.readBinding('web') as AssociationBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const prop = this.associationProperty(assoc, visited)\n result.properties.push(prop)\n }\n for (const parent of input.listParents()) {\n const shape = this.entity(parent, visited)\n result.inherits.push(shape)\n }\n return result\n }\n\n /**\n * Serializes a `DomainProperty` to an AMF property shape.\n *\n * This method converts a `DomainProperty` into an `IApiPropertyShape`,\n * defining its characteristics such as data type, required status, and\n * range (the shape of the property's value).\n *\n * @param input The `DomainProperty` to serialize.\n * @returns An `IApiPropertyShape` representing the property in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.property(myDomainProperty);\n * ```\n */\n property(input: DomainProperty): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.getRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this.updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes a `DomainAssociation` to an AMF property shape, handling the\n * association's target entity or entities.\n *\n * This method is similar to `property()`, but it specifically handles\n * associations between entities. It determines the range of the property\n * based on the association's target(s) and generates the appropriate\n * AMF shape (e.g., a scalar shape for a linked schema, a union shape for\n * multiple targets).\n *\n * @param input The `DomainAssociation` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiPropertyShape` representing the association in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.associationProperty(myDomainAssociation);\n * ```\n */\n associationProperty(input: DomainAssociation, visited: Set<string> = new Set<string>()): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, visited)\n\n this.updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DomainAssociation, visited: Set<string> = new Set<string>()): IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n return this.createLinkedShape(input)\n }\n const items = this.associationUnion(input, visited)\n if (!items) {\n return\n }\n if (Array.isArray(items)) {\n return this.createUnionShape(input, items)\n }\n const unionType = (schema && schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_NOT) {\n // Need to investigate more about \"not\" union type.\n // AMF supports it, but I am not sure how to handle it.\n const wrapper = anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * @param input The data association instance.\n * @returns An AMF API scalar shape with the link to the schema.\n */\n protected createLinkedShape(input: DomainAssociation): IApiScalarShape {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType(DATA_TYPE_STRING)\n return range\n }\n\n protected createUnionShape(input: DomainAssociation, items: IShapeUnion[]): IApiUnionShape | IApiArrayShape {\n const range = unionShape(input.key)\n this.updateBaseProperties(input, range)\n range.anyOf = []\n const unionType = (input.schema && input.schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_ANY_OF) {\n range.anyOf = items\n } else if (unionType === UNION_TYPE_ALL_OF) {\n range.and = items\n } else if (unionType === UNION_TYPE_ONE_OF) {\n range.xone = items\n } else {\n // the \"not\" union type only supports a single schema.\n // I am not sure how this should be handled. Will take the first one\n // for now.\n range.not = items[0]\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(\n input: DomainAssociation,\n visited: Set<string> = new Set<string>()\n ): IShapeUnion | IShapeUnion[] | undefined {\n const result: IShapeUnion[] = []\n for (const item of input.listTargets()) {\n result.push(this.entity(item, visited))\n }\n if (!result.length) {\n return undefined\n }\n if (result.length > 1) {\n return result\n }\n return result[0]\n }\n\n /**\n * The DomainProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n */\n protected getRange(input: DomainProperty): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: PropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n const { multiple, type } = input\n if (multiple) {\n return this.createArrayShape(input, schema, bindings)\n }\n if (type === DATA_TYPE_BINARY) {\n return this.createFileShape(input, bindings)\n }\n return this.createScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DomainProperty is multiple\n */\n protected setShapeSchema(\n input: DomainProperty,\n result: IApiAnyShape,\n schema: PropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.noValue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this.createArrayExamples(schema.examples, type)\n } else {\n result.examples = this.createExamples(schema.examples, type)\n }\n }\n }\n\n protected createArrayShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape {\n const result = arrayShape(input.key)\n const { type } = input\n if (type === DATA_TYPE_BINARY) {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this.createFileShape(input, bindings)\n } else {\n result.items = this.createScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as IApiScalarShape).dataType as string\n this.setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected createScalarShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiScalarShape {\n const result = scalarShape(input.key)\n this.updateBaseProperties(input, result)\n this.setScalarCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this.setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected createExamples(examples: string[], type: string): IApiDataExample[] {\n const result: IApiDataExample[] = []\n for (const current of examples) {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n structuredValue: AmfDataNode.scalar(current, type).toJSON(),\n }\n result.push(item)\n }\n return result\n }\n\n protected createArrayExamples(examples: string[], type: string): IApiDataExample[] {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n }\n const value = new AmfDataNode('array')\n for (const item of examples) {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n }\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): IApiFileShape {\n const result = fileShape(input.key)\n this.updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this.setScalarCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected setScalarCommonProperties(\n result: IApiFileShape | IApiScalarShape,\n input: DomainProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n if (bindings?.pattern) {\n result.pattern = bindings.pattern\n }\n const { schema, type } = input\n if (schema) {\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected updateBaseProperties(input: DomainProperty | DomainAssociation | DomainEntity, target: IApiShape): void {\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DomainPropertyKind) {\n target.deprecated = (input as DomainProperty).deprecated\n } else if (input.kind === DomainEntityKind) {\n target.deprecated = (input as DomainEntity).deprecated\n }\n }\n\n protected createRecursiveShape(input: DomainEntity): IApiRecursiveShape {\n return recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n protected refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape {\n const result = arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
|
|
@@ -176,4 +176,495 @@ export type DataDomainGraph = Graph<unknown, DomainGraphNodeType, DomainGraphEdg
|
|
|
176
176
|
* The serialized version of the data domain graph.
|
|
177
177
|
*/
|
|
178
178
|
export type SerializedGraph = GraphJson<unknown, object, DomainGraphEdge>;
|
|
179
|
+
/**
|
|
180
|
+
* Represents a standardized, machine-readable error response body
|
|
181
|
+
* as defined by RFC 7807 for HTTP APIs.
|
|
182
|
+
*/
|
|
183
|
+
export interface ProblemDetails {
|
|
184
|
+
/**
|
|
185
|
+
* A URI that identifies the specific problem type. Should resolve to human-readable docs.
|
|
186
|
+
* e.g., "https://docs.apinow.app/errors/validation-failed"
|
|
187
|
+
*/
|
|
188
|
+
type: string;
|
|
189
|
+
/**
|
|
190
|
+
* A short, human-readable summary of the problem type.
|
|
191
|
+
* e.g., "Validation Error"
|
|
192
|
+
*/
|
|
193
|
+
title: string;
|
|
194
|
+
/**
|
|
195
|
+
* The HTTP status code generated by the origin server for this problem.
|
|
196
|
+
*/
|
|
197
|
+
status?: number;
|
|
198
|
+
/**
|
|
199
|
+
* A human-readable explanation specific to this occurrence of the problem.
|
|
200
|
+
*/
|
|
201
|
+
detail?: string;
|
|
202
|
+
/**
|
|
203
|
+
* A URI that identifies the specific occurrence of the problem.
|
|
204
|
+
* Can be the API request path that caused the error.
|
|
205
|
+
*/
|
|
206
|
+
instance: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The set of supported filter operators for the List action.
|
|
210
|
+
* These are used in query parameters, e.g., ?price[gte]=100
|
|
211
|
+
*
|
|
212
|
+
* - eq: Equal
|
|
213
|
+
* - nq: Not Equal
|
|
214
|
+
* - lt: Less Than
|
|
215
|
+
* - lte: Less Than or Equal
|
|
216
|
+
* - gt: Greater Than
|
|
217
|
+
* - gte: Greater Than or Equal
|
|
218
|
+
* - ex: Checks if the field exists
|
|
219
|
+
* - re: Regular expression match
|
|
220
|
+
* - bf: Date before a specific value
|
|
221
|
+
* - af: Date after a specific value
|
|
222
|
+
* - cn: String contains substring / Array contains element
|
|
223
|
+
* - st: String starts with
|
|
224
|
+
* - end: String ends with
|
|
225
|
+
* - in: Value is one of the elements in the provided array
|
|
226
|
+
* - nin: Value is not one of the elements in the provided array
|
|
227
|
+
*/
|
|
228
|
+
export type ResourceFilterOperator = 'eq' | 'nq' | 'lt' | 'lte' | 'gt' | 'gte' | 'ex' | 're' | 'bf' | 'af' | 'cn' | 'st' | 'end' | 'in' | 'nin';
|
|
229
|
+
/**
|
|
230
|
+
* The session transport configuration interface.
|
|
231
|
+
* This defines the properties that are common to all session transports.
|
|
232
|
+
*/
|
|
233
|
+
interface SessionTransport {
|
|
234
|
+
/**
|
|
235
|
+
* Whether the session transport is enabled.
|
|
236
|
+
*/
|
|
237
|
+
enabled: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* The kind of session transport. Each interface defines its own kind.
|
|
240
|
+
*/
|
|
241
|
+
kind: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Configuration for cookie-based session transport.
|
|
245
|
+
*/
|
|
246
|
+
export interface CookieConfiguration extends SessionTransport {
|
|
247
|
+
kind: 'cookie';
|
|
248
|
+
/**
|
|
249
|
+
* The lifetime of the cookie session.
|
|
250
|
+
* This is a string representing the duration, e.g., "7d" for 7 days or "24h" for 24 hours.
|
|
251
|
+
*
|
|
252
|
+
* @default "7d"
|
|
253
|
+
*/
|
|
254
|
+
lifetime: string;
|
|
255
|
+
/**
|
|
256
|
+
* Whether the cookie can only be accessed by the server.
|
|
257
|
+
* This is a security feature to prevent client-side scripts from accessing the cookie.
|
|
258
|
+
* If set to false, the cookie can be accessed by client-side scripts.
|
|
259
|
+
* @default true
|
|
260
|
+
*/
|
|
261
|
+
httpOnly: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the cookie should only be sent over secure connections (HTTPS).
|
|
264
|
+
* This is a security feature to prevent the cookie from being sent over unencrypted connections.
|
|
265
|
+
* @default true
|
|
266
|
+
*/
|
|
267
|
+
secure: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* The SameSite attribute of the cookie.
|
|
270
|
+
* This attribute controls whether the cookie is sent with cross-site requests.
|
|
271
|
+
* - 'none' means the cookie is sent with cross-site requests.
|
|
272
|
+
* - 'lax' means the cookie is sent with top-level navigations and will be sent along with GET
|
|
273
|
+
* requests initiated by third-party websites.
|
|
274
|
+
* @default 'none'
|
|
275
|
+
*/
|
|
276
|
+
sameSite: 'none' | 'lax';
|
|
277
|
+
/**
|
|
278
|
+
* The name of the cookie.
|
|
279
|
+
* This is the key under which the session data will be stored in the cookie.
|
|
280
|
+
* @default 'as' - 'as' stands for "api session"
|
|
281
|
+
*/
|
|
282
|
+
name: string;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Configuration for JWT-based session transport.
|
|
286
|
+
*/
|
|
287
|
+
export interface JwtConfiguration extends SessionTransport {
|
|
288
|
+
kind: 'jwt';
|
|
289
|
+
/**
|
|
290
|
+
* The lifetime of the JWT token.
|
|
291
|
+
* This is a string representing the duration, e.g., "7d" for 7 days or "15m" for 15 minutes.
|
|
292
|
+
*
|
|
293
|
+
* @default "7d"
|
|
294
|
+
*/
|
|
295
|
+
lifetime: string;
|
|
296
|
+
}
|
|
297
|
+
export interface SessionConfiguration {
|
|
298
|
+
/**
|
|
299
|
+
* The secret used to sign the JWT and cookies. Should be handled securely.
|
|
300
|
+
* Not visible in the UI after being set.
|
|
301
|
+
*/
|
|
302
|
+
secret: string;
|
|
303
|
+
/**
|
|
304
|
+
* The properties from the `User` entity to be encoded into the session payload (JWT/cookie).
|
|
305
|
+
* These properties become available in the `request.auth` object at runtime.
|
|
306
|
+
*/
|
|
307
|
+
properties: string[];
|
|
308
|
+
/**
|
|
309
|
+
* The cookie-based session transport configuration.
|
|
310
|
+
*/
|
|
311
|
+
cookie?: CookieConfiguration;
|
|
312
|
+
/**
|
|
313
|
+
* The JWT-based session transport configuration.
|
|
314
|
+
*/
|
|
315
|
+
jwt?: JwtConfiguration;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Defines the authorization strategy for the API.
|
|
319
|
+
* It is a base interface that can be extended for different strategies.
|
|
320
|
+
* For MVP, we will start with Roles-Based Access Control (RBAC).
|
|
321
|
+
*/
|
|
322
|
+
export interface AuthorizationConfiguration {
|
|
323
|
+
/**
|
|
324
|
+
* The authorization strategy. For MVP, we will start with RBAC.
|
|
325
|
+
* Post-MVP will include Permission-Based Access Control (PBAC).
|
|
326
|
+
* The strategy determines how users are granted access to resources.
|
|
327
|
+
*
|
|
328
|
+
* - RBAC (Roles-Based Access Control): Users are assigned roles, and permissions are granted to those roles.
|
|
329
|
+
* - PBAC (Permission-Based Access Control): Users are granted permissions directly, allowing for more
|
|
330
|
+
* granular control.
|
|
331
|
+
*/
|
|
332
|
+
strategy: string;
|
|
333
|
+
}
|
|
334
|
+
export interface RolesBasedAccessControl extends AuthorizationConfiguration {
|
|
335
|
+
strategy: 'RBAC';
|
|
336
|
+
/**
|
|
337
|
+
* The property within the designated "User" entity that defines the user's role.
|
|
338
|
+
* This field is used in access rules to grant permissions.
|
|
339
|
+
*
|
|
340
|
+
* This property must be marked with the "Role" data semantic in the Data Modeler.
|
|
341
|
+
* It is required to publish the API.
|
|
342
|
+
*/
|
|
343
|
+
roleKey: string;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Configures the strategy for authenticating end-users.
|
|
347
|
+
* An API can only support one authentication strategy at a time.
|
|
348
|
+
* This is a base interface that can be extended for different strategies.
|
|
349
|
+
*/
|
|
350
|
+
export interface AuthenticationConfiguration {
|
|
351
|
+
/**
|
|
352
|
+
* The authentication method. For MVP, this is focused on username/password.
|
|
353
|
+
* This can be extended in the future to include 'SSO'.
|
|
354
|
+
*/
|
|
355
|
+
strategy: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Configuration for username/password authentication.
|
|
359
|
+
* This is the primary authentication method for the API (MVP).
|
|
360
|
+
*/
|
|
361
|
+
export interface UsernamePasswordConfiguration extends AuthenticationConfiguration {
|
|
362
|
+
strategy: 'UsernamePassword';
|
|
363
|
+
/**
|
|
364
|
+
* The specific property within the User entity that holds the password.
|
|
365
|
+
* This property must be marked with the "Password" data semantic in the Data Modeler.
|
|
366
|
+
*
|
|
367
|
+
* This property is required to publish the API.
|
|
368
|
+
*/
|
|
369
|
+
passwordKey?: string;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Represents a Data Entity from the Data Domain that the API will expose and operate upon.
|
|
373
|
+
*/
|
|
374
|
+
export interface ExposedEntity {
|
|
375
|
+
/**
|
|
376
|
+
* The key of the Data Entity from the Data Domain.
|
|
377
|
+
*/
|
|
378
|
+
key: string;
|
|
379
|
+
/**
|
|
380
|
+
* Optional configuration for resource-wide rate limiting and throttling.
|
|
381
|
+
* Defines rules to protect the resource from overuse.
|
|
382
|
+
*/
|
|
383
|
+
rateLimiting?: RateLimitingConfiguration;
|
|
384
|
+
/**
|
|
385
|
+
* Access control rules defining who can perform actions on this resource or collection.
|
|
386
|
+
* It override the top-level access rules defined in the API model.
|
|
387
|
+
*/
|
|
388
|
+
accessRule?: AccessRule[];
|
|
389
|
+
/**
|
|
390
|
+
* The collection of API actions (e.g., List, Read, Create) enabled for this entity.
|
|
391
|
+
*/
|
|
392
|
+
actions: ApiAction[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Represents a specific, configurable API operation applied to a Data Entity.
|
|
396
|
+
* Corresponds to common RESTful interactions.
|
|
397
|
+
*/
|
|
398
|
+
export type ApiAction = ListAction | ReadAction | CreateAction | UpdateAction | DeleteAction | SearchAction;
|
|
399
|
+
/**
|
|
400
|
+
* A base interface for common properties across all actions.
|
|
401
|
+
*/
|
|
402
|
+
interface Action {
|
|
403
|
+
/**
|
|
404
|
+
* The specific kind of action (e.g., 'List', 'Read', etc.)
|
|
405
|
+
*/
|
|
406
|
+
kind: string;
|
|
407
|
+
/**
|
|
408
|
+
* Access control rules defining who can perform this action. It is only applied if the
|
|
409
|
+
* authorization strategy is set to 'RBAC'.
|
|
410
|
+
* If no rules grant access, it's denied by default making it essentially private.
|
|
411
|
+
*
|
|
412
|
+
* Note, the API can defined top level access rules that apply to all actions. If this property is set,
|
|
413
|
+
* it overrides the top level access rules for this specific action.
|
|
414
|
+
*
|
|
415
|
+
* It is an ordered list, meaning the first rule that matches the user will be applied.
|
|
416
|
+
* If multiple rules match, the first one in the list takes precedence.
|
|
417
|
+
* If no rules match, the action is denied.
|
|
418
|
+
*/
|
|
419
|
+
accessRule?: AccessRule[];
|
|
420
|
+
/**
|
|
421
|
+
* Optional configuration for action-wide rate limiting and throttling.
|
|
422
|
+
* Defines rules to protect the action from overuse.
|
|
423
|
+
*/
|
|
424
|
+
rateLimiting?: RateLimitingConfiguration;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Represents a pagination strategy for API actions that return collections of resources.
|
|
428
|
+
* This is a base interface that can be extended for different pagination strategies.
|
|
429
|
+
*/
|
|
430
|
+
export interface PaginationStrategy {
|
|
431
|
+
/**
|
|
432
|
+
* The kind of pagination strategy. This is used to identify the specific pagination method.
|
|
433
|
+
* For example, 'cursor' for cursor-based pagination or 'offset' for offset-based pagination.
|
|
434
|
+
*/
|
|
435
|
+
kind: string;
|
|
436
|
+
/**
|
|
437
|
+
* The default page size for the pagination strategy.
|
|
438
|
+
* This is the number of items returned per page when no specific page size is requested.
|
|
439
|
+
*/
|
|
440
|
+
pageSize?: number;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Represents the cursor-based pagination strategy.
|
|
444
|
+
*/
|
|
445
|
+
export interface CursorPaginationStrategy extends PaginationStrategy {
|
|
446
|
+
kind: 'cursor';
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Represents the offset-based pagination strategy.
|
|
450
|
+
*/
|
|
451
|
+
export interface OffsetPaginationStrategy extends PaginationStrategy {
|
|
452
|
+
kind: 'offset';
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Enables retrieving a collection of resources.
|
|
456
|
+
* Endpoint: GET /[entity-collection-name]
|
|
457
|
+
*/
|
|
458
|
+
export interface ListAction extends Action {
|
|
459
|
+
kind: 'list';
|
|
460
|
+
/**
|
|
461
|
+
* The pagination strategy used for this action.
|
|
462
|
+
* This defines how the results are paginated when retrieving a collection of resources.
|
|
463
|
+
* It can be either 'cursor' or 'offset'.
|
|
464
|
+
*/
|
|
465
|
+
pagination: PaginationStrategy;
|
|
466
|
+
/**
|
|
467
|
+
* Fields from the entity that can be used for filtering.
|
|
468
|
+
* Must be marked as "indexable" in the Data Model.
|
|
469
|
+
*/
|
|
470
|
+
filterableFields: string[];
|
|
471
|
+
/**
|
|
472
|
+
* Fields from the entity that can be used for sorting.
|
|
473
|
+
*/
|
|
474
|
+
sortableFields: string[];
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Enables retrieving a single resource by its ID.
|
|
478
|
+
* Endpoint: GET /[entity-collection-name]/{id}
|
|
479
|
+
*/
|
|
480
|
+
export interface ReadAction extends Action {
|
|
481
|
+
kind: 'read';
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Enables adding a new resource to a collection.
|
|
485
|
+
* Endpoint: POST /[entity-collection-name]
|
|
486
|
+
*/
|
|
487
|
+
export interface CreateAction extends Action {
|
|
488
|
+
kind: 'create';
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Enables modifying an existing resource.
|
|
492
|
+
* Endpoints: PUT or PATCH /[entity-collection-name]/{id}
|
|
493
|
+
*/
|
|
494
|
+
export interface UpdateAction extends Action {
|
|
495
|
+
kind: 'update';
|
|
496
|
+
/**
|
|
497
|
+
* The allowed HTTP methods for updates. Default: PATCH only.
|
|
498
|
+
*
|
|
499
|
+
* These two methods represent the two common ways to update a resource:
|
|
500
|
+
* - PUT: Replaces the entire resource with the provided data.
|
|
501
|
+
* - PATCH: Applies a partial update to the resource, allowing for specific fields to be modified.
|
|
502
|
+
*/
|
|
503
|
+
allowedMethods: ('PUT' | 'PATCH')[];
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Enables removing an existing resource.
|
|
507
|
+
* Endpoint: DELETE /[entity-collection-name]/{id}
|
|
508
|
+
*/
|
|
509
|
+
export interface DeleteAction extends Action {
|
|
510
|
+
kind: 'delete';
|
|
511
|
+
/**
|
|
512
|
+
* The strategy for deletion. Default: Soft Delete.
|
|
513
|
+
*
|
|
514
|
+
* @default 'soft'
|
|
515
|
+
*/
|
|
516
|
+
strategy?: 'soft' | 'hard';
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Enables keyword-based search across specified fields.
|
|
520
|
+
* Endpoint: GET /[entity-collection-name]/search
|
|
521
|
+
*/
|
|
522
|
+
export interface SearchAction extends Action {
|
|
523
|
+
kind: 'search';
|
|
524
|
+
/**
|
|
525
|
+
* The fields within the entity to be included in the search scope.
|
|
526
|
+
* Must be "indexable" and typically text-based.
|
|
527
|
+
*/
|
|
528
|
+
fields: string[];
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Defines the access control policy for a specific API action.
|
|
532
|
+
* Based on the predefined rule types for session-based authentication.
|
|
533
|
+
*/
|
|
534
|
+
export type AccessRule = AllowPublicAccessRule | AllowAuthenticatedAccessRule | MatchResourceOwnerAccessRule | MatchUserRoleAccessRule | MatchUserPropertyAccessRule | MatchEmailDomainAccessRule;
|
|
535
|
+
export interface BaseAccessRule {
|
|
536
|
+
/**
|
|
537
|
+
* The unique identifier for the access rule.
|
|
538
|
+
* This is used to reference the rule in the API configuration.
|
|
539
|
+
*/
|
|
540
|
+
type: string;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* The action is allowed for all users, including unauthenticated ones.
|
|
544
|
+
* This is typically used for public APIs or resources that do not require authentication.
|
|
545
|
+
* It is the most permissive rule and should be used with caution.
|
|
546
|
+
*/
|
|
547
|
+
export interface AllowPublicAccessRule extends BaseAccessRule {
|
|
548
|
+
type: 'public';
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* The action is allowed for any authenticated user.
|
|
552
|
+
* This rule does not impose any additional restrictions based on user properties or resource ownership.
|
|
553
|
+
* It is used for resources that should be accessible to all logged-in users.
|
|
554
|
+
*/
|
|
555
|
+
export interface AllowAuthenticatedAccessRule extends BaseAccessRule {
|
|
556
|
+
type: 'authenticated';
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* The action is allowed if the authenticated user's ID matches a specific property on the resource.
|
|
560
|
+
* This is typically used to restrict access to resources owned by the user.
|
|
561
|
+
* For example, a user can only access their own profile or documents.
|
|
562
|
+
*/
|
|
563
|
+
export interface MatchResourceOwnerAccessRule extends BaseAccessRule {
|
|
564
|
+
type: 'resourceOwner';
|
|
565
|
+
/**
|
|
566
|
+
* The property on the resource that should match the authenticated user's ID.
|
|
567
|
+
* This is typically the ID of the user who owns the resource.
|
|
568
|
+
*
|
|
569
|
+
* The domain model should annotate this property with the "ResourceOwnerIdentifier" semantic
|
|
570
|
+
* to indicate that it is used for ownership checks.
|
|
571
|
+
*/
|
|
572
|
+
property: string;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* The action is allowed if the authenticated user has a specific role.
|
|
576
|
+
* This is used to enforce role-based access control (RBAC).
|
|
577
|
+
* For example, only users with the "admin" role can perform certain actions.
|
|
578
|
+
*/
|
|
579
|
+
export interface MatchUserRoleAccessRule extends BaseAccessRule {
|
|
580
|
+
type: 'matchUserRole';
|
|
581
|
+
/**
|
|
582
|
+
* The role that the authenticated user must have to access the resource.
|
|
583
|
+
* This is typically a property on the user entity that defines their role.
|
|
584
|
+
*
|
|
585
|
+
* The domain model should annotate this property with the "UserRole" semantic
|
|
586
|
+
* to indicate that it is used for role-based access control.
|
|
587
|
+
*/
|
|
588
|
+
role: string;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* The action is allowed if a specific property on the authenticated user matches an expected value.
|
|
592
|
+
* This is used to enforce other user-specific restrictions.
|
|
593
|
+
*/
|
|
594
|
+
export interface MatchUserPropertyAccessRule extends BaseAccessRule {
|
|
595
|
+
type: 'matchUserProperty';
|
|
596
|
+
/**
|
|
597
|
+
* The property on the authenticated user that should match the expected value.
|
|
598
|
+
*/
|
|
599
|
+
property: string;
|
|
600
|
+
/**
|
|
601
|
+
* The expected value for the user property.
|
|
602
|
+
*/
|
|
603
|
+
value: string;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* The action is allowed if the authenticated user's email domain matches a specific domain.
|
|
607
|
+
* This is used to restrict access based on the user's email address.
|
|
608
|
+
* For example, only users with an email address from "mycompany.com" can access certain resources.
|
|
609
|
+
*/
|
|
610
|
+
export interface MatchEmailDomainAccessRule extends BaseAccessRule {
|
|
611
|
+
type: 'matchEmailDomain';
|
|
612
|
+
/**
|
|
613
|
+
* The email domain that the authenticated user's email must match.
|
|
614
|
+
*/
|
|
615
|
+
domain: string;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Defines the rate limiting and throttling policies for the entire API.
|
|
619
|
+
*/
|
|
620
|
+
export interface RateLimitingConfiguration {
|
|
621
|
+
/**
|
|
622
|
+
* An ordered list of rules. The first rule that matches an incoming
|
|
623
|
+
* request will be applied.
|
|
624
|
+
*/
|
|
625
|
+
rules: RateLimitRule[];
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Represents a single rate limiting rule that applies to a specific
|
|
629
|
+
* type of client, using a token bucket algorithm.
|
|
630
|
+
*/
|
|
631
|
+
export interface RateLimitRule {
|
|
632
|
+
/**
|
|
633
|
+
* A human-readable description of what this rule is for.
|
|
634
|
+
* e.g., "Limit anonymous users to 60 requests per hour."
|
|
635
|
+
*/
|
|
636
|
+
description?: string;
|
|
637
|
+
/**
|
|
638
|
+
* Defines how to group requests for rate limiting. This determines
|
|
639
|
+
* who the limit applies to.
|
|
640
|
+
*
|
|
641
|
+
* - 'ip': Keys on the client's IP address. Best for anonymous traffic.
|
|
642
|
+
* - 'userId': Keys on the authenticated user's ID. Best for logged-in users.
|
|
643
|
+
* - 'role': Applies a shared limit to all users of a specific role.
|
|
644
|
+
*/
|
|
645
|
+
key: {
|
|
646
|
+
type: 'ip';
|
|
647
|
+
} | {
|
|
648
|
+
type: 'userId';
|
|
649
|
+
} | {
|
|
650
|
+
type: 'role';
|
|
651
|
+
value: string;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* The number of requests allowed over the defined interval.
|
|
655
|
+
* This is the rate at which tokens are added to the bucket.
|
|
656
|
+
*/
|
|
657
|
+
rate: number;
|
|
658
|
+
/**
|
|
659
|
+
* The time interval for the rate.
|
|
660
|
+
*/
|
|
661
|
+
interval: 'second' | 'minute' | 'hour' | 'day';
|
|
662
|
+
/**
|
|
663
|
+
* The maximum number of requests that can be made in a burst.
|
|
664
|
+
* This represents the "bucket size." A larger burst allows for
|
|
665
|
+
* more requests to be made in a short period before throttling begins.
|
|
666
|
+
*/
|
|
667
|
+
burst: number;
|
|
668
|
+
}
|
|
669
|
+
export {};
|
|
179
670
|
//# sourceMappingURL=types.d.ts.map
|