@dyedurham/search-and-file-widget 2.0.47 → 2.0.48

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.
Files changed (2) hide show
  1. package/dnd-filing-shell.js +88 -39
  2. package/package.json +11 -11
@@ -86778,6 +86778,8 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
86778
86778
  form.get(FederalFormationFormControl.ClienteleMarketType)?.setValue("", { emitEvent: false });
86779
86779
  form.get(FederalFormationFormControl.KeywordOrigin)?.setValue("", { emitEvent: false });
86780
86780
  form.get(FederalFormationFormControl.SimilarNamesSearchedOrRegistered)?.setValue("", { emitEvent: false });
86781
+ form.get(FederalFormationFormControl.SecondaryReservationNumber)?.setValue("", { emitEvent: false });
86782
+ form.get(FederalFormationFormControl.SecondaryReservationDate)?.setValue("", { emitEvent: false });
86781
86783
  }
86782
86784
  if (incorporationType !== NameType2.Numbered) {
86783
86785
  form.get(FederalFormationFormControl.LegalElement)?.setValue("", { emitEvent: false });
@@ -86793,6 +86795,8 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
86793
86795
  form.get(FederalFormationFormControl.ClienteleMarketType)?.updateValueAndValidity({ emitEvent: false });
86794
86796
  form.get(FederalFormationFormControl.KeywordOrigin)?.updateValueAndValidity({ emitEvent: false });
86795
86797
  form.get(FederalFormationFormControl.SimilarNamesSearchedOrRegistered)?.updateValueAndValidity({ emitEvent: false });
86798
+ form.get(FederalFormationFormControl.SecondaryReservationNumber)?.updateValueAndValidity({ emitEvent: false });
86799
+ form.get(FederalFormationFormControl.SecondaryReservationDate)?.updateValueAndValidity({ emitEvent: false });
86796
86800
  }
86797
86801
  },
86798
86802
  {
@@ -90578,13 +90582,39 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
90578
90582
  });
90579
90583
 
90580
90584
  // src/app/services/federal/federal-formation.service.ts
90581
- function buildSupportingDocumentUploadRequest(document2, bytes) {
90585
+ function buildSupportingDocumentUploadRequest(files) {
90582
90586
  return {
90583
- FileName: document2.name,
90584
- FileType: document2.extension,
90585
- FileContent: toBase64(bytes)
90587
+ Files: files.map(({ document: document2, bytes }) => ({
90588
+ FileName: toPdfFileName(document2.name),
90589
+ FileByte: toBase64(bytes)
90590
+ }))
90586
90591
  };
90587
90592
  }
90593
+ function toPdfFileName(name) {
90594
+ const trimmed = (name ?? "").trim() || "document";
90595
+ return /\.pdf$/i.test(trimmed) ? trimmed : `${trimmed}.pdf`;
90596
+ }
90597
+ function isPdf(document2, bytes) {
90598
+ const declaredPdf = !document2.extension || document2.extension.toLowerCase() === "pdf";
90599
+ const pdfSignature = bytes.length >= 4 && bytes[0] === 37 && bytes[1] === 80 && bytes[2] === 68 && bytes[3] === 70;
90600
+ return declaredPdf && pdfSignature;
90601
+ }
90602
+ function toUint8Array(value) {
90603
+ if (value instanceof Uint8Array)
90604
+ return value;
90605
+ if (value instanceof ArrayBuffer)
90606
+ return new Uint8Array(value);
90607
+ return void 0;
90608
+ }
90609
+ function isUploadSuccess(status) {
90610
+ return status === UPLOAD_STATUS_SUCCESS || String(status).toLowerCase() === "success";
90611
+ }
90612
+ function uploadError(messages, httpStatus) {
90613
+ const err = new Error(messages.join(" "));
90614
+ err.submitResult = { Errors: messages.map((ErrorMessage) => ({ ErrorMessage })) };
90615
+ err.httpStatus = httpStatus;
90616
+ return err;
90617
+ }
90588
90618
  function toBase64(bytes) {
90589
90619
  let binary = "";
90590
90620
  const chunkSize = 32768;
@@ -90593,12 +90623,14 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
90593
90623
  }
90594
90624
  return btoa(binary);
90595
90625
  }
