@ismou-workspace/contacts-contracts 0.0.0-stage → 0.1.2

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 CHANGED
@@ -1,3 +1,16 @@
1
- # Temporary Holding Version
1
+ # @ismou-workspace/contacts-contracts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The `contacts.contact` entity type of Ismou's Contacts app, and the DTOs of its API (`./api`).
4
+
5
+ Published by the [contacts](https://github.com/ismou-workspace/contacts) app for the apps that use its entities: apps never know each other, the entities come through the core, and these types describe them.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ pnpm add @ismou-workspace/contacts-contracts
11
+ ```
12
+
13
+ ## Documentation
14
+
15
+ - [The platform's documentation](https://github.com/ismou-workspace/sdk/tree/main/docs): architecture, conventions, design system.
16
+ - [Source](https://github.com/ismou-workspace/contacts/tree/main/contracts)
@@ -0,0 +1,12 @@
1
+ export declare const CONTACTS_API_PATHS: {
2
+ /** GET → `LabelList`; POST `LabelInput` → `Label`. */
3
+ readonly labels: '/api/labels';
4
+ /** PATCH `LabelInput` → `Label`; DELETE → 204. */
5
+ readonly label: '/api/labels/:labelId';
6
+ /** PUT `LabelMembership` → `LabelList`: the labels one contact carries, all of them. */
7
+ readonly memberLabels: '/api/label-members';
8
+ /** POST `LabelMemberMove` → 204: a contact moved to another provider keeps its labels. */
9
+ readonly memberMove: '/api/label-members/move';
10
+ };
11
+ /** The contact web client's page of one contact, of any provider. */
12
+ export declare const CONTACT_PAGE_PATH = "/contacts/:providerId/:ownerId/:contactId";
@@ -0,0 +1,16 @@
1
+ /*
2
+ * The contacts app's own API, for its web client: labels. Contacts themselves, of every
3
+ * provider, go through the core (`contacts.contact`, `@ismou-workspace/contacts-contracts`).
4
+ */
5
+ export const CONTACTS_API_PATHS = {
6
+ /** GET → `LabelList`; POST `LabelInput` → `Label`. */
7
+ labels: '/api/labels',
8
+ /** PATCH `LabelInput` → `Label`; DELETE → 204. */
9
+ label: '/api/labels/:labelId',
10
+ /** PUT `LabelMembership` → `LabelList`: the labels one contact carries, all of them. */
11
+ memberLabels: '/api/label-members',
12
+ /** POST `LabelMemberMove` → 204: a contact moved to another provider keeps its labels. */
13
+ memberMove: '/api/label-members/move',
14
+ };
15
+ /** The contact web client's page of one contact, of any provider. */
16
+ export const CONTACT_PAGE_PATH = '/contacts/:providerId/:ownerId/:contactId';
@@ -0,0 +1,2 @@
1
+ export { CONTACT_PAGE_PATH, CONTACTS_API_PATHS } from './contacts-api.ts';
2
+ export { LABEL_COLORS, type Label, type LabelColor, LabelColorSchema, type LabelFields, type LabelInput, LabelInputSchema, type LabelList, LabelListSchema, type LabelMember, type LabelMemberMove, LabelMemberMoveSchema, LabelMemberSchema, type LabelMembership, LabelMembershipSchema, LabelSchema, } from './label.entity.ts';
@@ -0,0 +1,3 @@
1
+ /* The contacts app's own contracts: its labels. The contact itself is `@ismou-workspace/contacts-contracts`. */
2
+ export { CONTACT_PAGE_PATH, CONTACTS_API_PATHS } from './contacts-api.js';
3
+ export { LABEL_COLORS, LabelColorSchema, LabelInputSchema, LabelListSchema, LabelMemberMoveSchema, LabelMemberSchema, LabelMembershipSchema, LabelSchema, } from './label.entity.js';
@@ -0,0 +1,102 @@
1
+ import { z } from 'zod';
2
+ /** The colours a label can take: the palette of the design system. */
3
+ export declare const LABEL_COLORS: readonly ['blue', 'cyan', 'green', 'violet', 'yellow', 'orange', 'red'];
4
+ export declare const LabelColorSchema: z.ZodEnum<{
5
+ blue: "blue";
6
+ cyan: "cyan";
7
+ green: "green";
8
+ orange: "orange";
9
+ red: "red";
10
+ violet: "violet";
11
+ yellow: "yellow";
12
+ }>;
13
+ export type LabelColor = z.infer<typeof LabelColorSchema>;
14
+ /** A contact of any provider and owner, as a label holds it. */
15
+ export declare const LabelMemberSchema: z.ZodObject<{
16
+ providerId: z.ZodString;
17
+ ownerId: z.ZodString;
18
+ contactId: z.ZodString;
19
+ }, z.core.$strip>;
20
+ export type LabelMember = z.infer<typeof LabelMemberSchema>;
21
+ /**
22
+ * A label of the contacts app: a name and a colour on contacts of any provider. It holds their
23
+ * references only: a contact no provider answers for is simply not shown. Each account's own.
24
+ */
25
+ export declare const LabelSchema: z.ZodObject<{
26
+ id: z.ZodUUID;
27
+ name: z.ZodString;
28
+ color: z.ZodEnum<{
29
+ blue: "blue";
30
+ cyan: "cyan";
31
+ green: "green";
32
+ orange: "orange";
33
+ red: "red";
34
+ violet: "violet";
35
+ yellow: "yellow";
36
+ }>;
37
+ members: z.ZodArray<z.ZodObject<{
38
+ providerId: z.ZodString;
39
+ ownerId: z.ZodString;
40
+ contactId: z.ZodString;
41
+ }, z.core.$strip>>;
42
+ }, z.core.$strip>;
43
+ export type Label = z.infer<typeof LabelSchema>;
44
+ export declare const LabelInputSchema: z.ZodObject<{
45
+ name: z.ZodString;
46
+ color: z.ZodEnum<{
47
+ blue: "blue";
48
+ cyan: "cyan";
49
+ green: "green";
50
+ orange: "orange";
51
+ red: "red";
52
+ violet: "violet";
53
+ yellow: "yellow";
54
+ }>;
55
+ }, z.core.$strip>;
56
+ export type LabelInput = z.input<typeof LabelInputSchema>;
57
+ export type LabelFields = z.output<typeof LabelInputSchema>;
58
+ export declare const LabelListSchema: z.ZodObject<{
59
+ labels: z.ZodArray<z.ZodObject<{
60
+ id: z.ZodUUID;
61
+ name: z.ZodString;
62
+ color: z.ZodEnum<{
63
+ blue: "blue";
64
+ cyan: "cyan";
65
+ green: "green";
66
+ orange: "orange";
67
+ red: "red";
68
+ violet: "violet";
69
+ yellow: "yellow";
70
+ }>;
71
+ members: z.ZodArray<z.ZodObject<{
72
+ providerId: z.ZodString;
73
+ ownerId: z.ZodString;
74
+ contactId: z.ZodString;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$strip>>;
77
+ }, z.core.$strip>;
78
+ export type LabelList = z.infer<typeof LabelListSchema>;
79
+ /** PUT on a contact's labels: every label it carries now (none removes it from every label). */
80
+ export declare const LabelMembershipSchema: z.ZodObject<{
81
+ member: z.ZodObject<{
82
+ providerId: z.ZodString;
83
+ ownerId: z.ZodString;
84
+ contactId: z.ZodString;
85
+ }, z.core.$strip>;
86
+ labelIds: z.ZodArray<z.ZodUUID>;
87
+ }, z.core.$strip>;
88
+ export type LabelMembership = z.infer<typeof LabelMembershipSchema>;
89
+ /** A contact moved to another provider (or deleted, `to: null`): its labels follow it. */
90
+ export declare const LabelMemberMoveSchema: z.ZodObject<{
91
+ from: z.ZodObject<{
92
+ providerId: z.ZodString;
93
+ ownerId: z.ZodString;
94
+ contactId: z.ZodString;
95
+ }, z.core.$strip>;
96
+ to: z.ZodNullable<z.ZodObject<{
97
+ providerId: z.ZodString;
98
+ ownerId: z.ZodString;
99
+ contactId: z.ZodString;
100
+ }, z.core.$strip>>;
101
+ }, z.core.$strip>;
102
+ export type LabelMemberMove = z.infer<typeof LabelMemberMoveSchema>;
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ /** The colours a label can take: the palette of the design system. */
3
+ export const LABEL_COLORS = ['blue', 'cyan', 'green', 'violet', 'yellow', 'orange', 'red'];
4
+ export const LabelColorSchema = z.enum(LABEL_COLORS);
5
+ /** A contact of any provider and owner, as a label holds it. */
6
+ export const LabelMemberSchema = z.object({
7
+ providerId: z.string().min(1),
8
+ ownerId: z.string().min(1),
9
+ contactId: z.string().min(1).max(300),
10
+ });
11
+ /**
12
+ * A label of the contacts app: a name and a colour on contacts of any provider. It holds their
13
+ * references only: a contact no provider answers for is simply not shown. Each account's own.
14
+ */
15
+ export const LabelSchema = z.object({
16
+ id: z.uuidv4(),
17
+ name: z.string(),
18
+ color: LabelColorSchema,
19
+ members: z.array(LabelMemberSchema),
20
+ });
21
+ export const LabelInputSchema = z.object({
22
+ name: z.string().trim().min(1).max(60),
23
+ color: LabelColorSchema,
24
+ });
25
+ export const LabelListSchema = z.object({
26
+ labels: z.array(LabelSchema),
27
+ });
28
+ /** PUT on a contact's labels: every label it carries now (none removes it from every label). */
29
+ export const LabelMembershipSchema = z.object({
30
+ member: LabelMemberSchema,
31
+ labelIds: z.array(z.uuidv4()).max(100),
32
+ });
33
+ /** A contact moved to another provider (or deleted, `to: null`): its labels follow it. */
34
+ export const LabelMemberMoveSchema = z.object({
35
+ from: LabelMemberSchema,
36
+ to: LabelMemberSchema.nullable(),
37
+ });
@@ -0,0 +1,82 @@
1
+ import { z } from 'zod';
2
+ export declare const CONTACT_TYPE_ID = "contacts.contact";
3
+ /** Who created a contact, and through which app (its manifest id): kept for the contact's life. */
4
+ export declare const ContactProvenanceSchema: z.ZodObject<{
5
+ accountId: z.ZodString;
6
+ appId: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export type ContactProvenance = z.infer<typeof ContactProvenanceSchema>;
9
+ /** A contact's data (its id, owner and dates are the envelope's). */
10
+ export declare const ContactSchema: z.ZodObject<{
11
+ firstName: z.ZodString;
12
+ lastName: z.ZodString;
13
+ email: z.ZodNullable<z.ZodEmail>;
14
+ phone: z.ZodNullable<z.ZodString>;
15
+ company: z.ZodNullable<z.ZodString>;
16
+ birthday: z.ZodNullable<z.ZodISODate>;
17
+ avatar: z.ZodDiscriminatedUnion<[z.ZodObject<{
18
+ kind: z.ZodLiteral<"generated">;
19
+ seed: z.ZodUUID;
20
+ }, z.core.$strip>, z.ZodObject<{
21
+ kind: z.ZodLiteral<"file">;
22
+ fileId: z.ZodUUID;
23
+ url: z.ZodURL;
24
+ }, z.core.$strip>], "kind">;
25
+ createdBy: z.ZodObject<{
26
+ accountId: z.ZodString;
27
+ appId: z.ZodString;
28
+ }, z.core.$strip>;
29
+ }, z.core.$strip>;
30
+ export type Contact = z.infer<typeof ContactSchema>;
31
+ /** Creating or changing a contact, at any provider (the body of `create` and `update`). */
32
+ export declare const ContactInputSchema: z.ZodObject<{
33
+ firstName: z.ZodString;
34
+ lastName: z.ZodDefault<z.ZodString>;
35
+ email: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodEmail]>>>>, z.ZodTransform<string | null, string | null | undefined>>;
36
+ phone: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null | undefined>>;
37
+ company: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null | undefined>>;
38
+ birthday: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodISODate]>>>, z.ZodTransform<string | null, string | null | undefined>>;
39
+ }, z.core.$strip>;
40
+ /** What a client sends, before parsing. */
41
+ export type ContactInput = z.input<typeof ContactInputSchema>;
42
+ /** What a provider stores, after parsing. */
43
+ export type ContactFields = z.output<typeof ContactInputSchema>;
44
+ /** A contact's fields, as the input that recreates it elsewhere (moving it to another provider). */
45
+ export declare function contactInputOf(contact: Contact): ContactFields;
46
+ /** `search`: matches first name, last name, email or company, case-insensitively. */
47
+ export declare const ContactListParamsSchema: z.ZodObject<{
48
+ search: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strip>;
50
+ export type ContactListParams = z.input<typeof ContactListParamsSchema>;
51
+ /** The contact's own operations, and what they take and answer. */
52
+ export declare const CONTACT_OPERATIONS: {
53
+ /** PUT multipart (`file`: an accepted image): the photo becomes the avatar → 204. */
54
+ readonly photo: 'photo';
55
+ /** POST `AvatarRegeneration`: the generated face of that seed, any photo deleted → 204. */
56
+ readonly avatar: 'avatar';
57
+ };
58
+ export declare const contactType: {
59
+ id: string;
60
+ version: number;
61
+ parent: string | null;
62
+ titleFields: string[];
63
+ schema: Record<string, z.JSONType>;
64
+ permissions: Record<string, string | null>;
65
+ operations: Record<string, string>;
66
+ kinds: string[];
67
+ actions: Record<string, {
68
+ permission: string;
69
+ target: "page" | "server";
70
+ }>;
71
+ messages: Partial<Record<"en" | "fr", {
72
+ name: string;
73
+ plural: string;
74
+ permissions: Record<string, {
75
+ label: string;
76
+ description: string;
77
+ }>;
78
+ operations: Record<string, string>;
79
+ kinds: Record<string, string>;
80
+ actions: Record<string, string>;
81
+ }>>;
82
+ };
@@ -0,0 +1,137 @@
1
+ import { AvatarSchema, defineEntityType } from '@ismou-workspace/contracts';
2
+ import { z } from 'zod';
3
+ /*
4
+ * `contacts.contact`: a person, whoever provides it (the contacts app, a Google bridge). Every
5
+ * provider serves these fields; pictures (`photo`, `avatar`) are operations a provider may
6
+ * leave out.
7
+ */
8
+ export const CONTACT_TYPE_ID = 'contacts.contact';
9
+ /** Optional free text: trimmed, and empty form values become `null`. */
10
+ const optionalText = (maxLength) => z
11
+ .string()
12
+ .trim()
13
+ .max(maxLength)
14
+ .nullish()
15
+ .transform((value) => (value ? value : null));
16
+ const optionalEmail = z
17
+ .string()
18
+ .trim()
19
+ .pipe(z.union([z.literal(''), z.email().max(254)]))
20
+ .nullish()
21
+ .transform((value) => (value ? value : null));
22
+ /** Who created a contact, and through which app (its manifest id): kept for the contact's life. */
23
+ export const ContactProvenanceSchema = z.object({
24
+ accountId: z.string(),
25
+ appId: z.string().min(1),
26
+ });
27
+ /** A contact's data (its id, owner and dates are the envelope's). */
28
+ export const ContactSchema = z.object({
29
+ firstName: z.string(),
30
+ lastName: z.string(),
31
+ email: z.email().nullable(),
32
+ phone: z.string().nullable(),
33
+ company: z.string().nullable(),
34
+ /** `YYYY-MM-DD`; the year may be a guess, the month and day are what count. */
35
+ birthday: z.iso.date().nullable(),
36
+ avatar: AvatarSchema,
37
+ createdBy: ContactProvenanceSchema,
38
+ });
39
+ /** Creating or changing a contact, at any provider (the body of `create` and `update`). */
40
+ export const ContactInputSchema = z.object({
41
+ firstName: z.string().trim().min(1).max(100),
42
+ lastName: z.string().trim().max(100).default(''),
43
+ email: optionalEmail,
44
+ phone: optionalText(40),
45
+ company: optionalText(120),
46
+ /** A calendar date (`YYYY-MM-DD`); empty form values become `null`. */
47
+ birthday: z
48
+ .union([z.literal(''), z.iso.date()])
49
+ .nullish()
50
+ .transform((value) => (value ? value : null)),
51
+ });
52
+ /** A contact's fields, as the input that recreates it elsewhere (moving it to another provider). */
53
+ export function contactInputOf(contact) {
54
+ return {
55
+ firstName: contact.firstName,
56
+ lastName: contact.lastName,
57
+ email: contact.email,
58
+ phone: contact.phone,
59
+ company: contact.company,
60
+ birthday: contact.birthday,
61
+ };
62
+ }
63
+ /** `search`: matches first name, last name, email or company, case-insensitively. */
64
+ export const ContactListParamsSchema = z.object({
65
+ search: z.string().trim().max(100).optional(),
66
+ });
67
+ /** The contact's own operations, and what they take and answer. */
68
+ export const CONTACT_OPERATIONS = {
69
+ /** PUT multipart (`file`: an accepted image): the photo becomes the avatar → 204. */
70
+ photo: 'photo',
71
+ /** POST `AvatarRegeneration`: the generated face of that seed, any photo deleted → 204. */
72
+ avatar: 'avatar',
73
+ };
74
+ export const contactType = defineEntityType({
75
+ id: CONTACT_TYPE_ID,
76
+ version: 1,
77
+ parent: null,
78
+ titleFields: ['firstName', 'lastName'],
79
+ data: ContactSchema,
80
+ permissions: { read: null, write: 'read', share: 'read' },
81
+ operations: {
82
+ list: 'read',
83
+ read: 'read',
84
+ create: 'write',
85
+ update: 'write',
86
+ delete: 'write',
87
+ [CONTACT_OPERATIONS.photo]: 'write',
88
+ [CONTACT_OPERATIONS.avatar]: 'write',
89
+ },
90
+ messages: {
91
+ en: {
92
+ name: 'Contact',
93
+ plural: 'Contacts',
94
+ permissions: {
95
+ read: { label: 'View contacts', description: 'See contacts and their details.' },
96
+ write: {
97
+ label: 'Edit contacts',
98
+ description: 'Create, change and delete contacts, and their pictures.',
99
+ },
100
+ share: { label: 'Share contacts', description: 'Share contacts with other people.' },
101
+ },
102
+ operations: {
103
+ list: 'List contacts',
104
+ read: 'View a contact',
105
+ create: 'Create contacts',
106
+ update: 'Edit contacts',
107
+ delete: 'Delete contacts',
108
+ photo: 'Upload a photo',
109
+ avatar: 'Change the face',
110
+ },
111
+ },
112
+ fr: {
113
+ name: 'Contact',
114
+ plural: 'Contacts',
115
+ permissions: {
116
+ read: { label: 'Voir les contacts', description: 'Voir les contacts et leurs détails.' },
117
+ write: {
118
+ label: 'Modifier les contacts',
119
+ description: 'Créer, modifier et supprimer des contacts, et leurs images.',
120
+ },
121
+ share: {
122
+ label: 'Partager les contacts',
123
+ description: "Partager des contacts avec d'autres personnes.",
124
+ },
125
+ },
126
+ operations: {
127
+ list: 'Lister les contacts',
128
+ read: 'Voir un contact',
129
+ create: 'Créer des contacts',
130
+ update: 'Modifier des contacts',
131
+ delete: 'Supprimer des contacts',
132
+ photo: 'Envoyer une photo',
133
+ avatar: 'Changer le visage',
134
+ },
135
+ },
136
+ },
137
+ });
@@ -0,0 +1 @@
1
+ export { CONTACT_OPERATIONS, CONTACT_TYPE_ID, type Contact, type ContactFields, type ContactInput, ContactInputSchema, type ContactListParams, ContactListParamsSchema, type ContactProvenance, ContactProvenanceSchema, ContactSchema, contactInputOf, contactType, } from './contact.type.ts';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /* The `contacts.contact` entity type (see docs/architecture/entities/entity-types.md). */
2
+ export { CONTACT_OPERATIONS, CONTACT_TYPE_ID, ContactInputSchema, ContactListParamsSchema, ContactProvenanceSchema, ContactSchema, contactInputOf, contactType, } from './contact.type.js';
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@ismou-workspace/contacts-contracts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.2",
4
+ "description": "The contacts.contact entity type of Ismou's Contacts app, and the DTOs of its API (./api).",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./api": {
13
+ "types": "./dist/api/index.d.ts",
14
+ "default": "./dist/api/index.js"
15
+ }
16
+ },
17
+ "dependencies": {
18
+ "@ismou-workspace/contracts": "^0.1.1",
19
+ "zod": "4.6.7"
20
+ },
21
+ "devDependencies": {
22
+ "@ismou-workspace/tsconfig": "^0.1.1",
23
+ "typescript": "7.0.2",
24
+ "vitest": "5.1.2"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/ismou-workspace/contacts.git",
29
+ "directory": "contracts"
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc --project tsconfig.build.json",
39
+ "typecheck": "tsc --project tsconfig.json",
40
+ "test": "vitest run"
41
+ }
6
42
  }