@alfresco/adf-process-services-cloud 7.0.0-alpha.2 → 7.0.0-alpha.2-10617418261

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.
@@ -12754,6 +12754,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
12754
12754
  }]
12755
12755
  }] });
12756
12756
 
12757
+ /*!
12758
+ * @license
12759
+ * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
12760
+ *
12761
+ * Licensed under the Apache License, Version 2.0 (the "License");
12762
+ * you may not use this file except in compliance with the License.
12763
+ * You may obtain a copy of the License at
12764
+ *
12765
+ * http://www.apache.org/licenses/LICENSE-2.0
12766
+ *
12767
+ * Unless required by applicable law or agreed to in writing, software
12768
+ * distributed under the License is distributed on an "AS IS" BASIS,
12769
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12770
+ * See the License for the specific language governing permissions and
12771
+ * limitations under the License.
12772
+ */
12773
+ const DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i');
12774
+ const PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i');
12775
+ class ProcessNameCloudPipe {
12776
+ constructor(localizedDatePipe) {
12777
+ this.localizedDatePipe = localizedDatePipe;
12778
+ }
12779
+ transform(processNameFormat, processInstance) {
12780
+ let processName = processNameFormat;
12781
+ if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) {
12782
+ const presentDateTime = getTime(new Date());
12783
+ processName = processName.replace(DATE_TIME_IDENTIFIER_REG_EXP, this.localizedDatePipe.transform(presentDateTime, 'medium'));
12784
+ }
12785
+ if (processName.match(PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) {
12786
+ const selectedProcessDefinitionName = processInstance ? processInstance.processDefinitionName : '';
12787
+ processName = processName.replace(PROCESS_DEFINITION_IDENTIFIER_REG_EXP, selectedProcessDefinitionName);
12788
+ }
12789
+ return processName;
12790
+ }
12791
+ }
12792
+ ProcessNameCloudPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ProcessNameCloudPipe, deps: [{ token: i1$1.LocalizedDatePipe }], target: i0.ɵɵFactoryTarget.Pipe });
12793
+ ProcessNameCloudPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: ProcessNameCloudPipe, name: "processNameCloud" });
12794
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ProcessNameCloudPipe, decorators: [{
12795
+ type: Pipe,
12796
+ args: [{ name: 'processNameCloud' }]
12797
+ }], ctorParameters: function () { return [{ type: i1$1.LocalizedDatePipe }]; } });
12798
+
12757
12799
  /*!
12758
12800
  * @license
12759
12801
  * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
@@ -12780,6 +12822,31 @@ class ProcessPayloadCloud {
12780
12822
  }
12781
12823
  }
12782
12824
 
12825
+ /*!
12826
+ * @license
12827
+ * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
12828
+ *
12829
+ * Licensed under the Apache License, Version 2.0 (the "License");
12830
+ * you may not use this file except in compliance with the License.
12831
+ * You may obtain a copy of the License at
12832
+ *
12833
+ * http://www.apache.org/licenses/LICENSE-2.0
12834
+ *
12835
+ * Unless required by applicable law or agreed to in writing, software
12836
+ * distributed under the License is distributed on an "AS IS" BASIS,
12837
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12838
+ * See the License for the specific language governing permissions and
12839
+ * limitations under the License.
12840
+ */
12841
+ class ProcessWithFormPayloadCloud {
12842
+ constructor(obj) {
12843
+ this.processName = obj.processName;
12844
+ this.processDefinitionKey = obj.processDefinitionKey;
12845
+ this.variables = obj.variables;
12846
+ this.values = obj.values;
12847
+ }
12848
+ }
12849
+
12783
12850
  /*!
12784
12851
  * @license
12785
12852
  * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
@@ -12825,6 +12892,11 @@ class StartProcessCloudService extends BaseCloudService {
12825
12892
  payload.payloadType = 'StartProcessPayload';
12826
12893
  return this.post(url, payload).pipe(map((result) => result.entry));
12827
12894
  }
12895
+ startProcessWithForm(appName, formId, version, payload) {
12896
+ const url = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit/versions/${version}`;
12897
+ payload.payloadType = 'StartProcessPayload';
12898
+ return this.post(url, payload);
12899
+ }
12828
12900
  /**
12829
12901
  * Update an existing process instance
12830
12902
  *
@@ -12876,48 +12948,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
12876
12948
  }]
12877
12949
  }] });
12878
12950
 
12879
- /*!
12880
- * @license
12881
- * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
12882
- *
12883
- * Licensed under the Apache License, Version 2.0 (the "License");
12884
- * you may not use this file except in compliance with the License.
12885
- * You may obtain a copy of the License at
12886
- *
12887
- * http://www.apache.org/licenses/LICENSE-2.0
12888
- *
12889
- * Unless required by applicable law or agreed to in writing, software
12890
- * distributed under the License is distributed on an "AS IS" BASIS,
12891
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12892
- * See the License for the specific language governing permissions and
12893
- * limitations under the License.
12894
- */
12895
- const DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i');
12896
- const PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i');
12897
- class ProcessNameCloudPipe {
12898
- constructor(localizedDatePipe) {
12899
- this.localizedDatePipe = localizedDatePipe;
12900
- }
12901
- transform(processNameFormat, processInstance) {
12902
- let processName = processNameFormat;
12903
- if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) {
12904
- const presentDateTime = getTime(new Date());
12905
- processName = processName.replace(DATE_TIME_IDENTIFIER_REG_EXP, this.localizedDatePipe.transform(presentDateTime, 'medium'));
12906
- }
12907
- if (processName.match(PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) {
12908
- const selectedProcessDefinitionName = processInstance ? processInstance.processDefinitionName : '';
12909
- processName = processName.replace(PROCESS_DEFINITION_IDENTIFIER_REG_EXP, selectedProcessDefinitionName);
12910
- }
12911
- return processName;
12912
- }
12913
- }
12914
- ProcessNameCloudPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ProcessNameCloudPipe, deps: [{ token: i1$1.LocalizedDatePipe }], target: i0.ɵɵFactoryTarget.Pipe });
12915
- ProcessNameCloudPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: ProcessNameCloudPipe, name: "processNameCloud" });
12916
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ProcessNameCloudPipe, decorators: [{
12917
- type: Pipe,
12918
- args: [{ name: 'processNameCloud' }]
12919
- }], ctorParameters: function () { return [{ type: i1$1.LocalizedDatePipe }]; } });
12920
-
12921
12951
  /*!
12922
12952
  * @license
12923
12953
  * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
@@ -13124,27 +13154,38 @@ class StartProcessCloudComponent {
13124
13154
  }
13125
13155
  startProcess() {
13126
13156
  this.isProcessStarting = true;
13127
- let payloadVariables = {};
13128
- if (this.variables) {
13129
- payloadVariables = this.variables;
13130
- }
13131
- if (this.hasForm) {
13132
- payloadVariables = Object.assign(payloadVariables, this.formCloud.values);
13133
- }
13134
- const createPayload = new ProcessPayloadCloud({
13135
- name: this.processInstanceName.value,
13136
- processDefinitionKey: this.processPayloadCloud.processDefinitionKey,
13137
- variables: payloadVariables
13138
- });
13139
- this.startProcessCloudService.startProcess(this.appName, createPayload).subscribe((res) => {
13140
- this.success.emit(res);
13141
- this.isProcessStarting = false;
13142
- }, (err) => {
13143
- this.errorMessageId = 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.START';
13144
- this.error.emit(err);
13145
- this.isProcessStarting = false;
13157
+ const action = this.hasForm
13158
+ ? this.startProcessCloudService.startProcessWithForm(this.appName, this.processDefinitionCurrent.formKey, this.processDefinitionCurrent.version, new ProcessWithFormPayloadCloud({
13159
+ processName: this.processInstanceName.value,
13160
+ processDefinitionKey: this.processPayloadCloud.processDefinitionKey,
13161
+ variables: this.variables ?? {},
13162
+ values: this.formCloud.values
13163
+ }))
13164
+ : this.startProcessCloudService.startProcess(this.appName, new ProcessPayloadCloud({
13165
+ name: this.processInstanceName.value,
13166
+ processDefinitionKey: this.processPayloadCloud.processDefinitionKey,
13167
+ variables: this.variables ?? {}
13168
+ }));
13169
+ action.subscribe({
13170
+ next: (res) => {
13171
+ this.success.emit(res);
13172
+ this.isProcessStarting = false;
13173
+ },
13174
+ error: (err) => {
13175
+ this.errorMessageId = 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.START';
13176
+ this.unifyErrorResponse(err);
13177
+ this.error.emit(err);
13178
+ this.isProcessStarting = false;
13179
+ }
13146
13180
  });
13147
13181
  }
13182
+ unifyErrorResponse(err) {
13183
+ if (!err?.response?.body?.entry && err?.response?.body?.message) {
13184
+ err.response.body = {
13185
+ entry: JSON.parse(err.response.body.message)
13186
+ };
13187
+ }
13188
+ }
13148
13189
  cancelStartProcess() {
13149
13190
  this.cancel.emit();
13150
13191
  }