90596
- var FederalFormationService;
90626
+ var MAX_UPLOAD_FILE_BYTES, UPLOAD_STATUS_SUCCESS, FederalFormationService;
90597
90627
  var init_federal_formation_service = __esm({
90598
90628
  "src/app/services/federal/federal-formation.service.ts"() {
90599
90629
  init_core();
90600
90630
  init_common_utils();
90601
90631
  init_core();
90632
+ MAX_UPLOAD_FILE_BYTES = 10 * 1024 * 1024;
90633
+ UPLOAD_STATUS_SUCCESS = 1;
90602
90634
  FederalFormationService = class _FederalFormationService {
90603
90635
  config;
90604
90636
  setConfig(config2) {
@@ -90614,12 +90646,8 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
90614
90646
  const url = signature.proxyApiUrl;
90615
90647
  const req = requestBody;
90616
90648
  const resp = yield fetchWithJwtRetry(signature, () => postJson(fetchFn, url, signature.jwtToken, req, {
90617
- // 'ApiKey': 'a759101c-aeac-4fa6-90dc-8b56f01b2939',
90618
90649
  Authorization: `Bearer ${signature.jwtToken}`,
90619
- // 'AccountKey': '1c3e3a6e-2a8b-4dd2-b906-aec25a1a7227',
90620
- "x-target-url": `${this.config.ONAOI}api/Incorporation`,
90621
- "x-access-token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtaWNoZWwubGF2b2llQGF0aGVubmlhbi5jb20iLCJzdWIiOiI2N2RkY2IwNWRjNDAzMjg0ZTdmYTA3ZmIiLCJpYXQiOjE3NzAyMTI2OTQsImV4cCI6MTc3MDIxOTg5NCwiYmlkIjoiIiwiYXV0IjoidHJ1ZSIsIm9yZyI6Imh0dHBzOi8vb2xpdmUtMS50ZXN0LmF0aGVubmlhbi5jb20iLCJwZXIiOiIifQ.0QsFPBVGTA8JyacfEDx4qz5XVQB3AeL2-uCBiCs9qF0",
90622
- Cookie: "AWSALB=PpMRL+JDLimOntn4FPEpJ2ZX9rtRbn/7wOE1Ntyq9RGhYPgnJpjAN8xr8R5TyM4v1tBvC62q0YWVR2fQwDLLKWIIQm+U79VccsjiMHRffNr6an9tJNOOdpX94R53; AWSALBCORS=PpMRL+JDLimOntn4FPEpJ2ZX9rtRbn/7wOE1Ntyq9RGhYPgnJpjAN8xr8R5TyM4v1tBvC62q0YWVR2fQwDLLKWIIQm+U79VccsjiMHRffNr6an9tJNOOdpX94R53"
90650
+ "x-target-url": `${this.config.ONAOI}api/Incorporation`
90623
90651
  }));
90624
90652
  const raw = yield resp.text();
90625
90653
  const parsed = tryParseJson(raw);
@@ -90643,8 +90671,10 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
90643
90671
  }
90644
90672
  /**
90645
90673
  * Uploads the supporting documents selected on the corporate name section
90646
- * (deltaData.corporateName.supportingDocuments) to an existing service order.
90647
- * One PUT per document; stops at the first failure.
90674
+ * (deltaData.corporateName.supportingDocuments) to an existing service order, per OnCorp
90675
+ * ArtWebSvc v4.7.1: one PUT api/Incorporation/{serviceOrderId}/upload carrying every file.
90676
+ * Each file must be a PDF under 10 MB; the call only succeeds when the UploadResult and every
90677
+ * file report Status = Success.
90648
90678
  */
90649
90679
  uploadSupportingDocuments(_0, _1, _2) {
90650
90680
  return __async(this, arguments, function* (signature, serviceOrderId, documentIds, opts = {}) {
@@ -90660,31 +90690,49 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
90660
90690
  if (!signature.getDocumentBytes) {
90661
90691
  throw new Error("Missing getDocumentBytes (required input from Athennian to upload supporting documents).");
90662
90692
  }
90663
- const fetchFn = opts.fetchImpl ?? fetch;
90664
- const url = signature.proxyApiUrl;
90693
+ const files = [];
90694
+ const problems = [];
90665
90695
  for (const document2 of documents) {
90666
- const bytes = yield signature.getDocumentBytes(document2.documentId);
90667
- const body = buildSupportingDocumentUploadRequest(document2, bytes);
90668
- const resp = yield fetchWithJwtRetry(signature, () => fetchFn(url, {
90669
- method: "PUT",
90670
- headers: {
90671
- "Content-Type": "application/json",
90672
- Authorization: `Bearer ${signature.jwtToken}`,
90673
- "x-target-url": `${this.config.ONAOI}api/Incorporation/${encodeURIComponent(serviceOrderId)}/upload`
90674
- },
90675
- body: JSON.stringify(body)
90676
- }));
90677
- if (resp.ok) {
90678
- continue;
90696
+ const bytes = toUint8Array(yield signature.getDocumentBytes(document2.documentId));
90697
+ if (!bytes) {
90698
+ problems.push(`Supporting document "${document2.name}" could not be read.`);
90699
+ } else if (!isPdf(document2, bytes)) {
90700
+ problems.push(`Supporting document "${document2.name}" is not a PDF. Only PDF files can be filed.`);
90701
+ } else if (bytes.length >= MAX_UPLOAD_FILE_BYTES) {
90702
+ problems.push(`Supporting document "${document2.name}" is larger than 10 MB.`);
90703
+ } else {
90704
+ files.push({ document: document2, bytes });
90679
90705
  }
90680
- const raw = yield resp.text();
90681
- const parsed = tryParseJson(raw);
90682
- const payload = parsed.ok ? unwrapRequestResults(parsed.value) : void 0;
90683
- const err = payload ? buildGenericError(resp.status, `Upload of "${document2.name}" failed`, payload) : new Error(`Upload of "${document2.name}" returned ${resp.status} ${resp.statusText}: ${raw || "(empty response)"}`);
90684
- err.submitResult = payload;
90685
- err.httpStatus = resp.status;
90686
- throw err;
90687
90706
  }
90707
+ if (problems.length) {
90708
+ throw uploadError(problems);
90709
+ }
90710
+ const fetchFn = opts.fetchImpl ?? fetch;
90711
+ const body = JSON.stringify(buildSupportingDocumentUploadRequest(files));
90712
+ const resp = yield fetchWithJwtRetry(signature, () => fetchFn(signature.proxyApiUrl, {
90713
+ method: "PUT",
90714
+ headers: {
90715
+ "Content-Type": "application/json",
90716
+ Authorization: `Bearer ${signature.jwtToken}`,
90717
+ "x-target-url": `${this.config.ONAOI}api/Incorporation/${encodeURIComponent(serviceOrderId)}/upload`
90718
+ },
90719
+ body
90720
+ }));
90721
+ const raw = yield resp.text();
90722
+ const parsed = tryParseJson(raw);
90723
+ if (!parsed.ok) {
90724
+ throw uploadError([`Supporting document upload returned ${resp.status} ${resp.statusText}: ${raw || "(empty response)"}`], resp.status);
90725
+ }
90726
+ const result = unwrapRequestResults(parsed.value);
90727
+ const failedFiles = (result?.FileUploadResponses ?? []).filter((f) => !isUploadSuccess(f.Status));
90728
+ if (resp.ok && isUploadSuccess(result?.Status) && !failedFiles.length) {
90729
+ return;
90730
+ }
90731
+ const messages = [
90732
+ ...(result?.Errors ?? []).map((e) => e.ErrorMessage ?? e.ErrorId ?? ""),
90733
+ ...failedFiles.flatMap((f) => (f.Errors?.length ? f.Errors : [{}]).map((e) => `Upload of "${f.FileName ?? "document"}" failed${e.ErrorMessage ? `: ${e.ErrorMessage}` : "."}`))
90734
+ ].filter(Boolean);
90735
+ throw uploadError(messages.length ? messages : [`Supporting document upload failed (HTTP ${resp.status}).`], resp.status);
90688
90736
  });
90689
90737
  }
90690
90738
  submitFormationRequest(_0, _1) {
@@ -90698,12 +90746,8 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
90698
90746
  const resp = yield fetchWithJwtRetry(signature, () => fetchFn(url, {
90699
90747
  method: "POST",
90700
90748
  headers: {
90701
- // 'ApiKey': 'a759101c-aeac-4fa6-90dc-8b56f01b2939',
90702
- // 'AccountKey': '1c3e3a6e-2a8b-4dd2-b906-aec25a1a7227',
90703
90749
  Authorization: `Bearer ${signature.jwtToken}`,
90704
- Cookie: "AWSALB=PpMRL+JDLimOntn4FPEpJ2ZX9rtRbn/7wOE1Ntyq9RGhYPgnJpjAN8xr8R5TyM4v1tBvC62q0YWVR2fQwDLLKWIIQm+U79VccsjiMHRffNr6an9tJNOOdpX94R53; AWSALBCORS=PpMRL+JDLimOntn4FPEpJ2ZX9rtRbn/7wOE1Ntyq9RGhYPgnJpjAN8xr8R5TyM4v1tBvC62q0YWVR2fQwDLLKWIIQm+U79VccsjiMHRffNr6an9tJNOOdpX94R53",
90705
- "x-target-url": `${this.config.ONAOI}api/Incorporation/${encodeURIComponent(serviceOrderId)}/submit`,
90706
- "x-access-token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtaWNoZWwubGF2b2llQGF0aGVubmlhbi5jb20iLCJzdWIiOiI2N2RkY2IwNWRjNDAzMjg0ZTdmYTA3ZmIiLCJpYXQiOjE3NzAyMTI2OTQsImV4cCI6MTc3MDIxOTg5NCwiYmlkIjoiIiwiYXV0IjoidHJ1ZSIsIm9yZyI6Imh0dHBzOi8vb2xpdmUtMS50ZXN0LmF0aGVubmlhbi5jb20iLCJwZXIiOiIifQ.0QsFPBVGTA8JyacfEDx4qz5XVQB3AeL2-uCBiCs9qF0"
90750
+ "x-target-url": `${this.config.ONAOI}api/Incorporation/${encodeURIComponent(serviceOrderId)}/submit`
90707
90751
  }
90708
90752
  }));
90709
90753
  const raw = yield resp.text();
@@ -93191,6 +93235,11 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
93191
93235
  return;
93192
93236
  }
93193
93237
  }
93238
+ if (response instanceof Error && response.message?.trim()) {
93239
+ const message = response.message.trim();
93240
+ this.errors.set([message.length > 500 ? `${message.slice(0, 500)}\u2026` : message]);
93241
+ return;
93242
+ }
93194
93243
  let parsed = response;
93195
93244
  try {
93196
93245
  parsed = JSON.parse(JSON.stringify(response));
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
- {
2
- "name": "@dyedurham/search-and-file-widget",
3
- "version": "2.0.47",
4
- "description": "",
5
- "main": "dnd-filing-shell.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "",
10
- "license": "ISC"
11
- }
1
+ {
2
+ "name": "@dyedurham/search-and-file-widget",
3
+ "version": "2.0.48",
4
+ "description": "",
5
+ "main": "dnd-filing-shell.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC"
11
+ }