@voyantjs/customer-portal 0.2.0 → 0.3.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/LICENSE ADDED
@@ -0,0 +1,109 @@
1
+ # Functional Source License, Version 1.1, Apache 2.0 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-Apache-2.0
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 PixelMakers Studio SRL
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly
28
+ display and redistribute the Software for any Permitted Purpose identified
29
+ below.
30
+
31
+ ### Permitted Purpose
32
+
33
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing
34
+ Use means making the Software available to others in a commercial product or
35
+ service that:
36
+
37
+ 1. substitutes for the Software;
38
+
39
+ 2. substitutes for any other product or service we offer using the Software
40
+ that exists as of the date we make the Software available; or
41
+
42
+ 3. offers the same or substantially similar functionality as the Software.
43
+
44
+ Permitted Purposes specifically include using the Software:
45
+
46
+ 1. for your internal use and access;
47
+
48
+ 2. for non-commercial education;
49
+
50
+ 3. for non-commercial research; and
51
+
52
+ 4. in connection with professional services that you provide to a licensee
53
+ using the Software in accordance with these Terms and Conditions.
54
+
55
+ ### Patents
56
+
57
+ To the extent your use for a Permitted Purpose would necessarily infringe
58
+ our patents, the license grant above includes a license under our patents.
59
+ If you make a claim against any party that the Software infringes or
60
+ contributes to the infringement of any patent, then your patent license to
61
+ the Software ends immediately.
62
+
63
+ ### Redistribution
64
+
65
+ The Terms and Conditions apply to all copies, modifications and derivatives
66
+ of the Software.
67
+
68
+ If you redistribute any copies, modifications or derivatives of the
69
+ Software, you must include a copy of or a link to these Terms and Conditions
70
+ and not remove any copyright notices provided in or with the Software.
71
+
72
+ ### Disclaimer
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS
75
+ OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A
76
+ PARTICULAR PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
77
+
78
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO
79
+ THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
80
+ DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
81
+
82
+ ### Trademarks
83
+
84
+ Except for displaying the License Details and identifying us as the origin
85
+ of the Software, you have no right under these Terms and Conditions to use
86
+ our trademarks, trade names, service marks or product names.
87
+
88
+ ---
89
+
90
+ ## Grant of Future License
91
+
92
+ We hereby irrevocably grant you an additional license to use the Software
93
+ under the Apache License, Version 2.0 that is effective on the second
94
+ anniversary of the date we make the Software available. On or after that
95
+ date, you may use the Software under the Apache License, Version 2.0, in
96
+ which case the following will apply:
97
+
98
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
99
+ use this file except in compliance with the License.
100
+
101
+ You may obtain a copy of the License at
102
+
103
+ http://www.apache.org/licenses/LICENSE-2.0
104
+
105
+ Unless required by applicable law or agreed to in writing, software
106
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
107
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
108
+ License for the specific language governing permissions and limitations
109
+ under the License.
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ export { customerPortalRoutes } from "./routes.js";
5
5
  export type { PublicCustomerPortalRoutes } from "./routes-public.js";
6
6
  export { publicCustomerPortalRoutes } from "./routes-public.js";
7
7
  export { publicCustomerPortalService } from "./service-public.js";
