@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.
Files changed (53) hide show
  1. package/README.md +31 -50
  2. package/dist/index.cjs +1469 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.mts +3324 -0
  5. package/dist/index.d.ts +3322 -5
  6. package/dist/index.mjs +1325 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/registry/index.cjs +412 -0
  9. package/dist/registry/index.cjs.map +1 -0
  10. package/dist/registry/index.d.mts +60 -0
  11. package/dist/registry/index.d.ts +60 -0
  12. package/dist/registry/index.mjs +405 -0
  13. package/dist/registry/index.mjs.map +1 -0
  14. package/package.json +29 -8
  15. package/dist/commons/api-response.d.ts +0 -178
  16. package/dist/commons/api-response.d.ts.map +0 -1
  17. package/dist/commons/api-response.js +0 -49
  18. package/dist/commons/api-response.js.map +0 -1
  19. package/dist/commons/coded-concept.d.ts +0 -28
  20. package/dist/commons/coded-concept.d.ts.map +0 -1
  21. package/dist/commons/coded-concept.js +0 -20
  22. package/dist/commons/coded-concept.js.map +0 -1
  23. package/dist/commons/index.d.ts +0 -9
  24. package/dist/commons/index.d.ts.map +0 -1
  25. package/dist/commons/index.js +0 -9
  26. package/dist/commons/index.js.map +0 -1
  27. package/dist/commons/setting-option.d.ts +0 -37
  28. package/dist/commons/setting-option.d.ts.map +0 -1
  29. package/dist/commons/setting-option.js +0 -27
  30. package/dist/commons/setting-option.js.map +0 -1
  31. package/dist/commons/timestamp.d.ts +0 -7
  32. package/dist/commons/timestamp.d.ts.map +0 -1
  33. package/dist/commons/timestamp.js +0 -9
  34. package/dist/commons/timestamp.js.map +0 -1
  35. package/dist/example.test.d.ts +0 -6
  36. package/dist/example.test.d.ts.map +0 -1
  37. package/dist/example.test.js +0 -147
  38. package/dist/example.test.js.map +0 -1
  39. package/dist/index.d.ts.map +0 -1
  40. package/dist/index.js +0 -7
  41. package/dist/index.js.map +0 -1
  42. package/dist/models/index.d.ts +0 -6
  43. package/dist/models/index.d.ts.map +0 -1
  44. package/dist/models/index.js +0 -6
  45. package/dist/models/index.js.map +0 -1
  46. package/dist/models/settings.d.ts +0 -189
  47. package/dist/models/settings.d.ts.map +0 -1
  48. package/dist/models/settings.js +0 -34
  49. package/dist/models/settings.js.map +0 -1
  50. package/dist/models/user.d.ts +0 -1110
  51. package/dist/models/user.d.ts.map +0 -1
  52. package/dist/models/user.js +0 -59
  53. 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
- ## Schemas
29
+ ## Registry
31
30
 
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 |
31
+ Registry helpers are exposed from a dedicated subpath:
41
32
 
42
- ### Folder structure
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 (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
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
- Add new shared schemas under `src/commons/` (one file each) and new entity schemas under `src/models/`. Re-export both from `src/index.ts`.
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
- ## Contributing
76
-
77
- ### Using an AI agent
77
+ ## Publishing
78
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
79
+ ```bash
80
+ npm publish --access public
81
+ ```