@aidc-toolkit/app-extension 1.0.28-beta → 1.0.31-beta

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/dist/index.js CHANGED
@@ -1706,6 +1706,8 @@ var Proxy2 = class _Proxy {
1706
1706
  /**
1707
1707
  * Logger.
1708
1708
  */
1709
+ // TODO Add configuration parameter to output JSON.
1710
+ // TODO Change this to LogLevels.Trace when configuration available.
1709
1711
  #logger = getLogger(LogLevels.Info);
1710
1712
  /**
1711
1713
  * Abstract class descriptors map, keyed on declaration class name. Abstract classes are not used directly by target
@@ -1883,9 +1885,9 @@ var Proxy2 = class _Proxy {
1883
1885
  /**
1884
1886
  * @inheritDoc
1885
1887
  */
1886
- log(methodName, args, result) {
1888
+ log(logLevel, methodName, args, result) {
1887
1889
  const methodDescriptor = methodDescriptorsMap.get(methodName);
1888
- logger.info(JSON.stringify({
1890
+ logger.log(logLevel, "", JSON.stringify({
1889
1891
  namespace: decoratorClassDescriptor.namespace,
1890
1892
  className: name,
1891
1893
  methodName,
@@ -1934,8 +1936,15 @@ var Proxy2 = class _Proxy {
1934
1936
  parameterDescriptors
1935
1937
  });
1936
1938
  return function methodProxy(...args) {
1937
- const result = target.call(this, ...args);
1938
- this.log(name, args, result);
1939
+ const targetLogger = this;
1940
+ let result;
1941
+ try {
1942
+ result = target.call(this, ...args);
1943
+ targetLogger.log(LogLevels.Info, name, args, result);
1944
+ } catch (e) {
1945
+ targetLogger.log(LogLevels.Error, name, args, e instanceof Error ? `${e.name}: ${e.message}` : `Unknown exception: ${String(e)}`);
1946
+ throw e;
1947
+ }
1939
1948
  return result;
1940
1949
  };
1941
1950
  };
@@ -3593,19 +3602,22 @@ var Generator = class _Generator {
3593
3602
  * @param localizedKeyPrefix
3594
3603
  * Localized key prefix.
3595
3604
  *
3605
+ * @param namespacePrefix
3606
+ * Namespace prefix to be appended to name.
3607
+ *
3596
3608
  * @param localizationCallback
3597
3609
  * Callback to finalize localization.
3598
3610
  *
3599
3611
  * @returns
3600
3612
  * Localization.
3601
3613
  */
3602
- #generateLocalization(locale, localizedKeyPrefix, localizationCallback) {
3614
+ #generateLocalization(locale, localizedKeyPrefix, namespacePrefix, localizationCallback) {
3603
3615
  const lngOption = {
3604
3616
  lng: locale
3605
3617
  };
3606
3618
  return localizationCallback(locale, {
3607
3619
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists.
3608
- name: i18nextAppExtension.t(`${localizedKeyPrefix}name`, lngOption),
3620
+ name: `${namespacePrefix}${i18nextAppExtension.t(`${localizedKeyPrefix}name`, lngOption)}`,
3609
3621
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists.
3610
3622
  description: i18nextAppExtension.t(`${localizedKeyPrefix}description`, lngOption)
3611
3623
  });
@@ -3620,17 +3632,19 @@ var Generator = class _Generator {
3620
3632
  try {
3621
3633
  for (const [_namespaceClassName, classDescriptor] of proxy.classDescriptorsMap.entries()) {
3622
3634
  const namespace = classDescriptor.namespace;
3635
+ const namespacePrefix = namespace === void 0 ? "" : `${namespace}.`;
3636
+ const namespacePath = namespace === void 0 ? "" : `${namespace}/`;
3623
3637
  this.createProxyObject(classDescriptor);
3624
3638
  for (const methodDescriptor of classDescriptor.methodDescriptors) {
3625
3639
  const namespaceFunctionName = methodDescriptor.namespaceFunctionName;
3626
3640
  const functionLocalizationsMap = new Map(this.#locales.map(
3627
- (locale) => [locale, this.#generateLocalization(locale, `Functions.${namespaceFunctionName}.`, (locale2, localization) => ({
3641
+ (locale) => [locale, this.#generateLocalization(locale, `Functions.${namespaceFunctionName}.`, namespacePrefix, (locale2, localization) => ({
3628
3642
  ...localization,
3629
- documentationURL: `${_Generator.#DOCUMENTATION_BASE_URL}${locale2 === this.defaultLocale ? "" : `${locale2}/`}${_Generator.#DOCUMENTATION_PATH}${namespace === void 0 ? "" : `${namespace}/`}${localization.name}.html`,
3643
+ documentationURL: `${_Generator.#DOCUMENTATION_BASE_URL}${locale2 === this.defaultLocale ? "" : `${locale2}/`}${_Generator.#DOCUMENTATION_PATH}${namespacePath}${localization.name}.html`,
3630
3644
  parametersMap: new Map(methodDescriptor.parameterDescriptors.map(
3631
3645
  (parameterDescriptor) => (
3632
3646
  // eslint-disable-next-line max-nested-callbacks -- Callback is empty.
3633
- [parameterDescriptor.name, this.#generateLocalization(locale2, `Parameters.${parameterDescriptor.name}.`, (_locale, localization2) => localization2)]
3647
+ [parameterDescriptor.name, this.#generateLocalization(locale2, `Parameters.${parameterDescriptor.name}.`, "", (_locale, localization2) => localization2)]
3634
3648
  )
3635
3649
  ))
3636
3650
  }))]