@patientprism/snippet-sdk 1.0.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.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # Patient Prism SDK
2
+ This package includes the Patient Prism Snippet SDK typings, used to assist you with integrating the Patient Prism Snippet into your custom application flow.
3
+
4
+ # How to use
5
+ ```ts
6
+ import type { PrismSDK, Submission } from '@patientprism/snippet-sdk';
7
+
8
+ // Submitting a form
9
+ const data: Submission = {
10
+ name: {
11
+ type: 'text',
12
+ value: 'John Doe',
13
+ label: 'Name'
14
+ }
15
+ };
16
+
17
+ (window.$prism as PrismSDK).submission.send(data, 'elementId');
18
+ ```
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@patientprism/snippet-sdk",
3
+ "type": "module",
4
+ "types": "types/index.d.ts",
5
+ "version": "1.0.0",
6
+ "scripts": {
7
+ "test": "vitest run",
8
+ "test:watch": "vitest watch",
9
+ "dev": "vite dev",
10
+ "build": "vite build",
11
+ "build:types": "sh ./build-type-declarations.sh"
12
+ },
13
+ "dependencies": {},
14
+ "devDependencies": {}
15
+ }
@@ -0,0 +1,58 @@
1
+ export type SubmissionField = {
2
+ type: string;
3
+ value: string | number;
4
+ label: string;
5
+ };
6
+ export type SubmissionOptions = Record<string, string | number | null>;
7
+ export type Submission = Record<string, SubmissionField>;
8
+ /**
9
+ * Object containing methods related to Swap functionality.
10
+ */
11
+ export type SwapSDK = {
12
+ /**
13
+ * Initializes the Swap functionality.
14
+ */
15
+ init: () => void;
16
+ };
17
+ /**
18
+ * Object containing methods related to Submission functionality.
19
+ */
20
+ export type SubmissionSDK = {
21
+ /**
22
+ * Initialize the Submission functionality.
23
+ */
24
+ init: () => void;
25
+ /**
26
+ * Send the form submission.
27
+ */
28
+ send: (data: Submission, elementID: string | HTMLElement, options?: SubmissionOptions) => void;
29
+ };
30
+ /**
31
+ * The global `$prism` object for managing Prism-related functionality.
32
+ */
33
+ export type PrismSDK = {
34
+ /**
35
+ * Indicates whether Prism has been loaded or not.
36
+ */
37
+ loaded: boolean;
38
+ /**
39
+ * Indicates whether Prism is in debug mode or not.
40
+ */
41
+ debug: boolean;
42
+ /**
43
+ * Logs a message to the console if debug mode is enabled.
44
+ */
45
+ log: (message: string) => void;
46
+ /**
47
+ * Object containing methods related to Swap functionality.
48
+ */
49
+ swap: SwapSDK;
50
+ /**
51
+ * Object containing methods related to Submission functionality.
52
+ */
53
+ submission: SubmissionSDK;
54
+ };
55
+
56
+ declare global {
57
+ interface Window { $prism: PrismSDK }
58
+ }