@alfresco/adf-process-services-cloud 9.2.0-33428582503 → 9.2.0-33748326393

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.
@@ -1868,7 +1868,6 @@ class WebSocketService {
1868
1868
  this.httpLink = inject(HttpLink);
1869
1869
  this.authService = inject(AuthenticationService);
1870
1870
  this.appConfigService = inject(AppConfigService);
1871
- this.subscriptionProtocol = 'graphql-ws';
1872
1871
  }
1873
1872
  getSubscription(options) {
1874
1873
  const { apolloClientName, subscriptionOptions } = options;
@@ -1906,8 +1905,7 @@ class WebSocketService {
1906
1905
  operation.setContext(({ headers }) => ({
1907
1906
  headers: {
1908
1907
  ...headers,
1909
- ...(this.subscriptionProtocol === 'graphql-ws' && { Authorization: `Bearer ${this.authService.getToken()}` }),
1910
- ...(this.subscriptionProtocol === 'transport-ws' && { 'X-Authorization': `Bearer ${this.authService.getToken()}` })
1908
+ Authorization: `Bearer ${this.authService.getToken()}`
1911
1909
  }
1912
1910
  }));
1913
1911
  return forward(operation);
@@ -1915,14 +1913,15 @@ class WebSocketService {
1915
1913
  const errorLink = onError(({ graphQLErrors, networkError, operation, forward }) => {
1916
1914
  if (graphQLErrors) {
1917
1915
  for (const error of graphQLErrors) {
1918
- if (error.extensions && error.extensions['code'] === 'UNAUTHENTICATED') {
1919
- authLink(operation, forward);
1916
+ if (error.extensions?.['code'] === 'UNAUTHENTICATED') {
1917
+ return authLink(operation, forward);
1920
1918
  }
1921
1919
  }
1922
1920
  }
1923
1921
  if (networkError) {
1924
1922
  console.error(`[Network error]: ${networkError}`);
1925
1923
  }
1924
+ return undefined;
1926
1925
  });
1927
1926
  const retryLink = new RetryLink({
1928
1927
  delay: {
@@ -1937,28 +1936,31 @@ class WebSocketService {
1937
1936
  });
1938
1937
  this.apollo.createNamed(options.apolloClientName, {
1939
1938
  headers: {
1940
- ...(this.subscriptionProtocol === 'graphql-ws' && { Authorization: `Bearer ${this.authService.getToken()}` }),
1941
- ...(this.subscriptionProtocol === 'transport-ws' && { 'X-Authorization': `Bearer ${this.authService.getToken()}` })
1939
+ Authorization: `Bearer ${this.authService.getToken()}`
1942
1940
  },
1943
1941
  link: from$1([authLink, retryLink, errorLink, link]),
1944
1942
  cache: new InMemoryCache({ merge: true })
1945
1943
  });
1946
1944
  }
1947
1945
  createGraphQLWsLink(options) {
1948
- this.wsLink = new GraphQLWsLink(createClient({
1946
+ this.wsLink = new GraphQLWsLink(this.createWsClient({
1949
1947
  url: this.createWsUrl(options.wsUrl) + '/v2/ws/graphql',
1950
1948
  connectionParams: () => ({
1951
1949
  Authorization: 'Bearer ' + this.authService.getToken()
1952
1950
  }),
1953
1951
  on: {
1954
- error: () => {
1955
- this.apollo.removeClient(options.apolloClientName);
1956
- this.initSubscriptions(options);
1957
- }
1952
+ error: () => this.reconnect(options)
1958
1953
  },
1959
1954
  lazy: true
1960
1955
  }));
1961
1956
  }
1957
+ createWsClient(clientOptions) {
1958
+ return createClient(clientOptions);
1959
+ }
1960
+ reconnect(options) {
1961
+ this.apollo.removeClient(options.apolloClientName);
1962
+ this.initSubscriptions(options);
1963
+ }
1962
1964
  createHttpLinkHandler(options) {
1963
1965
  this.httpLinkHandler = options.httpUrl
1964
1966
  ? this.httpLink.create({
@@ -8674,6 +8676,7 @@ class FormCloudComponent extends FormBaseComponent {
8674
8676
  }
8675
8677
  refreshFormData(previousData = []) {
8676
8678
  const snapshot = this.snapshotRuntimeState();
8679
+ this.mergeProcessVariables(this.data ?? []);
8677
8680
  this.form = this.parseForm(this.formCloudRepresentationJSON);
8678
8681
  if (!this.form) {
8679
8682
  return;
@@ -8681,12 +8684,31 @@ class FormCloudComponent extends FormBaseComponent {
8681
8684
  const changedFieldIds = this.getChangedFieldIds(previousData, this.data ?? []);
8682
8685
  this.restoreRuntimeState(this.form, snapshot, changedFieldIds);
8683
8686
  this.setCheckParentVisibilityForValidationOnFields();
8684
- this.visibilityService.refreshVisibility(this.form);
8687
+ this.visibilityService.refreshVisibility(this.form, this.data);
8685
8688
  this.form.validateForm();
8686
8689
  this.onFormLoaded(this.form);
8687
8690
  this.formService.formRulesEvent.next(new FormRulesEvent('dataRefreshed', new FormEvent(this.form)));
8688
8691
  this.onFormDataRefreshed(this.form);
8689
8692
  }
8693
+ /**
8694
+ * Keeps the process variables on the stored representation up to date with the latest data, so that a
8695
+ * variable omitted by a later partial refresh still resolves to the most recent value received.
8696
+ *
8697
+ * @param updates Variables received on the latest data refresh
8698
+ */
8699
+ mergeProcessVariables(updates) {
8700
+ if (!this.formCloudRepresentationJSON) {
8701
+ return;
8702
+ }
8703
+ const existing = this.formCloudRepresentationJSON.processVariables ?? [];
8704
+ const byName = new Map();
8705
+ for (const variable of [...existing, ...updates]) {
8706
+ if (variable?.name) {
8707
+ byName.set(variable.name, variable);
8708
+ }
8709
+ }
8710
+ this.formCloudRepresentationJSON.processVariables = Array.from(byName.values());
8711
+ }
8690
8712
  snapshotRuntimeState() {
8691
8713
  const snapshot = new Map();
8692
8714
  if (!this.form) {