8
- export type { BootstrapCustomerPortalInput, BootstrapCustomerPortalResult, CreateCustomerPortalCompanionInput, CustomerPortalBookingDetail, CustomerPortalBookingDocument, CustomerPortalBookingSummary, CustomerPortalBootstrapCandidate, CustomerPortalCompanion, CustomerPortalContactExistsQuery, CustomerPortalContactExistsResult, CustomerPortalProfile, UpdateCustomerPortalCompanionInput, UpdateCustomerPortalProfileInput, } from "./validation-public.js";
9
- export { bootstrapCustomerPortalResultSchema, bootstrapCustomerPortalSchema, createCustomerPortalCompanionSchema, customerPortalBookingDetailSchema, customerPortalBookingDocumentSchema, customerPortalBookingSummarySchema, customerPortalBootstrapCandidateSchema, customerPortalCompanionSchema, customerPortalContactExistsQuerySchema, customerPortalContactExistsResultSchema, customerPortalProfileSchema, updateCustomerPortalCompanionSchema, updateCustomerPortalProfileSchema, } from "./validation-public.js";
8
+ export type { BootstrapCustomerPortalInput, BootstrapCustomerPortalResult, CreateCustomerPortalCompanionInput, CustomerPortalBookingDetail, CustomerPortalBookingDocument, CustomerPortalBookingSummary, CustomerPortalBootstrapCandidate, CustomerPortalCompanion, CustomerPortalContactExistsQuery, CustomerPortalContactExistsResult, CustomerPortalPhoneContactExistsQuery, CustomerPortalPhoneContactExistsResult, CustomerPortalProfile, UpdateCustomerPortalCompanionInput, UpdateCustomerPortalProfileInput, } from "./validation-public.js";
9
+ export { bootstrapCustomerPortalResultSchema, bootstrapCustomerPortalSchema, createCustomerPortalCompanionSchema, customerPortalBookingDetailSchema, customerPortalBookingDocumentSchema, customerPortalBookingSummarySchema, customerPortalBootstrapCandidateSchema, customerPortalCompanionSchema, customerPortalContactExistsQuerySchema, customerPortalContactExistsResultSchema, customerPortalPhoneContactExistsQuerySchema, customerPortalPhoneContactExistsResultSchema, customerPortalProfileSchema, updateCustomerPortalCompanionSchema, updateCustomerPortalProfileSchema, } from "./validation-public.js";
10
10
  export declare const customerPortalModule: Module;
11
11
  export declare const customerPortalHonoModule: HonoModule;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAKvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AACjE,YAAY,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,kCAAkC,EAClC,2BAA2B,EAC3B,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EAChC,uBAAuB,EACvB,gCAAgC,EAChC,iCAAiC,EACjC,qBAAqB,EACrB,kCAAkC,EAClC,gCAAgC,GACjC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,mCAAmC,EACnC,6BAA6B,EAC7B,mCAAmC,EACnC,iCAAiC,EACjC,mCAAmC,EACnC,kCAAkC,EAClC,sCAAsC,EACtC,6BAA6B,EAC7B,sCAAsC,EACtC,uCAAuC,EACvC,2BAA2B,EAC3B,mCAAmC,EACnC,iCAAiC,GAClC,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,oBAAoB,EAAE,MAElC,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,UAItC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAKvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AACjE,YAAY,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,kCAAkC,EAClC,2BAA2B,EAC3B,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EAChC,uBAAuB,EACvB,gCAAgC,EAChC,iCAAiC,EACjC,qCAAqC,EACrC,sCAAsC,EACtC,qBAAqB,EACrB,kCAAkC,EAClC,gCAAgC,GACjC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,mCAAmC,EACnC,6BAA6B,EAC7B,mCAAmC,EACnC,iCAAiC,EACjC,mCAAmC,EACnC,kCAAkC,EAClC,sCAAsC,EACtC,6BAA6B,EAC7B,sCAAsC,EACtC,uCAAuC,EACvC,2CAA2C,EAC3C,4CAA4C,EAC5C,2BAA2B,EAC3B,mCAAmC,EACnC,iCAAiC,GAClC,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,oBAAoB,EAAE,MAElC,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,UAItC,CAAA"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { publicCustomerPortalRoutes } from "./routes-public.js";
3
3
  export { customerPortalRoutes } from "./routes.js";
4
4
  export { publicCustomerPortalRoutes } from "./routes-public.js";
5
5
  export { publicCustomerPortalService } from "./service-public.js";
6
- export { bootstrapCustomerPortalResultSchema, bootstrapCustomerPortalSchema, createCustomerPortalCompanionSchema, customerPortalBookingDetailSchema, customerPortalBookingDocumentSchema, customerPortalBookingSummarySchema, customerPortalBootstrapCandidateSchema, customerPortalCompanionSchema, customerPortalContactExistsQuerySchema, customerPortalContactExistsResultSchema, customerPortalProfileSchema, updateCustomerPortalCompanionSchema, updateCustomerPortalProfileSchema, } from "./validation-public.js";
6
+ export { bootstrapCustomerPortalResultSchema, bootstrapCustomerPortalSchema, createCustomerPortalCompanionSchema, customerPortalBookingDetailSchema, customerPortalBookingDocumentSchema, customerPortalBookingSummarySchema, customerPortalBootstrapCandidateSchema, customerPortalCompanionSchema, customerPortalContactExistsQuerySchema, customerPortalContactExistsResultSchema, customerPortalPhoneContactExistsQuerySchema, customerPortalPhoneContactExistsResultSchema, customerPortalProfileSchema, updateCustomerPortalCompanionSchema, updateCustomerPortalProfileSchema, } from "./validation-public.js";
7
7
  export const customerPortalModule = {
8
8
  name: "customer-portal",
9
9
  };
