@centricare/contract 0.1.1 → 0.2.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 +31 -50
- package/dist/index.cjs +1469 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +3324 -0
- package/dist/index.d.ts +3322 -5
- package/dist/index.mjs +1325 -0
- package/dist/index.mjs.map +1 -0
- package/dist/registry/index.cjs +412 -0
- package/dist/registry/index.cjs.map +1 -0
- package/dist/registry/index.d.mts +60 -0
- package/dist/registry/index.d.ts +60 -0
- package/dist/registry/index.mjs +405 -0
- package/dist/registry/index.mjs.map +1 -0
- package/package.json +29 -8
- package/dist/commons/api-response.d.ts +0 -178
- package/dist/commons/api-response.d.ts.map +0 -1
- package/dist/commons/api-response.js +0 -49
- package/dist/commons/api-response.js.map +0 -1
- package/dist/commons/coded-concept.d.ts +0 -28
- package/dist/commons/coded-concept.d.ts.map +0 -1
- package/dist/commons/coded-concept.js +0 -20
- package/dist/commons/coded-concept.js.map +0 -1
- package/dist/commons/index.d.ts +0 -9
- package/dist/commons/index.d.ts.map +0 -1
- package/dist/commons/index.js +0 -9
- package/dist/commons/index.js.map +0 -1
- package/dist/commons/setting-option.d.ts +0 -37
- package/dist/commons/setting-option.d.ts.map +0 -1
- package/dist/commons/setting-option.js +0 -27
- package/dist/commons/setting-option.js.map +0 -1
- package/dist/commons/timestamp.d.ts +0 -7
- package/dist/commons/timestamp.d.ts.map +0 -1
- package/dist/commons/timestamp.js +0 -9
- package/dist/commons/timestamp.js.map +0 -1
- package/dist/example.test.d.ts +0 -6
- package/dist/example.test.d.ts.map +0 -1
- package/dist/example.test.js +0 -147
- package/dist/example.test.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/models/index.d.ts +0 -6
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -6
- package/dist/models/index.js.map +0 -1
- package/dist/models/settings.d.ts +0 -189
- package/dist/models/settings.d.ts.map +0 -1
- package/dist/models/settings.js +0 -34
- package/dist/models/settings.js.map +0 -1
- package/dist/models/user.d.ts +0 -1110
- package/dist/models/user.d.ts.map +0 -1
- package/dist/models/user.js +0 -59
- package/dist/models/user.js.map +0 -1
package/README.md
CHANGED
|
@@ -17,7 +17,6 @@ pnpm add @centricare/contract
|
|
|
17
17
|
```ts
|
|
18
18
|
import { userSchema, User } from "@centricare/contract";
|
|
19
19
|
|
|
20
|
-
// Validate incoming data
|
|
21
20
|
const result = userSchema.safeParse(req.body);
|
|
22
21
|
|
|
23
22
|
if (!result.success) {
|
|
@@ -27,37 +26,40 @@ if (!result.success) {
|
|
|
27
26
|
const user: User = result.data;
|
|
28
27
|
```
|
|
29
28
|
|
|
30
|
-
##
|
|
29
|
+
## Registry
|
|
31
30
|
|
|
32
|
-
|
|
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 |
|
|
31
|
+
Registry helpers are exposed from a dedicated subpath:
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
```ts
|
|
34
|
+
import { validateCode, getCode, getOptions, getSystems } from "@centricare/contract/registry";
|
|
35
|
+
|
|
36
|
+
validateCode("crn:status:system", "active"); // true
|
|
37
|
+
getOptions("crn:contact"); // [{ value: "mobile", label: "Mobile" }, ...]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
They are intentionally **not** exported from the package root. See
|
|
41
|
+
[src/registry/README.md](./src/registry/README.md).
|
|
42
|
+
|
|
43
|
+
The package ships both ESM (`*.mjs`) and CommonJS (`*.cjs`) builds, with matching
|
|
44
|
+
type declarations.
|
|
45
|
+
|
|
46
|
+
## Folder Structure
|
|
43
47
|
|
|
44
48
|
```
|
|
45
49
|
src/
|
|
46
|
-
├── commons/ # Shared/primitive schemas (
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
50
|
+
├── commons/ # Shared/primitive schemas (see src/commons/README.md)
|
|
51
|
+
├── models/ # Data entity schemas (see src/models/README.md)
|
|
52
|
+
└── registry/ # CentriCare registry schemas (see src/registry/README.md)
|
|
58
53
|
```
|
|
59
54
|
|
|
60
|
-
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
- **[AGENTS.md](./AGENTS.md)** — AI agent guidance and project conventions
|
|
58
|
+
- **[CONVENTIONS.md](./CONVENTIONS.md)** — Code conventions and coding standards
|
|
59
|
+
- **[EXAMPLES.md](./EXAMPLES.md)** — Usage examples
|
|
60
|
+
- **[src/commons/README.md](./src/commons/README.md)** — Shared primitive schemas
|
|
61
|
+
- **[src/models/README.md](./src/models/README.md)** — Data entity schemas
|
|
62
|
+
- **[src/registry/README.md](./src/registry/README.md)** — CentriCare registry schemas
|
|
61
63
|
|
|
62
64
|
## Development
|
|
63
65
|
|
|
@@ -72,29 +74,8 @@ npm run build
|
|
|
72
74
|
npm run dev
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
##
|
|
76
|
-
|
|
77
|
-
### Using an AI agent
|
|
77
|
+
## Publishing
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
79
|
+
```bash
|
|
80
|
+
npm publish --access public
|
|
81
|
+
```
|