@primocaredentgroup/prescriptions-component 0.1.0

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 (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/dist/_internal/client/PrescriptionsComponentClient.d.ts +25 -0
  4. package/dist/_internal/client/PrescriptionsComponentClient.d.ts.map +1 -0
  5. package/dist/_internal/client/PrescriptionsComponentClient.js +61 -0
  6. package/dist/_internal/client/PrescriptionsComponentClient.js.map +1 -0
  7. package/dist/_internal/client/index.d.ts +3 -0
  8. package/dist/_internal/client/index.d.ts.map +1 -0
  9. package/dist/_internal/client/index.js +2 -0
  10. package/dist/_internal/client/index.js.map +1 -0
  11. package/dist/_internal/client/types.d.ts +47 -0
  12. package/dist/_internal/client/types.d.ts.map +1 -0
  13. package/dist/_internal/client/types.js +2 -0
  14. package/dist/_internal/client/types.js.map +1 -0
  15. package/dist/_internal/component/convex.config.d.ts +7 -0
  16. package/dist/_internal/component/convex.config.d.ts.map +1 -0
  17. package/dist/_internal/component/convex.config.js +8 -0
  18. package/dist/_internal/component/convex.config.js.map +1 -0
  19. package/dist/_internal/component/functions.d.ts +9 -0
  20. package/dist/_internal/component/functions.d.ts.map +1 -0
  21. package/dist/_internal/component/functions.js +11 -0
  22. package/dist/_internal/component/functions.js.map +1 -0
  23. package/dist/_internal/component/index.d.ts +18 -0
  24. package/dist/_internal/component/index.d.ts.map +1 -0
  25. package/dist/_internal/component/index.js +20 -0
  26. package/dist/_internal/component/index.js.map +1 -0
  27. package/dist/_internal/component/schema.d.ts +2 -0
  28. package/dist/_internal/component/schema.d.ts.map +1 -0
  29. package/dist/_internal/component/schema.js +2 -0
  30. package/dist/_internal/component/schema.js.map +1 -0
  31. package/dist/_internal/react/PrescriptionsWidget.d.ts +18 -0
  32. package/dist/_internal/react/PrescriptionsWidget.d.ts.map +1 -0
  33. package/dist/_internal/react/PrescriptionsWidget.js +137 -0
  34. package/dist/_internal/react/PrescriptionsWidget.js.map +1 -0
  35. package/dist/_internal/react/index.d.ts +3 -0
  36. package/dist/_internal/react/index.d.ts.map +1 -0
  37. package/dist/_internal/react/index.js +2 -0
  38. package/dist/_internal/react/index.js.map +1 -0
  39. package/dist/client/index.d.ts +1 -0
  40. package/dist/client/index.js +1 -0
  41. package/dist/component/convex.config.d.ts +2 -0
  42. package/dist/component/convex.config.js +2 -0
  43. package/dist/component/index.d.ts +1 -0
  44. package/dist/component/index.js +1 -0
  45. package/dist/convex/lib/auth.d.ts +7 -0
  46. package/dist/convex/lib/auth.d.ts.map +1 -0
  47. package/dist/convex/lib/auth.js +38 -0
  48. package/dist/convex/lib/auth.js.map +1 -0
  49. package/dist/convex/lib/clinicalNormalize.d.ts +13 -0
  50. package/dist/convex/lib/clinicalNormalize.d.ts.map +1 -0
  51. package/dist/convex/lib/clinicalNormalize.js +82 -0
  52. package/dist/convex/lib/clinicalNormalize.js.map +1 -0
  53. package/dist/convex/lib/dental.d.ts +13 -0
  54. package/dist/convex/lib/dental.d.ts.map +1 -0
  55. package/dist/convex/lib/dental.js +79 -0
  56. package/dist/convex/lib/dental.js.map +1 -0
  57. package/dist/convex/lib/dynamicFieldsStrict.d.ts +9 -0
  58. package/dist/convex/lib/dynamicFieldsStrict.d.ts.map +1 -0
  59. package/dist/convex/lib/dynamicFieldsStrict.js +65 -0
  60. package/dist/convex/lib/dynamicFieldsStrict.js.map +1 -0
  61. package/dist/convex/lib/dynamicRules.d.ts +61 -0
  62. package/dist/convex/lib/dynamicRules.d.ts.map +1 -0
  63. package/dist/convex/lib/dynamicRules.js +221 -0
  64. package/dist/convex/lib/dynamicRules.js.map +1 -0
  65. package/dist/convex/lib/storage.d.ts +59 -0
  66. package/dist/convex/lib/storage.d.ts.map +1 -0
  67. package/dist/convex/lib/storage.js +120 -0
  68. package/dist/convex/lib/storage.js.map +1 -0
  69. package/dist/convex/lib/utils.d.ts +61 -0
  70. package/dist/convex/lib/utils.d.ts.map +1 -0
  71. package/dist/convex/lib/utils.js +135 -0
  72. package/dist/convex/lib/utils.js.map +1 -0
  73. package/dist/convex/lib/validation.d.ts +24 -0
  74. package/dist/convex/lib/validation.d.ts.map +1 -0
  75. package/dist/convex/lib/validation.js +333 -0
  76. package/dist/convex/lib/validation.js.map +1 -0
  77. package/dist/convex/mutations/digitalAssets.d.ts +54 -0
  78. package/dist/convex/mutations/digitalAssets.d.ts.map +1 -0
  79. package/dist/convex/mutations/digitalAssets.js +297 -0
  80. package/dist/convex/mutations/digitalAssets.js.map +1 -0
  81. package/dist/convex/mutations/operational.d.ts +38 -0
  82. package/dist/convex/mutations/operational.d.ts.map +1 -0
  83. package/dist/convex/mutations/operational.js +226 -0
  84. package/dist/convex/mutations/operational.js.map +1 -0
  85. package/dist/convex/mutations/phases.d.ts +45 -0
  86. package/dist/convex/mutations/phases.d.ts.map +1 -0
  87. package/dist/convex/mutations/phases.js +334 -0
  88. package/dist/convex/mutations/phases.js.map +1 -0
  89. package/dist/convex/mutations/prescriptions.d.ts +191 -0
  90. package/dist/convex/mutations/prescriptions.d.ts.map +1 -0
  91. package/dist/convex/mutations/prescriptions.js +1263 -0
  92. package/dist/convex/mutations/prescriptions.js.map +1 -0
  93. package/dist/convex/mutations/syncJobs.d.ts +37 -0
  94. package/dist/convex/mutations/syncJobs.d.ts.map +1 -0
  95. package/dist/convex/mutations/syncJobs.js +238 -0
  96. package/dist/convex/mutations/syncJobs.js.map +1 -0
  97. package/dist/convex/prescriptions/fields.d.ts +50 -0
  98. package/dist/convex/prescriptions/fields.d.ts.map +1 -0
  99. package/dist/convex/prescriptions/fields.js +242 -0
  100. package/dist/convex/prescriptions/fields.js.map +1 -0
  101. package/dist/convex/queries/dynamicFields.d.ts +27 -0
  102. package/dist/convex/queries/dynamicFields.d.ts.map +1 -0
  103. package/dist/convex/queries/dynamicFields.js +119 -0
  104. package/dist/convex/queries/dynamicFields.js.map +1 -0
  105. package/dist/convex/queries/prescriptions.d.ts +583 -0
  106. package/dist/convex/queries/prescriptions.d.ts.map +1 -0
  107. package/dist/convex/queries/prescriptions.js +208 -0
  108. package/dist/convex/queries/prescriptions.js.map +1 -0
  109. package/dist/convex/schema.d.ts +962 -0
  110. package/dist/convex/schema.d.ts.map +1 -0
  111. package/dist/convex/schema.js +434 -0
  112. package/dist/convex/schema.js.map +1 -0
  113. package/dist/convex/types.d.ts +267 -0
  114. package/dist/convex/types.d.ts.map +1 -0
  115. package/dist/convex/types.js +2 -0
  116. package/dist/convex/types.js.map +1 -0
  117. package/dist/react/index.d.ts +1 -0
  118. package/dist/react/index.js +1 -0
  119. package/dist/react/styles.css +54 -0
  120. package/package.json +82 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PrimoCore
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # Prescriptions Component (Convex Component + React Widget)
2
+
3
+ Pacchetto npm embeddabile in PrimoCore con:
4
+ - Convex component (`src/component`)
5
+ - client wrapper tipizzato (`src/client`)
6
+ - React widget embeddabile (`src/react`)
7
+ - host di esempio locale (`example`, solo sviluppo)
8
+
9
+ ## Installazione
10
+
11
+ ```bash
12
+ npm install @primocore/prescriptions-component
13
+ ```
14
+
15
+ ## Entry disponibili dal pacchetto
16
+
17
+ - `@primocore/prescriptions-component` -> client typed
18
+ - `@primocore/prescriptions-component/react` -> widget React
19
+ - `@primocore/prescriptions-component/component` -> Convex component
20
+ - `@primocore/prescriptions-component/component/convex.config` -> config registrazione Convex component
21
+ - `@primocore/prescriptions-component/styles.css` -> stile opzionale widget
22
+
23
+ ## Registrazione Convex Component
24
+
25
+ Nel progetto host Convex, registra il componente puntando a:
26
+ - `@primocore/prescriptions-component/component`
27
+ - `@primocore/prescriptions-component/component/convex.config`
28
+
29
+ Gli endpoint dev-only (seed/migrazioni) non sono esportati dal surface pubblico del pacchetto.
30
+
31
+ ## Uso React Widget con Auth0 (`getAccessToken`)
32
+
33
+ ```tsx
34
+ import { PrescriptionsWidget } from "@primocore/prescriptions-component/react";
35
+ import type { ExternalContext } from "@primocore/prescriptions-component";
36
+ import { useAuth0 } from "@auth0/auth0-react";
37
+
38
+ function EmbeddedPrescriptions() {
39
+ const { getAccessTokenSilently } = useAuth0();
40
+
41
+ const externalContext: ExternalContext = {
42
+ clinicId: "CLINIC-001",
43
+ patientId: "PAT-001",
44
+ doctorId: "DOC-001",
45
+ pdcItemId: "PDC-001",
46
+ };
47
+
48
+ return (
49
+ <PrescriptionsWidget
50
+ convexUrl={import.meta.env.VITE_CONVEX_URL}
51
+ getAccessToken={() =>
52
+ getAccessTokenSilently({
53
+ authorizationParams: {
54
+ audience: "https://api.primocore.local",
55
+ },
56
+ })
57
+ }
58
+ externalContext={externalContext}
59
+ mode="create"
60
+ />
61
+ );
62
+ }
63
+ ```
64
+
65
+ Se vuoi importare esplicitamente lo stile:
66
+
67
+ ```ts
68
+ import "@primocore/prescriptions-component/styles.css";
69
+ ```
70
+
71
+ ## Build e pubblicazione
72
+
73
+ ```bash
74
+ # build package (output in dist/)
75
+ npm run build
76
+
77
+ # verifica contenuto pacchetto pubblicabile
78
+ npm pack
79
+
80
+ # pubblicazione npm public (scope @primocore)
81
+ npm publish --access public
82
+ ```
83
+
84
+ `prepublishOnly` esegue automaticamente `npm run build` e blocca la publish in caso di errore.
@@ -0,0 +1,25 @@
1
+ import type { ExternalContext, CreateDraftOptions, ClinicalDataPatch, DynamicValuesPayload } from "./types";
2
+ type ConvexCaller = {
3
+ query: (name: string, args?: Record<string, unknown>) => Promise<unknown>;
4
+ mutation: (name: string, args?: Record<string, unknown>) => Promise<unknown>;
5
+ };
6
+ export declare class PrescriptionsComponentClient {
7
+ private readonly client;
8
+ constructor(client: ConvexCaller);
9
+ createDraft(externalContext: ExternalContext, options: CreateDraftOptions): Promise<unknown>;
10
+ listPrescriptions(filters: {
11
+ clinicId?: string;
12
+ status?: string;
13
+ patientId?: string;
14
+ doctorId?: string;
15
+ limit?: number;
16
+ }): Promise<unknown>;
17
+ getPrescription(prescriptionId: string): Promise<unknown>;
18
+ previewDynamicFields(prescriptionId: string, phaseTypeKey?: string): Promise<unknown>;
19
+ updateFieldValues(prescriptionId: string, values: DynamicValuesPayload): Promise<unknown>;
20
+ updateClinicalDraft(prescriptionId: string, clinicalDataPatch: ClinicalDataPatch): Promise<unknown>;
21
+ sendToLab(prescriptionId: string): Promise<unknown>;
22
+ signPrescription(prescriptionId: string, signaturePayload?: string): Promise<unknown>;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=PrescriptionsComponentClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrescriptionsComponentClient.d.ts","sourceRoot":"","sources":["../../../src/client/PrescriptionsComponentClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9E,CAAC;AAEF,qBAAa,4BAA4B;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAE3C,WAAW,CAAC,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,kBAAkB;IAiBzE,iBAAiB,CAAC,OAAO,EAAE;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAIK,eAAe,CAAC,cAAc,EAAE,MAAM;IAMtC,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;IAOlE,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB;IAOtE,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB;IAOhF,SAAS,CAAC,cAAc,EAAE,MAAM;IAMhC,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,gBAAgB,SAAuB;CAMvF"}
@@ -0,0 +1,61 @@
1
+ import { componentFunctions } from "../component";
2
+ export class PrescriptionsComponentClient {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ async createDraft(externalContext, options) {
8
+ if (!externalContext.doctorId) {
9
+ throw new Error("externalContext.doctorId è obbligatorio per createDraft");
10
+ }
11
+ if (!externalContext.pdcItemId) {
12
+ throw new Error("externalContext.pdcItemId è obbligatorio per createDraft");
13
+ }
14
+ return this.client.mutation(componentFunctions.mutations.createDraft, {
15
+ clinicId: externalContext.clinicId,
16
+ doctorId: externalContext.doctorId,
17
+ patientId: externalContext.patientId,
18
+ pdcItemId: externalContext.pdcItemId,
19
+ listinoId: options.listinoId,
20
+ flowKey: options.flowKey ?? "prosthetics-standard",
21
+ });
22
+ }
23
+ async listPrescriptions(filters) {
24
+ return this.client.query(componentFunctions.queries.listPrescriptions, filters);
25
+ }
26
+ async getPrescription(prescriptionId) {
27
+ return this.client.query(componentFunctions.queries.getPrescriptionById, {
28
+ prescriptionId,
29
+ });
30
+ }
31
+ async previewDynamicFields(prescriptionId, phaseTypeKey) {
32
+ return this.client.query(componentFunctions.queries.previewDynamicFields, {
33
+ prescriptionId,
34
+ phaseTypeKey,
35
+ });
36
+ }
37
+ async updateFieldValues(prescriptionId, values) {
38
+ return this.client.mutation(componentFunctions.mutations.updateFieldValues, {
39
+ prescriptionId,
40
+ values,
41
+ });
42
+ }
43
+ async updateClinicalDraft(prescriptionId, clinicalDataPatch) {
44
+ return this.client.mutation(componentFunctions.mutations.updateClinicalDraft, {
45
+ prescriptionId,
46
+ clinicalDataPatch,
47
+ });
48
+ }
49
+ async sendToLab(prescriptionId) {
50
+ return this.client.mutation(componentFunctions.mutations.sendToLab, {
51
+ prescriptionId,
52
+ });
53
+ }
54
+ async signPrescription(prescriptionId, signaturePayload = "embedded-signature") {
55
+ return this.client.mutation(componentFunctions.mutations.signPrescription, {
56
+ prescriptionId,
57
+ signaturePayload,
58
+ });
59
+ }
60
+ }
61
+ //# sourceMappingURL=PrescriptionsComponentClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrescriptionsComponentClient.js","sourceRoot":"","sources":["../../../src/client/PrescriptionsComponentClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAalD,MAA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ED,KAAK,CAAC,iBAAiB,CAAC,cAAsB,EAAE,MAA4B;QAC1E,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,CAAC,iBAAiB,EAAE;YAC1E,cAAc;YACd,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,cAAsB,EAAE,iBAAoC;QACpF,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,CAAC,mBAAmB,EAAE;YAC5E,cAAc;YACd,iBAAiB;SAClB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,cAAsB;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,CAAC,SAAS,EAAE;YAClE,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,gBAAgB,GAAG,oBAAoB;QACpF,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,CAAC,gBAAgB,EAAE;YACzE,cAAc;YACd,gBAAgB;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { PrescriptionsComponentClient } from "./PrescriptionsComponentClient";
2
+ export type { ExternalContext, WidgetMode, CreateDraftOptions, ClinicalDataPatch, DynamicValuesPayload, } from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,YAAY,EACV,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { PrescriptionsComponentClient } from "./PrescriptionsComponentClient";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,47 @@
1
+ export type ExternalContext = {
2
+ clinicId: string;
3
+ patientId: string;
4
+ doctorId?: string;
5
+ pdcItemId?: string;
6
+ extra?: Record<string, string | number | boolean | null>;
7
+ };
8
+ export type WidgetMode = "create" | "detail" | "list";
9
+ export type CreateDraftOptions = {
10
+ listinoId: string;
11
+ flowKey?: string;
12
+ };
13
+ export type ClinicalDataPatch = {
14
+ prostheticService?: {
15
+ serviceCode?: string;
16
+ serviceLabel?: string;
17
+ };
18
+ application?: {
19
+ type: "TOOTH";
20
+ toothNumber: number;
21
+ } | {
22
+ type: "MULTI_TOOTH";
23
+ teeth: number[];
24
+ } | {
25
+ type: "BRIDGE";
26
+ teeth: Array<{
27
+ toothNumber: number;
28
+ role: "abutment" | "pontic";
29
+ }>;
30
+ } | {
31
+ type: "QUADRANT";
32
+ quadrant: number;
33
+ } | {
34
+ type: "SEXTANT";
35
+ sextant: number;
36
+ } | {
37
+ type: "ARCH";
38
+ arch: "UPPER" | "LOWER";
39
+ } | {
40
+ type: "FULL_MOUTH";
41
+ } | null;
42
+ shade?: string | null;
43
+ notePreparazione?: string | null;
44
+ lineaMargine?: string | null;
45
+ };
46
+ export type DynamicValuesPayload = Record<string, unknown>;
47
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAA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GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export declare const componentName = "prescriptions";
2
+ export declare const componentConfig: {
3
+ name: string;
4
+ schemaPath: string;
5
+ };
6
+ export default componentConfig;
7
+ //# sourceMappingURL=convex.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,eAAO,MAAM,eAAe;;;CAI3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ export const componentName = "prescriptions";
2
+ export const componentConfig = {
3
+ name: componentName,
4
+ // This component owns prescriptions state in its internal DB schema.
5
+ schemaPath: "./schema",
6
+ };
7
+ export default componentConfig;
8
+ //# sourceMappingURL=convex.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,aAAa;IACnB,qEAAqE;IACrE,UAAU,EAAE,UAAU;CACvB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { createDraft, updateClinicalDraft, submitToDoctor, signPrescription, sendToLab, reviseAfterSignature, cancelPrescription, markAsShipped, unmarkAsShipped, createFromCalendar, } from "../../convex/mutations/prescriptions";
2
+ export { updateFeedback, scheduleAppointment, repeatPhase, skipPhase, } from "../../convex/mutations/phases";
3
+ export { generateStlUploadUrl, confirmStlUpload, deleteStlFile, setPrescriptionType, updateStlDescription, } from "../../convex/mutations/digitalAssets";
4
+ export { retryJob } from "../../convex/mutations/syncJobs";
5
+ export { updateNotes, addAttachment, removeAttachment, saveUiState, } from "../../convex/mutations/operational";
6
+ export { updateFieldValue, updateFieldValues } from "../../convex/prescriptions/fields";
7
+ export { getById, list, listAll, getActivePrescriptionForPdcItem, countByStatus, getRevisionHistory, } from "../../convex/queries/prescriptions";
8
+ export { previewDynamicFields } from "../../convex/queries/dynamicFields";
9
+ //# sourceMappingURL=functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/component/functions.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,kBAAkB,GACnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,SAAS,GACV,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAExF,OAAO,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EACP,+BAA+B,EAC/B,aAAa,EACb,kBAAkB,GACnB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,11 @@
1
+ // Component public backend surface (business endpoints only).
2
+ // Dev/seed/migration endpoints intentionally excluded.
3
+ export { createDraft, updateClinicalDraft, submitToDoctor, signPrescription, sendToLab, reviseAfterSignature, cancelPrescription, markAsShipped, unmarkAsShipped, createFromCalendar, } from "../../convex/mutations/prescriptions";
4
+ export { updateFeedback, scheduleAppointment, repeatPhase, skipPhase, } from "../../convex/mutations/phases";
5
+ export { generateStlUploadUrl, confirmStlUpload, deleteStlFile, setPrescriptionType, updateStlDescription, } from "../../convex/mutations/digitalAssets";
6
+ export { retryJob } from "../../convex/mutations/syncJobs";
7
+ export { updateNotes, addAttachment, removeAttachment, saveUiState, } from "../../convex/mutations/operational";
8
+ export { updateFieldValue, updateFieldValues } from "../../convex/prescriptions/fields";
9
+ export { getById, list, listAll, getActivePrescriptionForPdcItem, countByStatus, getRevisionHistory, } from "../../convex/queries/prescriptions";
10
+ export { previewDynamicFields } from "../../convex/queries/dynamicFields";
11
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/component/functions.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,uDAAuD;AAEvD,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,kBAAkB,GACnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,SAAS,GACV,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAExF,OAAO,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EACP,+BAA+B,EAC/B,aAAa,EACb,kBAAkB,GACnB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,18 @@
1
+ export { default as componentConfig, componentName } from "./convex.config";
2
+ export { default as schema } from "./schema";
3
+ export * as functions from "./functions";
4
+ export declare const componentFunctions: {
5
+ readonly queries: {
6
+ readonly listPrescriptions: "queries/prescriptions:list";
7
+ readonly getPrescriptionById: "queries/prescriptions:getById";
8
+ readonly previewDynamicFields: "queries/dynamicFields:previewDynamicFields";
9
+ };
10
+ readonly mutations: {
11
+ readonly createDraft: "mutations/prescriptions:createDraft";
12
+ readonly updateClinicalDraft: "mutations/prescriptions:updateClinicalDraft";
13
+ readonly updateFieldValues: "prescriptions/fields:updateFieldValues";
14
+ readonly sendToLab: "mutations/prescriptions:sendToLab";
15
+ readonly signPrescription: "mutations/prescriptions:signPrescription";
16
+ };
17
+ };
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAIzC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;CAarB,CAAC"}
@@ -0,0 +1,20 @@
1
+ export { default as componentConfig, componentName } from "./convex.config";
2
+ export { default as schema } from "./schema";
3
+ export * as functions from "./functions";
4
+ // Public function names exposed by the component client wrapper.
5
+ // Dev-only seed/migration endpoints are intentionally NOT exported.
6
+ export const componentFunctions = {
7
+ queries: {
8
+ listPrescriptions: "queries/prescriptions:list",
9
+ getPrescriptionById: "queries/prescriptions:getById",
10
+ previewDynamicFields: "queries/dynamicFields:previewDynamicFields",
11
+ },
12
+ mutations: {
13
+ createDraft: "mutations/prescriptions:createDraft",
14
+ updateClinicalDraft: "mutations/prescriptions:updateClinicalDraft",
15
+ updateFieldValues: "prescriptions/fields:updateFieldValues",
16
+ sendToLab: "mutations/prescriptions:sendToLab",
17
+ signPrescription: "mutations/prescriptions:signPrescription",
18
+ },
19
+ };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,iEAAiE;AACjE,oEAAoE;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE;QACP,iBAAiB,EAAE,4BAA4B;QAC/C,mBAAmB,EAAE,+BAA+B;QACpD,oBAAoB,EAAE,4CAA4C;KACnE;IACD,SAAS,EAAE;QACT,WAAW,EAAE,qCAAqC;QAClD,mBAAmB,EAAE,6CAA6C;QAClE,iBAAiB,EAAE,wCAAwC;QAC3D,SAAS,EAAE,mCAAmC;QAC9C,gBAAgB,EAAE,0CAA0C;KAC7D;CACO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from "../../convex/schema";
2
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from "../../convex/schema";
2
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ExternalContext } from "../client";
2
+ import "./styles.css";
3
+ type NavigateTarget = {
4
+ type: "list" | "detail";
5
+ prescriptionId?: string;
6
+ };
7
+ export type PrescriptionsWidgetProps = {
8
+ convexUrl: string;
9
+ getAccessToken: () => Promise<string>;
10
+ externalContext: ExternalContext;
11
+ initialPrescriptionId?: string;
12
+ mode?: "create" | "detail";
13
+ onNavigate?: (to: NavigateTarget) => void;
14
+ className?: string;
15
+ };
16
+ export declare function PrescriptionsWidget(props: PrescriptionsWidgetProps): import("react/jsx-runtime").JSX.Element;
17
+ export default PrescriptionsWidget;
18
+ //# sourceMappingURL=PrescriptionsWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrescriptionsWidget.d.ts","sourceRoot":"","sources":["../../../src/react/PrescriptionsWidget.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,WAAW,CAAC;AAC7D,OAAO,cAAc,CAAC;AAEtB,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,eAAe,EAAE,eAAe,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAqBF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CA0NlE;AAED,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,137 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useState } from "react";
3
+ import { ConvexReactClient } from "convex/react";
4
+ import { PrescriptionsComponentClient } from "../client";
5
+ import "./styles.css";
6
+ export function PrescriptionsWidget(props) {
7
+ const [sessionExpired, setSessionExpired] = useState(false);
8
+ const [errorMessage, setErrorMessage] = useState(null);
9
+ const [activeMode, setActiveMode] = useState(props.initialPrescriptionId ? "detail" : props.mode === "create" ? "create" : "list");
10
+ const [selectedPrescriptionId, setSelectedPrescriptionId] = useState(props.initialPrescriptionId ?? null);
11
+ const [items, setItems] = useState([]);
12
+ const [detail, setDetail] = useState(null);
13
+ const [loading, setLoading] = useState(false);
14
+ const convexClient = useMemo(() => new ConvexReactClient(props.convexUrl), [props.convexUrl]);
15
+ const apiClient = useMemo(() => new PrescriptionsComponentClient(convexClient), [convexClient]);
16
+ const safeGetAccessToken = useCallback(async () => {
17
+ try {
18
+ const token = await props.getAccessToken();
19
+ if (!token) {
20
+ throw new Error("Token vuoto");
21
+ }
22
+ setSessionExpired(false);
23
+ return token;
24
+ }
25
+ catch (error) {
26
+ setSessionExpired(true);
27
+ throw error;
28
+ }
29
+ }, [props]);
30
+ useEffect(() => {
31
+ let mounted = true;
32
+ convexClient.setAuth(async () => {
33
+ const token = await safeGetAccessToken();
34
+ if (!mounted) {
35
+ throw new Error("Widget unmounted");
36
+ }
37
+ return token;
38
+ });
39
+ safeGetAccessToken().catch(() => undefined);
40
+ const refreshInterval = window.setInterval(() => {
41
+ safeGetAccessToken().catch(() => undefined);
42
+ }, 60_000);
43
+ return () => {
44
+ mounted = false;
45
+ window.clearInterval(refreshInterval);
46
+ const maybeClient = convexClient;
47
+ maybeClient.clearAuth?.();
48
+ };
49
+ }, [convexClient, safeGetAccessToken]);
50
+ const loadList = useCallback(async () => {
51
+ setLoading(true);
52
+ setErrorMessage(null);
53
+ try {
54
+ const response = (await apiClient.listPrescriptions({
55
+ clinicId: props.externalContext.clinicId,
56
+ patientId: props.externalContext.patientId,
57
+ limit: 20,
58
+ }));
59
+ setItems(response);
60
+ }
61
+ catch (error) {
62
+ setErrorMessage(error instanceof Error ? error.message : "Errore caricamento elenco");
63
+ }
64
+ finally {
65
+ setLoading(false);
66
+ }
67
+ }, [apiClient, props.externalContext.clinicId, props.externalContext.patientId]);
68
+ const loadDetail = useCallback(async (prescriptionId) => {
69
+ setLoading(true);
70
+ setErrorMessage(null);
71
+ try {
72
+ const response = (await apiClient.getPrescription(prescriptionId));
73
+ setDetail(response);
74
+ }
75
+ catch (error) {
76
+ setErrorMessage(error instanceof Error ? error.message : "Errore caricamento dettaglio");
77
+ }
78
+ finally {
79
+ setLoading(false);
80
+ }
81
+ }, [apiClient]);
82
+ useEffect(() => {
83
+ if (activeMode === "list") {
84
+ loadList().catch(() => undefined);
85
+ }
86
+ }, [activeMode, loadList]);
87
+ useEffect(() => {
88
+ if (activeMode === "detail" && selectedPrescriptionId) {
89
+ loadDetail(selectedPrescriptionId).catch(() => undefined);
90
+ }
91
+ }, [activeMode, selectedPrescriptionId, loadDetail]);
92
+ const handleCreateDraft = async () => {
93
+ setLoading(true);
94
+ setErrorMessage(null);
95
+ try {
96
+ const created = (await apiClient.createDraft(props.externalContext, {
97
+ listinoId: "LIST-EMBED",
98
+ flowKey: "prosthetics-standard",
99
+ }));
100
+ setSelectedPrescriptionId(created.prescriptionId);
101
+ setActiveMode("detail");
102
+ props.onNavigate?.({ type: "detail", prescriptionId: created.prescriptionId });
103
+ }
104
+ catch (error) {
105
+ setErrorMessage(error instanceof Error ? error.message : "Errore creazione bozza");
106
+ }
107
+ finally {
108
+ setLoading(false);
109
+ }
110
+ };
111
+ const handleSendToLab = async () => {
112
+ if (!selectedPrescriptionId)
113
+ return;
114
+ setLoading(true);
115
+ setErrorMessage(null);
116
+ try {
117
+ await apiClient.sendToLab(selectedPrescriptionId);
118
+ await loadDetail(selectedPrescriptionId);
119
+ }
120
+ catch (error) {
121
+ setErrorMessage(error instanceof Error ? error.message : "Errore invio laboratorio");
122
+ }
123
+ finally {
124
+ setLoading(false);
125
+ }
126
+ };
127
+ if (sessionExpired) {
128
+ return (_jsx("div", { className: `pcw-root ${props.className ?? ""}`, children: _jsxs("div", { className: "pcw-panel pcw-error", children: [_jsx("h3", { children: "Sessione scaduta" }), _jsx("p", { children: "Non e' stato possibile recuperare un token valido da `getAccessToken`." })] }) }));
129
+ }
130
+ return (_jsxs("div", { className: `pcw-root ${props.className ?? ""}`, children: [_jsxs("div", { className: "pcw-toolbar", children: [_jsx("button", { type: "button", onClick: () => { setActiveMode("list"); props.onNavigate?.({ type: "list" }); }, children: "Lista" }), _jsx("button", { type: "button", onClick: () => setActiveMode("create"), children: "Crea" }), _jsx("button", { type: "button", onClick: () => selectedPrescriptionId && loadDetail(selectedPrescriptionId), children: "Refresh" })] }), errorMessage && (_jsx("div", { className: "pcw-panel pcw-error", children: _jsx("p", { children: errorMessage }) })), activeMode === "create" && (_jsxs("div", { className: "pcw-panel", children: [_jsx("h3", { children: "Nuova prescrizione" }), _jsx("p", { children: "Verranno usati i riferimenti esterni passati da PrimoCore (`externalContext`)." }), _jsx("button", { type: "button", onClick: handleCreateDraft, disabled: loading, children: loading ? "Creazione..." : "Crea bozza" })] })), activeMode === "list" && (_jsxs("div", { className: "pcw-panel", children: [_jsx("h3", { children: "Prescrizioni" }), loading && _jsx("p", { children: "Caricamento..." }), !loading && items.length === 0 && _jsx("p", { children: "Nessuna prescrizione trovata." }), !loading && items.length > 0 && (_jsx("ul", { className: "pcw-list", children: items.map((item) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => {
131
+ setSelectedPrescriptionId(item._id);
132
+ setActiveMode("detail");
133
+ props.onNavigate?.({ type: "detail", prescriptionId: item._id });
134
+ }, children: ["#", item._id, " - ", item.status, " - ", new Date(item.createdAt).toLocaleString("it-IT")] }) }, item._id))) }))] })), activeMode === "detail" && (_jsxs("div", { className: "pcw-panel", children: [_jsx("h3", { children: "Dettaglio prescrizione" }), !selectedPrescriptionId && _jsx("p", { children: "Seleziona una prescrizione dalla lista." }), selectedPrescriptionId && loading && _jsx("p", { children: "Caricamento dettaglio..." }), selectedPrescriptionId && detail?.prescription && (_jsxs("div", { className: "pcw-detail", children: [_jsxs("p", { children: [_jsx("strong", { children: "ID:" }), " ", detail.prescription._id] }), _jsxs("p", { children: [_jsx("strong", { children: "Status:" }), " ", detail.prescription.status] }), _jsxs("p", { children: [_jsx("strong", { children: "Clinic:" }), " ", detail.prescription.clinicId] }), _jsxs("p", { children: [_jsx("strong", { children: "Patient:" }), " ", detail.prescription.patientId] }), _jsxs("p", { children: [_jsx("strong", { children: "Doctor:" }), " ", detail.prescription.doctorId] }), _jsx("button", { type: "button", onClick: handleSendToLab, disabled: loading, children: loading ? "Invio..." : "Invia al laboratorio" })] }))] }))] }));
135
+ }
136
+ export default PrescriptionsWidget;
137
+ //# sourceMappingURL=PrescriptionsWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrescriptionsWidget.js","sourceRoot":"","sources":["../../../src/react/PrescriptionsWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,cAAc,CAAC;AAoCtB,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACtE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAC1C,KA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G,wCAAyB,OAAE,MAAM,CAAC,YAAY,CAAC,SAAS,IAAK,EAChE,wBAAG,uCAAwB,OAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,IAAK,EAC9D,iBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,YAC9D,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,sBAAsB,GACvC,IACL,CACP,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC;AAED,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { PrescriptionsWidget } from "./PrescriptionsWidget";
2
+ export type { PrescriptionsWidgetProps } from "./PrescriptionsWidget";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { PrescriptionsWidget } from "./PrescriptionsWidget";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "../_internal/client/index.js";
@@ -0,0 +1 @@
1
+ export * from "../_internal/client/index.js";
@@ -0,0 +1,2 @@
1
+ export * from "../_internal/component/convex.config.js";
2
+ export { default } from "../_internal/component/convex.config.js";
@@ -0,0 +1,2 @@
1
+ export * from "../_internal/component/convex.config.js";
2
+ export { default } from "../_internal/component/convex.config.js";
@@ -0,0 +1 @@
1
+ export * from "../_internal/component/index.js";
@@ -0,0 +1 @@
1
+ export * from "../_internal/component/index.js";