package/dist/routes.d.ts CHANGED
@@ -20,7 +20,22 @@ export declare const customerPortalRoutes: import("hono/hono-base").HonoBase<Env
20
20
  status: import("hono/utils/http-status").ContentfulStatusCode;
21
21
  };
22
22
  };
23
- }, "/", "/contact-exists">;
23
+ } & {
24
+ "/contact-exists/phone": {
25
+ $get: {
26
+ input: {};
27
+ output: {
28
+ data: {
29
+ phone: string;
30
+ customerRecordExists: boolean;
31
+ linkedCustomerRecordExists: boolean;
32
+ };
33
+ };
34
+ outputFormat: "json";
35
+ status: import("hono/utils/http-status").ContentfulStatusCode;
36
+ };
37
+ };
38
+ }, "/", "/contact-exists/phone">;
24
39
  export type CustomerPortalRoutes = typeof customerPortalRoutes;
25
40
  export {};
26
41
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAMjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;KACvB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;0BAQ/B,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAA"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AASjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;KACvB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAmB7B,CAAA;AAEJ,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAA"}
package/dist/routes.js CHANGED
@@ -1,9 +1,16 @@
1
1
  import { Hono } from "hono";
2
2
  import { publicCustomerPortalService } from "./service-public.js";
3
- import { customerPortalContactExistsQuerySchema } from "./validation-public.js";
4
- export const customerPortalRoutes = new Hono().get("/contact-exists", async (c) => {
3
+ import { customerPortalContactExistsQuerySchema, customerPortalPhoneContactExistsQuerySchema, } from "./validation-public.js";
4
+ export const customerPortalRoutes = new Hono()
5
+ .get("/contact-exists", async (c) => {
5
6
  const query = customerPortalContactExistsQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
6
7
  return c.json({
7
8
  data: await publicCustomerPortalService.contactExists(c.get("db"), query.email),
8
9
  });
10
+ })
11
+ .get("/contact-exists/phone", async (c) => {
12
+ const query = customerPortalPhoneContactExistsQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
13
+ return c.json({
14
+ data: await publicCustomerPortalService.phoneContactExists(c.get("db"), query.phone),
15
+ });
9
16
  });
@@ -1,7 +1,8 @@
1
1
  import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
- import type { BootstrapCustomerPortalInput, BootstrapCustomerPortalResult, CreateCustomerPortalCompanionInput, CustomerPortalBookingDetail, CustomerPortalBookingSummary, CustomerPortalCompanion, CustomerPortalContactExistsResult, CustomerPortalProfile, UpdateCustomerPortalCompanionInput, UpdateCustomerPortalProfileInput } from "./validation-public.js";
2
+ import type { BootstrapCustomerPortalInput, BootstrapCustomerPortalResult, CreateCustomerPortalCompanionInput, CustomerPortalBookingDetail, CustomerPortalBookingSummary, CustomerPortalCompanion, CustomerPortalContactExistsResult, CustomerPortalPhoneContactExistsResult, CustomerPortalProfile, UpdateCustomerPortalCompanionInput, UpdateCustomerPortalProfileInput } from "./validation-public.js";
3
3
  export declare const publicCustomerPortalService: {
4
4
  contactExists(db: PostgresJsDatabase, email: string): Promise<CustomerPortalContactExistsResult>;
5
+ phoneContactExists(db: PostgresJsDatabase, phone: string): Promise<CustomerPortalPhoneContactExistsResult>;
5
6
  getProfile(db: PostgresJsDatabase, userId: string): Promise<CustomerPortalProfile | null>;
6
7
  updateProfile(db: PostgresJsDatabase, userId: string, input: UpdateCustomerPortalProfileInput): Promise<{
7
8
  profile: CustomerPortalProfile;
@@ -1 +1 @@
1
- {"version":3,"file":"service-public.d.ts","sourceRoot":"","sources":["../src/service-public.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,kCAAkC,EAClC,2BAA2B,EAC3B,4BAA4B,EAE5B,uBAAuB,EACvB,iCAAiC,EACjC,qBAAqB,EACrB,kCAAkC,EAClC,gCAAgC,EACjC,MAAM,wBAAwB,CAAA;AA+U/B,eAAO,MAAM,2BAA2B;sBAEhC,kBAAkB,SACf,MAAM,GACZ,OAAO,CAAC,iCAAiC,CAAC;mBAsBxB,kBAAkB,UAAU,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;sBA8BzF,kBAAkB,UACd,MAAM,SACP,gCAAgC,GACtC,OAAO,CACR;QAAE,OAAO,EAAE,qBAAqB,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,WAAW,GAAG,0BAA0B,CAAA;KAAE,CACzF;kBAmIK,kBAAkB,UACd,MAAM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CAAC,qBAAqB,GAAG,IAAI,CAAC;sBA8BzF,kBAAkB,UACd,MAAM,SACP,gCAAgC,GACtC,OAAO,CACR;QAAE,OAAO,EAAE,qBAAqB,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,WAAW,GAAG,0BAA0B,CAAA;KAAE,CACzF;kBAmIK,kBAAkB,UACd,MAAM,SACP,4BAA4B,GAClC,OAAO,CACN,6BAA6B,GAC7B;QAAE,KAAK,EAAE,WAAW,GAAG,2BAA2B,GAAG,yBAAyB,CAAA;KAAE,CACnF;uBA8IwB,kBAAkB,UAAU,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;wBAiB1F,kBAAkB,UACd,MAAM,SACP,kCAAkC,GACxC,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;wBA0BpC,kBAAkB,UACd,MAAM,eACD,MAAM,SACZ,kCAAkC,GACxC,OAAO,CAAC,uBAAuB,GAAG,IAAI,GAAG,WAAW,CAAC;wBAuClD,kBAAkB,UACd,MAAM,eACD,MAAM,GAClB,OAAO,CAAC,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;qBAyB3C,kBAAkB,UACd,MAAM,GACb,OAAO,CAAC,4BAA4B,EAAE,GAAG,IAAI,CAAC;mBAwD3C,kBAAkB,UACd,MAAM,aACH,MAAM,GAChB,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC;6BAoCf,kBAAkB,UAAU,MAAM,aAAa,MAAM;;;;;;;CAIrF,CAAA"}
@@ -32,6 +32,9 @@ function normalizeNullableString(value) {
32
32
  function normalizeEmail(value) {
33
33
  return value.trim().toLowerCase();
34
34
  }
35
+ function normalizePhone(value) {
36
+ return value.trim();
37
+ }
35
38
  function toCustomerCompanion(row) {
36
39
  return {
37
40
  id: row.id,
@@ -121,6 +124,48 @@ async function listCustomerRecordCandidatesByEmail(db, email) {
121
124
  }));
122
125
  return candidates;
123
126
  }
127
+ async function listCustomerRecordCandidatesByPhone(db, phone) {
128
+ const normalizedPhone = normalizePhone(phone);
129
+ const rows = await db
130
+ .select({
131
+ id: people.id,
132
+ firstName: people.firstName,
133
+ lastName: people.lastName,
134
+ preferredLanguage: people.preferredLanguage,
135
+ preferredCurrency: people.preferredCurrency,
136
+ birthday: people.birthday,
137
+ relation: people.relation,
138
+ status: people.status,
139
+ source: people.source,
140
+ sourceRef: people.sourceRef,
141
+ })
142
+ .from(people)
143
+ .innerJoin(identityContactPoints, and(eq(identityContactPoints.entityType, "person"), eq(identityContactPoints.entityId, people.id), inArray(identityContactPoints.kind, ["phone", "mobile", "whatsapp", "sms"]), or(eq(identityContactPoints.normalizedValue, normalizedPhone), eq(identityContactPoints.value, normalizedPhone))))
144
+ .orderBy(desc(people.updatedAt));
145
+ const uniqueRows = new Map();
146
+ for (const row of rows) {
147
+ if (!uniqueRows.has(row.id)) {
148
+ uniqueRows.set(row.id, row);
149
+ }
150
+ }
151
+ return Array.from(uniqueRows.values()).map((row) => ({
152
+ id: row.id,
153
+ firstName: row.firstName,
154
+ lastName: row.lastName,
155
+ preferredLanguage: row.preferredLanguage ?? null,
156
+ preferredCurrency: row.preferredCurrency ?? null,
157
+ birthday: row.birthday ?? null,
158
+ email: null,
159
+ phone: normalizedPhone,
160
+ address: null,
161
+ city: null,
162
+ country: null,
163
+ relation: row.relation ?? null,
164
+ status: row.status,
165
+ claimedByAnotherUser: row.source === linkedCustomerSource && Boolean(row.sourceRef),
166
+ linkable: row.source === linkedCustomerSource ? row.sourceRef == null : row.sourceRef == null,
167
+ }));
168
+ }
124
169
  async function getCustomerRecord(db, userId) {
125
170
  const personId = await resolveLinkedCustomerRecordId(db, userId);
126
171
  if (!personId) {
@@ -290,6 +335,15 @@ export const publicCustomerPortalService = {
290
335
  linkedCustomerRecordExists: customerCandidates.some((candidate) => candidate.claimedByAnotherUser),
291
336
  };
292
337
  },
338
+ async phoneContactExists(db, phone) {
339
+ const normalizedPhone = normalizePhone(phone);
340
+ const customerCandidates = await listCustomerRecordCandidatesByPhone(db, normalizedPhone);
341
+ return {
342
+ phone: normalizedPhone,
343
+ customerRecordExists: customerCandidates.length > 0,
344
+ linkedCustomerRecordExists: customerCandidates.some((candidate) => candidate.claimedByAnotherUser),
345
+ };
346
+ },
293
347
  async getProfile(db, userId) {
294
348
  const [authProfile, customerRecord] = await Promise.all([
295
349
  getAuthProfileRow(db, userId),
@@ -109,6 +109,14 @@ export declare const customerPortalContactExistsResultSchema: z.ZodObject<{
109
109
  customerRecordExists: z.ZodBoolean;
110
110
  linkedCustomerRecordExists: z.ZodBoolean;
111
111
  }, z.core.$strip>;
112
+ export declare const customerPortalPhoneContactExistsQuerySchema: z.ZodObject<{
113
+ phone: z.ZodString;
114
+ }, z.core.$strip>;
115
+ export declare const customerPortalPhoneContactExistsResultSchema: z.ZodObject<{
116
+ phone: z.ZodString;
117
+ customerRecordExists: z.ZodBoolean;
118
+ linkedCustomerRecordExists: z.ZodBoolean;
119
+ }, z.core.$strip>;
112
120
  export declare const bootstrapCustomerPortalSchema: z.ZodObject<{
113
121
  customerRecordId: z.ZodOptional<z.ZodString>;
114
122
  createCustomerIfMissing: z.ZodDefault<z.ZodBoolean>;
@@ -502,6 +510,8 @@ export type CustomerPortalProfile = z.infer<typeof customerPortalProfileSchema>;
502
510
  export type UpdateCustomerPortalProfileInput = z.infer<typeof updateCustomerPortalProfileSchema>;
503
511
  export type CustomerPortalContactExistsQuery = z.infer<typeof customerPortalContactExistsQuerySchema>;
504
512
  export type CustomerPortalContactExistsResult = z.infer<typeof customerPortalContactExistsResultSchema>;
513
+ export type CustomerPortalPhoneContactExistsQuery = z.infer<typeof customerPortalPhoneContactExistsQuerySchema>;
514
+ export type CustomerPortalPhoneContactExistsResult = z.infer<typeof customerPortalPhoneContactExistsResultSchema>;
505
515
  export type BootstrapCustomerPortalInput = z.infer<typeof bootstrapCustomerPortalSchema>;
506
516
  export type BootstrapCustomerPortalResult = z.infer<typeof bootstrapCustomerPortalResultSchema>;
507
517
  export type CustomerPortalBootstrapCandidate = z.infer<typ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AAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACnF,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAA;AACpG,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAA;AACpG,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC7F,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAA;AAC/F,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA"}
@@ -138,6 +138,14 @@ export const customerPortalContactExistsResultSchema = z.object({
138
138
  customerRecordExists: z.boolean(),
139
139
  linkedCustomerRecordExists: z.boolean(),
140
140
  });
141
+ export const customerPortalPhoneContactExistsQuerySchema = z.object({
142
+ phone: z.string().min(1).max(50),
143
+ });
144
+ export const customerPortalPhoneContactExistsResultSchema = z.object({
145
+ phone: z.string(),
146
+ customerRecordExists: z.boolean(),
147
+ linkedCustomerRecordExists: z.boolean(),
148
+ });
141
149
  export const bootstrapCustomerPortalSchema = z
142
150
  .object({
143
151
  customerRecordId: z.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/customer-portal",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,59 +9,52 @@
9
9
  },
10
10
  "type": "module",
11
11
  "exports": {
12
- ".": "./src/index.ts",
13
- "./routes": "./src/routes.ts",
14
- "./public-routes": "./src/routes-public.ts",
15
- "./public-validation": "./src/validation-public.ts"
16
- },
17
- "scripts": {
18
- "build": "tsc -p tsconfig.json",
19
- "clean": "rm -rf dist",
20
- "prepack": "pnpm run build",
21
- "typecheck": "tsc --noEmit",
22
- "lint": "biome check src/",
23
- "test": "vitest run"
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ },
16
+ "./routes": {
17
+ "types": "./dist/routes.d.ts",
18
+ "import": "./dist/routes.js"
19
+ },
20
+ "./public-routes": {
21
+ "types": "./dist/routes-public.d.ts",
22
+ "import": "./dist/routes-public.js"
23
+ },
24
+ "./public-validation": {
25
+ "types": "./dist/validation-public.d.ts",
26
+ "import": "./dist/validation-public.js"
27
+ }
24
28
  },
25
29
  "dependencies": {
26
- "@voyantjs/bookings": "workspace:*",
27
- "@voyantjs/core": "workspace:*",
28
- "@voyantjs/crm": "workspace:*",
29
- "@voyantjs/db": "workspace:*",
30
- "@voyantjs/hono": "workspace:*",
31
- "@voyantjs/identity": "workspace:*",
32
30
  "drizzle-orm": "^0.45.2",
33
31
  "hono": "^4.12.10",
34
- "zod": "^4.3.6"
32
+ "zod": "^4.3.6",
33
+ "@voyantjs/bookings": "0.3.1",
34
+ "@voyantjs/core": "0.3.1",
35
+ "@voyantjs/crm": "0.3.1",
36
+ "@voyantjs/db": "0.3.1",
37
+ "@voyantjs/hono": "0.3.1",
38
+ "@voyantjs/identity": "0.3.1"
35
39
  },
36
40
  "devDependencies": {
37
- "@voyantjs/voyant-typescript-config": "workspace:*",
38
41
  "typescript": "^6.0.2",
39
- "vitest": "^4.1.2"
42
+ "vitest": "^4.1.2",
43
+ "@voyantjs/voyant-typescript-config": "0.1.0"
40
44
  },
41
45
  "files": [
42
46
  "dist"
43
47
  ],
44
48
  "publishConfig": {
45
- "access": "public",
46
- "exports": {
47
- ".": {
48
- "types": "./dist/index.d.ts",
49
- "import": "./dist/index.js"
50
- },
51
- "./routes": {
52
- "types": "./dist/routes.d.ts",
53
- "import": "./dist/routes.js"
54
- },
55
- "./public-routes": {
56
- "types": "./dist/routes-public.d.ts",
57
- "import": "./dist/routes-public.js"
58
- },
59
- "./public-validation": {
60
- "types": "./dist/validation-public.d.ts",
61
- "import": "./dist/validation-public.js"
62
- }
63
- },
64
- "main": "./dist/index.js",
65
- "types": "./dist/index.d.ts"
66
- }
67
- }
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "build": "tsc -p tsconfig.json",
53
+ "clean": "rm -rf dist",
54
+ "typecheck": "tsc --noEmit",
55
+ "lint": "biome check src/",
56
+ "test": "vitest run"
57
+ },
58
+ "main": "./dist/index.js",
59
+ "types": "./dist/index.d.ts"
60
+ }