@api-client/core 0.13.4 → 0.13.6
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/amf/AmfShapeGenerator.js +1 -1
- package/build/src/amf/AmfShapeGenerator.js.map +1 -1
- package/build/src/amf/DataValueGenerator.js +1 -1
- package/build/src/amf/DataValueGenerator.js.map +1 -1
- package/build/src/amf/models/AmfDataNode.js +1 -1
- package/build/src/amf/models/AmfDataNode.js.map +1 -1
- package/build/src/browser.d.ts +1 -1
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +2 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/DataDomain.js +1 -1
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainAssociation.js +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.js +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.js +1 -1
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainModel.js +1 -1
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainNamespace.js +1 -1
- package/build/src/modeling/DomainNamespace.js.map +1 -1
- package/build/src/modeling/DomainProperty.js +1 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
- package/build/src/modeling/legacy/DataAssociation.js +1 -1
- package/build/src/modeling/legacy/DataAssociation.js.map +1 -1
- package/build/src/modeling/legacy/DataEntity.js +1 -1
- package/build/src/modeling/legacy/DataEntity.js.map +1 -1
- package/build/src/modeling/legacy/DataEntityBuilder.js +1 -1
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -1
- package/build/src/modeling/legacy/DataModel.js +1 -1
- package/build/src/modeling/legacy/DataModel.js.map +1 -1
- package/build/src/modeling/legacy/DataNamespace.js +1 -1
- package/build/src/modeling/legacy/DataNamespace.js.map +1 -1
- package/build/src/modeling/legacy/DataProperty.js +1 -1
- package/build/src/modeling/legacy/DataProperty.js.map +1 -1
- package/build/src/models/AuthorizationData.js +1 -1
- package/build/src/models/AuthorizationData.js.map +1 -1
- package/build/src/models/CertificateFile.js +1 -1
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/ClientCertificate.js +1 -1
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/Environment.js +1 -1
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/Folder.js +1 -1
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/HostRule.js +1 -1
- package/build/src/models/HostRule.js.map +1 -1
- package/build/src/models/HttpProject.js +1 -1
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/Project.js +1 -1
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/ProjectFolder.js +1 -1
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectRequest.js +1 -1
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/ProjectSchema.js +1 -1
- package/build/src/models/ProjectSchema.js.map +1 -1
- package/build/src/models/store/Backend.d.ts +8 -0
- package/build/src/models/store/Backend.d.ts.map +1 -1
- package/build/src/models/store/Backend.js.map +1 -1
- package/build/src/models/store/DataFile.js +1 -1
- package/build/src/models/store/DataFile.js.map +1 -1
- package/build/src/models/store/File.js +1 -1
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/Invitation.js +1 -1
- package/build/src/models/store/Invitation.js.map +1 -1
- package/build/src/models/store/Organization.js +1 -1
- package/build/src/models/store/Organization.js.map +1 -1
- package/build/src/models/store/Permission.d.ts +34 -0
- package/build/src/models/store/Permission.d.ts.map +1 -1
- package/build/src/models/store/Permission.js +28 -2
- package/build/src/models/store/Permission.js.map +1 -1
- package/build/src/models/store/UserIdentity.js +1 -1
- package/build/src/models/store/UserIdentity.js.map +1 -1
- package/build/src/models/transformers/ArcDexieTransformer.js +1 -1
- package/build/src/models/transformers/ArcDexieTransformer.js.map +1 -1
- package/build/src/models/transformers/ArcLegacyTransformer.js +1 -1
- package/build/src/models/transformers/ArcLegacyTransformer.js.map +1 -1
- package/build/src/models/transformers/ArcPouchTransformer.js +1 -1
- package/build/src/models/transformers/ArcPouchTransformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV21Transformer.js +1 -1
- package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV2Transformer.js +1 -1
- package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -1
- package/build/src/nanoid.d.ts +10 -0
- package/build/src/nanoid.d.ts.map +1 -0
- package/build/src/nanoid.js +11 -0
- package/build/src/nanoid.js.map +1 -0
- package/build/src/patch/PatchClient.js +1 -1
- package/build/src/patch/PatchClient.js.map +1 -1
- package/build/src/sdk/FilesSdk.js +1 -1
- package/build/src/sdk/FilesSdk.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/package.json +2 -1
- package/src/amf/AmfShapeGenerator.ts +1 -1
- package/src/amf/DataValueGenerator.ts +1 -1
- package/src/amf/models/AmfDataNode.ts +1 -1
- package/src/modeling/DataDomain.ts +1 -1
- package/src/modeling/DomainAssociation.ts +1 -1
- package/src/modeling/DomainEntity.ts +1 -1
- package/src/modeling/DomainFile.ts +1 -1
- package/src/modeling/DomainModel.ts +1 -1
- package/src/modeling/DomainNamespace.ts +1 -1
- package/src/modeling/DomainProperty.ts +1 -1
- package/src/modeling/amf/ShapeGenerator.ts +1 -1
- package/src/modeling/legacy/DataAssociation.ts +1 -1
- package/src/modeling/legacy/DataEntity.ts +1 -1
- package/src/modeling/legacy/DataEntityBuilder.ts +1 -1
- package/src/modeling/legacy/DataModel.ts +1 -1
- package/src/modeling/legacy/DataNamespace.ts +1 -1
- package/src/modeling/legacy/DataProperty.ts +1 -1
- package/src/models/AuthorizationData.ts +1 -1
- package/src/models/CertificateFile.ts +1 -1
- package/src/models/ClientCertificate.ts +1 -1
- package/src/models/Environment.ts +1 -1
- package/src/models/Folder.ts +1 -1
- package/src/models/HostRule.ts +1 -1
- package/src/models/HttpProject.ts +1 -1
- package/src/models/Project.ts +1 -1
- package/src/models/ProjectFolder.ts +1 -1
- package/src/models/ProjectRequest.ts +1 -1
- package/src/models/ProjectSchema.ts +1 -1
- package/src/models/store/Backend.ts +8 -0
- package/src/models/store/DataFile.ts +1 -1
- package/src/models/store/File.ts +1 -1
- package/src/models/store/Invitation.ts +1 -1
- package/src/models/store/Organization.ts +1 -1
- package/src/models/store/Permission.ts +59 -2
- package/src/models/store/UserIdentity.ts +1 -1
- package/src/models/transformers/ArcDexieTransformer.ts +1 -1
- package/src/models/transformers/ArcLegacyTransformer.ts +1 -1
- package/src/models/transformers/ArcPouchTransformer.ts +1 -1
- package/src/models/transformers/PostmanV21Transformer.ts +1 -1
- package/src/models/transformers/PostmanV2Transformer.ts +1 -1
- package/src/nanoid.ts +10 -0
- package/src/patch/PatchClient.ts +1 -1
- package/src/sdk/FilesSdk.ts +1 -1
- package/tests/unit/modeling/domain_file.spec.ts +4 -0
- package/tests/unit/models/File/new.spec.ts +2 -0
- package/tests/unit/models/File/toJSON.spec.ts +2 -0
- package/tests/unit/models/Folder/create.spec.ts +4 -0
- package/tests/unit/models/Permission/all.spec.ts +88 -0
- package/tests/unit/models/Project/create.spec.ts +4 -0
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataNamespace.js","sourceRoot":"","sources":["../../../../src/modeling/legacy/DataNamespace.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAU,KAAK,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAoB,eAAe,EAAqB,MAAM,sBAAsB,C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,CAAC,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,GAAW;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;IAChD,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport { IThing, Thing } from '../../models/Thing.js'\nimport { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js'\nimport { IDataEntity, DataEntity } from './DataEntity.js'\nimport { IDataModel, DataModel } from './DataModel.js'\nimport { IDataProperty, DataProperty } from './DataProperty.js'\nimport {\n DataNamespaceKind,\n DataModelKind,\n DataEntityKind,\n DataPropertyKind,\n DataAssociationKind,\n} from '../../models/kinds.js'\nimport { nanoid } from 'nanoid'\nimport type { DataDomainRemoveOptions } from '../types.js'\n\n/**\n * @deprecated\n */\ntype ItemKind = typeof DataNamespaceKind | typeof DataModelKind\n\n/**\n * @deprecated\n */\nexport interface DataItemAdaptingOptions {\n /**\n * The index at which to adapt the item.\n */\n index?: number\n}\n/**\n * @deprecated\n */\ninterface IDataDefinitions {\n models?: IDataModel[]\n entities?: IDataEntity[]\n properties?: IDataProperty[]\n associations?: IDataAssociation[]\n namespaces?: IDataNamespace[]\n tags?: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * @deprecated\n */\ninterface DataDefinitions {\n models: DataModel[]\n // @todo: This should be a map of entities with a key of the entity key.\n entities: DataEntity[]\n // @todo: This should be a map of properties with a key of the property key.\n properties: DataProperty[]\n // @todo: This should be a map of associations with a key of the association key.\n associations: DataAssociation[]\n namespaces: DataNamespace[]\n /**\n * Common for the entire root namespace tags.\n * These are kept separately so the UI can generate autocomplete for tags.\n */\n tags: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * Data definition for a foreign namespace.\n * Each foreign namespace is resolved to a specific version.\n * This makes sure that the local data are always referencing an existing\n * entity as breaking changes should be resolved when upgrading a version.\n * @deprecated\n */\ninterface ForeignNamespace {\n key: string\n version: string\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n * @deprecated\n */\nexport interface IDataNamespace {\n kind: typeof DataNamespaceKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The ordered list of items in this namespace.\n */\n items: IDataItem[]\n /**\n * The data namespace description.\n */\n info: IThing\n /**\n * The list of definitions used in the namespace.\n */\n definitions: IDataDefinitions\n}\n\n/**\n * Data item is a reference to an object in the top namespace definitions\n * to the namespace items.\n * @deprecated\n */\nexport interface IDataItem {\n /**\n * The kind of the item.\n */\n kind: ItemKind\n /**\n * The identifier in the `definitions` array of the namespace.\n */\n key: string\n}\n\n/**\n * @deprecated\n */\nexport class DataItem implements IDataItem {\n kind: ItemKind = DataModelKind\n\n key = ''\n\n /**\n * A reference to the top level namespace.\n */\n private root: DataNamespace\n\n static isDataItem(input: unknown): boolean {\n const typed = input as IDataItem\n if (!input || ![DataModelKind, DataNamespaceKind].includes(typed.kind)) {\n return false\n }\n return true\n }\n\n static dataNamespace(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataNamespaceKind,\n key,\n })\n return item\n }\n\n static dataModel(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataModelKind,\n key,\n })\n return item\n }\n\n /**\n * @param root The top-most data namespace.\n * @param input The project item definition used to restore the state.\n */\n constructor(root: DataNamespace, input: string | IDataItem) {\n this.root = root\n let init: IDataItem\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n throw new Error('Specify the type of the item.')\n }\n this.new(init)\n }\n\n new(init: IDataItem): void {\n if (!DataItem.isDataItem(init)) {\n throw new Error(`Not a data item.`)\n }\n const { kind, key } = init\n this.kind = kind\n this.key = key\n }\n\n toJSON(): IDataItem {\n const result: IDataItem = {\n kind: this.kind,\n key: this.key,\n }\n return result\n }\n\n getItem(): DataNamespace | DataModel | undefined {\n const { root, key, kind } = this\n const { definitions } = root\n if (kind === DataModelKind) {\n return definitions.models.find((i) => i.key === key)\n }\n if (kind === kind) {\n return definitions.namespaces.find((i) => i.key === key)\n }\n }\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n * @deprecated\n */\nexport class DataNamespace {\n kind = DataNamespaceKind\n\n key = ''\n\n /**\n * The ordered list of items in this namespace.\n */\n items: DataItem[] = []\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * When a namespace is a sub-namespace this is the reference to the\n * root namespace with all definitions.\n */\n root?: DataNamespace\n /**\n * The list of definitions used in the namespace.\n */\n definitions: DataDefinitions\n\n /**\n * The list of foreign namespaces.\n * This is used to find entities from foreign namespaces.\n * Values here are treated as read only (objects can be frozen).\n *\n * This should be set by the application and the namespace will do\n * nothing to populate this value.\n */\n foreign: DataNamespace[] = []\n\n /**\n * Creates a new data namespace from a name.\n * @param name The name to set.\n */\n static fromName(name: string, root?: DataNamespace): DataNamespace {\n const ns = new DataNamespace(undefined, root)\n const info = Thing.fromName(name)\n ns.info = info\n return ns\n }\n\n /**\n * @deprecated\n */\n static definitions(): DataDefinitions {\n return {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n }\n\n constructor(input?: string | IDataNamespace, root?: DataNamespace) {\n this.root = root\n this.definitions = {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n\n let init: IDataNamespace\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n if (!init.kind) {\n init.kind = DataNamespaceKind\n }\n } else {\n init = {\n kind: DataNamespaceKind,\n key: nanoid(),\n definitions: {},\n items: [],\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataNamespace): void {\n if (!init || !init.definitions || !init.items) {\n throw new Error(`Not a data namespace.`)\n }\n const { key = nanoid(), definitions = {}, items, info } = init\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(items)) {\n this.items = items.map((i) => new DataItem(this, i))\n } else {\n this.items = []\n }\n if (Array.isArray(definitions.associations)) {\n this.definitions.associations = definitions.associations.map((i) => new DataAssociation(this, i))\n } else {\n this.definitions.associations = []\n }\n if (Array.isArray(definitions.properties)) {\n this.definitions.properties = definitions.properties.map((i) => new DataProperty(this, i))\n } else {\n this.definitions.properties = []\n }\n // note, entities must be restored after properties / associations\n if (Array.isArray(definitions.entities)) {\n this.definitions.entities = definitions.entities.map((i) => new DataEntity(this, i))\n } else {\n this.definitions.entities = []\n }\n // must be set after entities.\n if (Array.isArray(definitions.models)) {\n this.definitions.models = definitions.models.map((i) => new DataModel(this, i))\n } else {\n this.definitions.models = []\n }\n if (Array.isArray(definitions.namespaces)) {\n this.definitions.namespaces = definitions.namespaces.map((i) => new DataNamespace(i, this))\n } else {\n this.definitions.namespaces = []\n }\n if (Array.isArray(definitions.tags)) {\n this.definitions.tags = [...definitions.tags]\n } else {\n this.definitions.tags = []\n }\n }\n\n toJSON(): IDataNamespace {\n const result: IDataNamespace = {\n key: this.key,\n kind: DataNamespaceKind,\n info: this.info.toJSON(),\n items: this.items.map((i) => i.toJSON()),\n definitions: {},\n }\n const { associations, entities, models, namespaces, properties, tags } = this.definitions\n if (Array.isArray(associations) && associations.length) {\n result.definitions.associations = associations.map((i) => i.toJSON())\n }\n if (Array.isArray(entities) && entities.length) {\n result.definitions.entities = entities.map((i) => i.toJSON())\n }\n if (Array.isArray(models) && models.length) {\n result.definitions.models = models.map((i) => i.toJSON())\n }\n if (Array.isArray(namespaces) && namespaces.length) {\n result.definitions.namespaces = namespaces.map((i) => i.toJSON())\n }\n if (Array.isArray(properties) && properties.length) {\n result.definitions.properties = properties.map((i) => i.toJSON())\n }\n if (Array.isArray(tags) && tags.length) {\n result.definitions.tags = [...tags]\n }\n return result\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataNamespace | undefined {\n return this.getParentInstance()\n }\n\n /**\n * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.\n */\n getParentInstance(): DataNamespace | undefined {\n const { root, key } = this\n if (root) {\n return root.findParent(key)\n }\n // we are the root namespace.\n return undefined\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listNamespaces(): DataNamespace[] {\n const result: DataNamespace[] = []\n const { items } = this\n const root = this.getRoot()\n const { namespaces } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataNamespaceKind) {\n return\n }\n const def = namespaces.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listDataModels(): DataModel[] {\n const result: DataModel[] = []\n const { items } = this\n const root = this.getRoot()\n const { models } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataModelKind) {\n return\n }\n const def = models.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * @returns The root of the namespaces tree. It might be the same object.\n */\n getRoot(): DataNamespace {\n if (this.root) {\n return this.root\n }\n return this as unknown as DataNamespace\n }\n\n /**\n * Removes self from the parent namespace with all data models.\n * This does noting for the root namespace.\n */\n remove(opts?: DataDomainRemoveOptions): void {\n const { root } = this\n if (!root) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const models = this.listDataModels()\n const children = this.listNamespaces()\n models.forEach((m) => m.remove(opts))\n children.forEach((c) => c.remove(opts))\n const index = root.definitions.namespaces.findIndex((i) => i.key === this.key)\n if (index >= 0) {\n root.definitions.namespaces.splice(index, 1)\n }\n }\n\n /**\n * Checks if this is the root namespace.\n * @returns True if this is the root namespace.\n */\n isRoot(): boolean {\n return this.root === undefined\n }\n\n /**\n * Finds a parent namespace for the given namespace.\n * @param key The namespace key to find the parent for.\n * @returns The parent namespace or undefined when the namespace does not exist. It may return the root namespace.\n */\n findParent(key: string): DataNamespace | undefined {\n const { definitions, items = [] } = this\n const rootIndex = items.findIndex((i) => i.key === key)\n if (rootIndex >= 0) {\n return this\n }\n const definition = definitions.namespaces.find((i) => i.items.some((item) => item.key === key))\n if (definition) {\n return definition\n }\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n * @param parent The optional key of the parent namespace to add the new namespace to.\n */\n addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataNamespace\n if (typeof init === 'string') {\n definition = DataNamespace.fromName(init, this.root || this)\n } else if (init instanceof DataNamespace) {\n definition = init\n } else {\n definition = new DataNamespace(init, this.root || this)\n }\n ;(this.root || this).definitions.namespaces.push(definition)\n const item = DataItem.dataNamespace(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Adapts an existing namespace to this namespace.\n * This will remove the namespace from the parent namespace and add it to this one.\n *\n * @param ns The namespace to adapt.\n * @param opts Adapting options.\n */\n adaptNamespace(ns: DataNamespace, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (ns === this) {\n throw new Error(`Unable to adapt a namespace that is self.`)\n }\n if (ns.root !== this.root) {\n throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`)\n }\n if (ns.getParentInstance() === this) {\n throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`)\n }\n // Check for circular dependency\n let current: DataNamespace | undefined = this\n while (current) {\n if (current === ns) {\n throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`)\n }\n current = current.getParentInstance()\n }\n const parent = ns.getParentInstance() || this.root\n if (!parent) {\n throw new Error(`The namespace ${ns.key} has no parent.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === ns.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Adapts an existing data model to this namespace.\n * This will remove the data model from the parent namespace and add it to this one.\n * @param model The data model to adapt.\n * @param opts The adapting options.\n */\n adaptDataModel(model: DataModel, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (model.root !== this.root) {\n throw new Error(`The data model ${model.key} is not in the same namespace as this data namespace.`)\n }\n const parent = model.getParentInstance()\n if (!parent) {\n throw new Error(`The data model ${model.key} has no parent.`)\n }\n if (parent === this) {\n throw new Error(`The data model ${model.key} is already adapted by this data namespace.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === model.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Finds a namespace in the definitions.\n * @param key The key of the namespace to find.\n * @returns The namespace definition or undefined when not found.\n */\n findNamespace(key: string): DataNamespace | undefined {\n const { definitions } = this.root || this\n return definitions.namespaces.find((i) => i.key === key)\n }\n\n /**\n * Finds a namespace and calls the `remove()` on it.\n * @param key The key of the namespace to find.\n */\n removeNamespace(key: string, opts?: DataDomainRemoveOptions): void {\n const root = this.root || this\n if (root.key === key) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const { definitions } = root\n const ns = definitions.namespaces.find((i) => i.key === key)\n if (ns) {\n ns.remove(opts)\n }\n }\n\n /**\n * Adds a data model to a namespace.\n * @param init The name of the data model to add, data model's schema, or its instance.\n * @param parent The optional key of the parent namespace to add the new data model to.\n */\n addDataModel(init: string | IDataModel | DataModel, parent?: string): DataModel {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataModel\n if (typeof init === 'string') {\n definition = DataModel.fromName(this.root || this, init)\n } else if (init instanceof DataModel) {\n definition = init\n } else {\n definition = new DataModel(this.root || this, init)\n }\n ;(this.root || this).definitions.models.push(definition)\n const item = DataItem.dataModel(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Finds a data model in the definitions.\n * @param key The key of the data model to find.\n * @returns The data model definition or undefined when not found.\n */\n findDataModel(key: string): DataModel | undefined {\n const { definitions } = this.root || this\n return definitions.models.find((i) => i.key === key)\n }\n\n /**\n * A convenience function to remove an object from the namespace.\n * @param key The key of the object to remove.\n * @param kind The kind of the object to remove.\n * @param opts The options for the removal.\n * @throws Error when the kind is not known.\n */\n removeObject(key: string, kind: string, opts?: DataDomainRemoveOptions): void {\n switch (kind) {\n case DataNamespaceKind:\n this.findNamespace(key)?.remove(opts)\n break\n case DataModelKind:\n this.findDataModel(key)?.remove(opts)\n break\n case DataEntityKind:\n this.findEntity(key)?.remove(opts)\n break\n case DataPropertyKind:\n this.findProperty(key)?.remove()\n break\n case DataAssociationKind:\n this.findAssociation(key)?.remove()\n break\n default:\n throw new Error(`Unknown kind ${kind} for the object ${key}.`)\n }\n }\n\n /**\n * Finds a data model and calls the `remove()` on it.\n * @param key The key of the data model to find.\n */\n removeDataModel(key: string, opts?: DataDomainRemoveOptions): void {\n const { definitions } = this.root || this\n const model = definitions.models.find((i) => i.key === key)\n if (model) {\n model.remove(opts)\n }\n }\n\n /**\n * @returns The graph of associations where keys are the source\n * entities and the value is the list of all target entities.\n */\n associationGraph(): Record<string, string[]> {\n const graph: Record<string, string[]> = {}\n const { definitions } = this.root || this\n const { associations, entities } = definitions\n for (const assoc of associations) {\n if (!assoc.targets.length) {\n continue\n }\n const srcEntity = entities.find((i) => i.associations.some((a) => a === assoc))\n if (!srcEntity) {\n continue\n }\n if (!graph[srcEntity.key]) {\n graph[srcEntity.key] = []\n }\n const targetIds = assoc.targets.map((i) => i.key)\n graph[srcEntity.key].splice(0, 0, ...targetIds)\n }\n return graph\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n *\n * @param from The key of the from entity\n * @param to The key of the target entity\n * @param g The graph generated with `associationGraph()`\n * @param path The current list of entity ids. Do not set this, it is for the recursive processing of the graph.\n * @param visited The list of visited paths to avoid cycles.\n * Do not set this, it is for the recursive processing of the graph.\n */\n *associationPath(\n from: string,\n to: string,\n g: Record<string, string[]>,\n path: string[] = [],\n visited = new Set<string>()\n ): Generator<string[]> {\n if (from === to) {\n yield path.concat(to)\n return\n }\n if (visited.has(from)) {\n // it's a cycle\n return\n }\n if (g[from]) {\n visited.add(from)\n path.push(from)\n\n for (const neighbor of g[from]) {\n yield* this.associationPath(neighbor, to, g, path, visited)\n }\n\n visited.delete(from)\n path.pop()\n }\n }\n\n /**\n * Scans all associations for foreign namespaces and returns\n * the list of all namespaces used in the association graph.\n * This will never add this namespace's key.\n *\n * This function should be used to read keys for all related\n * namespaces through associations.\n *\n * @returns All keys of foreign namespaces.\n */\n computeForeignNamespaceKeys(): string[] {\n const result: string[] = []\n const { associations = [] } = this.definitions\n associations.forEach((association) => {\n const { targets = [] } = association\n targets.forEach((target) => {\n const { namespace } = target\n if (!namespace || namespace === this.key) {\n return\n }\n result.push(namespace)\n })\n })\n return result\n }\n\n /**\n * Finds an entity in this namespace.\n * @param key The key of the entity to find.\n */\n findEntity(key: string): DataEntity | undefined {\n const { definitions } = this.root || this\n return definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Finds a property by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findProperty(key: string): DataProperty | undefined {\n const { definitions } = this.root || this\n return definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Finds an association by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findAssociation(key: string): DataAssociation | undefined {\n const { definitions } = this.root || this\n return definitions.associations.find((i) => i.key === key)\n }\n\n /**\n * Searches for entities for association targets.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param targets The list of targets\n * @returns A list of entities. An `undefined` is put at the index where an entity cannot be found\n */\n findAssociatedEntities(targets: AssociationTarget[]): (DataEntity | undefined)[] {\n const result: (DataEntity | undefined)[] = []\n targets.forEach((target) => {\n let ns: DataNamespace | undefined\n if (target.namespace) {\n ns = this.foreign.find((i) => i.key === target.namespace)\n } else {\n ns = this\n }\n if (!ns) {\n result.push(undefined)\n return\n }\n const entity = ns.findEntity(target.key)\n if (entity) {\n result.push(entity)\n } else {\n result.push(undefined)\n }\n })\n return result\n }\n\n /**\n * Finds an associated entity in the current or foreign namespace.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param key The key of the entity to find.\n * @param namespace The optional namespace to search in.\n * If not set, the current namespace is used.\n * This is used to find entities in foreign namespaces.\n * @returns The entity or undefined if not found.\n */\n findAssociatedEntity(key: string, namespace?: string): DataEntity | undefined {\n let ns: DataNamespace | undefined\n if (namespace) {\n ns = this.foreign.find((i) => i.key === namespace)\n } else {\n ns = this\n }\n if (!ns) {\n return undefined\n }\n return ns.findEntity(key)\n }\n\n addForeign(ns: DataNamespace): void {\n const exists = this.foreign.some((i) => i.key === ns.key)\n if (exists) {\n return\n }\n this.foreign.push(ns)\n }\n\n removeForeign(ns: DataNamespace): void {\n const index = this.foreign.findIndex((i) => i === ns)\n if (index >= 0) {\n this.foreign.splice(index, 1)\n }\n }\n\n hasForeignNamespace(key: string): boolean {\n return this.foreign.some((i) => i.key === key)\n }\n\n /**\n * Checks whether the namespace is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this namespace is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataNamespace.js","sourceRoot":"","sources":["../../../../src/modeling/legacy/DataNamespace.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAU,KAAK,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAoB,eAAe,EAAqB,MAAM,sBAAsB,CAAA;AAC3F,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAc,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAiB,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AA4GxC;;GAEG;AACH,MAAM,OAAO,QAAQ;IACnB,IAAI,GAAa,aAAa,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AE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\nimport { IThing, Thing } from '../../models/Thing.js'\nimport { IDataAssociation, DataAssociation, AssociationTarget } from './DataAssociation.js'\nimport { IDataEntity, DataEntity } from './DataEntity.js'\nimport { IDataModel, DataModel } from './DataModel.js'\nimport { IDataProperty, DataProperty } from './DataProperty.js'\nimport {\n DataNamespaceKind,\n DataModelKind,\n DataEntityKind,\n DataPropertyKind,\n DataAssociationKind,\n} from '../../models/kinds.js'\nimport { nanoid } from '../../nanoid.js'\nimport type { DataDomainRemoveOptions } from '../types.js'\n\n/**\n * @deprecated\n */\ntype ItemKind = typeof DataNamespaceKind | typeof DataModelKind\n\n/**\n * @deprecated\n */\nexport interface DataItemAdaptingOptions {\n /**\n * The index at which to adapt the item.\n */\n index?: number\n}\n/**\n * @deprecated\n */\ninterface IDataDefinitions {\n models?: IDataModel[]\n entities?: IDataEntity[]\n properties?: IDataProperty[]\n associations?: IDataAssociation[]\n namespaces?: IDataNamespace[]\n tags?: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * @deprecated\n */\ninterface DataDefinitions {\n models: DataModel[]\n // @todo: This should be a map of entities with a key of the entity key.\n entities: DataEntity[]\n // @todo: This should be a map of properties with a key of the property key.\n properties: DataProperty[]\n // @todo: This should be a map of associations with a key of the association key.\n associations: DataAssociation[]\n namespaces: DataNamespace[]\n /**\n * Common for the entire root namespace tags.\n * These are kept separately so the UI can generate autocomplete for tags.\n */\n tags: string[]\n /**\n * The list of foreign namespaces associated with this namespace.\n */\n foreign?: ForeignNamespace[]\n}\n\n/**\n * Data definition for a foreign namespace.\n * Each foreign namespace is resolved to a specific version.\n * This makes sure that the local data are always referencing an existing\n * entity as breaking changes should be resolved when upgrading a version.\n * @deprecated\n */\ninterface ForeignNamespace {\n key: string\n version: string\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n * @deprecated\n */\nexport interface IDataNamespace {\n kind: typeof DataNamespaceKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The ordered list of items in this namespace.\n */\n items: IDataItem[]\n /**\n * The data namespace description.\n */\n info: IThing\n /**\n * The list of definitions used in the namespace.\n */\n definitions: IDataDefinitions\n}\n\n/**\n * Data item is a reference to an object in the top namespace definitions\n * to the namespace items.\n * @deprecated\n */\nexport interface IDataItem {\n /**\n * The kind of the item.\n */\n kind: ItemKind\n /**\n * The identifier in the `definitions` array of the namespace.\n */\n key: string\n}\n\n/**\n * @deprecated\n */\nexport class DataItem implements IDataItem {\n kind: ItemKind = DataModelKind\n\n key = ''\n\n /**\n * A reference to the top level namespace.\n */\n private root: DataNamespace\n\n static isDataItem(input: unknown): boolean {\n const typed = input as IDataItem\n if (!input || ![DataModelKind, DataNamespaceKind].includes(typed.kind)) {\n return false\n }\n return true\n }\n\n static dataNamespace(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataNamespaceKind,\n key,\n })\n return item\n }\n\n static dataModel(root: DataNamespace, key: string): DataItem {\n const item = new DataItem(root, {\n kind: DataModelKind,\n key,\n })\n return item\n }\n\n /**\n * @param root The top-most data namespace.\n * @param input The project item definition used to restore the state.\n */\n constructor(root: DataNamespace, input: string | IDataItem) {\n this.root = root\n let init: IDataItem\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n throw new Error('Specify the type of the item.')\n }\n this.new(init)\n }\n\n new(init: IDataItem): void {\n if (!DataItem.isDataItem(init)) {\n throw new Error(`Not a data item.`)\n }\n const { kind, key } = init\n this.kind = kind\n this.key = key\n }\n\n toJSON(): IDataItem {\n const result: IDataItem = {\n kind: this.kind,\n key: this.key,\n }\n return result\n }\n\n getItem(): DataNamespace | DataModel | undefined {\n const { root, key, kind } = this\n const { definitions } = root\n if (kind === DataModelKind) {\n return definitions.models.find((i) => i.key === key)\n }\n if (kind === kind) {\n return definitions.namespaces.find((i) => i.key === key)\n }\n }\n}\n\n/**\n * Data namespace is a logical description of the hierarchy in the data.\n * @deprecated\n */\nexport class DataNamespace {\n kind = DataNamespaceKind\n\n key = ''\n\n /**\n * The ordered list of items in this namespace.\n */\n items: DataItem[] = []\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * When a namespace is a sub-namespace this is the reference to the\n * root namespace with all definitions.\n */\n root?: DataNamespace\n /**\n * The list of definitions used in the namespace.\n */\n definitions: DataDefinitions\n\n /**\n * The list of foreign namespaces.\n * This is used to find entities from foreign namespaces.\n * Values here are treated as read only (objects can be frozen).\n *\n * This should be set by the application and the namespace will do\n * nothing to populate this value.\n */\n foreign: DataNamespace[] = []\n\n /**\n * Creates a new data namespace from a name.\n * @param name The name to set.\n */\n static fromName(name: string, root?: DataNamespace): DataNamespace {\n const ns = new DataNamespace(undefined, root)\n const info = Thing.fromName(name)\n ns.info = info\n return ns\n }\n\n /**\n * @deprecated\n */\n static definitions(): DataDefinitions {\n return {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n }\n\n constructor(input?: string | IDataNamespace, root?: DataNamespace) {\n this.root = root\n this.definitions = {\n models: [],\n associations: [],\n entities: [],\n properties: [],\n namespaces: [],\n tags: [],\n }\n\n let init: IDataNamespace\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n if (!init.kind) {\n init.kind = DataNamespaceKind\n }\n } else {\n init = {\n kind: DataNamespaceKind,\n key: nanoid(),\n definitions: {},\n items: [],\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataNamespace): void {\n if (!init || !init.definitions || !init.items) {\n throw new Error(`Not a data namespace.`)\n }\n const { key = nanoid(), definitions = {}, items, info } = init\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(items)) {\n this.items = items.map((i) => new DataItem(this, i))\n } else {\n this.items = []\n }\n if (Array.isArray(definitions.associations)) {\n this.definitions.associations = definitions.associations.map((i) => new DataAssociation(this, i))\n } else {\n this.definitions.associations = []\n }\n if (Array.isArray(definitions.properties)) {\n this.definitions.properties = definitions.properties.map((i) => new DataProperty(this, i))\n } else {\n this.definitions.properties = []\n }\n // note, entities must be restored after properties / associations\n if (Array.isArray(definitions.entities)) {\n this.definitions.entities = definitions.entities.map((i) => new DataEntity(this, i))\n } else {\n this.definitions.entities = []\n }\n // must be set after entities.\n if (Array.isArray(definitions.models)) {\n this.definitions.models = definitions.models.map((i) => new DataModel(this, i))\n } else {\n this.definitions.models = []\n }\n if (Array.isArray(definitions.namespaces)) {\n this.definitions.namespaces = definitions.namespaces.map((i) => new DataNamespace(i, this))\n } else {\n this.definitions.namespaces = []\n }\n if (Array.isArray(definitions.tags)) {\n this.definitions.tags = [...definitions.tags]\n } else {\n this.definitions.tags = []\n }\n }\n\n toJSON(): IDataNamespace {\n const result: IDataNamespace = {\n key: this.key,\n kind: DataNamespaceKind,\n info: this.info.toJSON(),\n items: this.items.map((i) => i.toJSON()),\n definitions: {},\n }\n const { associations, entities, models, namespaces, properties, tags } = this.definitions\n if (Array.isArray(associations) && associations.length) {\n result.definitions.associations = associations.map((i) => i.toJSON())\n }\n if (Array.isArray(entities) && entities.length) {\n result.definitions.entities = entities.map((i) => i.toJSON())\n }\n if (Array.isArray(models) && models.length) {\n result.definitions.models = models.map((i) => i.toJSON())\n }\n if (Array.isArray(namespaces) && namespaces.length) {\n result.definitions.namespaces = namespaces.map((i) => i.toJSON())\n }\n if (Array.isArray(properties) && properties.length) {\n result.definitions.properties = properties.map((i) => i.toJSON())\n }\n if (Array.isArray(tags) && tags.length) {\n result.definitions.tags = [...tags]\n }\n return result\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataNamespace | undefined {\n return this.getParentInstance()\n }\n\n /**\n * @returns The parent namespace of this namespace. It returns `undefined` when this is the root namespace.\n */\n getParentInstance(): DataNamespace | undefined {\n const { root, key } = this\n if (root) {\n return root.findParent(key)\n }\n // we are the root namespace.\n return undefined\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listNamespaces(): DataNamespace[] {\n const result: DataNamespace[] = []\n const { items } = this\n const root = this.getRoot()\n const { namespaces } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataNamespaceKind) {\n return\n }\n const def = namespaces.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * Lists namespaces that are in this namespace items.\n */\n listDataModels(): DataModel[] {\n const result: DataModel[] = []\n const { items } = this\n const root = this.getRoot()\n const { models } = root.definitions\n items.forEach((i) => {\n if (i.kind !== DataModelKind) {\n return\n }\n const def = models.find((j) => j.key === i.key)\n if (def) {\n result.push(def)\n }\n })\n return result\n }\n\n /**\n * @returns The root of the namespaces tree. It might be the same object.\n */\n getRoot(): DataNamespace {\n if (this.root) {\n return this.root\n }\n return this as unknown as DataNamespace\n }\n\n /**\n * Removes self from the parent namespace with all data models.\n * This does noting for the root namespace.\n */\n remove(opts?: DataDomainRemoveOptions): void {\n const { root } = this\n if (!root) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const models = this.listDataModels()\n const children = this.listNamespaces()\n models.forEach((m) => m.remove(opts))\n children.forEach((c) => c.remove(opts))\n const index = root.definitions.namespaces.findIndex((i) => i.key === this.key)\n if (index >= 0) {\n root.definitions.namespaces.splice(index, 1)\n }\n }\n\n /**\n * Checks if this is the root namespace.\n * @returns True if this is the root namespace.\n */\n isRoot(): boolean {\n return this.root === undefined\n }\n\n /**\n * Finds a parent namespace for the given namespace.\n * @param key The namespace key to find the parent for.\n * @returns The parent namespace or undefined when the namespace does not exist. It may return the root namespace.\n */\n findParent(key: string): DataNamespace | undefined {\n const { definitions, items = [] } = this\n const rootIndex = items.findIndex((i) => i.key === key)\n if (rootIndex >= 0) {\n return this\n }\n const definition = definitions.namespaces.find((i) => i.items.some((item) => item.key === key))\n if (definition) {\n return definition\n }\n return undefined\n }\n\n /**\n * Adds a data namespace to the structure.\n * @param init The name of the namespace to add, namespace's schema, or instance.\n * @param parent The optional key of the parent namespace to add the new namespace to.\n */\n addNamespace(init: string | IDataNamespace | DataNamespace, parent?: string): DataNamespace {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataNamespace\n if (typeof init === 'string') {\n definition = DataNamespace.fromName(init, this.root || this)\n } else if (init instanceof DataNamespace) {\n definition = init\n } else {\n definition = new DataNamespace(init, this.root || this)\n }\n ;(this.root || this).definitions.namespaces.push(definition)\n const item = DataItem.dataNamespace(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Adapts an existing namespace to this namespace.\n * This will remove the namespace from the parent namespace and add it to this one.\n *\n * @param ns The namespace to adapt.\n * @param opts Adapting options.\n */\n adaptNamespace(ns: DataNamespace, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (ns === this) {\n throw new Error(`Unable to adapt a namespace that is self.`)\n }\n if (ns.root !== this.root) {\n throw new Error(`The namespace ${ns.key} is not in the same namespace as this data namespace.`)\n }\n if (ns.getParentInstance() === this) {\n throw new Error(`The namespace ${ns.key} is already adapted by this data namespace.`)\n }\n // Check for circular dependency\n let current: DataNamespace | undefined = this\n while (current) {\n if (current === ns) {\n throw new Error(`Unable to adapt namespace ${ns.key} under itself or one of its children.`)\n }\n current = current.getParentInstance()\n }\n const parent = ns.getParentInstance() || this.root\n if (!parent) {\n throw new Error(`The namespace ${ns.key} has no parent.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === ns.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Adapts an existing data model to this namespace.\n * This will remove the data model from the parent namespace and add it to this one.\n * @param model The data model to adapt.\n * @param opts The adapting options.\n */\n adaptDataModel(model: DataModel, opts: DataItemAdaptingOptions = {}): void {\n if (opts.index !== undefined) {\n if (opts.index < 0) {\n throw new Error(`The index ${opts.index} cannot be below 0.`)\n }\n if (opts.index >= this.items.length) {\n throw new Error(`The index ${opts.index} is not valid.`)\n }\n }\n if (model.root !== this.root) {\n throw new Error(`The data model ${model.key} is not in the same namespace as this data namespace.`)\n }\n const parent = model.getParentInstance()\n if (!parent) {\n throw new Error(`The data model ${model.key} has no parent.`)\n }\n if (parent === this) {\n throw new Error(`The data model ${model.key} is already adapted by this data namespace.`)\n }\n // it has a parent (above check) so it has the index.\n const index = parent.items.findIndex((i) => i.key === model.key)\n const [item] = parent.items.splice(index, 1)\n if (opts.index !== undefined) {\n this.items.splice(opts.index, 0, item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Finds a namespace in the definitions.\n * @param key The key of the namespace to find.\n * @returns The namespace definition or undefined when not found.\n */\n findNamespace(key: string): DataNamespace | undefined {\n const { definitions } = this.root || this\n return definitions.namespaces.find((i) => i.key === key)\n }\n\n /**\n * Finds a namespace and calls the `remove()` on it.\n * @param key The key of the namespace to find.\n */\n removeNamespace(key: string, opts?: DataDomainRemoveOptions): void {\n const root = this.root || this\n if (root.key === key) {\n throw new Error(`Unable to remove the root namespace this way.`)\n }\n const { definitions } = root\n const ns = definitions.namespaces.find((i) => i.key === key)\n if (ns) {\n ns.remove(opts)\n }\n }\n\n /**\n * Adds a data model to a namespace.\n * @param init The name of the data model to add, data model's schema, or its instance.\n * @param parent The optional key of the parent namespace to add the new data model to.\n */\n addDataModel(init: string | IDataModel | DataModel, parent?: string): DataModel {\n let root: DataNamespace\n if (parent) {\n const rootCandidate = this.findNamespace(parent)\n if (!rootCandidate) {\n throw new Error(`Unable to find the parent namespace ${parent}`)\n }\n root = rootCandidate\n } else {\n root = this\n }\n let definition: DataModel\n if (typeof init === 'string') {\n definition = DataModel.fromName(this.root || this, init)\n } else if (init instanceof DataModel) {\n definition = init\n } else {\n definition = new DataModel(this.root || this, init)\n }\n ;(this.root || this).definitions.models.push(definition)\n const item = DataItem.dataModel(this.root || this, definition.key)\n if (!Array.isArray(root.items)) {\n root.items = []\n }\n root.items.push(item)\n return definition\n }\n\n /**\n * Finds a data model in the definitions.\n * @param key The key of the data model to find.\n * @returns The data model definition or undefined when not found.\n */\n findDataModel(key: string): DataModel | undefined {\n const { definitions } = this.root || this\n return definitions.models.find((i) => i.key === key)\n }\n\n /**\n * A convenience function to remove an object from the namespace.\n * @param key The key of the object to remove.\n * @param kind The kind of the object to remove.\n * @param opts The options for the removal.\n * @throws Error when the kind is not known.\n */\n removeObject(key: string, kind: string, opts?: DataDomainRemoveOptions): void {\n switch (kind) {\n case DataNamespaceKind:\n this.findNamespace(key)?.remove(opts)\n break\n case DataModelKind:\n this.findDataModel(key)?.remove(opts)\n break\n case DataEntityKind:\n this.findEntity(key)?.remove(opts)\n break\n case DataPropertyKind:\n this.findProperty(key)?.remove()\n break\n case DataAssociationKind:\n this.findAssociation(key)?.remove()\n break\n default:\n throw new Error(`Unknown kind ${kind} for the object ${key}.`)\n }\n }\n\n /**\n * Finds a data model and calls the `remove()` on it.\n * @param key The key of the data model to find.\n */\n removeDataModel(key: string, opts?: DataDomainRemoveOptions): void {\n const { definitions } = this.root || this\n const model = definitions.models.find((i) => i.key === key)\n if (model) {\n model.remove(opts)\n }\n }\n\n /**\n * @returns The graph of associations where keys are the source\n * entities and the value is the list of all target entities.\n */\n associationGraph(): Record<string, string[]> {\n const graph: Record<string, string[]> = {}\n const { definitions } = this.root || this\n const { associations, entities } = definitions\n for (const assoc of associations) {\n if (!assoc.targets.length) {\n continue\n }\n const srcEntity = entities.find((i) => i.associations.some((a) => a === assoc))\n if (!srcEntity) {\n continue\n }\n if (!graph[srcEntity.key]) {\n graph[srcEntity.key] = []\n }\n const targetIds = assoc.targets.map((i) => i.key)\n graph[srcEntity.key].splice(0, 0, ...targetIds)\n }\n return graph\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n *\n * @param from The key of the from entity\n * @param to The key of the target entity\n * @param g The graph generated with `associationGraph()`\n * @param path The current list of entity ids. Do not set this, it is for the recursive processing of the graph.\n * @param visited The list of visited paths to avoid cycles.\n * Do not set this, it is for the recursive processing of the graph.\n */\n *associationPath(\n from: string,\n to: string,\n g: Record<string, string[]>,\n path: string[] = [],\n visited = new Set<string>()\n ): Generator<string[]> {\n if (from === to) {\n yield path.concat(to)\n return\n }\n if (visited.has(from)) {\n // it's a cycle\n return\n }\n if (g[from]) {\n visited.add(from)\n path.push(from)\n\n for (const neighbor of g[from]) {\n yield* this.associationPath(neighbor, to, g, path, visited)\n }\n\n visited.delete(from)\n path.pop()\n }\n }\n\n /**\n * Scans all associations for foreign namespaces and returns\n * the list of all namespaces used in the association graph.\n * This will never add this namespace's key.\n *\n * This function should be used to read keys for all related\n * namespaces through associations.\n *\n * @returns All keys of foreign namespaces.\n */\n computeForeignNamespaceKeys(): string[] {\n const result: string[] = []\n const { associations = [] } = this.definitions\n associations.forEach((association) => {\n const { targets = [] } = association\n targets.forEach((target) => {\n const { namespace } = target\n if (!namespace || namespace === this.key) {\n return\n }\n result.push(namespace)\n })\n })\n return result\n }\n\n /**\n * Finds an entity in this namespace.\n * @param key The key of the entity to find.\n */\n findEntity(key: string): DataEntity | undefined {\n const { definitions } = this.root || this\n return definitions.entities.find((i) => i.key === key)\n }\n\n /**\n * Finds a property by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findProperty(key: string): DataProperty | undefined {\n const { definitions } = this.root || this\n return definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Finds an association by its key.\n * @param key The key of the property to find\n * @returns The property or undefined if not found.\n */\n findAssociation(key: string): DataAssociation | undefined {\n const { definitions } = this.root || this\n return definitions.associations.find((i) => i.key === key)\n }\n\n /**\n * Searches for entities for association targets.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param targets The list of targets\n * @returns A list of entities. An `undefined` is put at the index where an entity cannot be found\n */\n findAssociatedEntities(targets: AssociationTarget[]): (DataEntity | undefined)[] {\n const result: (DataEntity | undefined)[] = []\n targets.forEach((target) => {\n let ns: DataNamespace | undefined\n if (target.namespace) {\n ns = this.foreign.find((i) => i.key === target.namespace)\n } else {\n ns = this\n }\n if (!ns) {\n result.push(undefined)\n return\n }\n const entity = ns.findEntity(target.key)\n if (entity) {\n result.push(entity)\n } else {\n result.push(undefined)\n }\n })\n return result\n }\n\n /**\n * Finds an associated entity in the current or foreign namespace.\n * This is a helper function to discover entities in the current and foreign namespaces.\n *\n * @param key The key of the entity to find.\n * @param namespace The optional namespace to search in.\n * If not set, the current namespace is used.\n * This is used to find entities in foreign namespaces.\n * @returns The entity or undefined if not found.\n */\n findAssociatedEntity(key: string, namespace?: string): DataEntity | undefined {\n let ns: DataNamespace | undefined\n if (namespace) {\n ns = this.foreign.find((i) => i.key === namespace)\n } else {\n ns = this\n }\n if (!ns) {\n return undefined\n }\n return ns.findEntity(key)\n }\n\n addForeign(ns: DataNamespace): void {\n const exists = this.foreign.some((i) => i.key === ns.key)\n if (exists) {\n return\n }\n this.foreign.push(ns)\n }\n\n removeForeign(ns: DataNamespace): void {\n const index = this.foreign.findIndex((i) => i === ns)\n if (index >= 0) {\n this.foreign.splice(index, 1)\n }\n }\n\n hasForeignNamespace(key: string): boolean {\n return this.foreign.some((i) => i.key === key)\n }\n\n /**\n * Checks whether the namespace is a child of the given namespace.\n * The relationship doesn't have to be direct, as long as the namespace is in the hierarchy it will return true.\n *\n * @param key The key of the parent namespace to check.\n * @returns True if this namespace is a child of the given namespace.\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Thing } from '../../models/Thing.js';
|
|
2
|
-
import { nanoid } from 'nanoid';
|
|
2
|
+
import { nanoid } from '../../nanoid.js';
|
|
3
3
|
import { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js';
|
|
4
4
|
import { DataPropertyKind } from '../../models/kinds.js';
|
|
5
5
|
import { BinaryFormats, DataPropertyAttributes, DataPropertyList, DataPropertyTypes, NumberFormats, } from '../DataFormat.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataProperty.js","sourceRoot":"","sources":["../../../../src/modeling/legacy/DataProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAEL,aAAa,EAEb,sBAAsB,EAEtB,gBAAgB,EAEhB,iBAAiB,EAEjB,aAAa,GACd,MAAM,kBAAkB,CAAA;AAwKzB;;GAEG;AACH,MAAM,OAAO,YAAY;IAyGd;IAxGT,IAAI,GAAG,gBAAgB,CAAA;IAEvB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAU;IAElB;;OA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AAE,EAAE,EAAqB,CAAA;YACvD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,MAA6B,CAAA;IAC7C,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAwB;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAoB,CAAA;QAC1E,OAAO,IAAI,EAAE,MAAM,CAAA;IACrB,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACjG,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../../models/Thing.js'\nimport { nanoid } from 'nanoid'\nimport { DataNamespace } from './DataNamespace.js'\nimport { IApiPropertyShape } from '../../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js'\nimport { PropertyBinding, PropertyBindings, PropertyWebBindings } from '../Bindings.js'\nimport { DataPropertyKind } from '../../models/kinds.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DataPropertyAttribute,\n DataPropertyAttributes,\n type DataPropertyFormat,\n DataPropertyList,\n type DataPropertyType,\n DataPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from '../DataFormat.js'\nimport type { DataEntity } from './DataEntity.js'\n\n/**\n * Describes the default value set on a property schema.\n * @deprecated\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 * @deprecated\n */\nexport interface DataPropertySchema {\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\n/**\n * @deprecated\n */\nexport interface IDataProperty {\n kind: typeof DataPropertyKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data property description.\n */\n info: IThing\n /**\n * Wether the data property is required.\n */\n required?: boolean\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n taxonomy?: string[]\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers, but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DataPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: DataPropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: PropertyBinding[]\n}\n\n/**\n * @deprecated\n */\nexport class DataProperty {\n kind = DataPropertyKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Wether the data property is required.\n */\n required?: boolean\n\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n\n /**\n * Optional general purpose tags for the UI.\n *\n * Note to implementations, use the `addTag()` method as it propagates the \"tag\" value in the namespace.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n taxonomy: string[] = []\n\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DataPropertyType = 'string'\n\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: DataPropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings: PropertyBinding[] = []\n\n /**\n * @deprecated Use the direct import of types.\n */\n static get supportedTypes(): DataPropertyType[] {\n return [...DataPropertyTypes]\n }\n\n static fromName(root: DataNamespace, name: string): DataProperty {\n const property = new DataProperty(root)\n property.info = Thing.fromName(name)\n return property\n }\n\n static fromType(root: DataNamespace, type: DataPropertyType): DataProperty {\n const result = new DataProperty(root)\n result.type = type\n return result\n }\n\n /**\n * @param input The data property definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataProperty\n ) {\n let init: IDataProperty\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataPropertyKind,\n key: nanoid(),\n info: Thing.fromName('').toJSON(),\n type: 'string',\n }\n }\n this.new(init)\n }\n\n new(init: IDataProperty): void {\n if (!DataProperty.isDataProperty(init)) {\n throw new Error(`Not a data property.`)\n }\n const {\n info,\n key = nanoid(),\n kind = DataPropertyKind,\n multiple,\n required,\n type = DataPropertyList.string,\n index,\n primary,\n readOnly,\n writeOnly,\n tags,\n taxonomy,\n deprecated,\n schema,\n bindings,\n } = init\n this.kind = kind\n this.key = key\n this.type = type\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (typeof multiple === 'boolean') {\n this.multiple = multiple\n } else {\n this.multiple = undefined\n }\n if (typeof required === 'boolean') {\n this.required = required\n } else {\n this.required = undefined\n }\n if (typeof index === 'boolean') {\n this.index = index\n } else {\n this.index = undefined\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof primary === 'boolean') {\n this.primary = primary\n } else {\n this.primary = undefined\n }\n if (typeof readOnly === 'boolean') {\n this.readOnly = readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof writeOnly === 'boolean') {\n this.writeOnly = writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (schema) {\n this.schema = structuredClone(schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(bindings)) {\n this.bindings = bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n static isDataProperty(input: unknown): boolean {\n const typed = input as IDataProperty\n if (!input || typed.kind !== DataPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataProperty {\n const result: IDataProperty = {\n kind: DataPropertyKind,\n info: this.info.toJSON(),\n key: this.key,\n type: this.type || DataPropertyList.string,\n }\n if (typeof this.index === 'boolean') {\n result.index = this.index\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n if (typeof this.primary === 'boolean') {\n result.primary = this.primary\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (typeof this.readOnly === 'boolean') {\n result.readOnly = this.readOnly\n }\n if (typeof this.writeOnly === 'boolean') {\n result.writeOnly = this.writeOnly\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (this.schema) {\n result.schema = structuredClone(this.schema)\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = this.bindings.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes self from the parent entity and the namespace definition.\n */\n remove(): void {\n const { root } = this\n const entity = root.definitions.entities.find((i) => i.properties.some((j) => j.key === this.key))\n if (entity) {\n const assocIndex = entity.properties.findIndex((i) => i.key === this.key)\n entity.properties.splice(assocIndex, 1)\n }\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === this.key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new AmfShapeGenerator()\n return serializer.property(this)\n }\n\n /**\n * Checks whether the passed value is one of the supported data types.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data types.\n */\n static isValidType(value: unknown): value is DataPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DataPropertyTypes.includes(value as DataPropertyType)\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DataPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DataPropertyAttributes.includes(value as DataPropertyAttribute)\n }\n\n /**\n * Checks whether the passed value of one of the supported `format` values.\n *\n * @param value The value to test\n * @returns `true` when the value is one of the supported `format` values.\n */\n static isValidFormat(value: unknown): value is DataPropertyFormat {\n if (value === undefined) {\n // It is the valid value.\n return true\n }\n if (typeof value !== 'string') {\n return false\n }\n if (NumberFormats.includes(value as NumberFormat)) {\n return true\n }\n if (BinaryFormats.includes(value as BinaryFormat)) {\n return true\n }\n return false\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): DataPropertySchema {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): PropertyWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as PropertyBinding\n this.bindings.push(object)\n }\n return object.schema as PropertyWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): PropertyBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as PropertyBinding\n return item?.schema\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DataEntity | undefined {\n return this.root.definitions.entities.find((e) => e.properties.some((e) => e.key === this.key))\n }\n\n /**\n * Checks whether the property is a child of the given namespace, data model, or an entity.\n * The relationship doesn't have to be direct, as long as the property is in the hierarchy it will return true.\n *\n * @param key The key of the parent to check.\n * @returns True if this data property is a child of the given namespace, data model, or an entity\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataProperty.js","sourceRoot":"","sources":["../../../../src/modeling/legacy/DataProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAEL,aAAa,EAEb,sBAAsB,EAEtB,gBAAgB,EAEhB,iBAAiB,EAEjB,aAAa,GACd,MAAM,kBAAkB,CAAA;AAwKzB;;GAEG;AACH,MAAM,OAAO,YAAY;IAyGd;IAxGT,IAAI,GAAG,gBAAgB,CAAA;IAEvB,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,OAAO,CAAU;IAEjB;;OAEG;IACH,KAAK,CAAU;IAEf;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,SAAS,CAAU;IAEnB;;OAEG;IACH,UAAU,CAAU;IAEpB;;;;OAIG;IACH,IAAI,GAAa,EAAE,CAAA;IAEnB;;;;OAIG;IACH,QAAQ,GAAa,EAAE,CAAA;IAEvB;;;;;;OAMG;IACH,IAAI,GAAqB,QAAQ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AoB,CAAA;QAC1E,OAAO,IAAI,EAAE,MAAM,CAAA;IACrB,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACjG,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,GAAW;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../../models/Thing.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { IApiPropertyShape } from '../../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js'\nimport { PropertyBinding, PropertyBindings, PropertyWebBindings } from '../Bindings.js'\nimport { DataPropertyKind } from '../../models/kinds.js'\nimport {\n type BinaryFormat,\n BinaryFormats,\n type DataPropertyAttribute,\n DataPropertyAttributes,\n type DataPropertyFormat,\n DataPropertyList,\n type DataPropertyType,\n DataPropertyTypes,\n type NumberFormat,\n NumberFormats,\n} from '../DataFormat.js'\nimport type { DataEntity } from './DataEntity.js'\n\n/**\n * Describes the default value set on a property schema.\n * @deprecated\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 * @deprecated\n */\nexport interface DataPropertySchema {\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\n/**\n * @deprecated\n */\nexport interface IDataProperty {\n kind: typeof DataPropertyKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data property description.\n */\n info: IThing\n /**\n * Wether the data property is required.\n */\n required?: boolean\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n taxonomy?: string[]\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers, but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DataPropertyType\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: DataPropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: PropertyBinding[]\n}\n\n/**\n * @deprecated\n */\nexport class DataProperty {\n kind = DataPropertyKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Wether the data property is required.\n */\n required?: boolean\n\n /**\n * Whether the data property allows multiple items.\n */\n multiple?: boolean\n\n /**\n * Whether this property describes a primary key of the entity.\n */\n primary?: boolean\n\n /**\n * Whether this property describes an indexed property of the entity.\n */\n index?: boolean\n\n /**\n * Whether the property is read only in the schema.\n */\n readOnly?: boolean\n\n /**\n * Whether the property is write only in the schema.\n */\n writeOnly?: boolean\n\n /**\n * Whether this property is deprecated.\n */\n deprecated?: boolean\n\n /**\n * Optional general purpose tags for the UI.\n *\n * Note to implementations, use the `addTag()` method as it propagates the \"tag\" value in the namespace.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the property.\n */\n taxonomy: string[] = []\n\n /**\n * The data type for this property.\n * Note, not all schemas support the same type. For example, defining `sint32`\n * works for protocol buffers but does not for JSON. In such case we use default\n * translation `sint32` -> `number`. Another way it to create\n * a derivative entity for specific schema to describe specific schema case.\n */\n type: DataPropertyType = 'string'\n\n /**\n * The general schema definition of this property.\n * This is propagated to all bindings (when they support these properties).\n */\n schema?: DataPropertySchema\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings: PropertyBinding[] = []\n\n /**\n * @deprecated Use the direct import of types.\n */\n static get supportedTypes(): DataPropertyType[] {\n return [...DataPropertyTypes]\n }\n\n static fromName(root: DataNamespace, name: string): DataProperty {\n const property = new DataProperty(root)\n property.info = Thing.fromName(name)\n return property\n }\n\n static fromType(root: DataNamespace, type: DataPropertyType): DataProperty {\n const result = new DataProperty(root)\n result.type = type\n return result\n }\n\n /**\n * @param input The data property definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataProperty\n ) {\n let init: IDataProperty\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataPropertyKind,\n key: nanoid(),\n info: Thing.fromName('').toJSON(),\n type: 'string',\n }\n }\n this.new(init)\n }\n\n new(init: IDataProperty): void {\n if (!DataProperty.isDataProperty(init)) {\n throw new Error(`Not a data property.`)\n }\n const {\n info,\n key = nanoid(),\n kind = DataPropertyKind,\n multiple,\n required,\n type = DataPropertyList.string,\n index,\n primary,\n readOnly,\n writeOnly,\n tags,\n taxonomy,\n deprecated,\n schema,\n bindings,\n } = init\n this.kind = kind\n this.key = key\n this.type = type\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (typeof multiple === 'boolean') {\n this.multiple = multiple\n } else {\n this.multiple = undefined\n }\n if (typeof required === 'boolean') {\n this.required = required\n } else {\n this.required = undefined\n }\n if (typeof index === 'boolean') {\n this.index = index\n } else {\n this.index = undefined\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n if (typeof primary === 'boolean') {\n this.primary = primary\n } else {\n this.primary = undefined\n }\n if (typeof readOnly === 'boolean') {\n this.readOnly = readOnly\n } else {\n this.readOnly = undefined\n }\n if (typeof writeOnly === 'boolean') {\n this.writeOnly = writeOnly\n } else {\n this.writeOnly = undefined\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (schema) {\n this.schema = structuredClone(schema)\n } else {\n this.schema = undefined\n }\n if (Array.isArray(bindings)) {\n this.bindings = bindings.map((i) => structuredClone(i))\n } else {\n this.bindings = []\n }\n }\n\n static isDataProperty(input: unknown): boolean {\n const typed = input as IDataProperty\n if (!input || typed.kind !== DataPropertyKind) {\n return false\n }\n return true\n }\n\n toJSON(): IDataProperty {\n const result: IDataProperty = {\n kind: DataPropertyKind,\n info: this.info.toJSON(),\n key: this.key,\n type: this.type || DataPropertyList.string,\n }\n if (typeof this.index === 'boolean') {\n result.index = this.index\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n if (typeof this.primary === 'boolean') {\n result.primary = this.primary\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (typeof this.readOnly === 'boolean') {\n result.readOnly = this.readOnly\n }\n if (typeof this.writeOnly === 'boolean') {\n result.writeOnly = this.writeOnly\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (this.schema) {\n result.schema = structuredClone(this.schema)\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = this.bindings.map((i) => structuredClone(i))\n }\n return result\n }\n\n /**\n * Removes self from the parent entity and the namespace definition.\n */\n remove(): void {\n const { root } = this\n const entity = root.definitions.entities.find((i) => i.properties.some((j) => j.key === this.key))\n if (entity) {\n const assocIndex = entity.properties.findIndex((i) => i.key === this.key)\n entity.properties.splice(assocIndex, 1)\n }\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === this.key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new AmfShapeGenerator()\n return serializer.property(this)\n }\n\n /**\n * Checks whether the passed value is one of the supported data types.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data types.\n */\n static isValidType(value: unknown): value is DataPropertyType {\n if (typeof value !== 'string') {\n return false\n }\n return DataPropertyTypes.includes(value as DataPropertyType)\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DataPropertyAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DataPropertyAttributes.includes(value as DataPropertyAttribute)\n }\n\n /**\n * Checks whether the passed value of one of the supported `format` values.\n *\n * @param value The value to test\n * @returns `true` when the value is one of the supported `format` values.\n */\n static isValidFormat(value: unknown): value is DataPropertyFormat {\n if (value === undefined) {\n // It is the valid value.\n return true\n }\n if (typeof value !== 'string') {\n return false\n }\n if (NumberFormats.includes(value as NumberFormat)) {\n return true\n }\n if (BinaryFormats.includes(value as BinaryFormat)) {\n return true\n }\n return false\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): DataPropertySchema {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): PropertyWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as PropertyBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as PropertyBinding\n this.bindings.push(object)\n }\n return object.schema as PropertyWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): PropertyBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as PropertyBinding\n return item?.schema\n }\n\n /**\n * Returns a parent data entity where this data property exist.\n */\n getParentInstance(): DataEntity | undefined {\n return this.root.definitions.entities.find((e) => e.properties.some((e) => e.key === this.key))\n }\n\n /**\n * Checks whether the property is a child of the given namespace, data model, or an entity.\n * The relationship doesn't have to be direct, as long as the property is in the hierarchy it will return true.\n *\n * @param key The key of the parent to check.\n * @returns True if this data property is a child of the given namespace, data model, or an entity\n */\n isChildOf(key: string): boolean {\n if (this.key === key) {\n return false\n }\n const parent = this.getParentInstance()\n if (!parent) {\n return false\n }\n if (parent.key === key) {\n return true\n }\n return parent.isChildOf(key)\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationData.js","sourceRoot":"","sources":["../../../src/models/AuthorizationData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"AuthorizationData.js","sourceRoot":"","sources":["../../../src/models/AuthorizationData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AASrC;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B,GAAG,GAAG,EAAE,CAAA;IACR,QAAQ,CAAS;IACjB,QAAQ,CAAS;IACjB,MAAM,CAAS;IAEf;;OAEG;IACH,YAAY,KAAmC;QAC7C,IAAI,IAAwB,CAAA;QAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,CAAA;QACd,CAAC;aAAM,CAAC;YACN,IAAI,GAAG;gBACL,GAAG,EAAE,MAAM,EAAE;aACd,CAAA;QACH,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAwB;QAC1B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,CAAA;QAC3D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAuB;YACjC,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QACjC,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QACjC,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QAC7B,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from '../nanoid.js'\n\nexport interface IAuthorizationData {\n key: string\n username?: string\n password?: string\n domain?: string\n}\n\n/**\n * Represents an auth data stored in API Client's data store to be retrieved\n * when the response status is 401.\n *\n * Each entry represent a Basic or NTLM authorization.\n */\nexport class AuthorizationData {\n key = ''\n username?: string\n password?: string\n domain?: string\n\n /**\n * @param input The provider definition used to restore the state.\n */\n constructor(input?: string | IAuthorizationData) {\n let init: IAuthorizationData\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n key: nanoid(),\n }\n }\n this.new(init)\n }\n\n /**\n * Creates a new provider clearing anything that is so far defined.\n *\n * Note, this throws an error when the provider is not an API Client provider object.\n */\n new(init: IAuthorizationData): void {\n const { username, password, domain, key = nanoid() } = init\n this.username = username\n this.password = password\n this.domain = domain\n this.key = key\n }\n\n toJSON(): IAuthorizationData {\n const result: IAuthorizationData = {\n key: this.key,\n }\n if (this.username) {\n result.username = this.username\n }\n if (this.password) {\n result.password = this.password\n }\n if (this.domain) {\n result.domain = this.domain\n }\n return result\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CertificateFile.js","sourceRoot":"","sources":["../../../src/models/CertificateFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"CertificateFile.js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AK,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,CAAA;QACd,CAAC;aAAM,CAAC;YACN,IAAI,GAAG;gBACL,IAAI,EAAE,mBAAmB;gBACzB,GAAG,EAAE,MAAM,EAAE;gBACb,YAAY,EAAE,EAAE;gBAChB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;gBACjC,OAAO,EAAE,EAAE;gBACX,aAAa,EAAE,EAAE;gBACjB,WAAW,EAAE,EAAE;gBACf,YAAY,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE;aACjD,CAAA;QACH,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAEQ,GAAG,CAAC,IAAsB;QACjC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC5C,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,KAAc;QACjC,MAAM,KAAK,GAAG,KAAyB,CAAA;QACvC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACjD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEQ,MAAM;QACb,MAAM,MAAM,GAAqB;YAC/B,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,IAAI,EAAE,mBAAmB;SAC1B,CAAA;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { Certificate, ICertificate } from './ClientCertificate.js'\nimport { CertificateFileKind } from './kinds.js'\nimport { IFile, File } from './store/File.js'\nimport { Thing } from './Thing.js'\n\nexport interface ICertificateFile extends IFile {\n kind: typeof CertificateFileKind\n}\n\nexport class CertificateFile extends File {\n override kind = CertificateFileKind\n\n static fromCertificate(\n certificate: ICertificate | Certificate,\n organization: string,\n owner?: string\n ): CertificateFile {\n const init: ICertificateFile = {\n kind: CertificateFileKind,\n key: certificate.key,\n organization,\n info: Thing.fromName(certificate.name).toJSON(),\n lastModified: { user: owner || '', time: 0, byMe: false },\n owner,\n parents: [],\n permissionIds: [],\n permissions: [],\n }\n return new CertificateFile(init)\n }\n\n /**\n * @param name The name to set.\n * @param owner The user id that is the owner of the file.\n */\n static override fromName(name: string, organization: string, owner?: string): CertificateFile {\n return super.fromName(name, organization, owner, CertificateFileKind) as CertificateFile\n }\n\n constructor(input?: string | ICertificateFile) {\n super()\n let init: ICertificateFile\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: CertificateFileKind,\n key: nanoid(),\n organization: '',\n info: Thing.fromName('').toJSON(),\n parents: [],\n permissionIds: [],\n permissions: [],\n lastModified: { user: '', time: 0, byMe: false },\n }\n }\n this.new(init)\n }\n\n override new(init: ICertificateFile): this {\n if (!CertificateFile.isCertificate(init)) {\n throw new Error(`Not a certificate file.`)\n }\n super.new(init)\n this.kind = CertificateFileKind\n return this\n }\n\n static isCertificate(input: unknown): boolean {\n const typed = input as ICertificateFile\n if (!input || typed.kind !== CertificateFileKind) {\n return false\n }\n return true\n }\n\n override toJSON(): ICertificateFile {\n const result: ICertificateFile = {\n ...super.toJSON(),\n kind: CertificateFileKind,\n }\n return result\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientCertificate.js","sourceRoot":"","sources":["../../../src/models/ClientCertificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACj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AAA;IACb,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,OAAO,CAAC,IAAsB;QACnC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QACjD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QACjD,CAAC;QACD,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAgC,CAAA;YAClD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAoB;YAC9B,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,MAAoC,CAAA;YAClD,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js'\nimport { nanoid } from 'nanoid'\nimport {\n Certificate as LegacyCertificate,\n ARCCertificateIndex,\n RequestCertificate,\n} from './legacy/models/ClientCertificate.js'\n\nexport type CertificateType = 'p12' | 'pem'\n\nexport const Kind = 'Core#Certificate'\n\nexport type CertificateDataFormat = string | ArrayBuffer | Uint8Array\n\n/**\n * Represents a single certificate object (cert/key)\n */\nexport interface ICertificateData {\n /**\n * The certificate to use.\n * The `p12` type certificate must be a Buffer.\n */\n data: CertificateDataFormat\n /**\n * A passphrase to use to unlock the certificate.\n */\n passphrase?: string\n /**\n * The original data type of the certificate. This is only used internally by the data store\n * to move between buffers and string values stored in the store.\n * Outside the internal procedure of the data store this\n * is always `undefined` and the `data` contains the original data format.\n */\n type?: 'buffer'\n}\n\nexport interface ICertificate {\n kind: typeof Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * The custom name of the certificate.\n */\n name: string\n /**\n * The timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created?: number\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n}\n\nexport interface IP12Certificate extends ICertificate {\n type: 'p12'\n}\n\n/**\n * Represents a complete certificate configuration required to make\n * an HTTP request.\n */\nexport interface IPemCertificate extends ICertificate {\n type: 'pem'\n /**\n * The key for the `pem` type certificate.\n */\n certKey: ICertificateData\n}\n\nexport type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IPemCreateOptions {\n type: 'p12'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * The key contents.\n */\n key: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the key.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IP12CreateOptions {\n type: 'pem'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the certificate.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions\n\n/**\n * A class that represents a certificate in the system\n */\nexport class Certificate {\n kind = Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * Custom name of the certificate.\n */\n name: string\n /**\n * Timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created = 0\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n /**\n * The key for the `pem` type certificate.\n */\n certKey?: ICertificateData\n\n /**\n * Creates a new certificate instance for a PEM key\n *\n * @param pem The certificate contents\n * @param key The key contents\n * @param name The certificate name\n * @param keyPassphrase The key passphrase\n */\n static fromPem(\n pem: CertificateDataFormat,\n key: CertificateDataFormat,\n name = 'New PEM certificate',\n keyPassphrase?: string\n ): Certificate {\n const init: IPemCertificate = {\n kind: Kind,\n cert: {\n data: pem,\n },\n certKey: {\n data: key,\n },\n key: nanoid(),\n name,\n type: 'pem',\n created: Date.now(),\n }\n if (keyPassphrase) {\n init.certKey.passphrase = keyPassphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a new certificate instance for a P12 key\n *\n * @param cert The certificate contents\n * @param name The certificate name\n * @param passphrase The key passphrase\n */\n static fromP12(cert: CertificateDataFormat, name = 'New P12 certificate', passphrase?: string): Certificate {\n const init: IP12Certificate = {\n kind: Kind,\n cert: {\n data: cert,\n },\n key: nanoid(),\n name,\n type: 'p12',\n created: Date.now(),\n }\n if (passphrase) {\n init.cert.passphrase = passphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a certificate object from the ARC's legacy certificate definition.\n *\n * @param index The legacy certificate index object. If it has set `_id` it will be used as the `key`.\n * @param index The certificate data object as read from the data store. Do not restore the data\n * to its original format.\n */\n static fromLegacy(index: ARCCertificateIndex, cert: RequestCertificate): Certificate {\n const { name = '', type, created = Date.now(), _id = nanoid() } = index\n if (type === 'pem') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const key = Array.isArray(cert.key) ? cert.key[0] : (cert.key as LegacyCertificate)\n if (!key) {\n throw new Error(`Unable to create a PEM certificate without the key.`)\n }\n const init: IPemCertificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n certKey: key as ICertificateData,\n key: _id,\n name,\n type: 'pem',\n created,\n }\n return new Certificate(init)\n } else if (type === 'p12') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const init: IP12Certificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n key: _id,\n name,\n type: 'p12',\n created,\n }\n return new Certificate(init)\n }\n throw new Error(`Unable to create a certificate. Unknown type: ${type}.`)\n }\n\n constructor(certificate: HttpCertificate) {\n const { type, cert, key = nanoid(), name = '', created = Date.now() } = certificate\n this.key = key\n this.name = name\n this.type = type\n this.cert = Certificate.fromStore(cert)\n this.created = created\n if (type === 'pem') {\n const typed = certificate as IPemCertificate\n this.certKey = Certificate.fromStore(typed.certKey)\n }\n }\n\n /**\n * When needed it reads the certificate's original format.\n * @param data The certificate data.\n * @returns The restored certificate.\n */\n static fromStore(data: ICertificateData): ICertificateData {\n if (data.type) {\n delete data.type\n const content = data.data as string\n data.data = base64ToBuffer(content)\n }\n return data\n }\n\n /**\n * Prepares certificate object to be stored in the data store.\n * If the `data` property is not string then it assumes buffer (either\n * Node's or ArrayBuffer). In this case it converts buffer to base64 string.\n * It also adds `type` property set to `buffer` for the `fromStore()`\n * function to recognize what to do with the data.\n *\n * Note, for optimization, PEM keys should be strings as the content of the\n * certificate is already a base62 string. To spare double base64 conversion\n * use string data.\n *\n * @param data The certificate data object.\n * @throws When data is not set\n */\n static toStore(data: ICertificateData): ICertificateData {\n if (!data) {\n throw new Error('Certificate data is missing.')\n }\n if (!data.data) {\n throw new Error('Certificate content not set.')\n }\n if (typeof data.data !== 'string') {\n data.type = 'buffer'\n const buff = data.data as ArrayBuffer | Uint8Array\n data.data = bufferToBase64(buff)\n }\n return data\n }\n\n toJSON(): HttpCertificate {\n const result: HttpCertificate = {\n kind: Kind,\n key: this.key,\n cert: Certificate.toStore(this.cert),\n name: this.name,\n type: this.type,\n created: this.created,\n }\n\n if (this.type === 'pem' && this.certKey) {\n const typed = result as unknown as IPemCertificate\n typed.certKey = Certificate.toStore(this.certKey)\n }\n\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClientCertificate.js","sourceRoot":"","sources":["../../../src/models/ClientCertificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AASrC,MAAM,CAAC,MAAM,IAAI,GAAG,kBAAkB,CAAA;AAoHtC;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB,IAAI,GAAG,IAAI,CAAA;IACX;;OAEG;IACH,GAAG,CAAQ;IACX;;OAEG;IACH,IAAI,CAAQ;IACZ;;;OAGG;IACH,OAAO,GAAG,CAAC,CAAA;IACX;;OAEG;IACH,IAAI,CAAiB;IACrB;;OAEG;IACH,IAAI,CAAkB;IACtB;;OAEG;IACH,OAAO,CAAmB;IAE1B;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CACZ,GAA0B,EAC1B,GAA0B,EAC1B,IAAI,GAAG,qBAAqB,EAC5B,aAAsB;QAEtB,MAAM,IAAI,GAAoB;YAC5B,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,GAAG;aACV;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,GAAG;aACV;YACD,GAAG,EAAE,MAAM,EAAE;YACb,IAAI;YACJ,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;SACpB,CAAA;QACD,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,aAAa,CAAA;QACzC,C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AAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,MAAoC,CAAA;YAClD,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js'\nimport { nanoid } from '../nanoid.js'\nimport {\n Certificate as LegacyCertificate,\n ARCCertificateIndex,\n RequestCertificate,\n} from './legacy/models/ClientCertificate.js'\n\nexport type CertificateType = 'p12' | 'pem'\n\nexport const Kind = 'Core#Certificate'\n\nexport type CertificateDataFormat = string | ArrayBuffer | Uint8Array\n\n/**\n * Represents a single certificate object (cert/key)\n */\nexport interface ICertificateData {\n /**\n * The certificate to use.\n * The `p12` type certificate must be a Buffer.\n */\n data: CertificateDataFormat\n /**\n * A passphrase to use to unlock the certificate.\n */\n passphrase?: string\n /**\n * The original data type of the certificate. This is only used internally by the data store\n * to move between buffers and string values stored in the store.\n * Outside the internal procedure of the data store this\n * is always `undefined` and the `data` contains the original data format.\n */\n type?: 'buffer'\n}\n\nexport interface ICertificate {\n kind: typeof Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * The custom name of the certificate.\n */\n name: string\n /**\n * The timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created?: number\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n}\n\nexport interface IP12Certificate extends ICertificate {\n type: 'p12'\n}\n\n/**\n * Represents a complete certificate configuration required to make\n * an HTTP request.\n */\nexport interface IPemCertificate extends ICertificate {\n type: 'pem'\n /**\n * The key for the `pem` type certificate.\n */\n certKey: ICertificateData\n}\n\nexport type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IPemCreateOptions {\n type: 'p12'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * The key contents.\n */\n key: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the key.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport interface IP12CreateOptions {\n type: 'pem'\n /**\n * The certificate contents.\n */\n cert: CertificateDataFormat\n /**\n * Optional name for the certificate.\n */\n name?: string\n /**\n * Optional passphrase for the certificate.\n */\n passphrase?: string\n}\n\n/**\n * @deprecated Do not use this type anymore. Create a cert instance instead.\n */\nexport type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions\n\n/**\n * A class that represents a certificate in the system\n */\nexport class Certificate {\n kind = Kind\n /**\n * The data store key to refer.\n */\n key: string\n /**\n * Custom name of the certificate.\n */\n name: string\n /**\n * Timestamp when the certificate was inserted into the data store.\n * Required when returning a result. Auto-generated when inserting, if missing.\n */\n created = 0\n /**\n * Certificate type. Either `p12` or `pem`.\n */\n type: CertificateType\n /**\n * Certificate or list of certificates to use.\n */\n cert: ICertificateData\n /**\n * The key for the `pem` type certificate.\n */\n certKey?: ICertificateData\n\n /**\n * Creates a new certificate instance for a PEM key\n *\n * @param pem The certificate contents\n * @param key The key contents\n * @param name The certificate name\n * @param keyPassphrase The key passphrase\n */\n static fromPem(\n pem: CertificateDataFormat,\n key: CertificateDataFormat,\n name = 'New PEM certificate',\n keyPassphrase?: string\n ): Certificate {\n const init: IPemCertificate = {\n kind: Kind,\n cert: {\n data: pem,\n },\n certKey: {\n data: key,\n },\n key: nanoid(),\n name,\n type: 'pem',\n created: Date.now(),\n }\n if (keyPassphrase) {\n init.certKey.passphrase = keyPassphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a new certificate instance for a P12 key\n *\n * @param cert The certificate contents\n * @param name The certificate name\n * @param passphrase The key passphrase\n */\n static fromP12(cert: CertificateDataFormat, name = 'New P12 certificate', passphrase?: string): Certificate {\n const init: IP12Certificate = {\n kind: Kind,\n cert: {\n data: cert,\n },\n key: nanoid(),\n name,\n type: 'p12',\n created: Date.now(),\n }\n if (passphrase) {\n init.cert.passphrase = passphrase\n }\n return new Certificate(init)\n }\n\n /**\n * Creates a certificate object from the ARC's legacy certificate definition.\n *\n * @param index The legacy certificate index object. If it has set `_id` it will be used as the `key`.\n * @param index The certificate data object as read from the data store. Do not restore the data\n * to its original format.\n */\n static fromLegacy(index: ARCCertificateIndex, cert: RequestCertificate): Certificate {\n const { name = '', type, created = Date.now(), _id = nanoid() } = index\n if (type === 'pem') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const key = Array.isArray(cert.key) ? cert.key[0] : (cert.key as LegacyCertificate)\n if (!key) {\n throw new Error(`Unable to create a PEM certificate without the key.`)\n }\n const init: IPemCertificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n certKey: key as ICertificateData,\n key: _id,\n name,\n type: 'pem',\n created,\n }\n return new Certificate(init)\n } else if (type === 'p12') {\n const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert\n const init: IP12Certificate = {\n kind: Kind,\n cert: data as ICertificateData, // these are compatible.\n key: _id,\n name,\n type: 'p12',\n created,\n }\n return new Certificate(init)\n }\n throw new Error(`Unable to create a certificate. Unknown type: ${type}.`)\n }\n\n constructor(certificate: HttpCertificate) {\n const { type, cert, key = nanoid(), name = '', created = Date.now() } = certificate\n this.key = key\n this.name = name\n this.type = type\n this.cert = Certificate.fromStore(cert)\n this.created = created\n if (type === 'pem') {\n const typed = certificate as IPemCertificate\n this.certKey = Certificate.fromStore(typed.certKey)\n }\n }\n\n /**\n * When needed it reads the certificate's original format.\n * @param data The certificate data.\n * @returns The restored certificate.\n */\n static fromStore(data: ICertificateData): ICertificateData {\n if (data.type) {\n delete data.type\n const content = data.data as string\n data.data = base64ToBuffer(content)\n }\n return data\n }\n\n /**\n * Prepares certificate object to be stored in the data store.\n * If the `data` property is not string then it assumes buffer (either\n * Node's or ArrayBuffer). In this case it converts buffer to base64 string.\n * It also adds `type` property set to `buffer` for the `fromStore()`\n * function to recognize what to do with the data.\n *\n * Note, for optimization, PEM keys should be strings as the content of the\n * certificate is already a base62 string. To spare double base64 conversion\n * use string data.\n *\n * @param data The certificate data object.\n * @throws When data is not set\n */\n static toStore(data: ICertificateData): ICertificateData {\n if (!data) {\n throw new Error('Certificate data is missing.')\n }\n if (!data.data) {\n throw new Error('Certificate content not set.')\n }\n if (typeof data.data !== 'string') {\n data.type = 'buffer'\n const buff = data.data as ArrayBuffer | Uint8Array\n data.data = bufferToBase64(buff)\n }\n return data\n }\n\n toJSON(): HttpCertificate {\n const result: HttpCertificate = {\n kind: Kind,\n key: this.key,\n cert: Certificate.toStore(this.cert),\n name: this.name,\n type: this.type,\n created: this.created,\n }\n\n if (this.type === 'pem' && this.certKey) {\n const typed = result as unknown as IPemCertificate\n typed.certKey = Certificate.toStore(this.certKey)\n }\n\n return result\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Property } from './Property.js';
|
|
2
2
|
import { Server } from './Server.js';
|
|
3
3
|
import { Thing } from './Thing.js';
|
|
4
|
-
import { nanoid } from 'nanoid';
|
|
4
|
+
import { nanoid } from '../nanoid.js';
|
|
5
5
|
import { RequestAuthorization } from './RequestAuthorization.js';
|
|
6
6
|
export const Kind = 'Core#Environment';
|
|
7
7
|
/**
|