@sneat/contactus-core 0.1.3 → 0.1.4

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 (38) hide show
  1. package/fesm2022/sneat-contactus-core.mjs +180 -0
  2. package/fesm2022/sneat-contactus-core.mjs.map +1 -0
  3. package/package.json +13 -2
  4. package/types/sneat-contactus-core.d.ts +418 -0
  5. package/eslint.config.js +0 -7
  6. package/ng-package.json +0 -7
  7. package/project.json +0 -38
  8. package/src/index.ts +0 -3
  9. package/src/lib/apidto/index.ts +0 -3
  10. package/src/lib/apidto/requests.ts +0 -131
  11. package/src/lib/apidto/responses.ts +0 -21
  12. package/src/lib/contexts/contact-context.ts +0 -22
  13. package/src/lib/contexts/index.ts +0 -2
  14. package/src/lib/contexts/member-group.ts +0 -35
  15. package/src/lib/contexts/person-context.ts +0 -41
  16. package/src/lib/dto/address.ts +0 -26
  17. package/src/lib/dto/contact-base.ts +0 -47
  18. package/src/lib/dto/contact-group-brief.ts +0 -8
  19. package/src/lib/dto/contact-group.ts +0 -19
  20. package/src/lib/dto/contact-roles.ts +0 -99
  21. package/src/lib/dto/contact-types.ts +0 -41
  22. package/src/lib/dto/contact.ts +0 -85
  23. package/src/lib/dto/contact2item.ts +0 -23
  24. package/src/lib/dto/contactus-space.ts +0 -8
  25. package/src/lib/dto/index.ts +0 -14
  26. package/src/lib/dto/member-types.ts +0 -29
  27. package/src/lib/dto/member.ts +0 -87
  28. package/src/lib/dto/person.ts +0 -92
  29. package/src/lib/dto/pet-kind.ts +0 -16
  30. package/src/lib/dto/requests.ts +0 -1
  31. package/src/lib/dto/term.ts +0 -28
  32. package/src/lib/sanity.spec.ts +0 -5
  33. package/src/test-setup.ts +0 -3
  34. package/tsconfig.json +0 -13
  35. package/tsconfig.lib.json +0 -19
  36. package/tsconfig.lib.prod.json +0 -7
  37. package/tsconfig.spec.json +0 -31
  38. package/vite.config.mts +0 -10
