@cratis/arc 19.7.2 → 19.8.0
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/commands/Command.ts +31 -9
- package/commands/ICommand.ts +4 -2
- package/commands/for_Command/when_executing/with_allowed_severity_warning.ts +44 -0
- package/dist/cjs/commands/Command.d.ts +3 -1
- package/dist/cjs/commands/Command.d.ts.map +1 -1
- package/dist/cjs/commands/Command.js +26 -9
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/commands/ICommand.d.ts +2 -1
- package/dist/cjs/commands/ICommand.d.ts.map +1 -1
- package/dist/cjs/commands/for_Command/when_executing/with_allowed_severity_warning.d.ts +2 -0
- package/dist/cjs/commands/for_Command/when_executing/with_allowed_severity_warning.d.ts.map +1 -0
- package/dist/cjs/identity/IIdentity.d.ts +2 -0
- package/dist/cjs/identity/IIdentity.d.ts.map +1 -1
- package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/cjs/identity/IdentityProvider.js +4 -0
- package/dist/cjs/identity/IdentityProvider.js.map +1 -1
- package/dist/cjs/identity/IdentityProviderResult.d.ts +1 -0
- package/dist/cjs/identity/IdentityProviderResult.d.ts.map +1 -1
- package/dist/cjs/identity/for_IdentityProvider/when_getting_current/with_roles.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_getting_current/with_roles.d.ts.map +1 -0
- package/dist/cjs/identity/for_IdentityProvider/when_getting_current/without_roles.d.ts +2 -0
- package/dist/cjs/identity/for_IdentityProvider/when_getting_current/without_roles.d.ts.map +1 -0
- package/dist/esm/commands/Command.d.ts +3 -1
- package/dist/esm/commands/Command.d.ts.map +1 -1
- package/dist/esm/commands/Command.js +26 -9
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/commands/ICommand.d.ts +2 -1
- package/dist/esm/commands/ICommand.d.ts.map +1 -1
- package/dist/esm/commands/for_Command/when_executing/with_allowed_severity_warning.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_executing/with_allowed_severity_warning.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_allowed_severity_warning.js +36 -0
- package/dist/esm/commands/for_Command/when_executing/with_allowed_severity_warning.js.map +1 -0
- package/dist/esm/identity/IIdentity.d.ts +2 -0
- package/dist/esm/identity/IIdentity.d.ts.map +1 -1
- package/dist/esm/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/esm/identity/IdentityProvider.js +4 -0
- package/dist/esm/identity/IdentityProvider.js.map +1 -1
- package/dist/esm/identity/IdentityProviderResult.d.ts +1 -0
- package/dist/esm/identity/IdentityProviderResult.d.ts.map +1 -1
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/with_roles.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/with_roles.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/with_roles.js +36 -0
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/with_roles.js.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/without_roles.d.ts +2 -0
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/without_roles.d.ts.map +1 -0
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/without_roles.js +29 -0
- package/dist/esm/identity/for_IdentityProvider/when_getting_current/without_roles.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/identity/IIdentity.ts +12 -0
- package/identity/IdentityProvider.ts +4 -0
- package/identity/IdentityProviderResult.ts +1 -0
- package/identity/for_IdentityProvider/when_getting_current/with_roles.ts +45 -0
- package/identity/for_IdentityProvider/when_getting_current/without_roles.ts +36 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.js","sources":["../../../commands/Command.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ICommand, PropertyChanged } from './ICommand';\nimport { CommandResult } from \"./CommandResult\";\nimport { CommandValidator } from './CommandValidator';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { Globals } from '../Globals';\nimport { joinPaths } from '../joinPaths';\nimport { UrlHelpers } from '../UrlHelpers';\nimport { GetHttpHeaders } from '../GetHttpHeaders';\nimport { PropertyDescriptor } from '../reflection/PropertyDescriptor';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { ValidationResultSeverity } from '../validation/ValidationResultSeverity';\n\ntype Callback = {\n callback: WeakRef<PropertyChanged>;\n thisArg: WeakRef<object>;\n}\n\n/**\n * Represents an implementation of {@link ICommand} that works with HTTP fetch.\n */\nexport abstract class Command<TCommandContent = object, TCommandResponse = object> implements ICommand<TCommandContent, TCommandResponse> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _httpHeadersCallback: GetHttpHeaders;\n abstract readonly route: string;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n readonly validation?: CommandValidator<any>;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n abstract readonly propertyDescriptors: PropertyDescriptor[];\n abstract get requestParameters(): string[];\n\n private _initialValues: object = {};\n private _hasChanges = false;\n private _callbacks: Callback[] = [];\n\n /**\n * Initializes a new instance of the {@link Command<,>} class.\n * @param _responseType Type of response.\n * @param _isResponseTypeEnumerable Whether or not the response type is enumerable.\n */\n constructor(readonly _responseType: Constructor = Object, readonly _isResponseTypeEnumerable: boolean) {\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n async execute(): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n if (clientValidationErrors.length > 0) {\n return CommandResult.validationFailed(clientValidationErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n if (validationErrors.length > 0) {\n return CommandResult.validationFailed(validationErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n const result = await this.performRequest(actualRoute, 'Command not found at route', 'Error during server call');\n this.setInitialValuesFromCurrentValues();\n return result;\n }\n\n /** @inheritdoc */\n async validate(): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n if (clientValidationErrors.length > 0) {\n return CommandResult.validationFailed(clientValidationErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n if (validationErrors.length > 0) {\n return CommandResult.validationFailed(validationErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n actualRoute = `${actualRoute}/validate`;\n return this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');\n }\n\n private buildPayload(): object {\n const payload = {};\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n payload[property] = this[property];\n });\n return payload;\n }\n\n private validateRequiredProperties(): ValidationResult[] {\n const validationErrors: ValidationResult[] = [];\n this.propertyDescriptors.forEach(propertyDescriptor => {\n if (!propertyDescriptor.isOptional && !this.requestParameters.includes(propertyDescriptor.name)) {\n const value = this[propertyDescriptor.name];\n if (value === undefined || value === null || value === '') {\n validationErrors.push(new ValidationResult(\n ValidationResultSeverity.Error,\n `${propertyDescriptor.name} is required`,\n [propertyDescriptor.name],\n null\n ));\n }\n }\n });\n return validationErrors;\n }\n\n private buildHeaders(): HeadersInit {\n const customHeaders = this._httpHeadersCallback?.() ?? {};\n const headers = {\n ...customHeaders,\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n return headers;\n }\n\n private async performRequest(\n route: string,\n notFoundMessage: string,\n errorMessage: string\n ): Promise<CommandResult<TCommandResponse>> {\n const payload = this.buildPayload();\n const headers = this.buildHeaders();\n const actualRoute = joinPaths(this._apiBasePath, route);\n const url = UrlHelpers.createUrlFrom(this._origin, this._apiBasePath, actualRoute);\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JsonSerializer.serialize(payload)\n });\n\n if (response.status === 404) {\n return CommandResult.failed([`${notFoundMessage} '${actualRoute}'`]) as CommandResult<TCommandResponse>;\n }\n\n const result = await response.json();\n return new CommandResult(result, this._responseType, this._isResponseTypeEnumerable);\n } catch (ex) {\n return CommandResult.failed([`${errorMessage}: ${ex}`]) as CommandResult<TCommandResponse>;\n }\n }\n\n /** @inheritdoc */\n clear(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = undefined;\n });\n this._initialValues = {};\n this._hasChanges = false;\n }\n\n /** @inheritdoc */\n setInitialValues(values: TCommandContent) {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (Object.prototype.hasOwnProperty.call(values, property)) {\n this._initialValues[property] = values[property];\n this[property] = values[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n setInitialValuesFromCurrentValues() {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (this[property]) {\n this._initialValues[property] = this[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n revertChanges(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = this._initialValues[property];\n });\n }\n\n /** @inheritdoc */\n get hasChanges() {\n return this._hasChanges;\n }\n\n /** @inheritdoc */\n propertyChanged(property: string) {\n this.updateHasChanges();\n\n this._callbacks.forEach(callbackContainer => {\n const callback = callbackContainer.callback.deref();\n const thisArg = callbackContainer.thisArg.deref();\n if (callback && thisArg) {\n callback.call(thisArg, property);\n } else {\n this._callbacks = this._callbacks.filter(_ => _.callback !== callbackContainer.callback);\n }\n });\n }\n\n /** @inheritdoc */\n onPropertyChanged(callback: PropertyChanged, thisArg: object) {\n this._callbacks.push({\n callback: new WeakRef(callback),\n thisArg: new WeakRef(thisArg)\n });\n }\n\n private updateHasChanges() {\n this._hasChanges = this.propertyDescriptors.some(propertyDescriptor => {\n const property = propertyDescriptor.name;\n return this[property] !== this._initialValues[property];\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;MAuBsB,OAAO,CAAA;AAqBJ,IAAA,aAAA;AAA8C,IAAA,yBAAA;AApB3D,IAAA,aAAa;AACb,IAAA,YAAY;AACZ,IAAA,OAAO;AACP,IAAA,oBAAoB;AAGnB,IAAA,UAAU;IAKX,cAAc,GAAW,EAAE;IAC3B,WAAW,GAAG,KAAK;IACnB,UAAU,GAAe,EAAE;IAOnC,WAAA,CAAqB,aAAA,GAA6B,MAAM,EAAW,yBAAkC,EAAA;QAAhF,IAAA,CAAA,aAAa,GAAb,aAAa;QAAiC,IAAA,CAAA,yBAAyB,GAAzB,yBAAyB;QACxF,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE;QAC/C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE;QACnC,IAAI,CAAC,oBAAoB,GAAG,OAAO,EAAE,CAAC;IAC1C;AAGA,IAAA,eAAe,CAAC,YAAoB,EAAA;AAChC,QAA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O,CAAC,KAAK,EAAE;AACjD,YAAA,IAAI,QAAQ,IAAI,OAAO,EAAE;AACrB,gBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;YACpC;iBAAO;gBACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,iBAAiB,CAAC,QAAQ,CAAC;YAC5F;AACJ,QAAA,CAAC,CAAC;IACN;IAGA,iBAAiB,CAAC,QAAyB,EAAE,OAAe,EAAA;AACxD,QAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;AACjB,YAAA,QAAQ,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC;AAC/B,YAAA,OAAO,EAAE,IAAI,OAAO,CAAC,OAAO;AAC/B,SAAA,CAAC;IACN;IAEQ,gBAAgB,GAAA;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,kBAAkB,IAAG;AAClE,YAAA,MAAM,QAAQ,GAAG,kBAAkB,CAAC,IAAI;YACxC,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;AAC3D,QAAA,CAAC,CAAC;IACN;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"Command.js","sources":["../../../commands/Command.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ICommand, PropertyChanged } from './ICommand';\nimport { CommandResult } from \"./CommandResult\";\nimport { CommandValidator } from './CommandValidator';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { Globals } from '../Globals';\nimport { joinPaths } from '../joinPaths';\nimport { UrlHelpers } from '../UrlHelpers';\nimport { GetHttpHeaders } from '../GetHttpHeaders';\nimport { PropertyDescriptor } from '../reflection/PropertyDescriptor';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { ValidationResultSeverity } from '../validation/ValidationResultSeverity';\n\ntype Callback = {\n callback: WeakRef<PropertyChanged>;\n thisArg: WeakRef<object>;\n}\n\n/**\n * Represents an implementation of {@link ICommand} that works with HTTP fetch.\n */\nexport abstract class Command<TCommandContent = object, TCommandResponse = object> implements ICommand<TCommandContent, TCommandResponse> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _httpHeadersCallback: GetHttpHeaders;\n abstract readonly route: string;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n readonly validation?: CommandValidator<any>;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n abstract readonly propertyDescriptors: PropertyDescriptor[];\n abstract get requestParameters(): string[];\n\n private _initialValues: object = {};\n private _hasChanges = false;\n private _callbacks: Callback[] = [];\n\n /**\n * Initializes a new instance of the {@link Command<,>} class.\n * @param _responseType Type of response.\n * @param _isResponseTypeEnumerable Whether or not the response type is enumerable.\n */\n constructor(readonly _responseType: Constructor = Object, readonly _isResponseTypeEnumerable: boolean) {\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n async execute(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors, allowedSeverity, ignoreWarnings);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors, allowedSeverity, ignoreWarnings);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n const result = await this.performRequest(actualRoute, 'Command not found at route', 'Error during server call', allowedSeverity, ignoreWarnings);\n this.setInitialValuesFromCurrentValues();\n return result;\n }\n\n /** @inheritdoc */\n async validate(): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n if (clientValidationErrors.length > 0) {\n return CommandResult.validationFailed(clientValidationErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n if (validationErrors.length > 0) {\n return CommandResult.validationFailed(validationErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n actualRoute = `${actualRoute}/validate`;\n return this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');\n }\n\n private buildPayload(): object {\n const payload = {};\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n payload[property] = this[property];\n });\n return payload;\n }\n\n private validateRequiredProperties(): ValidationResult[] {\n const validationErrors: ValidationResult[] = [];\n this.propertyDescriptors.forEach(propertyDescriptor => {\n if (!propertyDescriptor.isOptional && !this.requestParameters.includes(propertyDescriptor.name)) {\n const value = this[propertyDescriptor.name];\n if (value === undefined || value === null || value === '') {\n validationErrors.push(new ValidationResult(\n ValidationResultSeverity.Error,\n `${propertyDescriptor.name} is required`,\n [propertyDescriptor.name],\n null\n ));\n }\n }\n });\n return validationErrors;\n }\n\n private filterValidationResultsBySeverity(validationResults: ValidationResult[], allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): ValidationResult[] {\n if (ignoreWarnings === true) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n if (allowedSeverity === undefined) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n return validationResults.filter(result => result.severity > allowedSeverity);\n }\n\n private buildHeaders(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): HeadersInit {\n const customHeaders = this._httpHeadersCallback?.() ?? {};\n const headers = {\n ...customHeaders,\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n if (allowedSeverity !== undefined) {\n headers['X-Allowed-Severity'] = allowedSeverity.toString();\n }\n\n if (ignoreWarnings === true) {\n headers['X-Ignore-Warnings'] = 'true';\n }\n\n return headers;\n }\n\n private async performRequest(\n route: string,\n notFoundMessage: string,\n errorMessage: string,\n allowedSeverity?: ValidationResultSeverity,\n ignoreWarnings?: boolean\n ): Promise<CommandResult<TCommandResponse>> {\n const payload = this.buildPayload();\n const headers = this.buildHeaders(allowedSeverity, ignoreWarnings);\n const actualRoute = joinPaths(this._apiBasePath, route);\n const url = UrlHelpers.createUrlFrom(this._origin, this._apiBasePath, actualRoute);\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JsonSerializer.serialize(payload)\n });\n\n if (response.status === 404) {\n return CommandResult.failed([`${notFoundMessage} '${actualRoute}'`]) as CommandResult<TCommandResponse>;\n }\n\n const result = await response.json();\n return new CommandResult(result, this._responseType, this._isResponseTypeEnumerable);\n } catch (ex) {\n return CommandResult.failed([`${errorMessage}: ${ex}`]) as CommandResult<TCommandResponse>;\n }\n }\n\n /** @inheritdoc */\n clear(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = undefined;\n });\n this._initialValues = {};\n this._hasChanges = false;\n }\n\n /** @inheritdoc */\n setInitialValues(values: TCommandContent) {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (Object.prototype.hasOwnProperty.call(values, property)) {\n this._initialValues[property] = values[property];\n this[property] = values[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n setInitialValuesFromCurrentValues() {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (this[property]) {\n this._initialValues[property] = this[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n revertChanges(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = this._initialValues[property];\n });\n }\n\n /** @inheritdoc */\n get hasChanges() {\n return this._hasChanges;\n }\n\n /** @inheritdoc */\n propertyChanged(property: string) {\n this.updateHasChanges();\n\n this._callbacks.forEach(callbackContainer => {\n const callback = callbackContainer.callback.deref();\n const thisArg = callbackContainer.thisArg.deref();\n if (callback && thisArg) {\n callback.call(thisArg, property);\n } else {\n this._callbacks = this._callbacks.filter(_ => _.callback !== callbackContainer.callback);\n }\n });\n }\n\n /** @inheritdoc */\n onPropertyChanged(callback: PropertyChanged, thisArg: object) {\n this._callbacks.push({\n callback: new WeakRef(callback),\n thisArg: new WeakRef(thisArg)\n });\n }\n\n private updateHasChanges() {\n this._hasChanges = this.propertyDescriptors.some(propertyDescriptor => {\n const property = propertyDescriptor.name;\n return this[property] !== this._initialValues[property];\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;MAuBsB,OAAO,CAAA;AAqBJ,IAAA,aAAA;AAA8C,IAAA,yBAAA;AApB3D,IAAA,aAAa;AACb,IAAA,YAAY;AACZ,IAAA,OAAO;AACP,IAAA,oBAAoB;AAGnB,IAAA,UAAU;IAKX,cAAc,GAAW,EAAE;IAC3B,WAAW,GAAG,KAAK;IACnB,UAAU,GAAe,EAAE;I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5B,IAAI,CAAC,gBAAgB,EAAE;AAEvB,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,IAAG;YACxC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC,KAAK,EAAE;YACnD,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE;AACjD,YAAA,IAAI,QAAQ,IAAI,OAAO,EAAE;AACrB,gBAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;YACpC;iBAAO;gBACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,iBAAiB,CAAC,QAAQ,CAAC;YAC5F;AACJ,QAAA,CAAC,CAAC;IACN;IAGA,iBAAiB,CAAC,QAAyB,EAAE,OAAe,EAAA;AACxD,QAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;AACjB,YAAA,QAAQ,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC;AAC/B,YAAA,OAAO,EAAE,IAAI,OAAO,CAAC,OAAO;AAC/B,SAAA,CAAC;IACN;IAEQ,gBAAgB,GAAA;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,kBAAkB,IAAG;AAClE,YAAA,MAAM,QAAQ,GAAG,kBAAkB,CAAC,IAAI;YACxC,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;AAC3D,QAAA,CAAC,CAAC;IACN;AACH;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ICanBeConfigured } from '../ICanBeConfigured';
|
|
2
2
|
import { CommandResult } from './CommandResult';
|
|
3
3
|
import { PropertyDescriptor } from '../reflection/PropertyDescriptor';
|
|
4
|
+
import { ValidationResultSeverity } from '../validation/ValidationResultSeverity';
|
|
4
5
|
export type PropertyChanged = (property: string) => void;
|
|
5
6
|
export interface ICommand<TCommandContent = object, TCommandResponse = object> extends ICanBeConfigured {
|
|
6
7
|
readonly route: string;
|
|
7
8
|
readonly propertyDescriptors: PropertyDescriptor[];
|
|
8
|
-
execute(): Promise<CommandResult<TCommandResponse>>;
|
|
9
|
+
execute(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): Promise<CommandResult<TCommandResponse>>;
|
|
9
10
|
validate(): Promise<CommandResult<TCommandResponse>>;
|
|
10
11
|
clear(): void;
|
|
11
12
|
setInitialValues(values: TCommandContent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICommand.d.ts","sourceRoot":"","sources":["../../../commands/ICommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"ICommand.d.ts","sourceRoot":"","sources":["../../../commands/ICommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAKlF,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;AAKzD,MAAM,WAAW,QAAQ,CAAC,eAAe,GAAG,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAE,SAAQ,gBAAgB;IAInG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAKvB,QAAQ,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAQnD,OAAO,CAAC,eAAe,CAAC,EAAE,wBAAwB,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC;IASxH,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAMrD,KAAK,IAAI,IAAI,CAAC;IAMd,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAKhD,iCAAiC,IAAI,IAAI,CAAC;IAK1C,aAAa,IAAI,IAAI,CAAC;IAKtB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAM7B,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAOxC,iBAAiB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_allowed_severity_warning.d.ts","sourceRoot":"","sources":["../../../../../commands/for_Command/when_executing/with_allowed_severity_warning.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { given } from '../../../given';
|
|
2
|
+
import { a_command } from '../given/a_command';
|
|
3
|
+
import { ValidationResultSeverity } from '../../../validation/ValidationResultSeverity';
|
|
4
|
+
describe("when executing with allowed severity warning", given(class extends a_command {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.fetchStub.resolves({
|
|
8
|
+
status: 200,
|
|
9
|
+
json: async () => ({
|
|
10
|
+
correlationId: '00000000-0000-0000-0000-000000000000',
|
|
11
|
+
isSuccess: true,
|
|
12
|
+
isAuthorized: true,
|
|
13
|
+
isValid: true,
|
|
14
|
+
hasExceptions: false,
|
|
15
|
+
validationResults: [],
|
|
16
|
+
exceptionMessages: [],
|
|
17
|
+
exceptionStackTrace: '',
|
|
18
|
+
authorizationFailureReason: '',
|
|
19
|
+
response: null
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}, context => {
|
|
24
|
+
beforeEach(async () => {
|
|
25
|
+
await context.command.execute(ValidationResultSeverity.Warning);
|
|
26
|
+
});
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
context.fetchHelper.restore();
|
|
29
|
+
});
|
|
30
|
+
it("should call fetch", () => context.fetchStub.called.should.be.true);
|
|
31
|
+
it("should have sent X-Allowed-Severity header with value 2", () => {
|
|
32
|
+
const headers = context.fetchStub.firstCall.args[1].headers;
|
|
33
|
+
headers['X-Allowed-Severity'].should.equal('2');
|
|
34
|
+
});
|
|
35
|
+
}));
|
|
36
|
+
//# sourceMappingURL=with_allowed_severity_warning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_allowed_severity_warning.js","sourceRoot":"","sources":["../../../../../commands/for_Command/when_executing/with_allowed_severity_warning.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAGxF,QAAQ,CAAC,8CAA8C,EAAE,KAAK,CAAC,KAAM,SAAQ,SAAS;IAClF;QACI,KAAK,EAAE,CAAC;QAGR,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;YACpB,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;gBACf,aAAa,EAAE,sCAAsC;gBACrD,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,IAAI;gBAClB,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,KAAK;gBACpB,iBAAiB,EAAE,EAAE;gBACrB,iBAAiB,EAAE,EAAE;gBACrB,mBAAmB,EAAE,EAAE;gBACvB,0BAA0B,EAAE,EAAE;gBAC9B,QAAQ,EAAE,IAAI;aACjB,CAAC;SACL,CAAC,CAAC;IACP,CAAC;CACJ,EAAE,OAAO,CAAC,EAAE;IACT,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACvE,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC5D,OAAO,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IIdentity.d.ts","sourceRoot":"","sources":["../../../identity/IIdentity.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS,CAAC,QAAQ,GAAG,MAAM;IAKxC,EAAE,EAAE,MAAM,CAAC;IAKX,IAAI,EAAE,MAAM,CAAC;IAKb,OAAO,EAAE,QAAQ,CAAC;IAKlB,KAAK,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"IIdentity.d.ts","sourceRoot":"","sources":["../../../identity/IIdentity.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS,CAAC,QAAQ,GAAG,MAAM;IAKxC,EAAE,EAAE,MAAM,CAAC;IAKX,IAAI,EAAE,MAAM,CAAC;IAKb,KAAK,EAAE,MAAM,EAAE,CAAC;IAKhB,OAAO,EAAE,QAAQ,CAAC;IAKlB,KAAK,EAAE,OAAO,CAAC;IAOf,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAKhC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProvider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQhD,qBAAa,gBAAiB,SAAQ,iBAAiB;IAEnD,MAAM,CAAC,QAAQ,CAAC,UAAU,sBAAsB;IAChD,MAAM,CAAC,mBAAmB,EAAE,cAAc,GAAG,SAAS,CAAC;IACvD,MAAM,CAAC,WAAW,EAAE,MAAM,CAAM;IAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAM3B,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAQ7D,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQhD,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;WAUzB,UAAU,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"IdentityProvider.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProvider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQhD,qBAAa,gBAAiB,SAAQ,iBAAiB;IAEnD,MAAM,CAAC,QAAQ,CAAC,UAAU,sBAAsB;IAChD,MAAM,CAAC,mBAAmB,EAAE,cAAc,GAAG,SAAS,CAAC;IACvD,MAAM,CAAC,WAAW,EAAE,MAAM,CAAM;IAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAM3B,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAQ7D,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQhD,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;WAUzB,UAAU,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAsB/G,UAAU,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;WAIjG,OAAO,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IA0BlH,OAAO,CAAC,MAAM,CAAC,SAAS;IAYxB,OAAO,CAAC,MAAM,CAAC,WAAW;CAI7B"}
|
|
@@ -27,8 +27,10 @@ class IdentityProvider extends IIdentityProvider {
|
|
|
27
27
|
return {
|
|
28
28
|
id: result.id,
|
|
29
29
|
name: result.name,
|
|
30
|
+
roles: result.roles || [],
|
|
30
31
|
details: details,
|
|
31
32
|
isSet: true,
|
|
33
|
+
isInRole: (role) => (result.roles || []).includes(role),
|
|
32
34
|
refresh: () => IdentityProvider.refresh(type)
|
|
33
35
|
};
|
|
34
36
|
}
|
|
@@ -55,8 +57,10 @@ class IdentityProvider extends IIdentityProvider {
|
|
|
55
57
|
return {
|
|
56
58
|
id: result.id,
|
|
57
59
|
name: result.name,
|
|
60
|
+
roles: result.roles || [],
|
|
58
61
|
details: details,
|
|
59
62
|
isSet: true,
|
|
63
|
+
isInRole: (role) => (result.roles || []).includes(role),
|
|
60
64
|
refresh: () => IdentityProvider.refresh(type)
|
|
61
65
|
};
|
|
62
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.js","sources":["../../../identity/IdentityProvider.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { IIdentityProvider } from './IIdentityProvider';\nimport { IIdentity } from './IIdentity';\nimport { IdentityProviderResult } from './IdentityProviderResult';\nimport { GetHttpHeaders } from 'GetHttpHeaders';\nimport { Globals } from '../Globals';\nimport { UrlHelpers } from '../UrlHelpers';\nimport { joinPaths } from '../joinPaths';\n\n/**\n * Represents an implementation of {@link IIdentityProvider}.\n*/\nexport class IdentityProvider extends IIdentityProvider {\n\n static readonly CookieName = '.cratis-identity';\n static httpHeadersCallback: GetHttpHeaders | undefined;\n static apiBasePath: string = '';\n static origin: string = '';\n\n /**\n * Sets the HTTP headers callback.\n * @param callback Callback to set.\n */\n static setHttpHeadersCallback(callback: GetHttpHeaders): void {\n IdentityProvider.httpHeadersCallback = callback;\n }\n\n /**\n * Sets the API base path.\n * @param apiBasePath API base path to set.\n */\n static setApiBasePath(apiBasePath: string): void {\n IdentityProvider.apiBasePath = apiBasePath;\n }\n\n /**\n * Sets the origin.\n * @param origin Origin to set.\n */\n static setOrigin(origin: string): void {\n IdentityProvider.origin = origin;\n }\n\n /**\n * Gets the current identity by optionally specifying the details type.\n * @param type Optional constructor for the details type to enable type-safe deserialization.\n * @returns The current identity as {@link IIdentity}.\n * @remarks The `extends object` constraint is required for compatibility with JsonSerializer.deserializeFromInstance().\n */\n static async getCurrent<TDetails extends object = object>(type?: Constructor<TDetails>): Promise<IIdentity<TDetails>> {\n const cookie = this.getCookie();\n if (cookie.length == 2) {\n const json = atob(cookie[1]);\n const result = JSON.parse(json) as IdentityProviderResult;\n const details = type ? JsonSerializer.deserializeFromInstance(type, result.details) : result.details;\n return {\n id: result.id,\n name: result.name,\n details: details as TDetails,\n isSet: true,\n refresh: () => IdentityProvider.refresh(type)\n } as IIdentity<TDetails>;\n } else {\n const identity = await this.refresh<TDetails>(type);\n return identity;\n }\n }\n\n /** @inheritdoc */\n async getCurrent<TDetails extends object = object>(type?: Constructor<TDetails>): Promise<IIdentity<TDetails>> {\n return IdentityProvider.getCurrent<TDetails>(type);\n }\n\n static async refresh<TDetails extends object = object>(type?: Constructor<TDetails>): Promise<IIdentity<TDetails>> {\n IdentityProvider.clearCookie();\n const origin = IdentityProvider.origin || Globals.origin || '';\n const apiBasePath = IdentityProvider.apiBasePath || Globals.apiBasePath || '';\n const route = joinPaths(apiBasePath, '/.cratis/me');\n const url = UrlHelpers.createUrlFrom(origin, apiBasePath, route);\n const response = await fetch(\n url, {\n method: 'GET',\n headers: IdentityProvider.httpHeadersCallback?.() ?? {}\n });\n\n const result = await response.json() as IdentityProviderResult;\n const details = type ? JsonSerializer.deserializeFromInstance(type, result.details) : result.details;\n\n return {\n id: result.id,\n name: result.name,\n details: details as TDetails,\n isSet: true,\n refresh: () => IdentityProvider.refresh(type)\n };\n }\n\n private static getCookie() {\n if (typeof document === 'undefined') return [];\n const decoded = decodeURIComponent(document.cookie);\n const cookies = decoded.split(';').map(_ => _.trim());\n const cookie = cookies.find(_ => _.indexOf(`${IdentityProvider.CookieName}=`) == 0);\n if (cookie) {\n const keyValue = cookie.split('=');\n return [keyValue[0].trim(), keyValue[1].trim()];\n }\n return [];\n }\n\n private static clearCookie() {\n if (typeof document === 'undefined') return;\n document.cookie = `${IdentityProvider.CookieName}=;expires=Thu, 01 Jan 1970 00:00:00 GMT`;\n }\n}\n"],"names":[],"mappings":";;;;;;AAeM,MAAO,gBAAiB,SAAQ,iBAAiB,CAAA;AAEnD,IAAA,OAAgB,UAAU,GAAG,kBAAkB;IAC/C,OAAO,mBAAmB;AAC1B,IAAA,OAAO,WAAW,GAAW,EAAE;AAC/B,IAAA,OAAO,MAAM,GAAW,EAAE;IAM1B,OAAO,sBAAsB,CAAC,QAAwB,EAAA;AAClD,QAAA,gBAAgB,CAAC,mBAAmB,GAAG,QAAQ;IACnD;IAMA,OAAO,cAAc,CAAC,WAAmB,EAAA;AACrC,QAAA,gBAAgB,CAAC,WAAW,GAAG,WAAW;IAC9C;IAMA,OAAO,SAAS,CAAC,MAAc,EAAA;AAC3B,QAAA,gBAAgB,CAAC,MAAM,GAAG,MAAM;IACpC;AAQA,IAAA,aAAa,UAAU,CAAmC,IAA4B,EAAA;AAClF,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE;AAC/B,QAAA,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA2B;YACzD,MAAM,OAAO,GAAG,IAAI,GAAG,cAAc,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO;YACpG,OAAO;gBACH,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,IAAI,EAAE,MAAM,CAAC,IAAI;AACjB,gBAAA,OAAO,EAAE,OAAmB;AAC5B,gBAAA,KAAK,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"IdentityProvider.js","sources":["../../../identity/IdentityProvider.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { IIdentityProvider } from './IIdentityProvider';\nimport { IIdentity } from './IIdentity';\nimport { IdentityProviderResult } from './IdentityProviderResult';\nimport { GetHttpHeaders } from 'GetHttpHeaders';\nimport { Globals } from '../Globals';\nimport { UrlHelpers } from '../UrlHelpers';\nimport { joinPaths } from '../joinPaths';\n\n/**\n * Represents an implementation of {@link IIdentityProvider}.\n*/\nexport class IdentityProvider extends IIdentityProvider {\n\n static readonly CookieName = '.cratis-identity';\n static httpHeadersCallback: GetHttpHeaders | undefined;\n static apiBasePath: string = '';\n static origin: string = '';\n\n /**\n * Sets the HTTP headers callback.\n * @param callback Callback to set.\n */\n static setHttpHeadersCallback(callback: GetHttpHeaders): void {\n IdentityProvider.httpHeadersCallback = callback;\n }\n\n /**\n * Sets the API base path.\n * @param apiBasePath API base path to set.\n */\n static setApiBasePath(apiBasePath: string): void {\n IdentityProvider.apiBasePath = apiBasePath;\n }\n\n /**\n * Sets the origin.\n * @param origin Origin to set.\n */\n static setOrigin(origin: string): void {\n IdentityProvider.origin = origin;\n }\n\n /**\n * Gets the current identity by optionally specifying the details type.\n * @param type Optional constructor for the details type to enable type-safe deserialization.\n * @returns The current identity as {@link IIdentity}.\n * @remarks The `extends object` constraint is required for compatibility with JsonSerializer.deserializeFromInstance().\n */\n static async getCurrent<TDetails extends object = object>(type?: Constructor<TDetails>): Promise<IIdentity<TDetails>> {\n const cookie = this.getCookie();\n if (cookie.length == 2) {\n const json = atob(cookie[1]);\n const result = JSON.parse(json) as IdentityProviderResult;\n const details = type ? JsonSerializer.deserializeFromInstance(type, result.details) : result.details;\n return {\n id: result.id,\n name: result.name,\n roles: result.roles || [],\n details: details as TDetails,\n isSet: true,\n isInRole: (role: string) => (result.roles || []).includes(role),\n refresh: () => IdentityProvider.refresh(type)\n } as IIdentity<TDetails>;\n } else {\n const identity = await this.refresh<TDetails>(type);\n return identity;\n }\n }\n\n /** @inheritdoc */\n async getCurrent<TDetails extends object = object>(type?: Constructor<TDetails>): Promise<IIdentity<TDetails>> {\n return IdentityProvider.getCurrent<TDetails>(type);\n }\n\n static async refresh<TDetails extends object = object>(type?: Constructor<TDetails>): Promise<IIdentity<TDetails>> {\n IdentityProvider.clearCookie();\n const origin = IdentityProvider.origin || Globals.origin || '';\n const apiBasePath = IdentityProvider.apiBasePath || Globals.apiBasePath || '';\n const route = joinPaths(apiBasePath, '/.cratis/me');\n const url = UrlHelpers.createUrlFrom(origin, apiBasePath, route);\n const response = await fetch(\n url, {\n method: 'GET',\n headers: IdentityProvider.httpHeadersCallback?.() ?? {}\n });\n\n const result = await response.json() as IdentityProviderResult;\n const details = type ? JsonSerializer.deserializeFromInstance(type, result.details) : result.details;\n\n return {\n id: result.id,\n name: result.name,\n roles: result.roles || [],\n details: details as TDetails,\n isSet: true,\n isInRole: (role: string) => (result.roles || []).includes(role),\n refresh: () => IdentityProvider.refresh(type)\n };\n }\n\n private static getCookie() {\n if (typeof document === 'undefined') return [];\n const decoded = decodeURIComponent(document.cookie);\n const cookies = decoded.split(';').map(_ => _.trim());\n const cookie = cookies.find(_ => _.indexOf(`${IdentityProvider.CookieName}=`) == 0);\n if (cookie) {\n const keyValue = cookie.split('=');\n return [keyValue[0].trim(), keyValue[1].trim()];\n }\n return [];\n }\n\n private static clearCookie() {\n if (typeof document === 'undefined') return;\n document.cookie = `${IdentityProvider.CookieName}=;expires=Thu, 01 Jan 1970 00:00:00 GMT`;\n }\n}\n"],"names":[],"mappings":";;;;;;AAeM,MAAO,gBAAiB,SAAQ,iBAAiB,CAAA;AAEnD,IAAA,OAAgB,UAAU,GAAG,kBAAkB;IAC/C,OAAO,mBAAmB;AAC1B,IAAA,OAAO,WAAW,GAAW,EAAE;AAC/B,IAAA,OAAO,MAAM,GAAW,EAAE;IAM1B,OAAO,sBAAsB,CAAC,QAAwB,EAAA;AAClD,QAAA,gBAAgB,CAAC,mBAAmB,GAAG,QAAQ;IACnD;IA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nD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA,EAAG,gBAAgB,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,CAAC;QACnF,IAAI,MAAM,EAAE;YACR,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AAClC,YAAA,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACnD;AACA,QAAA,OAAO,EAAE;IACb;AAEQ,IAAA,OAAO,WAAW,GAAA;QACtB,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE;QACrC,QAAQ,CAAC,MAAM,GAAG,CAAA,EAAG,gBAAgB,CAAC,UAAU,yCAAyC;IAC7F;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProviderResult.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProviderResult.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,sBAAsB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
1
|
+
{"version":3,"file":"IdentityProviderResult.d.ts","sourceRoot":"","sources":["../../../identity/IdentityProviderResult.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,sBAAsB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_roles.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_getting_current/with_roles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IdentityProvider } from '../../IdentityProvider';
|
|
2
|
+
import { an_identity_provider } from '../given/an_identity_provider';
|
|
3
|
+
import { given } from '../../../given';
|
|
4
|
+
describe('when getting current with roles', given(an_identity_provider, () => {
|
|
5
|
+
let identity;
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
const identityData = {
|
|
8
|
+
id: 'test-user-id',
|
|
9
|
+
name: 'Test User',
|
|
10
|
+
roles: ['Admin', 'User'],
|
|
11
|
+
details: {}
|
|
12
|
+
};
|
|
13
|
+
const encodedData = btoa(JSON.stringify(identityData));
|
|
14
|
+
global.document.cookie = `.cratis-identity=${encodedData}`;
|
|
15
|
+
const result = await IdentityProvider.getCurrent();
|
|
16
|
+
identity = {
|
|
17
|
+
id: result.id,
|
|
18
|
+
name: result.name,
|
|
19
|
+
roles: result.roles,
|
|
20
|
+
isInRole: result.isInRole
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
it('should have the roles', () => {
|
|
24
|
+
identity.roles.should.deep.equal(['Admin', 'User']);
|
|
25
|
+
});
|
|
26
|
+
it('should return true when checking for Admin role', () => {
|
|
27
|
+
identity.isInRole('Admin').should.be.true;
|
|
28
|
+
});
|
|
29
|
+
it('should return true when checking for User role', () => {
|
|
30
|
+
identity.isInRole('User').should.be.true;
|
|
31
|
+
});
|
|
32
|
+
it('should return false when checking for non-existent role', () => {
|
|
33
|
+
identity.isInRole('SuperAdmin').should.be.false;
|
|
34
|
+
});
|
|
35
|
+
}));
|
|
36
|
+
//# sourceMappingURL=with_roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_roles.js","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_getting_current/with_roles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAA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C,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QAC/D,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"without_roles.d.ts","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_getting_current/without_roles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IdentityProvider } from '../../IdentityProvider';
|
|
2
|
+
import { an_identity_provider } from '../given/an_identity_provider';
|
|
3
|
+
import { given } from '../../../given';
|
|
4
|
+
describe('when getting current without roles', given(an_identity_provider, () => {
|
|
5
|
+
let identity;
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
const identityData = {
|
|
8
|
+
id: 'test-user-id',
|
|
9
|
+
name: 'Test User',
|
|
10
|
+
details: {}
|
|
11
|
+
};
|
|
12
|
+
const encodedData = btoa(JSON.stringify(identityData));
|
|
13
|
+
global.document.cookie = `.cratis-identity=${encodedData}`;
|
|
14
|
+
const result = await IdentityProvider.getCurrent();
|
|
15
|
+
identity = {
|
|
16
|
+
id: result.id,
|
|
17
|
+
name: result.name,
|
|
18
|
+
roles: result.roles,
|
|
19
|
+
isInRole: result.isInRole
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
it('should have empty roles array', () => {
|
|
23
|
+
identity.roles.should.be.empty;
|
|
24
|
+
});
|
|
25
|
+
it('should return false when checking for any role', () => {
|
|
26
|
+
identity.isInRole('Admin').should.be.false;
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
//# sourceMappingURL=without_roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"without_roles.js","sourceRoot":"","sources":["../../../../../identity/for_IdentityProvider/when_getting_current/without_roles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,QAAQ,CAAC,oCAAoC,EAAE,KAAK,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAC5E,IAAI,QAA4F,CAAC;IAEjG,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,YAAY,GAAG;YACjB,EAAE,EAAE,cAAc;YAClB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,EAAE;SACd,CAAC;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;QACtD,MAA4C,CAAC,QAAS,CAAC,MAAM,GAAG,oBAAoB,WAAW,EAAE,CAAC;QAEnG,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,UAAU,EAAE,CAAC;QACnD,QAAQ,GAAG;YACP,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC5B,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACrC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACtD,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;IAC/C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
|