@centricare/contract 0.0.0-stage → 0.1.1
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 +99 -2
- package/dist/commons/api-response.d.ts +178 -0
- package/dist/commons/api-response.d.ts.map +1 -0
- package/dist/commons/api-response.js +49 -0
- package/dist/commons/api-response.js.map +1 -0
- package/dist/commons/coded-concept.d.ts +28 -0
- package/dist/commons/coded-concept.d.ts.map +1 -0
- package/dist/commons/coded-concept.js +20 -0
- package/dist/commons/coded-concept.js.map +1 -0
- package/dist/commons/index.d.ts +9 -0
- package/dist/commons/index.d.ts.map +1 -0
- package/dist/commons/index.js +9 -0
- package/dist/commons/index.js.map +1 -0
- package/dist/commons/setting-option.d.ts +37 -0
- package/dist/commons/setting-option.d.ts.map +1 -0
- package/dist/commons/setting-option.js +27 -0
- package/dist/commons/setting-option.js.map +1 -0
- package/dist/commons/timestamp.d.ts +7 -0
- package/dist/commons/timestamp.d.ts.map +1 -0
- package/dist/commons/timestamp.js +9 -0
- package/dist/commons/timestamp.js.map +1 -0
- package/dist/example.test.d.ts +6 -0
- package/dist/example.test.d.ts.map +1 -0
- package/dist/example.test.js +147 -0
- package/dist/example.test.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +6 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/settings.d.ts +189 -0
- package/dist/models/settings.d.ts.map +1 -0
- package/dist/models/settings.js +34 -0
- package/dist/models/settings.js.map +1 -0
- package/dist/models/user.d.ts +1110 -0
- package/dist/models/user.d.ts.map +1 -0
- package/dist/models/user.js +59 -0
- package/dist/models/user.js.map +1 -0
- package/package.json +47 -4
package/README.md
CHANGED
|
@@ -1,3 +1,100 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @centricare/contract
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
Standardized Zod schemas used across CentriCare projects. This package provides shared validation schemas and inferred TypeScript types for data entities (e.g. User, Settings) and common primitives (e.g. CodedConcept, timestamp, API response envelope), ensuring consistent data shapes and validation rules across all CentriCare services.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @centricare/contract
|
|
9
|
+
# or
|
|
10
|
+
yarn add @centricare/contract
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @centricare/contract
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { userSchema, User } from "@centricare/contract";
|
|
19
|
+
|
|
20
|
+
// Validate incoming data
|
|
21
|
+
const result = userSchema.safeParse(req.body);
|
|
22
|
+
|
|
23
|
+
if (!result.success) {
|
|
24
|
+
return res.status(400).json({ errors: result.error.flatten() });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const user: User = result.data;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Schemas
|
|
31
|
+
|
|
32
|
+
| Schema | File | Description |
|
|
33
|
+
| --------------------- | ------------------------------- | ------------------------------------------------------------------------ |
|
|
34
|
+
| `timestampSchema` | `src/commons/timestamp.ts` | ISO date string |
|
|
35
|
+
| `apiResponseSchema` | `src/commons/api-response.ts` | Standardized API response envelope |
|
|
36
|
+
| `metadataSchema` | `src/commons/api-response.ts` | Pagination metadata (total, offset, limit, next, previous) |
|
|
37
|
+
| `codedConceptSchema` | `src/commons/coded-concept.ts` | Coded system value (system, value, display, valid, tags) |
|
|
38
|
+
| `settingOptionSchema` | `src/commons/setting-option.ts` | Single setting option item |
|
|
39
|
+
| `userSchema` | `src/models/user.ts` | User record (full_name, email, statuses, identifiers, demographic, etc.) |
|
|
40
|
+
| `settingsSchema` | `src/models/settings.ts` | Settings / preferences record |
|
|
41
|
+
|
|
42
|
+
### Folder structure
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
src/
|
|
46
|
+
├── commons/ # Shared/primitive schemas (one file per schema)
|
|
47
|
+
│ ├── timestamp.ts
|
|
48
|
+
│ ├── api-response.ts
|
|
49
|
+
│ ├── setting-option.ts
|
|
50
|
+
│ ├── coded-concept.ts
|
|
51
|
+
│ └── index.ts
|
|
52
|
+
├── models/ # Data entity schemas
|
|
53
|
+
│ ├── user.ts
|
|
54
|
+
│ ├── settings.ts
|
|
55
|
+
│ └── index.ts
|
|
56
|
+
├── index.ts # Package root export
|
|
57
|
+
└── example.test.ts
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Add new shared schemas under `src/commons/` (one file each) and new entity schemas under `src/models/`. Re-export both from `src/index.ts`.
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Install dependencies
|
|
66
|
+
npm install
|
|
67
|
+
|
|
68
|
+
# Build to dist/
|
|
69
|
+
npm run build
|
|
70
|
+
|
|
71
|
+
# Watch for changes during development
|
|
72
|
+
npm run dev
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Contributing
|
|
76
|
+
|
|
77
|
+
### Using an AI agent
|
|
78
|
+
|
|
79
|
+
If you are an AI agent contributing to this package, read [`AGENTS.md`](./AGENTS.md) first. It defines the project structure, code conventions, folder layout, Zod error message rules (`message` not `error`), schema/type pairing, create/update patterns, and import guidelines. Follow those conventions strictly so all schemas remain consistent.
|
|
80
|
+
|
|
81
|
+
### Without an AI agent
|
|
82
|
+
|
|
83
|
+
1. **Create a new schema file**
|
|
84
|
+
- Shared/primitive schema → `src/commons/<name>.ts` (one file per schema, kebab-case)
|
|
85
|
+
- Data entity schema → `src/models/<name>.ts`
|
|
86
|
+
|
|
87
|
+
2. **Follow the code conventions**
|
|
88
|
+
- Every Zod schema must export an inferred TypeScript type: `export type X = z.infer<typeof xSchema>;`
|
|
89
|
+
- Use `message` (not `error`) for custom Zod error messages
|
|
90
|
+
- Use `z.coerce.number()` for query-string parameters
|
|
91
|
+
- Omit auto-generated fields (`_id`, `id`, `created_at`, `updated_at`, `updated_by`, `schema_version`) from `create` and `update` schemas
|
|
92
|
+
- Use `.nullable()` for fields that can be `null` but must be present; use `.optional()` for fields that may be absent
|
|
93
|
+
|
|
94
|
+
3. **Register the schema**
|
|
95
|
+
- Add `export * from "./<name>";` to the appropriate barrel file (`src/commons/index.ts` or `src/models/index.ts`)
|
|
96
|
+
- The root `src/index.ts` re-exports both, so no change is needed there unless you add a new top-level folder
|
|
97
|
+
|
|
98
|
+
4. **Build and verify**
|
|
99
|
+
- Run `npm run build` to compile TypeScript to `dist/`
|
|
100
|
+
- Add validation examples to `src/example.test.ts` for new schemas
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Pagination metadata included in every standardized API response.
|
|
4
|
+
*/
|
|
5
|
+
export declare const metadataSchema: z.ZodObject<{
|
|
6
|
+
total: z.ZodNumber;
|
|
7
|
+
offset: z.ZodNumber;
|
|
8
|
+
limit: z.ZodNumber;
|
|
9
|
+
next: z.ZodNullable<z.ZodString>;
|
|
10
|
+
previous: z.ZodNullable<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
offset: number;
|
|
13
|
+
total: number;
|
|
14
|
+
limit: number;
|
|
15
|
+
next: string | null;
|
|
16
|
+
previous: string | null;
|
|
17
|
+
}, {
|
|
18
|
+
offset: number;
|
|
19
|
+
total: number;
|
|
20
|
+
limit: number;
|
|
21
|
+
next: string | null;
|
|
22
|
+
previous: string | null;
|
|
23
|
+
}>;
|
|
24
|
+
export type Metadata = z.infer<typeof metadataSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Standardized API response envelope used by CentriCare services.
|
|
27
|
+
* Based on /Docs/API/1. Standardized Response.md
|
|
28
|
+
*
|
|
29
|
+
* {
|
|
30
|
+
* "success": true,
|
|
31
|
+
* "message": "Successfully do something",
|
|
32
|
+
* "status_code": "200",
|
|
33
|
+
* "data": [],
|
|
34
|
+
* "metadata": {
|
|
35
|
+
* "total": 1,
|
|
36
|
+
* "offset": 0,
|
|
37
|
+
* "limit": 1,
|
|
38
|
+
* "next": null,
|
|
39
|
+
* "previous": null
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
export declare const apiResponseSchema: <T extends z.ZodTypeAny>(dataSchema: T) => z.ZodObject<{
|
|
44
|
+
success: z.ZodBoolean;
|
|
45
|
+
message: z.ZodString;
|
|
46
|
+
status_code: z.ZodString;
|
|
47
|
+
data: z.ZodArray<T, "many">;
|
|
48
|
+
metadata: z.ZodObject<{
|
|
49
|
+
total: z.ZodNumber;
|
|
50
|
+
offset: z.ZodNumber;
|
|
51
|
+
limit: z.ZodNumber;
|
|
52
|
+
next: z.ZodNullable<z.ZodString>;
|
|
53
|
+
previous: z.ZodNullable<z.ZodString>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
offset: number;
|
|
56
|
+
total: number;
|
|
57
|
+
limit: number;
|
|
58
|
+
next: string | null;
|
|
59
|
+
previous: string | null;
|
|
60
|
+
}, {
|
|
61
|
+
offset: number;
|
|
62
|
+
total: number;
|
|
63
|
+
limit: number;
|
|
64
|
+
next: string | null;
|
|
65
|
+
previous: string | null;
|
|
66
|
+
}>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
message: string;
|
|
69
|
+
success: boolean;
|
|
70
|
+
status_code: string;
|
|
71
|
+
data: T["_output"][];
|
|
72
|
+
metadata: {
|
|
73
|
+
offset: number;
|
|
74
|
+
total: number;
|
|
75
|
+
limit: number;
|
|
76
|
+
next: string | null;
|
|
77
|
+
previous: string | null;
|
|
78
|
+
};
|
|
79
|
+
}, {
|
|
80
|
+
message: string;
|
|
81
|
+
success: boolean;
|
|
82
|
+
status_code: string;
|
|
83
|
+
data: T["_input"][];
|
|
84
|
+
metadata: {
|
|
85
|
+
offset: number;
|
|
86
|
+
total: number;
|
|
87
|
+
limit: number;
|
|
88
|
+
next: string | null;
|
|
89
|
+
previous: string | null;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
92
|
+
export type ApiResponse<T> = {
|
|
93
|
+
success: boolean;
|
|
94
|
+
message: string;
|
|
95
|
+
status_code: string;
|
|
96
|
+
data: T[];
|
|
97
|
+
metadata: Metadata;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Schema for a single-resource API response.
|
|
101
|
+
* For single-resource requests, metadata.total is always 1,
|
|
102
|
+
* offset and limit default to 0, and next/previous are null.
|
|
103
|
+
*/
|
|
104
|
+
export declare const singleResourceResponseSchema: <T extends z.ZodTypeAny>(dataSchema: T) => z.ZodEffects<z.ZodObject<{
|
|
105
|
+
success: z.ZodBoolean;
|
|
106
|
+
message: z.ZodString;
|
|
107
|
+
status_code: z.ZodString;
|
|
108
|
+
data: z.ZodArray<T, "many">;
|
|
109
|
+
metadata: z.ZodObject<{
|
|
110
|
+
total: z.ZodNumber;
|
|
111
|
+
offset: z.ZodNumber;
|
|
112
|
+
limit: z.ZodNumber;
|
|
113
|
+
next: z.ZodNullable<z.ZodString>;
|
|
114
|
+
previous: z.ZodNullable<z.ZodString>;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
offset: number;
|
|
117
|
+
total: number;
|
|
118
|
+
limit: number;
|
|
119
|
+
next: string | null;
|
|
120
|
+
previous: string | null;
|
|
121
|
+
}, {
|
|
122
|
+
offset: number;
|
|
123
|
+
total: number;
|
|
124
|
+
limit: number;
|
|
125
|
+
next: string | null;
|
|
126
|
+
previous: string | null;
|
|
127
|
+
}>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
message: string;
|
|
130
|
+
success: boolean;
|
|
131
|
+
status_code: string;
|
|
132
|
+
data: T["_output"][];
|
|
133
|
+
metadata: {
|
|
134
|
+
offset: number;
|
|
135
|
+
total: number;
|
|
136
|
+
limit: number;
|
|
137
|
+
next: string | null;
|
|
138
|
+
previous: string | null;
|
|
139
|
+
};
|
|
140
|
+
}, {
|
|
141
|
+
message: string;
|
|
142
|
+
success: boolean;
|
|
143
|
+
status_code: string;
|
|
144
|
+
data: T["_input"][];
|
|
145
|
+
metadata: {
|
|
146
|
+
offset: number;
|
|
147
|
+
total: number;
|
|
148
|
+
limit: number;
|
|
149
|
+
next: string | null;
|
|
150
|
+
previous: string | null;
|
|
151
|
+
};
|
|
152
|
+
}>, {
|
|
153
|
+
message: string;
|
|
154
|
+
success: boolean;
|
|
155
|
+
status_code: string;
|
|
156
|
+
data: T["_output"][];
|
|
157
|
+
metadata: {
|
|
158
|
+
offset: number;
|
|
159
|
+
total: number;
|
|
160
|
+
limit: number;
|
|
161
|
+
next: string | null;
|
|
162
|
+
previous: string | null;
|
|
163
|
+
};
|
|
164
|
+
}, {
|
|
165
|
+
message: string;
|
|
166
|
+
success: boolean;
|
|
167
|
+
status_code: string;
|
|
168
|
+
data: T["_input"][];
|
|
169
|
+
metadata: {
|
|
170
|
+
offset: number;
|
|
171
|
+
total: number;
|
|
172
|
+
limit: number;
|
|
173
|
+
next: string | null;
|
|
174
|
+
previous: string | null;
|
|
175
|
+
};
|
|
176
|
+
}>;
|
|
177
|
+
export type SingleResourceResponse<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof singleResourceResponseSchema<T>>>;
|
|
178
|
+
//# sourceMappingURL=api-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.d.ts","sourceRoot":"","sources":["../../src/commons/api-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;EAMzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOnE,CAAC;AAEL,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EACjE,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAaZ,CAAC;AAEJ,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,KAAK,CAClE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,CACnD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Pagination metadata included in every standardized API response.
|
|
4
|
+
*/
|
|
5
|
+
export const metadataSchema = z.object({
|
|
6
|
+
total: z.number().int().nonnegative(),
|
|
7
|
+
offset: z.number().int().nonnegative(),
|
|
8
|
+
limit: z.number().int().nonnegative(),
|
|
9
|
+
next: z.string().nullable(),
|
|
10
|
+
previous: z.string().nullable(),
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Standardized API response envelope used by CentriCare services.
|
|
14
|
+
* Based on /Docs/API/1. Standardized Response.md
|
|
15
|
+
*
|
|
16
|
+
* {
|
|
17
|
+
* "success": true,
|
|
18
|
+
* "message": "Successfully do something",
|
|
19
|
+
* "status_code": "200",
|
|
20
|
+
* "data": [],
|
|
21
|
+
* "metadata": {
|
|
22
|
+
* "total": 1,
|
|
23
|
+
* "offset": 0,
|
|
24
|
+
* "limit": 1,
|
|
25
|
+
* "next": null,
|
|
26
|
+
* "previous": null
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
export const apiResponseSchema = (dataSchema) => z.object({
|
|
31
|
+
success: z.boolean(),
|
|
32
|
+
message: z.string(),
|
|
33
|
+
status_code: z.string(),
|
|
34
|
+
data: z.array(dataSchema),
|
|
35
|
+
metadata: metadataSchema,
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Schema for a single-resource API response.
|
|
39
|
+
* For single-resource requests, metadata.total is always 1,
|
|
40
|
+
* offset and limit default to 0, and next/previous are null.
|
|
41
|
+
*/
|
|
42
|
+
export const singleResourceResponseSchema = (dataSchema) => apiResponseSchema(dataSchema).refine((data) => data.metadata.total === 1 &&
|
|
43
|
+
data.metadata.offset === 0 &&
|
|
44
|
+
data.metadata.limit === 0 &&
|
|
45
|
+
data.metadata.next === null &&
|
|
46
|
+
data.metadata.previous === null, {
|
|
47
|
+
message: "Single resource response metadata must have total=1, offset=0, limit=0, next=null, previous=null",
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=api-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.js","sourceRoot":"","sources":["../../src/commons/api-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACrC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACtC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAIH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAyB,UAAa,EAAE,EAAE,CACzE,CAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IACzB,QAAQ,EAAE,cAAc;CACzB,CAAC,CAAC;AAUL;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,UAAa,EACb,EAAE,CACF,iBAAiB,CAAC,UAAU,CAAC,CAAC,MAAM,CAClC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC;IACzB,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;IAC1B,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC;IACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI;IAC3B,IAAI,CAAC,QAAQ,CAAC,QAAQ,KAAK,IAAI,EACjC;IACE,OAAO,EACL,kGAAkG;CACrG,CACF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* CodedConcept - A data type for coded system values based on a defined code system.
|
|
4
|
+
* Used across CentriCare models for statuses, identifiers, contacts, demographic fields, etc.
|
|
5
|
+
*
|
|
6
|
+
* Accepts only codes and code systems registered in the CentriCare Registry.
|
|
7
|
+
*/
|
|
8
|
+
export declare const codedConceptSchema: z.ZodObject<{
|
|
9
|
+
system: z.ZodString;
|
|
10
|
+
value: z.ZodString;
|
|
11
|
+
display: z.ZodOptional<z.ZodString>;
|
|
12
|
+
valid: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
13
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
value: string;
|
|
16
|
+
system: string;
|
|
17
|
+
valid?: string | undefined;
|
|
18
|
+
display?: string | undefined;
|
|
19
|
+
tags?: string[] | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
value: string;
|
|
22
|
+
system: string;
|
|
23
|
+
valid?: string | undefined;
|
|
24
|
+
display?: string | undefined;
|
|
25
|
+
tags?: string[] | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export type CodedConcept = z.infer<typeof codedConceptSchema>;
|
|
28
|
+
//# sourceMappingURL=coded-concept.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coded-concept.d.ts","sourceRoot":"","sources":["../../src/commons/coded-concept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;EAa7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { timestampSchema } from "./timestamp";
|
|
3
|
+
/**
|
|
4
|
+
* CodedConcept - A data type for coded system values based on a defined code system.
|
|
5
|
+
* Used across CentriCare models for statuses, identifiers, contacts, demographic fields, etc.
|
|
6
|
+
*
|
|
7
|
+
* Accepts only codes and code systems registered in the CentriCare Registry.
|
|
8
|
+
*/
|
|
9
|
+
export const codedConceptSchema = z.object({
|
|
10
|
+
system: z.string().min(1, { message: "system is required" }),
|
|
11
|
+
value: z.string().min(1, { message: "value is required" }),
|
|
12
|
+
display: z.string().optional(),
|
|
13
|
+
valid: z
|
|
14
|
+
.string()
|
|
15
|
+
.datetime({ offset: true })
|
|
16
|
+
.optional()
|
|
17
|
+
.refine((val) => !val || timestampSchema.safeParse(val).success, { message: "valid must be a valid ISO 8601 datetime if provided" }),
|
|
18
|
+
tags: z.array(z.string()).optional(),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=coded-concept.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coded-concept.js","sourceRoot":"","sources":["../../src/commons/coded-concept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAC5D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC1D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAC1B,QAAQ,EAAE;SACV,MAAM,CACL,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EACvD,EAAE,OAAO,EAAE,qDAAqD,EAAE,CACnE;IACH,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared/primitive schemas used across CentriCare projects.
|
|
3
|
+
* Each schema lives in its own file.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./timestamp";
|
|
6
|
+
export * from "./api-response";
|
|
7
|
+
export * from "./setting-option";
|
|
8
|
+
export * from "./coded-concept";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commons/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared/primitive schemas used across CentriCare projects.
|
|
3
|
+
* Each schema lives in its own file.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./timestamp";
|
|
6
|
+
export * from "./api-response";
|
|
7
|
+
export * from "./setting-option";
|
|
8
|
+
export * from "./coded-concept";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commons/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The type of a setting option value.
|
|
4
|
+
*
|
|
5
|
+
* Accepts "string", "number", "boolean", "date", or an array of those
|
|
6
|
+
* for options with multiple choices. Also accepts any valid registry system
|
|
7
|
+
* path (e.g. "crn:status:system") for options whose input type is determined
|
|
8
|
+
* by a registry code system.
|
|
9
|
+
*/
|
|
10
|
+
export declare const settingOptionTypeSchema: z.ZodUnion<[z.ZodEnum<["string", "number", "boolean", "date"]>, z.ZodArray<z.ZodEnum<["string", "number", "boolean", "date"]>, "many">, z.ZodString]>;
|
|
11
|
+
export type SettingOptionType = z.infer<typeof settingOptionTypeSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* A single setting option item.
|
|
14
|
+
*
|
|
15
|
+
* - `default` and `value` can be null but cannot be undefined or missing.
|
|
16
|
+
*/
|
|
17
|
+
export declare const settingOptionSchema: z.ZodObject<{
|
|
18
|
+
field: z.ZodString;
|
|
19
|
+
label: z.ZodOptional<z.ZodString>;
|
|
20
|
+
type: z.ZodUnion<[z.ZodEnum<["string", "number", "boolean", "date"]>, z.ZodArray<z.ZodEnum<["string", "number", "boolean", "date"]>, "many">, z.ZodString]>;
|
|
21
|
+
default: z.ZodNullable<z.ZodString>;
|
|
22
|
+
value: z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodNumber]>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
value: string | number | boolean | null;
|
|
25
|
+
type: string | ("string" | "number" | "boolean" | "date")[];
|
|
26
|
+
field: string;
|
|
27
|
+
default: string | null;
|
|
28
|
+
label?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
value: string | number | boolean | null;
|
|
31
|
+
type: string | ("string" | "number" | "boolean" | "date")[];
|
|
32
|
+
field: string;
|
|
33
|
+
default: string | null;
|
|
34
|
+
label?: string | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export type SettingOption = z.infer<typeof settingOptionSchema>;
|
|
37
|
+
//# sourceMappingURL=setting-option.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setting-option.d.ts","sourceRoot":"","sources":["../../src/commons/setting-option.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,uJAIlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAM9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The type of a setting option value.
|
|
4
|
+
*
|
|
5
|
+
* Accepts "string", "number", "boolean", "date", or an array of those
|
|
6
|
+
* for options with multiple choices. Also accepts any valid registry system
|
|
7
|
+
* path (e.g. "crn:status:system") for options whose input type is determined
|
|
8
|
+
* by a registry code system.
|
|
9
|
+
*/
|
|
10
|
+
export const settingOptionTypeSchema = z.union([
|
|
11
|
+
z.enum(["string", "number", "boolean", "date"]),
|
|
12
|
+
z.array(z.enum(["string", "number", "boolean", "date"])),
|
|
13
|
+
z.string(),
|
|
14
|
+
]);
|
|
15
|
+
/**
|
|
16
|
+
* A single setting option item.
|
|
17
|
+
*
|
|
18
|
+
* - `default` and `value` can be null but cannot be undefined or missing.
|
|
19
|
+
*/
|
|
20
|
+
export const settingOptionSchema = z.object({
|
|
21
|
+
field: z.string().min(1, { message: "field is required" }),
|
|
22
|
+
label: z.string().optional(),
|
|
23
|
+
type: settingOptionTypeSchema,
|
|
24
|
+
default: z.string().nullable(),
|
|
25
|
+
value: z.union([z.string(), z.boolean(), z.number()]).nullable(),
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=setting-option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setting-option.js","sourceRoot":"","sources":["../../src/commons/setting-option.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC7C,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,MAAM,EAAE;CACX,CAAC,CAAC;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC1D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;CACjE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.d.ts","sourceRoot":"","sources":["../../src/commons/timestamp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,eAAe,aAG1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../../src/commons/timestamp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;IACjD,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,iDAAiD;CAC3D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.test.d.ts","sourceRoot":"","sources":["../src/example.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|