@api-client/core 0.18.16 → 0.18.17
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/modeling/DataDomain.d.ts +7 -2
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js +15 -2
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainSerialization.d.ts +6 -3
- package/build/src/modeling/DomainSerialization.d.ts.map +1 -1
- package/build/src/modeling/DomainSerialization.js +374 -52
- package/build/src/modeling/DomainSerialization.js.map +1 -1
- package/build/src/modeling/types.d.ts +69 -2
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +12 -12
- package/package.json +1 -1
- package/src/modeling/DataDomain.ts +24 -3
- package/src/modeling/DomainSerialization.ts +442 -56
- package/src/modeling/types.ts +73 -2
- package/tests/unit/modeling/data_domain_serialization.spec.ts +504 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainSerialization.js","sourceRoot":"","sources":["../../../src/modeling/DomainSerialization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAExD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAA;AAElF,OAAO,EAAE,WAAW,EAA0B,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,YAAY,EAAsB,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAA;AAanF,SAAS,UAAU,CAAC,CAAkB,EAAE,SAAiB;IACvD,MAAM,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,IAAI,CAAC,KAAK,EAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;YAC9E,CAAC;YACD,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACxB,iEAAiE;gBACjE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC/B,mEAAmE;oBACnE,SAAQ;gBACV,CAAC;YACH,CAAC;YACD,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3D,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC/C,iFAAiF;oBACjF,SAAQ;gBACV,CAAC;YACH,CAAC;YACD,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;QACtE,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC","sourcesContent":["import type { JsonEdge, Node } from '@api-client/graph/graph/types.js'\nimport { Graph } from '@api-client/graph/graph/Graph.js'\nimport type { DataDomainGraph, DomainGraphEdge, DomainGraphNodeType, SerializedGraph } from './types.js'\nimport {\n DomainAssociationKind,\n DomainEntityKind,\n DomainModelKind,\n DomainNamespaceKind,\n DomainPropertyKind,\n} from '../models/kinds.js'\nimport { DomainNamespace, type DomainNamespaceSchema } from './DomainNamespace.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { DomainModel, type DomainModelSchema } from './DomainModel.js'\nimport { DomainEntity, DomainEntitySchema } from './DomainEntity.js'\nimport { DomainProperty, DomainPropertySchema } from './DomainProperty.js'\nimport { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'\n\ninterface GraphMergeResult {\n /**\n * The set of node ids generated for the foreign nodes.\n */\n nodes: Set<string>\n /**\n * The set of edge ids generated for the foreign edges.\n */\n edges: Set<string>\n}\n\nfunction writeNodes(g: DataDomainGraph, domainKey: string): Node<object>[] {\n const result: Node<object>[] = []\n for (const v of g.nodes()) {\n const nodeValue = g.node(v)\n if (!nodeValue || nodeValue.domain.key !== domainKey) {\n // Filter out foreign nodes\n continue\n }\n // We do only use single parent for the graph. Potentially this could be\n // replaced with the `g.parent(v)` method.\n const parents = [...g.parents(v)]\n const node: Node<object> = { v }\n node.value = nodeValue.toJSON()\n if (parents.length) {\n node.parents = parents\n }\n result.push(node)\n }\n return result\n}\n\nfunction writeEdges(g: DataDomainGraph, domainKey: string): JsonEdge<DomainGraphEdge>[] {\n const result: JsonEdge<DomainGraphEdge>[] = []\n for (const e of g.edges()) {\n const edgeValue = g.edge(e)\n if (!edgeValue) {\n continue\n }\n const sourceNode = g.node(e.v)\n const targetNode = g.node(e.w)\n if (!sourceNode || !targetNode) {\n continue\n }\n if (sourceNode.domain.key !== domainKey) {\n // Filter out edges starting from foreign nodes. These are foreign associations\n // that have nothing to do with the current domain.\n continue\n }\n if (targetNode.domain.key !== domainKey && edgeValue.type !== 'association' && edgeValue.type !== 'parent') {\n // Filter out edges to foreign nodes except for associations and parent-child relations\n continue\n }\n const edge: JsonEdge<DomainGraphEdge> = { v: e.v, w: e.w }\n if (e.name) {\n edge.name = e.name\n }\n edge.value = structuredClone(edgeValue)\n result.push(edge)\n }\n return result\n}\n\nexport function serialize(g: DataDomainGraph, domainKey: string): SerializedGraph {\n const json: SerializedGraph = {\n options: {\n directed: g.isDirected(),\n multigraph: g.isMultigraph(),\n compound: g.isCompound(),\n },\n nodes: writeNodes(g, domainKey),\n edges: writeEdges(g, domainKey),\n }\n return json\n}\n\n/**\n * Removes all foreign nodes, edges, and parents from the graph.\n * @param g The graph to remove the foreign nodes from\n * @param domainKey The key of the domain to remove\n */\nexport function removeForeignGraph(g: DataDomainGraph, domainKey: string): void {\n for (const node of g.nodes()) {\n const nodeValue = g.node(node)\n if (!nodeValue) {\n continue\n }\n if (nodeValue.domain.key === domainKey) {\n // This is a foreign node, remove it from the graph.\n g.removeNode(node)\n // When a node is removed, all edges and parents are removed as well.\n // No need to iterate over them.\n }\n }\n}\n\n/**\n * Merges a foreign domain graph into the current domain graph.\n * @param own Our domain graph\n * @param foreign The foreign domain graph\n * @param domain The key of the foreign domain\n */\nexport function mergeGraph(own: DataDomainGraph, foreign: DataDomainGraph, domain: string): GraphMergeResult {\n const nodes = new Set<string>()\n const edges = new Set<string>()\n // Copy nodes\n for (const node of foreign.nodes()) {\n const foreignNode = foreign.node(node)\n if (!foreignNode) {\n continue\n }\n const foreignKey = `${domain}:${node}`\n own.setNode(foreignKey, foreignNode)\n nodes.add(foreignKey)\n }\n // Copy edges\n for (const edge of foreign.edges()) {\n const label = foreign.edge(edge)\n if (!label) {\n continue\n }\n const foreignSource = `${domain}:${edge.v}`\n const foreignTarget = `${domain}:${edge.w}`\n // const foreignEdge = foreign.edge(edge)\n own.setEdge(foreignSource, foreignTarget, {\n foreign: true,\n domain,\n ...label,\n })\n edges.add(`${foreignSource}|${foreignTarget}`)\n }\n const notRootEntities = new Set<string>()\n // Copy parent-child relationships\n for (const node of foreign.nodes()) {\n const foreignNodeKey = `${domain}:${node}`\n for (const parent of foreign.parents(node)) {\n const foreignParentKey = `${domain}:${parent}`\n const srcNode = own.node(foreignNodeKey) as DomainGraphNodeType\n const targetNode = own.node(foreignParentKey) as DomainGraphNodeType\n if (srcNode.kind === DomainEntityKind && targetNode.kind === DomainEntityKind) {\n // entities can have multiple parents between them. We need to respect that.\n if (!notRootEntities.has(foreignNodeKey)) {\n // We use `setParent` in the first run to remove the entity from the root\n // of the graph.\n notRootEntities.add(foreignNodeKey)\n own.setParent(foreignNodeKey, foreignParentKey)\n } else {\n own.addParent(foreignNodeKey, foreignParentKey)\n }\n } else {\n // other nodes can only have a single parent.\n own.setParent(foreignNodeKey, foreignParentKey)\n }\n }\n }\n return {\n nodes,\n edges,\n }\n}\n\n/**\n * Properties and associations are stored as nodes with edges to the parent entity in the graph.\n * At the time of restoring these nodes, the graph has no edges yet.\n * This function finds the parent of the child node in the edges list.\n * @param child The DomainProperty or DomainAssociation key\n * @param edges The list of serialized graph edges\n * @returns The parent key of the child or undefined if not found\n */\nfunction findEdgeParent(child: string, edges: JsonEdge<DomainGraphEdge>[]): string | undefined {\n for (const edge of edges) {\n if (edge.w === child) {\n return edge.v\n }\n }\n return undefined\n}\n\n/**\n * Restores the previously serialized node entry.\n * @param root The DataDomain instance to use as the root for the graph\n * @param entry The node entry to restore\n * @param edges The list of serialized graph edges\n * @returns The restored node instance\n * @throws Error if the entry is malformed or the kind is unknown\n */\nfunction prepareNode(root: DataDomain, entry: unknown, edges: JsonEdge<DomainGraphEdge>[]): DomainGraphNodeType {\n if (!entry) {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n const domainElement = entry as { kind?: string }\n if (!domainElement.kind) {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n if (domainElement.kind === DomainNamespaceKind) {\n return new DomainNamespace(root, domainElement as DomainNamespaceSchema)\n }\n if (domainElement.kind === DomainModelKind) {\n return new DomainModel(root, domainElement as DomainModelSchema)\n }\n if (domainElement.kind === DomainEntityKind) {\n return new DomainEntity(root, domainElement as DomainEntitySchema)\n }\n if (domainElement.kind === DomainPropertyKind) {\n const typed = domainElement as DomainPropertySchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return new DomainProperty(root, parent, typed)\n }\n if (domainElement.kind === DomainAssociationKind) {\n const typed = domainElement as DomainAssociationSchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return new DomainAssociation(root, parent, typed)\n }\n throw new Error(`Unable to restore data domain graph. Unknown node kind ${domainElement.kind}`)\n}\n\n/**\n * To deserialize a graph:\n *\n * - Create a new DataDomain instance\n * - Restore all foreign nodes and edges\n * - Call the deserialize function\n *\n * @param root The DataDomain instance to use as the root for the graph\n * @param json The previously serialized graph\n * @returns Deserialized graph instance\n */\nexport function deserialize(root: DataDomain, json?: SerializedGraph, dependencies?: DataDomain[]): DataDomainGraph {\n const g = new Graph<unknown, DomainGraphNodeType, DomainGraphEdge>({\n compound: true,\n multigraph: true,\n directed: true,\n })\n let foreignNodes = new Set<string>()\n let foreignEdges = new Set<string>()\n if (dependencies) {\n for (const dependency of dependencies) {\n const result = mergeGraph(g, dependency.graph, dependency.key)\n if (result.edges.size) {\n foreignEdges = new Set([...foreignEdges, ...result.edges])\n }\n if (result.nodes.size) {\n foreignNodes = new Set([...foreignNodes, ...result.nodes])\n }\n root.dependencies.set(dependency.key, dependency)\n }\n }\n if (!json) {\n return g\n }\n if (Array.isArray(json.nodes)) {\n // 1st pass - set up nodes\n const parentInfo = new Map<string, string[]>()\n for (const entry of json.nodes) {\n g.setNode(entry.v, prepareNode(root, entry.value, json.edges))\n if (entry.parents) {\n parentInfo.set(entry.v, entry.parents)\n }\n }\n // 2nd pass - set up parents\n for (const [key, parents] of parentInfo) {\n // In data domain graph, all nodes that can have parents can only have a single parent.\n // It's the business logic of the library.\n // Parent-child relationships:\n // - Namespace -> Namespace\n // - Namespace -> Model\n // - Model -> Entity\n // Entities and Association are associated with the parent entity through edges.\n for (const parent of parents) {\n g.setParent(key, parent)\n }\n }\n }\n if (Array.isArray(json.edges)) {\n for (const entry of json.edges) {\n if (!entry.value) {\n throw new Error(`Unable to restore data domain graph. Malformed edge entry`)\n }\n if (entry.value.foreign) {\n // The `v` has to be local to the graph. The `w` must be foreign.\n if (!foreignNodes.has(entry.w)) {\n // console.warn(`Missing foreign node: ${entry.w}. Skipping edge.`)\n continue\n }\n }\n if (foreignNodes.has(entry.v) || foreignNodes.has(entry.w)) {\n if (!g.hasNode(entry.v) || !g.hasNode(entry.w)) {\n // console.warn(`Missing foreign node: ${entry.v} or ${entry.w}. Skipping edge.`)\n continue\n }\n }\n g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value)\n }\n }\n return g\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainSerialization.js","sourceRoot":"","sources":["../../../src/modeling/DomainSerialization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAWxD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAA;AAElF,OAAO,EAAE,WAAW,EAA0B,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,YAAY,EAAsB,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAA;AAanF,SAAS,UAAU,CAAC,CAAkB,EAAE,SAAiB;IACvD,MAAM,MAAM,GAAmB,EAAE,CAAA;IACjC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC3B,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACrD,2BAA2B;YAC3B,SAAQ;QACV,CAAC;QACD,wEAAwE;QACxE,0CAA0C;QAC1C,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QACjC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AAO;oBACP,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE;oBACrD,UAAU,EAAE,sBAAsB;iBACnC,CAAA;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA;IAEpE,OAAO;QACL,KAAK,EAAE,CAAC;QACR,MAAM;QACN,OAAO,EAAE,CAAC,SAAS;KACpB,CAAA;AACH,CAAC","sourcesContent":["import type { JsonEdge, Node } from '@api-client/graph/graph/types.js'\nimport { Graph } from '@api-client/graph/graph/Graph.js'\nimport type {\n DataDomainGraph,\n DomainGraphEdge,\n DomainGraphNodeType,\n SerializedGraph,\n DeserializationMode,\n DeserializationResult,\n DeserializationIssue,\n DeserializeOptions,\n} from './types.js'\nimport {\n DomainAssociationKind,\n DomainEntityKind,\n DomainModelKind,\n DomainNamespaceKind,\n DomainPropertyKind,\n} from '../models/kinds.js'\nimport { DomainNamespace, type DomainNamespaceSchema } from './DomainNamespace.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { DomainModel, type DomainModelSchema } from './DomainModel.js'\nimport { DomainEntity, DomainEntitySchema } from './DomainEntity.js'\nimport { DomainProperty, DomainPropertySchema } from './DomainProperty.js'\nimport { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'\n\ninterface GraphMergeResult {\n /**\n * The set of node ids generated for the foreign nodes.\n */\n nodes: Set<string>\n /**\n * The set of edge ids generated for the foreign edges.\n */\n edges: Set<string>\n}\n\nfunction writeNodes(g: DataDomainGraph, domainKey: string): Node<object>[] {\n const result: Node<object>[] = []\n for (const v of g.nodes()) {\n const nodeValue = g.node(v)\n if (!nodeValue || nodeValue.domain.key !== domainKey) {\n // Filter out foreign nodes\n continue\n }\n // We do only use single parent for the graph. Potentially this could be\n // replaced with the `g.parent(v)` method.\n const parents = [...g.parents(v)]\n const node: Node<object> = { v }\n node.value = nodeValue.toJSON()\n if (parents.length) {\n node.parents = parents\n }\n result.push(node)\n }\n return result\n}\n\nfunction writeEdges(g: DataDomainGraph, domainKey: string): JsonEdge<DomainGraphEdge>[] {\n const result: JsonEdge<DomainGraphEdge>[] = []\n for (const e of g.edges()) {\n const edgeValue = g.edge(e)\n if (!edgeValue) {\n continue\n }\n const sourceNode = g.node(e.v)\n const targetNode = g.node(e.w)\n if (!sourceNode || !targetNode) {\n continue\n }\n if (sourceNode.domain.key !== domainKey) {\n // Filter out edges starting from foreign nodes. These are foreign associations\n // that have nothing to do with the current domain.\n continue\n }\n if (targetNode.domain.key !== domainKey && edgeValue.type !== 'association' && edgeValue.type !== 'parent') {\n // Filter out edges to foreign nodes except for associations and parent-child relations\n continue\n }\n const edge: JsonEdge<DomainGraphEdge> = { v: e.v, w: e.w }\n if (e.name) {\n edge.name = e.name\n }\n edge.value = structuredClone(edgeValue)\n result.push(edge)\n }\n return result\n}\n\n/**\n * Validates the graph consistency before serialization.\n * Ensures that all required edges exist for properties and associations.\n * @param g The graph to validate\n * @param domainKey The domain key to validate\n * @throws Error if the graph is inconsistent\n */\nfunction validateGraphConsistency(g: DataDomainGraph, domainKey: string): void {\n const validationErrors: string[] = []\n\n // Get all nodes that belong to this domain\n const domainNodes = new Set<string>()\n for (const nodeId of g.nodes()) {\n const node = g.node(nodeId)\n if (node && node.domain.key === domainKey) {\n domainNodes.add(nodeId)\n }\n }\n\n // Validate that properties and associations have parent edges\n for (const nodeId of domainNodes) {\n const node = g.node(nodeId)\n if (!node) continue\n\n if (node.kind === DomainPropertyKind || node.kind === DomainAssociationKind) {\n // These nodes must have exactly one incoming edge from their parent entity\n const incomingEdges = [...g.inEdges(nodeId)]\n const parentEdges = incomingEdges.filter((edge) => {\n const sourceNode = g.node(edge.v)\n return sourceNode && sourceNode.domain.key === domainKey\n })\n\n if (parentEdges.length === 0) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has no parent entity edge. ` +\n `This will cause deserialization to fail.`\n )\n } else if (parentEdges.length > 1) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n const parentIds = parentEdges.map((e) => e.v).join(', ')\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has multiple parent edges: ${parentIds}. ` +\n `This may cause deserialization issues.`\n )\n } else {\n // Validate that the parent is actually an entity\n const parentEdge = parentEdges[0]\n const parentNode = g.node(parentEdge.v)\n if (!parentNode || parentNode.kind !== DomainEntityKind) {\n const nodeType = node.kind === DomainPropertyKind ? 'Property' : 'Association'\n validationErrors.push(\n `${nodeType} \"${node.info.name}\" (${nodeId}) has a parent that is not an entity. ` +\n `Parent: ${parentNode?.kind || 'unknown'} (${parentEdge.v})`\n )\n }\n }\n }\n\n // Validate that entities have model parents\n if (node.kind === DomainEntityKind) {\n const parents = [...g.parents(nodeId)]\n const hasModelParent = parents.some((parentId) => {\n const parent = g.node(parentId)\n return parent && parent.kind === DomainModelKind\n })\n\n if (!hasModelParent) {\n validationErrors.push(\n `Entity \"${node.info.name}\" (${nodeId}) has no model parent. ` + `Entities must belong to a model.`\n )\n }\n }\n\n // Validate that models have either namespace parents or are at root level\n if (node.kind === DomainModelKind) {\n const parents = [...g.parents(nodeId)]\n const hasNamespaceParent = parents.some((parentId) => {\n const parent = g.node(parentId)\n return parent && parent.kind === DomainNamespaceKind\n })\n\n // Models can either be at root level (no parents) or have a namespace parent\n // They should not have other types of parents\n if (parents.length > 0 && !hasNamespaceParent) {\n const invalidParents = parents\n .map((parentId) => {\n const parent = g.node(parentId)\n return `${parent?.kind || 'unknown'} (${parentId})`\n })\n .join(', ')\n validationErrors.push(\n `Model \"${node.info.name}\" (${nodeId}) has invalid parent types: ${invalidParents}. ` +\n `Models can only belong to namespaces or be at root level.`\n )\n }\n }\n }\n\n // Validate association targets exist\n for (const nodeId of domainNodes) {\n const node = g.node(nodeId)\n if (node && node.kind === DomainAssociationKind) {\n const association = node as DomainAssociation\n const outgoingEdges = [...g.outEdges(nodeId)]\n\n // Check that association has target edges\n const targetEdges = outgoingEdges.filter((edge) => {\n const edgeData = g.edge(edge)\n return edgeData && edgeData.type === 'association'\n })\n\n if (targetEdges.length === 0) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) has no target entities. ` +\n `Associations must reference at least one target entity.`\n )\n }\n\n // Validate that all target entities exist\n for (const targetEdge of targetEdges) {\n const targetNode = g.node(targetEdge.w)\n if (!targetNode) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) references non-existent target: ${targetEdge.w}`\n )\n } else if (targetNode.kind !== DomainEntityKind) {\n validationErrors.push(\n `Association \"${association.info.name}\" (${nodeId}) references non-entity target: ` +\n `${targetNode.kind} (${targetEdge.w})`\n )\n }\n }\n }\n }\n\n if (validationErrors.length > 0) {\n throw new Error(\n `Graph consistency validation failed for domain \"${domainKey}\":\\n` +\n validationErrors.map((error) => ` - ${error}`).join('\\n')\n )\n }\n}\n\nexport function serialize(g: DataDomainGraph, domainKey: string): SerializedGraph {\n // Validate graph consistency before serialization\n validateGraphConsistency(g, domainKey)\n\n const json: SerializedGraph = {\n options: {\n directed: g.isDirected(),\n multigraph: g.isMultigraph(),\n compound: g.isCompound(),\n },\n nodes: writeNodes(g, domainKey),\n edges: writeEdges(g, domainKey),\n }\n return json\n}\n\n/**\n * Removes all foreign nodes, edges, and parents from the graph.\n * @param g The graph to remove the foreign nodes from\n * @param domainKey The key of the domain to remove\n */\nexport function removeForeignGraph(g: DataDomainGraph, domainKey: string): void {\n for (const node of g.nodes()) {\n const nodeValue = g.node(node)\n if (!nodeValue) {\n continue\n }\n if (nodeValue.domain.key === domainKey) {\n // This is a foreign node, remove it from the graph.\n g.removeNode(node)\n // When a node is removed, all edges and parents are removed as well.\n // No need to iterate over them.\n }\n }\n}\n\n/**\n * Merges a foreign domain graph into the current domain graph.\n * @param own Our domain graph\n * @param foreign The foreign domain graph\n * @param domain The key of the foreign domain\n */\nexport function mergeGraph(own: DataDomainGraph, foreign: DataDomainGraph, domain: string): GraphMergeResult {\n const nodes = new Set<string>()\n const edges = new Set<string>()\n // Copy nodes\n for (const node of foreign.nodes()) {\n const foreignNode = foreign.node(node)\n if (!foreignNode) {\n continue\n }\n const foreignKey = `${domain}:${node}`\n own.setNode(foreignKey, foreignNode)\n nodes.add(foreignKey)\n }\n // Copy edges\n for (const edge of foreign.edges()) {\n const label = foreign.edge(edge)\n if (!label) {\n continue\n }\n const foreignSource = `${domain}:${edge.v}`\n const foreignTarget = `${domain}:${edge.w}`\n // const foreignEdge = foreign.edge(edge)\n own.setEdge(foreignSource, foreignTarget, {\n foreign: true,\n domain,\n ...label,\n })\n edges.add(`${foreignSource}|${foreignTarget}`)\n }\n const notRootEntities = new Set<string>()\n // Copy parent-child relationships\n for (const node of foreign.nodes()) {\n const foreignNodeKey = `${domain}:${node}`\n for (const parent of foreign.parents(node)) {\n const foreignParentKey = `${domain}:${parent}`\n const srcNode = own.node(foreignNodeKey) as DomainGraphNodeType\n const targetNode = own.node(foreignParentKey) as DomainGraphNodeType\n if (srcNode.kind === DomainEntityKind && targetNode.kind === DomainEntityKind) {\n // entities can have multiple parents between them. We need to respect that.\n if (!notRootEntities.has(foreignNodeKey)) {\n // We use `setParent` in the first run to remove the entity from the root\n // of the graph.\n notRootEntities.add(foreignNodeKey)\n own.setParent(foreignNodeKey, foreignParentKey)\n } else {\n own.addParent(foreignNodeKey, foreignParentKey)\n }\n } else {\n // other nodes can only have a single parent.\n own.setParent(foreignNodeKey, foreignParentKey)\n }\n }\n }\n return {\n nodes,\n edges,\n }\n}\n\n/**\n * Properties and associations are stored as nodes with edges to the parent entity in the graph.\n * At the time of restoring these nodes, the graph has no edges yet.\n * This function finds the parent of the child node in the edges list.\n * @param child The DomainProperty or DomainAssociation key\n * @param edges The list of serialized graph edges\n * @returns The parent key of the child or undefined if not found\n */\nfunction findEdgeParent(child: string, edges: JsonEdge<DomainGraphEdge>[]): string | undefined {\n for (const edge of edges) {\n if (edge.w === child) {\n return edge.v\n }\n }\n return undefined\n}\n\n/**\n * Restores the previously serialized node entry.\n * @param root The DataDomain instance to use as the root for the graph\n * @param entry The node entry to restore\n * @param edges The list of serialized graph edges\n * @param mode The deserialization mode\n * @param issues Array to collect issues in lenient mode\n * @returns The restored node instance or undefined if failed in lenient mode\n * @throws Error if the entry is malformed or the kind is unknown in strict mode\n */\nfunction prepareNode(\n root: DataDomain,\n entry: unknown,\n edges: JsonEdge<DomainGraphEdge>[],\n mode: DeserializationMode,\n issues: DeserializationIssue[]\n): DomainGraphNodeType | undefined {\n if (!entry) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: 'Unable to restore data domain graph. Malformed node entry',\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(issue.message)\n }\n return undefined\n }\n\n const domainElement = entry as { kind?: string; key?: string }\n if (!domainElement.kind) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: 'Unable to restore data domain graph. Node entry missing kind property',\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(issue.message)\n }\n return undefined\n }\n\n try {\n if (domainElement.kind === DomainNamespaceKind) {\n return new DomainNamespace(root, domainElement as DomainNamespaceSchema)\n }\n if (domainElement.kind === DomainModelKind) {\n return new DomainModel(root, domainElement as DomainModelSchema)\n }\n if (domainElement.kind === DomainEntityKind) {\n return new DomainEntity(root, domainElement as DomainEntitySchema)\n }\n if (domainElement.kind === DomainPropertyKind) {\n const typed = domainElement as DomainPropertySchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n const issue: DeserializationIssue = {\n type: 'missing_edge',\n severity: 'error',\n message: `Property \"${typed.info?.name || typed.key}\" has no parent entity edge`,\n affectedKey: typed.key,\n resolution: mode === 'lenient' ? 'Property will be skipped' : undefined,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return undefined\n }\n return new DomainProperty(root, parent, typed)\n }\n if (domainElement.kind === DomainAssociationKind) {\n const typed = domainElement as DomainAssociationSchema\n const parent = findEdgeParent(typed.key, edges)\n if (!parent) {\n const issue: DeserializationIssue = {\n type: 'missing_edge',\n severity: 'error',\n message: `Association \"${typed.info?.name || typed.key}\" has no parent entity edge`,\n affectedKey: typed.key,\n resolution: mode === 'lenient' ? 'Association will be skipped' : undefined,\n }\n issues.push(issue)\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Malformed node entry`)\n }\n return undefined\n }\n return new DomainAssociation(root, parent, typed)\n }\n\n const issue: DeserializationIssue = {\n type: 'unknown_kind',\n severity: 'error',\n message: `Unknown node kind: ${domainElement.kind}`,\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw new Error(`Unable to restore data domain graph. Unknown node kind ${domainElement.kind}`)\n }\n return undefined\n } catch (error) {\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message: `Failed to create node: ${error instanceof Error ? error.message : String(error)}`,\n affectedKey: domainElement.key,\n }\n issues.push(issue)\n\n if (mode === 'strict') {\n throw error\n }\n return undefined\n }\n}\n\n/**\n * To deserialize a graph:\n *\n * - Create a new DataDomain instance\n * - Restore all foreign nodes and edges\n * - Call the deserialize function\n *\n * @param root The DataDomain instance to use as the root for the graph\n * @param json The previously serialized graph\n * @param dependencies An array of foreign data domains to register with this domain\n * @param mode The deserialization mode - 'strict' throws errors, 'lenient' collects issues\n * @returns DeserializationResult with graph, issues, and success status\n * @throws Error in strict mode when any issue is encountered\n */\nexport function deserialize(root: DataDomain, options: DeserializeOptions = {}): DeserializationResult {\n const { json, dependencies, mode = 'strict' } = options\n const g = new Graph<unknown, DomainGraphNodeType, DomainGraphEdge>({\n compound: true,\n multigraph: true,\n directed: true,\n })\n const issues: DeserializationIssue[] = []\n let foreignNodes = new Set<string>()\n let foreignEdges = new Set<string>()\n\n // Process dependencies\n if (dependencies) {\n for (const dependency of dependencies) {\n try {\n const result = mergeGraph(g, dependency.graph, dependency.key)\n if (result.edges.size) {\n foreignEdges = new Set([...foreignEdges, ...result.edges])\n }\n if (result.nodes.size) {\n foreignNodes = new Set([...foreignNodes, ...result.nodes])\n }\n root.dependencies.set(dependency.key, dependency)\n } catch (error) {\n const message = `Failed to merge dependency \"${dependency.key}\": ${error instanceof Error ? error.message : String(error)}`\n\n if (mode === 'strict') {\n throw new Error(message)\n }\n\n const issue: DeserializationIssue = {\n type: 'missing_dependency',\n severity: 'error',\n message,\n affectedKey: dependency.key,\n resolution: 'Dependency will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n\n if (!json) {\n return {\n graph: g,\n issues,\n success: true,\n }\n }\n\n // Process nodes\n if (Array.isArray(json.nodes)) {\n // 1st pass - set up nodes\n const parentInfo = new Map<string, string[]>()\n for (const entry of json.nodes) {\n const node = prepareNode(root, entry.value, json.edges, mode, issues)\n if (node) {\n g.setNode(entry.v, node)\n if (entry.parents) {\n parentInfo.set(entry.v, entry.parents)\n }\n }\n // Note: prepareNode throws in strict mode, so we won't reach here if there's an error\n }\n\n // 2nd pass - set up parents\n for (const [key, parents] of parentInfo) {\n // Verify the node still exists (might have been skipped in lenient mode)\n if (!g.hasNode(key)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Cannot set parents for missing node: ${key}`,\n affectedKey: key,\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n for (const parent of parents) {\n // Verify parent exists\n if (!g.hasNode(parent)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Parent node \"${parent}\" not found for child \"${key}\"`,\n affectedKey: key,\n context: { parentKey: parent },\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n try {\n g.setParent(key, parent)\n } catch (error) {\n const message = `Failed to set parent \"${parent}\" for child \"${key}\": ${error instanceof Error ? error.message : String(error)}`\n const issue: DeserializationIssue = {\n type: 'invalid_parent',\n severity: 'warning',\n message,\n affectedKey: key,\n context: { parentKey: parent },\n resolution: 'Parent relationship will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n }\n\n // Process edges\n if (Array.isArray(json.edges)) {\n for (const entry of json.edges) {\n if (!entry.value) {\n const message = 'Edge entry missing value'\n\n if (mode === 'strict') {\n throw new Error(message)\n }\n\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'error',\n message,\n context: { edge: entry },\n }\n issues.push(issue)\n continue\n }\n\n // Handle foreign edges\n if (entry.value.foreign) {\n // The `v` has to be local to the graph. The `w` must be foreign.\n if (!foreignNodes.has(entry.w)) {\n // Note, we don't consider this an error, just a warning.\n // Because of that, we don't throw an error here.\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Missing foreign node: ${entry.w}`,\n affectedKey: entry.w,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n }\n\n // Check if nodes exist for the edge\n if (foreignNodes.has(entry.v) || foreignNodes.has(entry.w)) {\n if (!g.hasNode(entry.v) || !g.hasNode(entry.w)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Missing foreign node for edge: ${entry.v} -> ${entry.w}`,\n context: { sourceNode: entry.v, targetNode: entry.w },\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n } else {\n // Both nodes should be local - verify they exist\n if (!g.hasNode(entry.v)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Source node not found for edge: ${entry.v}`,\n affectedKey: entry.v,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n\n if (!g.hasNode(entry.w)) {\n const issue: DeserializationIssue = {\n type: 'missing_node',\n severity: 'warning',\n message: `Target node not found for edge: ${entry.w}`,\n affectedKey: entry.w,\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n continue\n }\n }\n\n try {\n g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value)\n } catch (error) {\n const message = `Failed to create edge ${entry.v} -> ${entry.w}: ${error instanceof Error ? error.message : String(error)}`\n const issue: DeserializationIssue = {\n type: 'malformed_entry',\n severity: 'warning',\n message,\n context: { sourceNode: entry.v, targetNode: entry.w },\n resolution: 'Edge will be skipped',\n }\n issues.push(issue)\n }\n }\n }\n\n const hasErrors = issues.some((issue) => issue.severity === 'error')\n\n return {\n graph: g,\n issues,\n success: !hasErrors,\n }\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { DomainModel } from './DomainModel.js';
|
|
|
6
6
|
import type { DomainNamespace } from './DomainNamespace.js';
|
|
7
7
|
import type { DomainProperty } from './DomainProperty.js';
|
|
8
8
|
import type { DomainNamespaceKind, DomainEntityKind, DomainModelKind, DomainPropertyKind, DomainAssociationKind, DataDomainKind } from '../models/kinds.js';
|
|
9
|
+
import type { DataDomain } from './DataDomain.js';
|
|
9
10
|
export interface DataDomainRemoveOptions {
|
|
10
11
|
/**
|
|
11
12
|
* When true, the object will be forcibly removed.
|
|
@@ -45,7 +46,7 @@ export interface DomainGraphEdge {
|
|
|
45
46
|
/**
|
|
46
47
|
* The type of the edge.
|
|
47
48
|
* - `association` The edge is to an association object.
|
|
48
|
-
* - When coming **from** an
|
|
49
|
+
* - When coming **from** an entity (the `v` property), that entity owns the association.
|
|
49
50
|
* - When coming **to** an entity (the `w` property), that entity is the target of the association.
|
|
50
51
|
* An association can have multiple targets.
|
|
51
52
|
* - `property` The edge is to a property object. Can only be created between an entity and a property.
|
|
@@ -612,7 +613,7 @@ export interface MatchUserPropertyAccessRule extends BaseAccessRule {
|
|
|
612
613
|
/**
|
|
613
614
|
* The action is allowed if the authenticated user's email domain matches a specific domain.
|
|
614
615
|
* This is used to restrict access based on the user's email address.
|
|
615
|
-
* For example, only users with an email address from "
|
|
616
|
+
* For example, only users with an email address from "my-company.com" can access certain resources.
|
|
616
617
|
*/
|
|
617
618
|
export interface MatchEmailDomainAccessRule extends BaseAccessRule {
|
|
618
619
|
type: 'matchEmailDomain';
|
|
@@ -742,5 +743,71 @@ export interface DomainImpactItem {
|
|
|
742
743
|
*/
|
|
743
744
|
parent?: string;
|
|
744
745
|
}
|
|
746
|
+
export interface DeserializeOptions {
|
|
747
|
+
/**
|
|
748
|
+
* The mode to use for deserialization.
|
|
749
|
+
*/
|
|
750
|
+
mode?: DeserializationMode;
|
|
751
|
+
/**
|
|
752
|
+
* The serialized graph to deserialize.
|
|
753
|
+
* This is the JSON representation of the graph.
|
|
754
|
+
*/
|
|
755
|
+
json?: SerializedGraph;
|
|
756
|
+
/**
|
|
757
|
+
* The list of foreign domains that this domain depends on.
|
|
758
|
+
*/
|
|
759
|
+
dependencies?: DataDomain[];
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Describes the mode for deserializing a domain graph.
|
|
763
|
+
*/
|
|
764
|
+
export type DeserializationMode = 'strict' | 'lenient';
|
|
765
|
+
/**
|
|
766
|
+
* Describes an issue found during deserialization.
|
|
767
|
+
*/
|
|
768
|
+
export interface DeserializationIssue {
|
|
769
|
+
/**
|
|
770
|
+
* The type of issue encountered.
|
|
771
|
+
*/
|
|
772
|
+
type: 'missing_node' | 'missing_edge' | 'invalid_parent' | 'missing_dependency' | 'malformed_entry' | 'unknown_kind';
|
|
773
|
+
/**
|
|
774
|
+
* The severity of the issue.
|
|
775
|
+
*/
|
|
776
|
+
severity: 'error' | 'warning' | 'info';
|
|
777
|
+
/**
|
|
778
|
+
* A human-readable description of the issue.
|
|
779
|
+
*/
|
|
780
|
+
message: string;
|
|
781
|
+
/**
|
|
782
|
+
* The key of the affected node, edge, or entity if applicable.
|
|
783
|
+
*/
|
|
784
|
+
affectedKey?: string;
|
|
785
|
+
/**
|
|
786
|
+
* Additional context about the issue.
|
|
787
|
+
*/
|
|
788
|
+
context?: Record<string, unknown>;
|
|
789
|
+
/**
|
|
790
|
+
* The action taken to handle this issue in lenient mode.
|
|
791
|
+
*/
|
|
792
|
+
resolution?: string;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* The result of a deserialization operation.
|
|
796
|
+
*/
|
|
797
|
+
export interface DeserializationResult {
|
|
798
|
+
/**
|
|
799
|
+
* The deserialized graph.
|
|
800
|
+
*/
|
|
801
|
+
graph: DataDomainGraph;
|
|
802
|
+
/**
|
|
803
|
+
* Issues encountered during deserialization.
|
|
804
|
+
*/
|
|
805
|
+
issues: DeserializationIssue[];
|
|
806
|
+
/**
|
|
807
|
+
* Whether the deserialization was successful.
|
|
808
|
+
* This is set to true when a critical failures occurred.
|
|
809
|
+
*/
|
|
810
|
+
success: boolean;
|
|
811
|
+
}
|
|
745
812
|
export {};
|
|
746
813
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modeling/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACf,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","s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E,MAAM,CAAA;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,KAAK,EAAE,eAAe,CAAA;IACtB;;OAEG;IACH,MAAM,EAAE,oBAAoB,EAAE,CAAA;IAC9B;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modeling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GraphJson } from '@api-client/graph/graph/types.js'\nimport type { Graph } from '@api-client/graph/graph/Graph.js'\nimport type { DomainAssociation } from './DomainAssociation.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { DomainModel } from './DomainModel.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { DomainProperty } from './DomainProperty.js'\nimport type {\n DomainNamespaceKind,\n DomainEntityKind,\n DomainModelKind,\n DomainPropertyKind,\n DomainAssociationKind,\n DataDomainKind,\n} from '../models/kinds.js'\n\nexport interface DataDomainRemoveOptions {\n /**\n * When true, the object will be forcibly removed.\n * The resolution defined in the `ImpactResolution` class will be applied.\n *\n * For example, when removing an entity that is a parent to another entity, it will\n * removed itself as a parent from the child entity.\n *\n * Note, this option should only be used when the DomainImpactAnalysis has been performed\n * and the user was informed of the impact.\n */\n force?: boolean\n}\n\nexport interface AssociationAddOptions {\n /**\n * When set, it is the the association target's origin data domain.\n * The key of the target data domain where this target entity is defined.\n * Only used when `key` is specified.\n */\n domain?: string\n /**\n * The key of the association target, if known.\n * If the target of the association is not specified, and the association has no other targets,\n * the association is ignored in the namespace while processing.\n */\n key?: string\n}\n\nexport interface DomainGraphEdge {\n /**\n * Indicates that the edge is to or from a foreign domain.\n */\n foreign?: boolean\n /**\n * The key of the foreign domain. Always set with the `foreign` property.\n */\n domain?: string\n /**\n * The type of the edge.\n * - `association` The edge is to an association object.\n * - When coming **from** an entiry (the `v` property), that entity owns the association.\n * - When coming **to** an entity (the `w` property), that entity is the target of the association.\n * An association can have multiple targets.\n * - `property` The edge is to a property object. Can only be created between an entity and a property.\n * - The **from** (`v`) is the entity.\n * - The **to** (`w`) is the property.\n * - `parent` The edge is to a parent object.\n * - The **from** (`v`) is the child entity.\n * - The **to** (`w`) is the parent entity.\n */\n type: 'association' | 'property' | 'parent'\n}\n\nexport type DomainGraphNodeType = DomainNamespace | DomainModel | DomainEntity | DomainProperty | DomainAssociation\n\n/**\n * An interface that describes the data domain dependency.\n */\nexport interface ForeignDomainDependency {\n /**\n * The system registered key of the foreign domain.\n */\n key: string\n /**\n * The version of the foreign domain used in this domain.\n */\n version: string\n}\n\nexport interface AssociationTarget {\n /**\n * The key of the target entity.\n */\n key: string\n /**\n * The key of the target data domain.\n * This is only set when the target is in a different data domain.\n */\n domain?: string\n}\n\n/**\n * Describes the default value set on a property schema.\n */\nexport interface SchemaDefaultValue {\n /**\n * The type of the default value.\n *\n * - `literal` The `value` should be used as-is.\n * - `function` The value represents the name of the function to be used.\n */\n type: 'literal' | 'function'\n /**\n * The actual value type depends on the `type`.\n * It is always a string and it has to be casted to the property's data type.\n */\n value: string\n}\n\n/**\n * A general schema definition for a property.\n * This is propagated to all bindings (when they support these properties).\n */\nexport interface PropertySchema {\n /**\n * The minimum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMinimum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n minimum?: number\n /**\n * The maximum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMaximum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n maximum?: number\n /**\n * When set, the minimum value is exclusive.\n *\n * - When `false`: value ≥ minimum.\n * - When `true`: value > minimum.\n */\n exclusiveMinimum?: boolean\n /**\n * When set, the exclusiveMaximum value is exclusive.\n *\n * - When `false`: value ≤ maximum.\n * - When `true`: value < minimum.\n */\n exclusiveMaximum?: boolean\n /**\n * The multiplier value for a number scalar.\n *\n * Examples:\n * - if `1` then every integer is allowed\n * - if `2` than every even number is allowed\n * - if `0.5` than every number dividable by `0.5` is allowed\n */\n multipleOf?: number\n /**\n * The enum values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n enum?: string[]\n /**\n * The default value for the property.\n * This is always encoded as a string. The actual type is defined in the `dataType` property.\n */\n defaultValue?: SchemaDefaultValue\n /**\n * The example values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n examples?: string[]\n /**\n * The pattern to use with a string scalar.\n */\n pattern?: string\n}\n\n/**\n * The shortcut type for the data domain graph.\n */\nexport type DataDomainGraph = Graph<unknown, DomainGraphNodeType, DomainGraphEdge>\n/**\n * The serialized version of the data domain graph.\n */\nexport type SerializedGraph = GraphJson<unknown, object, DomainGraphEdge>\n\n/**\n * Represents a standardized, machine-readable error response body\n * as defined by RFC 7807 for HTTP APIs.\n */\nexport interface ProblemDetails {\n /**\n * A URI that identifies the specific problem type. Should resolve to human-readable docs.\n * e.g., \"https://docs.apinow.app/errors/validation-failed\"\n */\n type: string\n\n /**\n * A short, human-readable summary of the problem type.\n * e.g., \"Validation Error\"\n */\n title: string\n\n /**\n * The HTTP status code generated by the origin server for this problem.\n */\n status?: number\n\n /**\n * A human-readable explanation specific to this occurrence of the problem.\n */\n detail?: string\n\n /**\n * A URI that identifies the specific occurrence of the problem.\n * Can be the API request path that caused the error.\n */\n instance: string\n}\n\n/**\n * The set of supported filter operators for the List action.\n * These are used in query parameters, e.g., ?price[gte]=100\n *\n * - eq: Equal\n * - nq: Not Equal\n * - lt: Less Than\n * - lte: Less Than or Equal\n * - gt: Greater Than\n * - gte: Greater Than or Equal\n * - ex: Checks if the field exists\n * - re: Regular expression match\n * - bf: Date before a specific value\n * - af: Date after a specific value\n * - cn: String contains substring / Array contains element\n * - st: String starts with\n * - end: String ends with\n * - in: Value is one of the elements in the provided array\n * - nin: Value is not one of the elements in the provided array\n */\nexport type ResourceFilterOperator =\n | 'eq' // Equal\n | 'nq' // Not equal\n | 'lt' // Less than\n | 'lte' // Less than or equal\n | 'gt' // Greater than\n | 'gte' // Greater than or equal\n | 'ex' // Checks if the field exists\n | 're' // Regular expression match\n | 'bf' // Date before a specific value\n | 'af' // Date after a specific value\n | 'cn' // String contains substring / Array contains element\n | 'st' // String starts with\n | 'end' // String ends with\n | 'in' // Value is one of the elements in the provided array\n | 'nin' // Value is not one of the elements in the provided array\n\n/**\n * The session transport configuration interface.\n * This defines the properties that are common to all session transports.\n */\ninterface SessionTransport {\n /**\n * Whether the session transport is enabled.\n */\n enabled: boolean\n /**\n * The kind of session transport. Each interface defines its own kind.\n */\n kind: string\n}\n\n/**\n * Configuration for cookie-based session transport.\n */\nexport interface CookieConfiguration extends SessionTransport {\n kind: 'cookie'\n /**\n * The lifetime of the cookie session.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"24h\" for 24 hours.\n *\n * @default \"7d\"\n */\n lifetime: string\n /**\n * Whether the cookie can only be accessed by the server.\n * This is a security feature to prevent client-side scripts from accessing the cookie.\n * If set to false, the cookie can be accessed by client-side scripts.\n * @default true\n */\n httpOnly: boolean // Defaults to true\n /**\n * Whether the cookie should only be sent over secure connections (HTTPS).\n * This is a security feature to prevent the cookie from being sent over unencrypted connections.\n * @default true\n */\n secure: boolean\n /**\n * The SameSite attribute of the cookie.\n * This attribute controls whether the cookie is sent with cross-site requests.\n * - 'none' means the cookie is sent with cross-site requests.\n * - 'lax' means the cookie is sent with top-level navigations and will be sent along with GET\n * requests initiated by third-party websites.\n * @default 'none'\n */\n sameSite: 'none' | 'lax'\n /**\n * The name of the cookie.\n * This is the key under which the session data will be stored in the cookie.\n * @default 'as' - 'as' stands for \"api session\"\n */\n name: string\n}\n\n/**\n * Configuration for JWT-based session transport.\n */\nexport interface JwtConfiguration extends SessionTransport {\n kind: 'jwt'\n /**\n * The lifetime of the JWT token.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"15m\" for 15 minutes.\n *\n * @default \"7d\"\n */\n lifetime: string\n}\n\nexport interface SessionConfiguration {\n /**\n * The secret used to sign the JWT and cookies. Should be handled securely.\n * Not visible in the UI after being set.\n */\n secret: string\n /**\n * The properties from the `User` entity to be encoded into the session payload (JWT/cookie).\n * These properties become available in the `request.auth` object at runtime.\n *\n * In practice, these are the ids of the properties in the `User` entity.\n */\n properties: string[]\n /**\n * The cookie-based session transport configuration.\n */\n cookie?: CookieConfiguration\n\n /**\n * The JWT-based session transport configuration.\n */\n jwt?: JwtConfiguration\n}\n\n/**\n * Defines the authorization strategy for the API.\n * It is a base interface that can be extended for different strategies.\n * For MVP, we will start with Roles-Based Access Control (RBAC).\n */\nexport interface AuthorizationConfiguration {\n /**\n * The authorization strategy. For MVP, we will start with RBAC.\n * Post-MVP will include Permission-Based Access Control (PBAC).\n * The strategy determines how users are granted access to resources.\n *\n * - RBAC (Roles-Based Access Control): Users are assigned roles, and permissions are granted to those roles.\n * - PBAC (Permission-Based Access Control): Users are granted permissions directly, allowing for more\n * granular control.\n */\n strategy: string\n}\n\nexport interface RolesBasedAccessControl extends AuthorizationConfiguration {\n strategy: 'RBAC'\n /**\n * The property within the designated \"User\" entity that defines the user's role.\n * This field is used in access rules to grant permissions.\n *\n * This property must be marked with the \"Role\" data semantic in the Data Modeler.\n * It is required to publish the API.\n */\n roleKey: string\n}\n\n/**\n * Configures the strategy for authenticating end-users.\n * An API can only support one authentication strategy at a time.\n * This is a base interface that can be extended for different strategies.\n */\nexport interface AuthenticationConfiguration {\n /**\n * The authentication method. For MVP, this is focused on username/password.\n * This can be extended in the future to include 'SSO'.\n */\n strategy: string\n}\n\n/**\n * Configuration for username/password authentication.\n * This is the primary authentication method for the API (MVP).\n */\nexport interface UsernamePasswordConfiguration extends AuthenticationConfiguration {\n strategy: 'UsernamePassword'\n /**\n * The specific property within the User entity that holds the password.\n * This property must be marked with the \"Password\" data semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n passwordKey?: string\n}\n\n/**\n * Represents a Data Entity from the Data Domain that the API will expose and operate upon.\n */\nexport interface ExposedEntity {\n /**\n * The key of the Data Entity from the Data Domain.\n */\n key: string\n\n /**\n * Optional configuration for resource-wide rate limiting and throttling.\n * Defines rules to protect the resource from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * Access control rules defining who can perform actions on this resource or collection.\n * It override the top-level access rules defined in the API model.\n */\n accessRule?: AccessRule[]\n\n /**\n * The collection of API actions (e.g., List, Read, Create) enabled for this entity.\n */\n actions: ApiAction[]\n}\n\n/**\n * Represents a specific, configurable API operation applied to a Data Entity.\n * Corresponds to common RESTful interactions.\n */\nexport type ApiAction = ListAction | ReadAction | CreateAction | UpdateAction | DeleteAction | SearchAction\n\n/**\n * A base interface for common properties across all actions.\n */\ninterface Action {\n /**\n * The specific kind of action (e.g., 'List', 'Read', etc.)\n */\n kind: string\n /**\n * Access control rules defining who can perform this action. It is only applied if the\n * authorization strategy is set to 'RBAC'.\n * If no rules grant access, it's denied by default making it essentially private.\n *\n * Note, the API can defined top level access rules that apply to all actions. If this property is set,\n * it overrides the top level access rules for this specific action.\n *\n * It is an ordered list, meaning the first rule that matches the user will be applied.\n * If multiple rules match, the first one in the list takes precedence.\n * If no rules match, the action is denied.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for action-wide rate limiting and throttling.\n * Defines rules to protect the action from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n}\n\n/**\n * Represents a pagination strategy for API actions that return collections of resources.\n * This is a base interface that can be extended for different pagination strategies.\n */\nexport interface PaginationStrategy {\n /**\n * The kind of pagination strategy. This is used to identify the specific pagination method.\n * For example, 'cursor' for cursor-based pagination or 'offset' for offset-based pagination.\n */\n kind: string\n /**\n * The default page size for the pagination strategy.\n * This is the number of items returned per page when no specific page size is requested.\n */\n pageSize?: number\n}\n\n/**\n * Represents the cursor-based pagination strategy.\n */\nexport interface CursorPaginationStrategy extends PaginationStrategy {\n kind: 'cursor'\n}\n\n/**\n * Represents the offset-based pagination strategy.\n */\nexport interface OffsetPaginationStrategy extends PaginationStrategy {\n kind: 'offset'\n}\n\n/**\n * Enables retrieving a collection of resources.\n * Endpoint: GET /[entity-collection-name]\n */\nexport interface ListAction extends Action {\n kind: 'list'\n /**\n * The pagination strategy used for this action.\n * This defines how the results are paginated when retrieving a collection of resources.\n * It can be either 'cursor' or 'offset'.\n */\n pagination: PaginationStrategy\n /**\n * Fields from the entity that can be used for filtering.\n * Must be marked as \"indexable\" in the Data Model.\n */\n filterableFields: string[]\n /**\n * Fields from the entity that can be used for sorting.\n */\n sortableFields: string[]\n}\n\n/**\n * Enables retrieving a single resource by its ID.\n * Endpoint: GET /[entity-collection-name]/{id}\n */\nexport interface ReadAction extends Action {\n kind: 'read'\n // Association handling (Link IDs vs. Embed) is defined on the\n // data association itself in the Data Modeler.\n}\n\n/**\n * Enables adding a new resource to a collection.\n * Endpoint: POST /[entity-collection-name]\n */\nexport interface CreateAction extends Action {\n kind: 'create'\n}\n\n/**\n * Enables modifying an existing resource.\n * Endpoints: PUT or PATCH /[entity-collection-name]/{id}\n */\nexport interface UpdateAction extends Action {\n kind: 'update'\n /**\n * The allowed HTTP methods for updates. Default: PATCH only.\n *\n * These two methods represent the two common ways to update a resource:\n * - PUT: Replaces the entire resource with the provided data.\n * - PATCH: Applies a partial update to the resource, allowing for specific fields to be modified.\n */\n allowedMethods: ('PUT' | 'PATCH')[]\n}\n\n/**\n * Enables removing an existing resource.\n * Endpoint: DELETE /[entity-collection-name]/{id}\n */\nexport interface DeleteAction extends Action {\n kind: 'delete'\n /**\n * The strategy for deletion. Default: Soft Delete.\n *\n * @default 'soft'\n */\n strategy?: 'soft' | 'hard'\n}\n\n/**\n * Enables keyword-based search across specified fields.\n * Endpoint: GET /[entity-collection-name]/search\n */\nexport interface SearchAction extends Action {\n kind: 'search'\n /**\n * The fields within the entity to be included in the search scope.\n * Must be \"indexable\" and typically text-based.\n */\n fields: string[]\n}\n\n/**\n * Defines the access control policy for a specific API action.\n * Based on the predefined rule types for session-based authentication.\n */\nexport type AccessRule =\n | AllowPublicAccessRule\n | AllowAuthenticatedAccessRule\n | MatchResourceOwnerAccessRule\n | MatchUserRoleAccessRule\n | MatchUserPropertyAccessRule\n | MatchEmailDomainAccessRule\n\nexport interface BaseAccessRule {\n /**\n * The unique identifier for the access rule.\n * This is used to reference the rule in the API configuration.\n */\n type: string\n}\n\n/**\n * The action is allowed for all users, including unauthenticated ones.\n * This is typically used for public APIs or resources that do not require authentication.\n * It is the most permissive rule and should be used with caution.\n */\nexport interface AllowPublicAccessRule extends BaseAccessRule {\n type: 'public'\n}\n/**\n * The action is allowed for any authenticated user.\n * This rule does not impose any additional restrictions based on user properties or resource ownership.\n * It is used for resources that should be accessible to all logged-in users.\n */\nexport interface AllowAuthenticatedAccessRule extends BaseAccessRule {\n type: 'authenticated'\n}\n/**\n * The action is allowed if the authenticated user's ID matches a specific property on the resource.\n * This is typically used to restrict access to resources owned by the user.\n * For example, a user can only access their own profile or documents.\n */\nexport interface MatchResourceOwnerAccessRule extends BaseAccessRule {\n type: 'resourceOwner'\n /**\n * The property on the resource that should match the authenticated user's ID.\n * This is typically the ID of the user who owns the resource.\n *\n * The domain model should annotate this property with the \"ResourceOwnerIdentifier\" semantic\n * to indicate that it is used for ownership checks.\n */\n property: string\n}\n\n/**\n * The action is allowed if the authenticated user has a specific role.\n * This is used to enforce role-based access control (RBAC).\n * For example, only users with the \"admin\" role can perform certain actions.\n */\nexport interface MatchUserRoleAccessRule extends BaseAccessRule {\n type: 'matchUserRole'\n /**\n * The role that the authenticated user must have to access the resource.\n * This is typically a property on the user entity that defines their role.\n *\n * The domain model should annotate this property with the \"UserRole\" semantic\n * to indicate that it is used for role-based access control.\n */\n role: string\n}\n/**\n * The action is allowed if a specific property on the authenticated user matches an expected value.\n * This is used to enforce other user-specific restrictions.\n */\nexport interface MatchUserPropertyAccessRule extends BaseAccessRule {\n type: 'matchUserProperty'\n /**\n * The property on the authenticated user that should match the expected value.\n */\n property: string\n /**\n * The expected value for the user property.\n */\n value: string\n}\n/**\n * The action is allowed if the authenticated user's email domain matches a specific domain.\n * This is used to restrict access based on the user's email address.\n * For example, only users with an email address from \"mycompany.com\" can access certain resources.\n */\nexport interface MatchEmailDomainAccessRule extends BaseAccessRule {\n type: 'matchEmailDomain'\n /**\n * The email domain that the authenticated user's email must match.\n */\n domain: string\n}\n\n/**\n * Defines the rate limiting and throttling policies for the entire API.\n */\nexport interface RateLimitingConfiguration {\n /**\n * An ordered list of rules. The first rule that matches an incoming\n * request will be applied.\n */\n rules: RateLimitRule[]\n}\n\n/**\n * Represents a single rate limiting rule that applies to a specific\n * type of client, using a token bucket algorithm.\n */\nexport interface RateLimitRule {\n /**\n * A human-readable description of what this rule is for.\n * e.g., \"Limit anonymous users to 60 requests per hour.\"\n */\n description?: string\n\n /**\n * Defines how to group requests for rate limiting. This determines\n * who the limit applies to.\n *\n * - 'ip': Keys on the client's IP address. Best for anonymous traffic.\n * - 'userId': Keys on the authenticated user's ID. Best for logged-in users.\n * - 'role': Applies a shared limit to all users of a specific role.\n */\n key: { type: 'ip' } | { type: 'userId' } | { type: 'role'; value: string }\n\n /**\n * The number of requests allowed over the defined interval.\n * This is the rate at which tokens are added to the bucket.\n */\n rate: number\n\n /**\n * The time interval for the rate.\n */\n interval: 'second' | 'minute' | 'hour' | 'day'\n\n /**\n * The maximum number of requests that can be made in a burst.\n * This represents the \"bucket size.\" A larger burst allows for\n * more requests to be made in a short period before throttling begins.\n */\n burst: number\n}\n\nexport type DomainImpactKinds =\n | typeof DomainNamespaceKind\n | typeof DomainEntityKind\n | typeof DomainModelKind\n | typeof DomainPropertyKind\n | typeof DomainAssociationKind\n | typeof DataDomainKind\n\n/**\n * The impact analysis report\n */\nexport interface DomainImpactReport {\n /**\n * The key of the impacted data object.\n * This is the key of the object that is being changed.\n */\n key: string\n /**\n * The kind of the impacted data object.\n * This is the kind of the object that is being changed.\n */\n kind: DomainImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: DomainImpactItem[]\n /**\n * Whether it is possible to proceed with the change.\n * If the change is not possible, the reason will be in the impact list.\n */\n canProceed: boolean\n}\n\nexport interface DomainImpactItem {\n /**\n * The key of the impacted data object.\n */\n key: string\n /**\n * The kind of the impacted data object.\n */\n kind: string\n /**\n * The type of the impact.\n *\n * - `delete` - The data object would be deleted.\n */\n type: 'delete' | 'publish'\n /**\n * The impact description.\n * Explains what will happen to the impacted data object.\n * This is a human-readable description of the impact.\n * It should be clear and concise.\n */\n impact: string\n /**\n * The severity of the impact.\n *\n * - `info` - The impact is informational.\n * - `warning` - The impact can potentially cause problems but is not a blocker.\n * - `error` - The impact is a blocker and needs to be resolved before proceeding.\n */\n severity: 'info' | 'warning' | 'error'\n /**\n * The type of the relationship between two impacted objects.\n */\n relationship?: 'child'\n /**\n * The resolution of the conflict if the change will be forced.\n */\n resolution?: string\n /**\n * The optional parent of the impacted data object.\n * For example, if the impacted item is a property, this will be the entity it belongs to.\n */\n parent?: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modeling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GraphJson } from '@api-client/graph/graph/types.js'\nimport type { Graph } from '@api-client/graph/graph/Graph.js'\nimport type { DomainAssociation } from './DomainAssociation.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { DomainModel } from './DomainModel.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { DomainProperty } from './DomainProperty.js'\nimport type {\n DomainNamespaceKind,\n DomainEntityKind,\n DomainModelKind,\n DomainPropertyKind,\n DomainAssociationKind,\n DataDomainKind,\n} from '../models/kinds.js'\nimport type { DataDomain } from './DataDomain.js'\n\nexport interface DataDomainRemoveOptions {\n /**\n * When true, the object will be forcibly removed.\n * The resolution defined in the `ImpactResolution` class will be applied.\n *\n * For example, when removing an entity that is a parent to another entity, it will\n * removed itself as a parent from the child entity.\n *\n * Note, this option should only be used when the DomainImpactAnalysis has been performed\n * and the user was informed of the impact.\n */\n force?: boolean\n}\n\nexport interface AssociationAddOptions {\n /**\n * When set, it is the the association target's origin data domain.\n * The key of the target data domain where this target entity is defined.\n * Only used when `key` is specified.\n */\n domain?: string\n /**\n * The key of the association target, if known.\n * If the target of the association is not specified, and the association has no other targets,\n * the association is ignored in the namespace while processing.\n */\n key?: string\n}\n\nexport interface DomainGraphEdge {\n /**\n * Indicates that the edge is to or from a foreign domain.\n */\n foreign?: boolean\n /**\n * The key of the foreign domain. Always set with the `foreign` property.\n */\n domain?: string\n /**\n * The type of the edge.\n * - `association` The edge is to an association object.\n * - When coming **from** an entity (the `v` property), that entity owns the association.\n * - When coming **to** an entity (the `w` property), that entity is the target of the association.\n * An association can have multiple targets.\n * - `property` The edge is to a property object. Can only be created between an entity and a property.\n * - The **from** (`v`) is the entity.\n * - The **to** (`w`) is the property.\n * - `parent` The edge is to a parent object.\n * - The **from** (`v`) is the child entity.\n * - The **to** (`w`) is the parent entity.\n */\n type: 'association' | 'property' | 'parent'\n}\n\nexport type DomainGraphNodeType = DomainNamespace | DomainModel | DomainEntity | DomainProperty | DomainAssociation\n\n/**\n * An interface that describes the data domain dependency.\n */\nexport interface ForeignDomainDependency {\n /**\n * The system registered key of the foreign domain.\n */\n key: string\n /**\n * The version of the foreign domain used in this domain.\n */\n version: string\n}\n\nexport interface AssociationTarget {\n /**\n * The key of the target entity.\n */\n key: string\n /**\n * The key of the target data domain.\n * This is only set when the target is in a different data domain.\n */\n domain?: string\n}\n\n/**\n * Describes the default value set on a property schema.\n */\nexport interface SchemaDefaultValue {\n /**\n * The type of the default value.\n *\n * - `literal` The `value` should be used as-is.\n * - `function` The value represents the name of the function to be used.\n */\n type: 'literal' | 'function'\n /**\n * The actual value type depends on the `type`.\n * It is always a string and it has to be casted to the property's data type.\n */\n value: string\n}\n\n/**\n * A general schema definition for a property.\n * This is propagated to all bindings (when they support these properties).\n */\nexport interface PropertySchema {\n /**\n * The minimum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMinimum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n minimum?: number\n /**\n * The maximum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMaximum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n maximum?: number\n /**\n * When set, the minimum value is exclusive.\n *\n * - When `false`: value ≥ minimum.\n * - When `true`: value > minimum.\n */\n exclusiveMinimum?: boolean\n /**\n * When set, the exclusiveMaximum value is exclusive.\n *\n * - When `false`: value ≤ maximum.\n * - When `true`: value < minimum.\n */\n exclusiveMaximum?: boolean\n /**\n * The multiplier value for a number scalar.\n *\n * Examples:\n * - if `1` then every integer is allowed\n * - if `2` than every even number is allowed\n * - if `0.5` than every number dividable by `0.5` is allowed\n */\n multipleOf?: number\n /**\n * The enum values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n enum?: string[]\n /**\n * The default value for the property.\n * This is always encoded as a string. The actual type is defined in the `dataType` property.\n */\n defaultValue?: SchemaDefaultValue\n /**\n * The example values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n examples?: string[]\n /**\n * The pattern to use with a string scalar.\n */\n pattern?: string\n}\n\n/**\n * The shortcut type for the data domain graph.\n */\nexport type DataDomainGraph = Graph<unknown, DomainGraphNodeType, DomainGraphEdge>\n/**\n * The serialized version of the data domain graph.\n */\nexport type SerializedGraph = GraphJson<unknown, object, DomainGraphEdge>\n\n/**\n * Represents a standardized, machine-readable error response body\n * as defined by RFC 7807 for HTTP APIs.\n */\nexport interface ProblemDetails {\n /**\n * A URI that identifies the specific problem type. Should resolve to human-readable docs.\n * e.g., \"https://docs.apinow.app/errors/validation-failed\"\n */\n type: string\n\n /**\n * A short, human-readable summary of the problem type.\n * e.g., \"Validation Error\"\n */\n title: string\n\n /**\n * The HTTP status code generated by the origin server for this problem.\n */\n status?: number\n\n /**\n * A human-readable explanation specific to this occurrence of the problem.\n */\n detail?: string\n\n /**\n * A URI that identifies the specific occurrence of the problem.\n * Can be the API request path that caused the error.\n */\n instance: string\n}\n\n/**\n * The set of supported filter operators for the List action.\n * These are used in query parameters, e.g., ?price[gte]=100\n *\n * - eq: Equal\n * - nq: Not Equal\n * - lt: Less Than\n * - lte: Less Than or Equal\n * - gt: Greater Than\n * - gte: Greater Than or Equal\n * - ex: Checks if the field exists\n * - re: Regular expression match\n * - bf: Date before a specific value\n * - af: Date after a specific value\n * - cn: String contains substring / Array contains element\n * - st: String starts with\n * - end: String ends with\n * - in: Value is one of the elements in the provided array\n * - nin: Value is not one of the elements in the provided array\n */\nexport type ResourceFilterOperator =\n | 'eq' // Equal\n | 'nq' // Not equal\n | 'lt' // Less than\n | 'lte' // Less than or equal\n | 'gt' // Greater than\n | 'gte' // Greater than or equal\n | 'ex' // Checks if the field exists\n | 're' // Regular expression match\n | 'bf' // Date before a specific value\n | 'af' // Date after a specific value\n | 'cn' // String contains substring / Array contains element\n | 'st' // String starts with\n | 'end' // String ends with\n | 'in' // Value is one of the elements in the provided array\n | 'nin' // Value is not one of the elements in the provided array\n\n/**\n * The session transport configuration interface.\n * This defines the properties that are common to all session transports.\n */\ninterface SessionTransport {\n /**\n * Whether the session transport is enabled.\n */\n enabled: boolean\n /**\n * The kind of session transport. Each interface defines its own kind.\n */\n kind: string\n}\n\n/**\n * Configuration for cookie-based session transport.\n */\nexport interface CookieConfiguration extends SessionTransport {\n kind: 'cookie'\n /**\n * The lifetime of the cookie session.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"24h\" for 24 hours.\n *\n * @default \"7d\"\n */\n lifetime: string\n /**\n * Whether the cookie can only be accessed by the server.\n * This is a security feature to prevent client-side scripts from accessing the cookie.\n * If set to false, the cookie can be accessed by client-side scripts.\n * @default true\n */\n httpOnly: boolean // Defaults to true\n /**\n * Whether the cookie should only be sent over secure connections (HTTPS).\n * This is a security feature to prevent the cookie from being sent over unencrypted connections.\n * @default true\n */\n secure: boolean\n /**\n * The SameSite attribute of the cookie.\n * This attribute controls whether the cookie is sent with cross-site requests.\n * - 'none' means the cookie is sent with cross-site requests.\n * - 'lax' means the cookie is sent with top-level navigations and will be sent along with GET\n * requests initiated by third-party websites.\n * @default 'none'\n */\n sameSite: 'none' | 'lax'\n /**\n * The name of the cookie.\n * This is the key under which the session data will be stored in the cookie.\n * @default 'as' - 'as' stands for \"api session\"\n */\n name: string\n}\n\n/**\n * Configuration for JWT-based session transport.\n */\nexport interface JwtConfiguration extends SessionTransport {\n kind: 'jwt'\n /**\n * The lifetime of the JWT token.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"15m\" for 15 minutes.\n *\n * @default \"7d\"\n */\n lifetime: string\n}\n\nexport interface SessionConfiguration {\n /**\n * The secret used to sign the JWT and cookies. Should be handled securely.\n * Not visible in the UI after being set.\n */\n secret: string\n /**\n * The properties from the `User` entity to be encoded into the session payload (JWT/cookie).\n * These properties become available in the `request.auth` object at runtime.\n *\n * In practice, these are the ids of the properties in the `User` entity.\n */\n properties: string[]\n /**\n * The cookie-based session transport configuration.\n */\n cookie?: CookieConfiguration\n\n /**\n * The JWT-based session transport configuration.\n */\n jwt?: JwtConfiguration\n}\n\n/**\n * Defines the authorization strategy for the API.\n * It is a base interface that can be extended for different strategies.\n * For MVP, we will start with Roles-Based Access Control (RBAC).\n */\nexport interface AuthorizationConfiguration {\n /**\n * The authorization strategy. For MVP, we will start with RBAC.\n * Post-MVP will include Permission-Based Access Control (PBAC).\n * The strategy determines how users are granted access to resources.\n *\n * - RBAC (Roles-Based Access Control): Users are assigned roles, and permissions are granted to those roles.\n * - PBAC (Permission-Based Access Control): Users are granted permissions directly, allowing for more\n * granular control.\n */\n strategy: string\n}\n\nexport interface RolesBasedAccessControl extends AuthorizationConfiguration {\n strategy: 'RBAC'\n /**\n * The property within the designated \"User\" entity that defines the user's role.\n * This field is used in access rules to grant permissions.\n *\n * This property must be marked with the \"Role\" data semantic in the Data Modeler.\n * It is required to publish the API.\n */\n roleKey: string\n}\n\n/**\n * Configures the strategy for authenticating end-users.\n * An API can only support one authentication strategy at a time.\n * This is a base interface that can be extended for different strategies.\n */\nexport interface AuthenticationConfiguration {\n /**\n * The authentication method. For MVP, this is focused on username/password.\n * This can be extended in the future to include 'SSO'.\n */\n strategy: string\n}\n\n/**\n * Configuration for username/password authentication.\n * This is the primary authentication method for the API (MVP).\n */\nexport interface UsernamePasswordConfiguration extends AuthenticationConfiguration {\n strategy: 'UsernamePassword'\n /**\n * The specific property within the User entity that holds the password.\n * This property must be marked with the \"Password\" data semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n passwordKey?: string\n}\n\n/**\n * Represents a Data Entity from the Data Domain that the API will expose and operate upon.\n */\nexport interface ExposedEntity {\n /**\n * The key of the Data Entity from the Data Domain.\n */\n key: string\n\n /**\n * Optional configuration for resource-wide rate limiting and throttling.\n * Defines rules to protect the resource from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * Access control rules defining who can perform actions on this resource or collection.\n * It override the top-level access rules defined in the API model.\n */\n accessRule?: AccessRule[]\n\n /**\n * The collection of API actions (e.g., List, Read, Create) enabled for this entity.\n */\n actions: ApiAction[]\n}\n\n/**\n * Represents a specific, configurable API operation applied to a Data Entity.\n * Corresponds to common RESTful interactions.\n */\nexport type ApiAction = ListAction | ReadAction | CreateAction | UpdateAction | DeleteAction | SearchAction\n\n/**\n * A base interface for common properties across all actions.\n */\ninterface Action {\n /**\n * The specific kind of action (e.g., 'List', 'Read', etc.)\n */\n kind: string\n /**\n * Access control rules defining who can perform this action. It is only applied if the\n * authorization strategy is set to 'RBAC'.\n * If no rules grant access, it's denied by default making it essentially private.\n *\n * Note, the API can defined top level access rules that apply to all actions. If this property is set,\n * it overrides the top level access rules for this specific action.\n *\n * It is an ordered list, meaning the first rule that matches the user will be applied.\n * If multiple rules match, the first one in the list takes precedence.\n * If no rules match, the action is denied.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for action-wide rate limiting and throttling.\n * Defines rules to protect the action from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n}\n\n/**\n * Represents a pagination strategy for API actions that return collections of resources.\n * This is a base interface that can be extended for different pagination strategies.\n */\nexport interface PaginationStrategy {\n /**\n * The kind of pagination strategy. This is used to identify the specific pagination method.\n * For example, 'cursor' for cursor-based pagination or 'offset' for offset-based pagination.\n */\n kind: string\n /**\n * The default page size for the pagination strategy.\n * This is the number of items returned per page when no specific page size is requested.\n */\n pageSize?: number\n}\n\n/**\n * Represents the cursor-based pagination strategy.\n */\nexport interface CursorPaginationStrategy extends PaginationStrategy {\n kind: 'cursor'\n}\n\n/**\n * Represents the offset-based pagination strategy.\n */\nexport interface OffsetPaginationStrategy extends PaginationStrategy {\n kind: 'offset'\n}\n\n/**\n * Enables retrieving a collection of resources.\n * Endpoint: GET /[entity-collection-name]\n */\nexport interface ListAction extends Action {\n kind: 'list'\n /**\n * The pagination strategy used for this action.\n * This defines how the results are paginated when retrieving a collection of resources.\n * It can be either 'cursor' or 'offset'.\n */\n pagination: PaginationStrategy\n /**\n * Fields from the entity that can be used for filtering.\n * Must be marked as \"indexable\" in the Data Model.\n */\n filterableFields: string[]\n /**\n * Fields from the entity that can be used for sorting.\n */\n sortableFields: string[]\n}\n\n/**\n * Enables retrieving a single resource by its ID.\n * Endpoint: GET /[entity-collection-name]/{id}\n */\nexport interface ReadAction extends Action {\n kind: 'read'\n // Association handling (Link IDs vs. Embed) is defined on the\n // data association itself in the Data Modeler.\n}\n\n/**\n * Enables adding a new resource to a collection.\n * Endpoint: POST /[entity-collection-name]\n */\nexport interface CreateAction extends Action {\n kind: 'create'\n}\n\n/**\n * Enables modifying an existing resource.\n * Endpoints: PUT or PATCH /[entity-collection-name]/{id}\n */\nexport interface UpdateAction extends Action {\n kind: 'update'\n /**\n * The allowed HTTP methods for updates. Default: PATCH only.\n *\n * These two methods represent the two common ways to update a resource:\n * - PUT: Replaces the entire resource with the provided data.\n * - PATCH: Applies a partial update to the resource, allowing for specific fields to be modified.\n */\n allowedMethods: ('PUT' | 'PATCH')[]\n}\n\n/**\n * Enables removing an existing resource.\n * Endpoint: DELETE /[entity-collection-name]/{id}\n */\nexport interface DeleteAction extends Action {\n kind: 'delete'\n /**\n * The strategy for deletion. Default: Soft Delete.\n *\n * @default 'soft'\n */\n strategy?: 'soft' | 'hard'\n}\n\n/**\n * Enables keyword-based search across specified fields.\n * Endpoint: GET /[entity-collection-name]/search\n */\nexport interface SearchAction extends Action {\n kind: 'search'\n /**\n * The fields within the entity to be included in the search scope.\n * Must be \"indexable\" and typically text-based.\n */\n fields: string[]\n}\n\n/**\n * Defines the access control policy for a specific API action.\n * Based on the predefined rule types for session-based authentication.\n */\nexport type AccessRule =\n | AllowPublicAccessRule\n | AllowAuthenticatedAccessRule\n | MatchResourceOwnerAccessRule\n | MatchUserRoleAccessRule\n | MatchUserPropertyAccessRule\n | MatchEmailDomainAccessRule\n\nexport interface BaseAccessRule {\n /**\n * The unique identifier for the access rule.\n * This is used to reference the rule in the API configuration.\n */\n type: string\n}\n\n/**\n * The action is allowed for all users, including unauthenticated ones.\n * This is typically used for public APIs or resources that do not require authentication.\n * It is the most permissive rule and should be used with caution.\n */\nexport interface AllowPublicAccessRule extends BaseAccessRule {\n type: 'public'\n}\n/**\n * The action is allowed for any authenticated user.\n * This rule does not impose any additional restrictions based on user properties or resource ownership.\n * It is used for resources that should be accessible to all logged-in users.\n */\nexport interface AllowAuthenticatedAccessRule extends BaseAccessRule {\n type: 'authenticated'\n}\n/**\n * The action is allowed if the authenticated user's ID matches a specific property on the resource.\n * This is typically used to restrict access to resources owned by the user.\n * For example, a user can only access their own profile or documents.\n */\nexport interface MatchResourceOwnerAccessRule extends BaseAccessRule {\n type: 'resourceOwner'\n /**\n * The property on the resource that should match the authenticated user's ID.\n * This is typically the ID of the user who owns the resource.\n *\n * The domain model should annotate this property with the \"ResourceOwnerIdentifier\" semantic\n * to indicate that it is used for ownership checks.\n */\n property: string\n}\n\n/**\n * The action is allowed if the authenticated user has a specific role.\n * This is used to enforce role-based access control (RBAC).\n * For example, only users with the \"admin\" role can perform certain actions.\n */\nexport interface MatchUserRoleAccessRule extends BaseAccessRule {\n type: 'matchUserRole'\n /**\n * The role that the authenticated user must have to access the resource.\n * This is typically a property on the user entity that defines their role.\n *\n * The domain model should annotate this property with the \"UserRole\" semantic\n * to indicate that it is used for role-based access control.\n */\n role: string\n}\n/**\n * The action is allowed if a specific property on the authenticated user matches an expected value.\n * This is used to enforce other user-specific restrictions.\n */\nexport interface MatchUserPropertyAccessRule extends BaseAccessRule {\n type: 'matchUserProperty'\n /**\n * The property on the authenticated user that should match the expected value.\n */\n property: string\n /**\n * The expected value for the user property.\n */\n value: string\n}\n/**\n * The action is allowed if the authenticated user's email domain matches a specific domain.\n * This is used to restrict access based on the user's email address.\n * For example, only users with an email address from \"my-company.com\" can access certain resources.\n */\nexport interface MatchEmailDomainAccessRule extends BaseAccessRule {\n type: 'matchEmailDomain'\n /**\n * The email domain that the authenticated user's email must match.\n */\n domain: string\n}\n\n/**\n * Defines the rate limiting and throttling policies for the entire API.\n */\nexport interface RateLimitingConfiguration {\n /**\n * An ordered list of rules. The first rule that matches an incoming\n * request will be applied.\n */\n rules: RateLimitRule[]\n}\n\n/**\n * Represents a single rate limiting rule that applies to a specific\n * type of client, using a token bucket algorithm.\n */\nexport interface RateLimitRule {\n /**\n * A human-readable description of what this rule is for.\n * e.g., \"Limit anonymous users to 60 requests per hour.\"\n */\n description?: string\n\n /**\n * Defines how to group requests for rate limiting. This determines\n * who the limit applies to.\n *\n * - 'ip': Keys on the client's IP address. Best for anonymous traffic.\n * - 'userId': Keys on the authenticated user's ID. Best for logged-in users.\n * - 'role': Applies a shared limit to all users of a specific role.\n */\n key: { type: 'ip' } | { type: 'userId' } | { type: 'role'; value: string }\n\n /**\n * The number of requests allowed over the defined interval.\n * This is the rate at which tokens are added to the bucket.\n */\n rate: number\n\n /**\n * The time interval for the rate.\n */\n interval: 'second' | 'minute' | 'hour' | 'day'\n\n /**\n * The maximum number of requests that can be made in a burst.\n * This represents the \"bucket size.\" A larger burst allows for\n * more requests to be made in a short period before throttling begins.\n */\n burst: number\n}\n\nexport type DomainImpactKinds =\n | typeof DomainNamespaceKind\n | typeof DomainEntityKind\n | typeof DomainModelKind\n | typeof DomainPropertyKind\n | typeof DomainAssociationKind\n | typeof DataDomainKind\n\n/**\n * The impact analysis report\n */\nexport interface DomainImpactReport {\n /**\n * The key of the impacted data object.\n * This is the key of the object that is being changed.\n */\n key: string\n /**\n * The kind of the impacted data object.\n * This is the kind of the object that is being changed.\n */\n kind: DomainImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: DomainImpactItem[]\n /**\n * Whether it is possible to proceed with the change.\n * If the change is not possible, the reason will be in the impact list.\n */\n canProceed: boolean\n}\n\nexport interface DomainImpactItem {\n /**\n * The key of the impacted data object.\n */\n key: string\n /**\n * The kind of the impacted data object.\n */\n kind: string\n /**\n * The type of the impact.\n *\n * - `delete` - The data object would be deleted.\n */\n type: 'delete' | 'publish'\n /**\n * The impact description.\n * Explains what will happen to the impacted data object.\n * This is a human-readable description of the impact.\n * It should be clear and concise.\n */\n impact: string\n /**\n * The severity of the impact.\n *\n * - `info` - The impact is informational.\n * - `warning` - The impact can potentially cause problems but is not a blocker.\n * - `error` - The impact is a blocker and needs to be resolved before proceeding.\n */\n severity: 'info' | 'warning' | 'error'\n /**\n * The type of the relationship between two impacted objects.\n */\n relationship?: 'child'\n /**\n * The resolution of the conflict if the change will be forced.\n */\n resolution?: string\n /**\n * The optional parent of the impacted data object.\n * For example, if the impacted item is a property, this will be the entity it belongs to.\n */\n parent?: string\n}\n\nexport interface DeserializeOptions {\n /**\n * The mode to use for deserialization.\n */\n mode?: DeserializationMode\n /**\n * The serialized graph to deserialize.\n * This is the JSON representation of the graph.\n */\n json?: SerializedGraph\n /**\n * The list of foreign domains that this domain depends on.\n */\n dependencies?: DataDomain[]\n}\n\n/**\n * Describes the mode for deserializing a domain graph.\n */\nexport type DeserializationMode = 'strict' | 'lenient'\n\n/**\n * Describes an issue found during deserialization.\n */\nexport interface DeserializationIssue {\n /**\n * The type of issue encountered.\n */\n type: 'missing_node' | 'missing_edge' | 'invalid_parent' | 'missing_dependency' | 'malformed_entry' | 'unknown_kind'\n /**\n * The severity of the issue.\n */\n severity: 'error' | 'warning' | 'info'\n /**\n * A human-readable description of the issue.\n */\n message: string\n /**\n * The key of the affected node, edge, or entity if applicable.\n */\n affectedKey?: string\n /**\n * Additional context about the issue.\n */\n context?: Record<string, unknown>\n /**\n * The action taken to handle this issue in lenient mode.\n */\n resolution?: string\n}\n\n/**\n * The result of a deserialization operation.\n */\nexport interface DeserializationResult {\n /**\n * The deserialized graph.\n */\n graph: DataDomainGraph\n /**\n * Issues encountered during deserialization.\n */\n issues: DeserializationIssue[]\n /**\n * Whether the deserialization was successful.\n * This is set to true when a critical failures occurred.\n */\n success: boolean\n}\n"]}
|