@@ -0,0 +1,180 @@
1
+ import { excludeUndefined } from '@sneat/core';
2
+ import { isNameEmpty, mustHaveAtLeastOneName } from '@sneat/auth-models';
3
+ import { Totals } from '@sneat/space-models';
4
+ import { validateRelated } from '@sneat/dto';
5
+
6
+ function validateAddress(address, requires) {
7
+ if (!address) {
8
+ throw new Error('Address is required');
9
+ }
10
+ if (address.countryID === '') {
11
+ throw new Error('Country is required');
12
+ }
13
+ if (requires?.city && !address?.city?.trim()) {
14
+ throw new Error('Address city is required');
15
+ }
16
+ if (requires?.lines && !address?.lines?.trim()) {
17
+ throw new Error('Address text is required');
18
+ }
19
+ return address;
20
+ }
21
+
22
+ function filterContactsByTextAndRole(// TODO(help-wanted): add test
23
+ contacts, text, role) {
24
+ return !text && !role
25
+ ? contacts
26
+ : contacts?.filter((c) => {
27
+ return isContactPassFilter(c, text, role);
28
+ });
29
+ }
30
+ function isContactPassFilter(c, text, role) {
31
+ const { brief } = c;
32
+ const names = brief?.names;
33
+ return ((!role || (!!c.brief?.roles && c?.brief.roles.includes(role))) &&
34
+ (!text ||
35
+ brief?.title?.toLowerCase().includes(text) ||
36
+ (!!names &&
37
+ (!!names.firstName?.toLowerCase().includes(text) ||
38
+ !!names.lastName?.toLowerCase().includes(text) ||
39
+ !!names.nickName?.toLowerCase().includes(text) ||
40
+ !!names.middleName?.toLowerCase().includes(text) ||
41
+ !!names.fullName?.toLowerCase().includes(text)))));
42
+ }
43
+ function addSpace(space) {
44
+ return (item) => ({ ...item, space });
45
+ }
46
+
47
+ const ContactRoleEmployee = 'employee';
48
+ const ContactRoleInsurer = 'insurer';
49
+ const ContactRolePet = 'pet';
50
+ const ContactRoleFriend = 'friend';
51
+ const ContactRoleRelative = 'relative';
52
+ // export type ContactRoleFriend = 'friend';
53
+ const ContactRoleParentOfFriend = 'parent_of_friend';
54
+ const ContactRoleDriver = 'driver';
55
+ const ContactRoleLocation = 'location';
56
+ const ContactRoleShip = 'ship';
57
+
58
+ function relationshipTitle(id) {
59
+ // TODO: Needs fix to replace all _ with space
60
+ return id ? id[0].toUpperCase() + id.substring(1).replace(/_+/g, ' ') : '';
61
+ }
62
+ const MemberRelationshipOther = 'other';
63
+ const MemberRelationshipUndisclosed = 'undisclosed';
64
+ // export function newCommuneMemberInfo(id: string, m: IMemberDto): ITeamMemberInfo {
65
+ // return excludeUndefined({
66
+ // id: id,
67
+ // userID: m.uid,
68
+ // title: m.title && m.uid && m.title === m.uid ? undefined : m.title,
69
+ // ageGroup: m.ageGroup,
70
+ // roles: m.roles,
71
+ // gender: m.gender,
72
+ // groupIds: m.groupIDs,
73
+ // });
74
+ // }
75
+ function memberDtoFromMemberInfo(memberInfo, spaceID, title) {
76
+ const memberType = 'member';
77
+ return excludeUndefined({
78
+ ...memberInfo,
79
+ spaceID,
80
+ title,
81
+ type: memberType,
82
+ });
83
+ }
84
+ const MemberGroupTypeAdults = 'adults';
85
+ const MemberGroupTypeKids = 'kids';
86
+ const MemberGroupTypePets = 'pets';
87
+ const MemberGroupTypeOther = 'other';
88
+
89
+ function relatedPersonToPerson(v) {
90
+ const v2 = { ...excludeUndefined(v) };
91
+ delete v2['related'];
92
+ return v2;
93
+ }
94
+ function isPersonNotReady(p, requires) {
95
+ const nameIsEmpty = isNameEmpty(p.names);
96
+ const isMissingRequiredFields = (!!requires.lastName?.required && !p.names?.lastName) ||
97
+ (!!requires.ageGroup?.required && !p.ageGroup) ||
98
+ (!!requires.gender?.required && !p.gender);
99
+ return nameIsEmpty || isMissingRequiredFields;
100
+ }
101
+ function isPersonReady(p, requires) {
102
+ return !isPersonNotReady(p, requires);
103
+ }
104
+ function isRelatedPersonNotReady(p, requires) {
105
+ return (isPersonNotReady(p, requires) ||
106
+ (p.type !== 'animal' && !!requires.relatedAs?.required && !p.related));
107
+ }
108
+ function isRelatedPersonReady(p, requires) {
109
+ return !isRelatedPersonNotReady(p, requires);
110
+ }
111
+ const emptyContactBase = {
112
+ type: undefined,
113
+ };
114
+ const emptyMemberPerson = emptyContactBase;
115
+
116
+ var PetKinds;
117
+ (function (PetKinds) {
118
+ PetKinds["dog"] = "dog";
119
+ PetKinds["cat"] = "cat";
120
+ PetKinds["hamster"] = "hamster";
121
+ PetKinds["rabbit"] = "rabbit";
122
+ PetKinds["bird"] = "bird";
123
+ PetKinds["fish"] = "fish";
124
+ PetKinds["turtle"] = "turtle";
125
+ PetKinds["snake"] = "snake";
126
+ PetKinds["lizard"] = "lizard";
127
+ PetKinds["horse"] = "horse";
128
+ PetKinds["pig"] = "pig";
129
+ PetKinds["cow"] = "cow";
130
+ })(PetKinds || (PetKinds = {}));
131
+
132
+ const ContactTypePerson = 'person', ContactTypeCompany = 'company', ContactTypeLocation = 'location', ContactTypeAnimal = 'animal', ContactTypeVehicle = 'vehicle';
133
+
134
+ const RoleSpaceMember = 'member';
135
+ const MemberRoleContributor = 'contributor';
136
+ const MemberRoleSpectator = 'spectator';
137
+ const MemberRoleParish = 'pastor';
138
+ var FamilyMemberRelation;
139
+ (function (FamilyMemberRelation) {
140
+ FamilyMemberRelation["child"] = "child";
141
+ FamilyMemberRelation["cousin"] = "cousin";
142
+ FamilyMemberRelation["grandparent"] = "grandparent";
143
+ FamilyMemberRelation["grandparentInLaw"] = "grandparent_in_law";
144
+ FamilyMemberRelation["parent"] = "parent";
145
+ FamilyMemberRelation["parentInLaw"] = "parent_in_law";
146
+ FamilyMemberRelation["partner"] = "partner";
147
+ FamilyMemberRelation["sibling"] = "sibling";
148
+ FamilyMemberRelation["spouse"] = "spouse";
149
+ })(FamilyMemberRelation || (FamilyMemberRelation = {}));
150
+
151
+ class Member {
152
+ constructor(member, isChecked = false) {
153
+ this.member = member;
154
+ this.isChecked = isChecked;
155
+ this.totals = new Totals(member.dbo?.totals);
156
+ }
157
+ get id() {
158
+ return this.member.id;
159
+ }
160
+ get title() {
161
+ return this.member.brief?.title || this.member.id;
162
+ }
163
+ get emoji() {
164
+ return this.member.dbo?.ageGroup === 'child' ? '🧒' : '🧑';
165
+ }
166
+ }
167
+
168
+ function validateCreateSpaceMemberRequest(request) {
169
+ mustHaveAtLeastOneName(request.names);
170
+ validateRelated(request.related);
171
+ }
172
+
173
+ // TODO: move to services?
174
+
175
+ /**
176
+ * Generated bundle index. Do not edit.
177
+ */
178
+
179
+ export { ContactRoleDriver, ContactRoleEmployee, ContactRoleFriend, ContactRoleInsurer, ContactRoleLocation, ContactRoleParentOfFriend, ContactRolePet, ContactRoleRelative, ContactRoleShip, ContactTypeAnimal, ContactTypeCompany, ContactTypeLocation, ContactTypePerson, ContactTypeVehicle, FamilyMemberRelation, Member, MemberGroupTypeAdults, MemberGroupTypeKids, MemberGroupTypeOther, MemberGroupTypePets, MemberRelationshipOther, MemberRelationshipUndisclosed, MemberRoleContributor, MemberRoleParish, MemberRoleSpectator, PetKinds, RoleSpaceMember, addSpace, emptyContactBase, emptyMemberPerson, filterContactsByTextAndRole, isContactPassFilter, isPersonNotReady, isPersonReady, isRelatedPersonNotReady, isRelatedPersonReady, memberDtoFromMemberInfo, relatedPersonToPerson, relationshipTitle, validateAddress, validateCreateSpaceMemberRequest };
180
+ //# sourceMappingURL=sneat-contactus-core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sneat-contactus-core.mjs","sources":["../../../../../libs/contactus/core/src/lib/dto/address.ts","../../../../../libs/contactus/core/src/lib/dto/contact.ts","../../../../../libs/contactus/core/src/lib/dto/contact-roles.ts","../../../../../libs/contactus/core/src/lib/dto/member.ts","../../../../../libs/contactus/core/src/lib/dto/person.ts","../../../../../libs/contactus/core/src/lib/dto/pet-kind.ts","../../../../../libs/contactus/core/src/lib/dto/contact-types.ts","../../../../../libs/contactus/core/src/lib/dto/member-types.ts","../../../../../libs/contactus/core/src/lib/contexts/person-context.ts","../../../../../libs/contactus/core/src/lib/apidto/requests.ts","../../../../../libs/contactus/core/src/lib/apidto/index.ts","../../../../../libs/contactus/core/src/sneat-contactus-core.ts"],"sourcesContent":["export interface IAddress {\n readonly countryID: string;\n readonly zipCode?: string;\n readonly state?: string;\n readonly city?: string;\n readonly lines?: string;\n}\n\nexport function validateAddress(\n address?: IAddress,\n requires?: { city?: boolean; lines?: boolean },\n): IAddress {\n if (!address) {\n throw new Error('Address is required');\n }\n if (address.countryID === '') {\n throw new Error('Country is required');\n }\n if (requires?.city && !address?.city?.trim()) {\n throw new Error('Address city is required');\n }\n if (requires?.lines && !address?.lines?.trim()) {\n throw new Error('Address text is required');\n }\n return address;\n}\n","import {\n IIdAndBrief,\n IIdAndBriefAndDbo,\n IIdAndBriefAndOptionalDbo,\n ISpaceItemBriefWithSpace,\n} from '@sneat/core';\nimport { IWithRelatedAndRelatedIDs } from '@sneat/dto';\nimport { ISpaceRef } from '@sneat/core';\nimport { IContactBase } from './contact-base';\nimport { ContactRole } from './contact-roles';\nimport { IContact2Asset } from './contact2item';\nimport { IPersonRecord } from './person';\n\n// // Default value: 'optional'\nexport type RequirementOption = 'required' | 'optional' | 'excluded';\n\nexport interface IContactBrief extends IContactBase {\n readonly parentID?: string;\n}\n\nexport type IContactWithBrief = IIdAndBrief<IContactBrief>;\n\nexport function filterContactsByTextAndRole( // TODO(help-wanted): add test\n contacts: readonly IContactWithCheck[] | undefined,\n text: string,\n role?: ContactRole,\n): readonly IContactWithCheck[] | undefined {\n return !text && !role\n ? contacts\n : contacts?.filter((c) => {\n return isContactPassFilter(c, text, role);\n });\n}\n\nexport function isContactPassFilter(\n c: IContactWithBrief,\n text: string,\n role?: ContactRole,\n): boolean {\n const { brief } = c;\n const names = brief?.names;\n return (\n (!role || (!!c.brief?.roles && c?.brief.roles.includes(role))) &&\n (!text ||\n brief?.title?.toLowerCase().includes(text) ||\n (!!names &&\n (!!names.firstName?.toLowerCase().includes(text) ||\n !!names.lastName?.toLowerCase().includes(text) ||\n !!names.nickName?.toLowerCase().includes(text) ||\n !!names.middleName?.toLowerCase().includes(text) ||\n !!names.fullName?.toLowerCase().includes(text))))\n );\n}\n\nexport interface IContactWithBriefAndSpace extends IContactWithBrief {\n readonly space: ISpaceRef;\n}\n\nexport function addSpace<IBrief>(\n space: ISpaceRef,\n): (item: IIdAndBrief<IBrief>) => ISpaceItemBriefWithSpace<IBrief> {\n return (item) => ({ ...item, space });\n}\n\nexport interface IContactDbo\n extends IContactBase, IPersonRecord, IWithRelatedAndRelatedIDs {\n readonly assets?: IContact2Asset[]; // TODO: Remove as it can be replaced with IWithRelatedItems?\n}\n\nexport type IContactWithDbo = IIdAndBriefAndDbo<IContactBrief, IContactDbo>;\n\nexport type IContactWithOptionalDbo = IIdAndBriefAndOptionalDbo<\n IContactBrief,\n IContactDbo\n>;\n\nexport interface IContactWithDboAndSpace\n extends IContactWithDbo, IContactWithBriefAndSpace {}\n\nexport interface IContactWithOptionalDboAndSpace\n extends IContactWithOptionalDbo, IContactWithBriefAndSpace {}\n\nexport interface IContactWithCheck extends IContactWithOptionalDboAndSpace {\n readonly isChecked?: boolean;\n}\n","export const ContactRoleEmployee = 'employee';\nexport const ContactRoleInsurer = 'insurer';\n\nexport const ContactRolePet = 'pet';\nexport const ContactRoleFriend = 'friend';\nexport const ContactRoleRelative = 'relative';\n\n// export type ContactRoleFriend = 'friend';\nexport const ContactRoleParentOfFriend = 'parent_of_friend';\nexport const ContactRoleDriver = 'driver';\nexport const ContactRoleLocation = 'location';\nexport type ContactRoleDwellingRelated =\n | typeof ContactRoleInsurer\n | 'cleaner'\n | 'gardener'\n | 'plumber'\n | 'handyman'\n | 'gp'\n | 'landlord'\n | 'tenant'\n | 'realtor';\nexport type ContactRoleVehicle =\n | typeof ContactRoleInsurer\n | 'mechanic'\n | 'electrician'\n | 'handyman'\n | typeof ContactRoleDriver;\nexport type ContactRoleMedRelated = 'GP' | 'med_specialist';\nexport type ContactRoleFamilyRelated =\n | typeof RoleSpaceMember\n | typeof ContactRolePet\n | typeof ContactRoleFriend\n | typeof ContactRoleRelative;\nexport type ContactRoleWorkRelated =\n | typeof ContactRoleEmployee\n | 'client'\n | 'supplier';\nexport type ContactRoleKidRelated =\n | typeof ContactRoleFriend\n | typeof ContactRoleParentOfFriend\n | 'teacher'\n | 'babysitter';\nexport const ContactRoleShip = 'ship';\nexport type ContactRoleLogistSubContact =\n | typeof ContactRoleShip\n | typeof ContactRoleLocation;\nexport type ContactRoleLogistParentContact = 'shipper' | 'dispatcher';\nimport { MemberRole, RoleSpaceMember } from './member-types';\n\nexport type LogistOrderContactRole =\n | ContactRoleLogistParentContact\n | ContactRoleLogistSubContact\n | 'consignee'\n | 'dispatch_point'\n | 'receive_point'\n | 'dispatch_agent'\n | 'receive_agent'\n | 'buyer'\n | 'courier'\n | 'freight_agent'\n | 'notify_party'\n | 'port'\n | 'port_from'\n | 'port_from_location'\n | 'port_to'\n | 'port_to_location'\n | 'shipping_line'\n | 'truck'\n | 'trucker'\n | 'warehouse';\nexport type ContactRole =\n | MemberRole\n | typeof RoleSpaceMember\n | ContactRoleFamilyRelated\n | ContactRoleWorkRelated\n | ContactRoleKidRelated\n | ContactRoleMedRelated\n | ContactRoleDwellingRelated\n | ContactRoleVehicle\n | LogistOrderContactRole\n | 'applicant';\n\nexport interface IContactRoleBrief {\n readonly title: string;\n readonly titlePlural?: string;\n readonly emoji?: string;\n readonly finder?: string;\n}\n\nexport interface IContactRoleWithIdAndBrief {\n readonly id: ContactRole;\n readonly brief: IContactRoleBrief;\n readonly hideInNewContactForm?: boolean;\n}\n\nexport interface IContactRoleWithIdAndOptionalBrief {\n readonly id: ContactRole;\n readonly brief?: IContactRoleBrief;\n}\n","import { IAvatar, SpaceMemberType } from '@sneat/auth-models';\nimport { EnumAsUnionOfKeys, excludeUndefined } from '@sneat/core';\nimport { ITitledRecordInfo, ITotalsHolder, IVerification } from '@sneat/dto';\nimport { IContactBrief } from './contact';\nimport { IContactGroupBrief } from './contact-group-brief';\nimport { FamilyMemberRelation, MemberRole } from './member-types';\nimport { IPersonRecord, ISpaceMemberInfo } from './person';\n\nexport function relationshipTitle(id: string): string {\n // TODO: Needs fix to replace all _ with space\n return id ? id[0].toUpperCase() + id.substring(1).replace(/_+/g, ' ') : '';\n}\n\nexport type FamilyMemberRelations = EnumAsUnionOfKeys<\n typeof FamilyMemberRelation\n>;\n\nexport const MemberRelationshipOther = 'other';\nexport const MemberRelationshipUndisclosed = 'undisclosed';\n\nexport type MemberRelationship =\n | FamilyMemberRelations\n | typeof MemberRelationshipOther\n | typeof MemberRelationshipUndisclosed;\n\nexport interface IMemberBase\n extends IPersonRecord, IVerification, ITotalsHolder {\n readonly type: SpaceMemberType;\n readonly title?: string;\n readonly userID?: string; // User ID\n readonly roles?: readonly MemberRole[];\n readonly avatar?: IAvatar;\n}\n\nexport type IMemberBrief = IContactBrief;\n\nexport interface IMemberDbo extends IMemberBase {\n position?: string;\n groups?: IContactGroupBrief[];\n}\n\nexport interface IWithContactGroups {\n groupIDs?: readonly string[];\n groups: Record<string, IContactGroupBrief>;\n}\n\n// export function newCommuneMemberInfo(id: string, m: IMemberDto): ITeamMemberInfo {\n// \treturn excludeUndefined({\n// \t\tid: id,\n// \t\tuserID: m.uid,\n// \t\ttitle: m.title && m.uid && m.title === m.uid ? undefined : m.title,\n// \t\tageGroup: m.ageGroup,\n// \t\troles: m.roles,\n// \t\tgender: m.gender,\n// \t\tgroupIds: m.groupIDs,\n// \t});\n// }\n\nexport function memberDtoFromMemberInfo(\n memberInfo: ISpaceMemberInfo,\n spaceID: string,\n title: string,\n): IMemberDbo {\n const memberType: SpaceMemberType = 'member';\n return excludeUndefined({\n ...memberInfo,\n spaceID,\n title,\n type: memberType,\n });\n}\n\n// Deprecated\nexport interface ICommuneDtoMemberGroupInfo extends ITitledRecordInfo {\n members: number;\n}\n\nexport const MemberGroupTypeAdults = 'adults';\nexport const MemberGroupTypeKids = 'kids';\nexport const MemberGroupTypePets = 'pets';\nexport const MemberGroupTypeOther = 'other';\n\nexport type MemberGroupType =\n | typeof MemberGroupTypeAdults\n | typeof MemberGroupTypeKids\n | typeof MemberGroupTypePets\n | typeof MemberGroupTypeOther;\n","import { isNameEmpty } from '@sneat/auth-models';\nimport { excludeUndefined } from '@sneat/core';\nimport { IWithRelatedOnly, IWithSpaceIDs } from '@sneat/dto';\nimport { IContactBase } from './contact-base';\nimport {\n ContactType,\n IPersonRequirements,\n MemberContactType,\n} from './contact-types';\n\nimport { MemberRole } from './member-types';\n\nexport type IPersonBrief = IContactBase;\n\nexport type IPerson = IContactBase;\n\nexport interface ISpaceMemberInfo extends IPerson {\n readonly id?: string;\n readonly userID?: string;\n readonly title?: string;\n readonly groupIDs?: readonly string[];\n readonly roles?: readonly MemberRole[];\n}\n\nexport interface IRelatedPerson extends IPerson, IWithRelatedOnly {\n // relatedAs to current user or a specific contact\n // readonly roles?: string[]; // Either member roles or contact roles\n}\n\nexport interface IMemberPerson extends IRelatedPerson {\n type: MemberContactType;\n}\n\nexport function relatedPersonToPerson(v: IRelatedPerson): IPerson {\n const v2 = { ...excludeUndefined(v) };\n delete v2['related'];\n return v2 as IPerson;\n}\n\nexport interface IRelatedPersonContact extends IRelatedPerson {\n readonly type: 'person';\n}\n\nexport interface ICreatePeronRequest extends IRelatedPersonContact {\n readonly status: 'active' | 'draft';\n}\n\nexport function isPersonNotReady(\n p: IPerson,\n requires: IPersonRequirements,\n): boolean {\n const nameIsEmpty = isNameEmpty(p.names);\n const isMissingRequiredFields =\n (!!requires.lastName?.required && !p.names?.lastName) ||\n (!!requires.ageGroup?.required && !p.ageGroup) ||\n (!!requires.gender?.required && !p.gender);\n return nameIsEmpty || isMissingRequiredFields;\n}\n\nexport function isPersonReady(\n p: IPerson,\n requires: IPersonRequirements,\n): boolean {\n return !isPersonNotReady(p, requires);\n}\n\nexport function isRelatedPersonNotReady(\n p: IRelatedPerson,\n requires: IPersonRequirements,\n): boolean {\n return (\n isPersonNotReady(p, requires) ||\n (p.type !== 'animal' && !!requires.relatedAs?.required && !p.related)\n );\n}\n\nexport function isRelatedPersonReady(\n p: IPerson,\n requires: IPersonRequirements,\n): boolean {\n return !isRelatedPersonNotReady(p, requires);\n}\n\nexport interface IPersonRecord extends IWithSpaceIDs, IPerson {\n /*, IPersonSize*/\n}\n\nexport const emptyContactBase: IContactBase = {\n type: undefined as unknown as ContactType,\n};\n\nexport const emptyMemberPerson = emptyContactBase as IMemberPerson;\n","export enum PetKinds {\n dog = 'dog',\n cat = 'cat',\n hamster = 'hamster',\n rabbit = 'rabbit',\n bird = 'bird',\n fish = 'fish',\n turtle = 'turtle',\n snake = 'snake',\n lizard = 'lizard',\n horse = 'horse',\n pig = 'pig',\n cow = 'cow',\n}\n\nexport type PetKind = keyof typeof PetKinds;\n","import { SpaceMemberType } from '@sneat/auth-models';\nimport { IFormField } from '@sneat/core';\n\nexport const ContactTypePerson = 'person',\n ContactTypeCompany = 'company',\n ContactTypeLocation = 'location',\n ContactTypeAnimal = 'animal',\n ContactTypeVehicle = 'vehicle';\n\nexport type ContactType =\n | SpaceMemberType\n | typeof ContactTypePerson\n | typeof ContactTypeCompany\n | typeof ContactTypeLocation\n | typeof ContactTypeAnimal\n | typeof ContactTypeVehicle\n | 'landlord'\n | 'tenant';\nexport type MemberContactType =\n | typeof ContactTypePerson\n | typeof ContactTypeAnimal;\n\nexport interface IEmail {\n readonly type: 'work' | 'personal';\n readonly address: string;\n}\n\nexport interface IPhone {\n readonly type: 'work' | 'mobile' | 'personal' | 'fax';\n readonly number: string;\n}\n\nexport interface IPersonRequirements {\n readonly lastName?: IFormField;\n readonly ageGroup?: IFormField;\n readonly gender?: IFormField;\n readonly phone?: IFormField;\n readonly email?: IFormField;\n readonly relatedAs?: IFormField;\n readonly roles?: IFormField;\n}\n","export type MembersVisibility = 'private' | 'protected' | 'public';\nexport const RoleSpaceMember = 'member';\nexport const MemberRoleContributor = 'contributor';\nexport const MemberRoleSpectator = 'spectator';\nexport const MemberRoleParish = 'pastor';\nexport type MemberRoleEducation =\n | 'administrator'\n | 'principal'\n | 'pupil'\n | 'teacher';\nexport type MemberRoleRealtor = 'administrator' | 'agent';\nexport type MemberRole =\n | typeof MemberRoleContributor\n | typeof MemberRoleSpectator\n | MemberRoleEducation\n | MemberRoleRealtor\n | typeof MemberRoleParish;\n\nexport enum FamilyMemberRelation {\n child = 'child',\n cousin = 'cousin',\n grandparent = 'grandparent',\n grandparentInLaw = 'grandparent_in_law',\n parent = 'parent',\n parentInLaw = 'parent_in_law',\n partner = 'partner',\n sibling = 'sibling',\n spouse = 'spouse',\n}\n","import { ISpaceItemWithBriefAndDbo } from '@sneat/core';\nimport {\n IContactGroupBrief,\n IContactGroupDbo,\n IMemberBrief,\n IMemberDbo,\n} from '../dto';\nimport { ISpaceItemNavContext, Totals } from '@sneat/space-models';\nimport { IPerson, IPersonBrief } from '../dto';\n\nexport type IMemberContext = ISpaceItemNavContext<IMemberBrief, IMemberDbo>;\nexport type IPersonContext = ISpaceItemWithBriefAndDbo<IPersonBrief, IPerson>;\n\nexport type IMemberGroupContext = ISpaceItemNavContext<\n IContactGroupBrief,\n IContactGroupDbo\n>;\n\nexport class Member {\n // TODO - document usage or remove\n public readonly totals: Totals;\n\n constructor(\n public member: IMemberContext,\n public isChecked = false,\n ) {\n this.totals = new Totals(member.dbo?.totals);\n }\n\n public get id(): string {\n return this.member.id;\n }\n\n public get title(): string {\n return this.member.brief?.title || this.member.id;\n }\n\n public get emoji(): string {\n return this.member.dbo?.ageGroup === 'child' ? '🧒' : '🧑';\n }\n}\n","import { mustHaveAtLeastOneName } from '@sneat/auth-models';\nimport { validateRelated } from '@sneat/dto';\nimport {\n ContactType,\n IAddress,\n IContact2Asset,\n IContact2ContactInRequest,\n ICreatePeronRequest,\n IMemberBrief,\n IRelatedPerson,\n MemberContactType,\n} from '../dto';\nimport { IMemberContext } from '../contexts';\nimport { ISpaceRequest, SpaceMemberStatus } from '@sneat/space-models';\n\nexport interface ICreateSpaceMemberRequest\n extends ISpaceRequest, IRelatedPerson {\n readonly type: MemberContactType;\n readonly status: SpaceMemberStatus;\n readonly countryID: string;\n readonly roles: readonly string[];\n readonly message?: string;\n}\n\nexport function validateCreateSpaceMemberRequest(\n request: ICreateSpaceMemberRequest,\n): void {\n mustHaveAtLeastOneName(request.names);\n validateRelated(request.related);\n}\n\nexport interface ICreateContactBaseRequest extends ISpaceRequest {\n readonly status: 'active' | 'draft';\n readonly type: ContactType;\n // countryID: string;\n readonly parentContactID?: string;\n readonly roles?: readonly string[];\n readonly relatedToAssets?: readonly IContact2Asset[];\n readonly relatedToContacts?: Readonly<\n Record<string, IContact2ContactInRequest>\n >;\n}\n\nexport interface ICreateContactPersonRequest extends ICreateContactBaseRequest {\n readonly type: 'person';\n readonly person?: ICreatePeronRequest;\n}\n\nexport interface ICreateContactLocationRequest extends ICreateContactBaseRequest {\n readonly type: 'location';\n readonly location?: ICreateLocationRequest;\n}\n\nexport interface IBasicContactRequest {\n // type: ContactType;\n // relationship?: string;\n // message?: string;\n readonly title: string;\n // parentContactID?: string;\n}\n\nexport interface ICreateContactBasicRequest extends ICreateContactBaseRequest {\n readonly basic: IBasicContactRequest;\n}\n\nexport interface ICreateLocationBaseRequest {\n readonly title: string;\n readonly address: IAddress;\n}\n\nexport type ICreateLocationRequest = ICreateLocationBaseRequest;\nexport type ICreateCompanyRequest = ICreateLocationBaseRequest;\n\nexport interface ICreateContactCompanyRequest extends ICreateContactBaseRequest {\n company?: ICreateCompanyRequest;\n}\n\nexport type ICreateContactRequest =\n | ICreateContactPersonRequest\n | ICreateContactCompanyRequest\n | ICreateContactLocationRequest\n | ICreateContactBasicRequest;\n\nexport interface IBy {\n readonly memberID?: string;\n readonly userID?: string;\n readonly title: string;\n}\n\ninterface IInvite {\n readonly message?: string;\n}\n\nexport interface IInviteFromContact {\n readonly memberID: string;\n readonly userID?: string;\n readonly title?: string;\n}\n\nexport type InviteChannel = 'email' | 'sms' | 'link';\n\nexport interface IInviteToContact {\n readonly channel: InviteChannel;\n readonly address?: string;\n readonly memberID?: string;\n readonly title?: string;\n}\n\nexport interface IPersonalInvite extends IInvite {\n readonly space: { readonly id: string; readonly title: string };\n readonly memberID: string;\n readonly from: IInviteFromContact;\n readonly to: IInviteToContact;\n}\n\nexport interface IAddSpaceMemberResponse {\n readonly member: IMemberContext;\n}\n\nexport interface IAcceptPersonalInviteRequest extends ISpaceRequest {\n readonly inviteID: string;\n readonly pin: string; // Do not make number as we can lose leading 0's\n readonly member?: IMemberBrief;\n // fullName?: string;\n // email?: string;\n}\n\nexport interface ICreatePersonalInviteRequest extends ISpaceRequest {\n readonly to: IInviteToContact;\n readonly message: string;\n}\n","// TODO: move to services?\nexport * from './requests';\nexport * from './responses';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAQM,SAAU,eAAe,CAC7B,OAAkB,EAClB,QAA8C,EAAA;IAE9C,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC;IACxC;AACA,IAAA,IAAI,OAAO,CAAC,SAAS,KAAK,EAAE,EAAE;AAC5B,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC;IACxC;AACA,IAAA,IAAI,QAAQ,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;AAC5C,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;IAC7C;AACA,IAAA,IAAI,QAAQ,EAAE,KAAK,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;AAC9C,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;IAC7C;AACA,IAAA,OAAO,OAAO;AAChB;;ACHM,SAAU,2BAA2B;AACzC,QAAkD,EAClD,IAAY,EACZ,IAAkB,EAAA;AAElB,IAAA,OAAO,CAAC,IAAI,IAAI,CAAC;AACf,UAAE;UACA,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,KAAI;YACrB,OAAO,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;AAC3C,QAAA,CAAC,CAAC;AACR;SAEgB,mBAAmB,CACjC,CAAoB,EACpB,IAAY,EACZ,IAAkB,EAAA;AAElB,IAAA,MAAM,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,IAAA,IAAW,KAAK,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;IACnD;AAEA,IAAA,IAAW,KAAK,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,IAAI;IAC5D;AACD;;AChBK,SAAU,gCAAgC,CAC9C,OAAkC,EAAA;AAElC,IAAA,sBAAsB,CAAC,OAAO,CAAC,KAAK,CAAC;AACrC,IAAA,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC;AAClC;;AC7BA;;ACAA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sneat/contactus-core",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -11,5 +11,16 @@
11
11
  "dependencies": {
12
12
  "tslib": "2.8.1"
13
13
  },
14
- "sideEffects": false
14
+ "sideEffects": false,
15
+ "module": "fesm2022/sneat-contactus-core.mjs",
16
+ "typings": "types/sneat-contactus-core.d.ts",
17
+ "exports": {
18
+ "./package.json": {
19
+ "default": "./package.json"
20
+ },
21
+ ".": {
22
+ "types": "./types/sneat-contactus-core.d.ts",
23
+ "default": "./fesm2022/sneat-contactus-core.mjs"
24
+ }
25
+ }
15
26
  }