@documedis/react-components 1.0.0-RC.3 → 1.0.0-RC.5

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.
@@ -1,20 +1,14 @@
1
- import { DomainError, Environment } from '../..';
2
- interface PrescriptionSignReactProps {
3
- accessToken: string;
4
- environment: Environment;
5
- chmed: string;
6
- sessionToken?: string;
7
- shouldGeneratePdf?: boolean;
8
- }
1
+ import { DomainError, Environment } from '@documedis/shared-components/core';
9
2
  /**
10
3
  * Props for the usePrescriptionSign hook
4
+ * Note: chmed is NOT included here because it's passed via the start() method
11
5
  */
12
6
  export type UsePrescriptionSigningProps = {
13
7
  /**
14
8
  * Environment configuration for the prescription service
15
9
  * - 'local': Development environment (localhost:52247)
16
- * - 'dev': Development Azure Container Apps
17
10
  * - 'int': Integration Azure Container Apps
11
+ * - 'demo': Demo Azure Container Apps
18
12
  * - 'prod': Production Azure Container Apps
19
13
  */
20
14
  environment: Environment;
@@ -34,9 +28,9 @@ export type UsePrescriptionSigningProps = {
34
28
  * Optional callback invoked when prescription signing succeeds.
35
29
  * Receives the signed CHMED data as a base64-encoded string.
36
30
  * Optionally receives the generatedPdf if the option
37
- * shouldGeneratePdf is set to true.
31
+ * generatePdf is set to true.
38
32
  *
39
- * @see shouldGeneratePdf
33
+ * @see generatePdf
40
34
  */
41
35
  onSuccess?: (signedCHMED: string, generatedPdf?: string) => void;
42
36
  /**
@@ -45,16 +39,21 @@ export type UsePrescriptionSigningProps = {
45
39
  */
46
40
  onError?: (error: DomainError) => void;
47
41
  /**
48
- * Flag to generate PDF after signing.
42
+ * Optional flag to generate PDF after signing.
43
+ * Defaults to false if not specified.
49
44
  */
50
- shouldGeneratePdf: boolean;
45
+ generatePdf?: boolean;
51
46
  };
52
47
  /**
53
48
  * Props for the PrescriptionSign React component
54
49
  * Uses camelCase (React convention) - internally converted to kebab-case for web component
55
50
  */
56
- export interface PrescriptionSignProps extends PrescriptionSignReactProps {
57
- /** Optional additional CSS class names to apply to the component */
51
+ export interface PrescriptionSignProps {
52
+ accessToken: string;
53
+ environment: Environment;
54
+ chmed: string;
55
+ sessionToken?: string;
56
+ generatePdf?: boolean;
58
57
  className?: string;
59
58
  /**
60
59
  * Optional callback invoked when the session token is updated.
@@ -74,4 +73,3 @@ export interface PrescriptionSignProps extends PrescriptionSignReactProps {
74
73
  */
75
74
  onError?: (error: DomainError) => void;
76
75
  }
77
- export {};
@@ -4,7 +4,7 @@ import { UsePrescriptionSigningProps } from './types';
4
4
  */
5
5
  export interface UsePrescriptionSignReturn {
6
6
  /** Function to initiate the signing process with CHMED data */
7
- start: (encodedCHMED: string, shouldGeneratePdf: boolean) => void;
7
+ start: (encodedCHMED: string, generatePdf?: boolean) => void;
8
8
  /** Function to terminate the signing process at any time */
9
9
  interrupt: () => void;
10
10
  /** Raw XState machine state (for advanced usage) */
package/index.d.ts CHANGED
@@ -1,23 +1,3 @@
1
1
  export * from './components/PharmacySelector';
2
2
  export * from './components/PrescriptionSign';
3
- export type Environment = 'local' | 'int' | 'demo' | 'prod';
4
- export interface Pharmacy {
5
- id: string;
6
- gln: string;
7
- name: string;
8
- hinEmail?: string;
9
- galenicaChain?: string;
10
- }
11
- export interface DomainError extends Error {
12
- readonly id: string;
13
- readonly timestamp: Date;
14
- readonly code: string;
15
- readonly userMessage: string;
16
- readonly cause?: unknown;
17
- toJSON(): {
18
- type: string;
19
- code: string;
20
- message: string;
21
- };
22
- toHttpStatus(): number;
23
- }
3
+ export type { Environment, DomainError, Pharmacy } from '@documedis/shared-components/core';
package/index.mjs CHANGED
@@ -11567,6 +11567,7 @@ const kL = () => ({
11567
11567
  INVALID_CONFIG: "INVALID_CONFIG",
11568
11568
  POPUP_BLOCKED: "POPUP_BLOCKED",
11569
11569
  BROWSER_INCOMPATIBLE: "BROWSER_INCOMPATIBLE",
11570
+ COMPONENT_INITIALIZATION_ERROR: "COMPONENT_INITIALIZATION_ERROR",
11570
11571
  KEYVAULT_ERROR: "KEYVAULT_ERROR",
11571
11572
  DATABASE_ERROR: "DATABASE_ERROR",
11572
11573
  CACHE_ERROR: "CACHE_ERROR",
@@ -16778,13 +16779,16 @@ const bF = "opener_origin", wF = "st", Tx = {
16778
16779
  }
16779
16780
  }
16780
16781
  }, kF = Wc(({ input: o, sendBack: n }) => {
16781
- const i = window.location.origin, l = Tx.addOriginParam(
16782
+ const i = window.location.origin;
16783
+ let l = Tx.addOriginParam(
16782
16784
  `${o.hinClient.backendUrl}/login/popup/hin`,
16783
16785
  btoa(i)
16784
- ), f = Tx.addSessionTokenParam(
16786
+ );
16787
+ o.sessionToken && o.sessionToken.length > 0 && (l = Tx.addSessionTokenParam(
16785
16788
  l,
16786
- o.sessionToken || ""
16787
- ), h = window.open(f.toString(), "_blank");
16789
+ o.sessionToken
16790
+ ));
16791
+ const f = l, h = window.open(f.toString(), "_blank");
16788
16792
  if (h)
16789
16793
  n({
16790
16794
  type: "OPEN_POPUP",
@@ -17275,7 +17279,7 @@ const bF = "opener_origin", wF = "st", Tx = {
17275
17279
  const i = await o.hinClient.signPrescription(
17276
17280
  o.sessionToken,
17277
17281
  n,
17278
- o.shouldGeneratePdf
17282
+ o.generatePdf
17279
17283
  );
17280
17284
  return {
17281
17285
  signedPrescription: i.SignedPrescriptionData,
@@ -17339,7 +17343,7 @@ const bF = "opener_origin", wF = "st", Tx = {
17339
17343
  encodedCHMED: void 0,
17340
17344
  signedCHMED: void 0,
17341
17345
  generatedPdf: void 0,
17342
- shouldGeneratePdf: !1,
17346
+ generatePdf: o.generatePdf,
17343
17347
  sessionToken: o.sessionToken,
17344
17348
  accessToken: o.accessToken,
17345
17349
  hinClient: new vF({
@@ -17356,7 +17360,7 @@ const bF = "opener_origin", wF = "st", Tx = {
17356
17360
  target: "Started",
17357
17361
  actions: gi(({ event: o }) => ({
17358
17362
  encodedCHMED: o.encodedCHMED,
17359
- shouldGeneratePdf: o.shouldGeneratePdf
17363
+ generatePdf: o.generatePdf
17360
17364
  }))
17361
17365
  }
17362
17366
  }
@@ -17371,7 +17375,7 @@ const bF = "opener_origin", wF = "st", Tx = {
17371
17375
  generatedPdf: void 0,
17372
17376
  popupRef: null,
17373
17377
  error: void 0,
17374
- shouldGeneratePdf: !1
17378
+ generatePdf: !1
17375
17379
  })
17376
17380
  },
17377
17381
  states: {
@@ -17696,7 +17700,7 @@ const bF = "opener_origin", wF = "st", Tx = {
17696
17700
  hinClient: o.hinClient,
17697
17701
  sessionToken: o.sessionToken,
17698
17702
  recover: n.recoverable || !1,
17699
- shouldGeneratePdf: o.shouldGeneratePdf
17703
+ generatePdf: o.generatePdf
17700
17704
  }),
17701
17705
  onDone: {
17702
17706
  target: "Success",
@@ -17808,11 +17812,11 @@ const FF = (o) => o.replace(/-./g, (n) => n.charAt(1).toUpperCase()), SR = (o) =
17808
17812
  i[f] = y;
17809
17813
  break;
17810
17814
  case "boolean":
17811
- i[l] = y === "" || y === "true";
17815
+ i[f] = y === "" || y === "true";
17812
17816
  break;
17813
17817
  case "number":
17814
17818
  const w = Number(y);
17815
- isNaN(w) || (i[l] = w);
17819
+ isNaN(w) || (i[f] = w);
17816
17820
  break;
17817
17821
  }
17818
17822
  }), i;
@@ -45108,7 +45112,7 @@ const X3 = ({
45108
45112
  sessionToken: l,
45109
45113
  environment: o,
45110
45114
  accessToken: n,
45111
- shouldGeneratePdf: f
45115
+ generatePdf: f
45112
45116
  }
45113
45117
  }), k = me.useCallback(
45114
45118
  (U, ee) => {
@@ -45128,7 +45132,7 @@ const X3 = ({
45128
45132
  document.dispatchEvent(re);
45129
45133
  return;
45130
45134
  }
45131
- w({ type: "START", encodedCHMED: U, shouldGeneratePdf: ee });
45135
+ w({ type: "START", encodedCHMED: U, generatePdf: ee });
45132
45136
  },
45133
45137
  [w]
45134
45138
  ), x = me.useCallback(() => {
@@ -45235,6 +45239,8 @@ Z3(() => MouseEvent);
45235
45239
  const ej = (o) => o.replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`), tj = (o) => {
45236
45240
  const n = {};
45237
45241
  return Object.entries(o).forEach(([i, l]) => {
45242
+ if (l == null)
45243
+ return;
45238
45244
  const f = ej(i);
45239
45245
  n[f] = String(l);
45240
45246
  }), n;
@@ -46238,17 +46244,17 @@ function Dj(o) {
46238
46244
  onSessionTokenUpdate: f,
46239
46245
  onSuccess: h,
46240
46246
  onError: y,
46241
- shouldGeneratePdf: w
46247
+ generatePdf: w = !1
46242
46248
  } = o, [b, k, x] = Tj(kR, {
46243
46249
  input: {
46244
46250
  sessionToken: l,
46245
46251
  environment: n,
46246
46252
  accessToken: i,
46247
- shouldGeneratePdf: w
46253
+ generatePdf: w
46248
46254
  }
46249
46255
  }), _ = Ld(
46250
- (T, N) => {
46251
- k({ type: "START", encodedCHMED: T, shouldGeneratePdf: N });
46256
+ (T, N = !1) => {
46257
+ k({ type: "START", encodedCHMED: T, generatePdf: N });
46252
46258
  },
46253
46259
  [k]
46254
46260
  ), E = Ld(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@documedis/react-components",
3
- "version": "1.0.0-RC.3",
3
+ "version": "1.0.0-RC.5",
4
4
  "description": "React components for Documedis healthcare applications - prescription signing, pharmacy selection, and more",
5
5
  "keywords": [
6
6
  "react",