@voyantjs/facilities 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/dist/routes.d.ts CHANGED
@@ -63,12 +63,12 @@ export declare const facilitiesRoutes: import("hono/hono-base").HonoBase<Env, {
63
63
  id: string;
64
64
  createdAt: string;
65
65
  updatedAt: string;
66
- description: string | null;
67
66
  parentFacilityId: string | null;
68
67
  ownerType: "internal" | "supplier" | "other" | "organization" | null;
69
68
  ownerId: string | null;
70
69
  status: "active" | "inactive" | "archived";
71
70
  code: string | null;
71
+ description: string | null;
72
72
  tags: string[];
73
73
  };
74
74
  };
@@ -688,8 +688,8 @@ export declare const facilitiesRoutes: import("hono/hono-base").HonoBase<Env, {
688
688
  id: string;
689
689
  createdAt: string;
690
690
  updatedAt: string;
691
- description: string | null;
692
691
  code: string | null;
692
+ description: string | null;
693
693
  facilityId: string;
694
694
  category: "other" | "service" | "amenity" | "accessibility" | "security" | "policy";
695
695
  valueText: string | null;
@@ -0,0 +1,109 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { CreateFacilityInput, FacilityListQuery, UpdateFacilityInput } from "./service-shared.js";
3
+ export declare function listFacilities(db: PostgresJsDatabase, query: FacilityListQuery): Promise<{
4
+ data: ({
5
+ id: string;
6
+ parentFacilityId: string | null;
7
+ ownerType: "internal" | "supplier" | "other" | "organization" | null;
8
+ ownerId: string | null;
9
+ kind: "other" | "property" | "hotel" | "resort" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "camp" | "lodge" | "office" | "attraction" | "restaurant";
10
+ status: "active" | "inactive" | "archived";
11
+ name: string;
12
+ code: string | null;
13
+ description: string | null;
14
+ timezone: string | null;
15
+ tags: string[];
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ } & {
19
+ addressLine1: string | null;
20
+ addressLine2: string | null;
21
+ city: string | null;
22
+ region: string | null;
23
+ country: string | null;
24
+ postalCode: string | null;
25
+ latitude: number | null;
26
+ longitude: number | null;
27
+ address: string | null;
28
+ })[];
29
+ total: number;
30
+ limit: number;
31
+ offset: number;
32
+ }>;
33
+ export declare function getFacilityById(db: PostgresJsDatabase, id: string): Promise<({
34
+ id: string;
35
+ parentFacilityId: string | null;
36
+ ownerType: "internal" | "supplier" | "other" | "organization" | null;
37
+ ownerId: string | null;
38
+ kind: "other" | "property" | "hotel" | "resort" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "camp" | "lodge" | "office" | "attraction" | "restaurant";
39
+ status: "active" | "inactive" | "archived";
40
+ name: string;
41
+ code: string | null;
42
+ description: string | null;
43
+ timezone: string | null;
44
+ tags: string[];
45
+ createdAt: Date;
46
+ updatedAt: Date;
47
+ } & {
48
+ addressLine1: string | null;
49
+ addressLine2: string | null;
50
+ city: string | null;
51
+ region: string | null;
52
+ country: string | null;
53
+ postalCode: string | null;
54
+ latitude: number | null;
55
+ longitude: number | null;
56
+ address: string | null;
57
+ }) | null>;
58
+ export declare function createFacility(db: PostgresJsDatabase, data: CreateFacilityInput): Promise<{
59
+ addressLine1: string | null;
60
+ addressLine2: string | null;
61
+ city: string | null;
62
+ region: string | null;
63
+ postalCode: string | null;
64
+ country: string | null;
65
+ latitude: number | null;
66
+ longitude: number | null;
67
+ address: string | null;
68
+ name: string;
69
+ kind: "other" | "property" | "hotel" | "resort" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "camp" | "lodge" | "office" | "attraction" | "restaurant";
70
+ timezone: string | null;
71
+ id: string;
72
+ createdAt: Date;
73
+ updatedAt: Date;
74
+ parentFacilityId: string | null;
75
+ ownerType: "internal" | "supplier" | "other" | "organization" | null;
76
+ ownerId: string | null;
77
+ status: "active" | "inactive" | "archived";
78
+ code: string | null;
79
+ description: string | null;
80
+ tags: string[];
81
+ }>;
82
+ export declare function updateFacility(db: PostgresJsDatabase, id: string, data: UpdateFacilityInput): Promise<{
83
+ addressLine1: string | null;
84
+ addressLine2: string | null;
85
+ city: string | null;
86
+ region: string | null;
87
+ postalCode: string | null;
88
+ country: string | null;
89
+ latitude: number | null;
90
+ longitude: number | null;
91
+ address: string | null;
92
+ id: string;
93
+ parentFacilityId: string | null;
94
+ ownerType: "internal" | "supplier" | "other" | "organization" | null;
95
+ ownerId: string | null;
96
+ kind: "other" | "property" | "hotel" | "resort" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "camp" | "lodge" | "office" | "attraction" | "restaurant";
97
+ status: "active" | "inactive" | "archived";
98
+ name: string;
99
+ code: string | null;
100
+ description: string | null;
101
+ timezone: string | null;
102
+ tags: string[];
103
+ createdAt: Date;
104
+ updatedAt: Date;
105
+ } | null>;
106
+ export declare function deleteFacility(db: PostgresJsDatabase, id: string): Promise<{
107
+ id: string;
108
+ } | null>;
109
+ //# sourceMappingURL=service-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-core.d.ts","sourceRoot":"","sources":["../src/service-core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAS5B,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DpF;AAED,wBAAsB,eAAe,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;WAMvE;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;GAiDrF;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;UAuD1B;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMtE"}
@@ -0,0 +1,152 @@
1
+ import { identityAddresses } from "@voyantjs/identity/schema";
2
+ import { and, desc, eq, sql } from "drizzle-orm";
3
+ import { facilities } from "./schema.js";
4
+ import { facilityEntityType, formatAddress, hydrateFacilities, paginate, syncFacilityAddress, } from "./service-shared.js";
5
+ export async function listFacilities(db, query) {
6
+ const conditions = [];
7
+ if (query.kind)
8
+ conditions.push(eq(facilities.kind, query.kind));
9
+ if (query.status)
10
+ conditions.push(eq(facilities.status, query.status));
11
+ if (query.ownerType)
12
+ conditions.push(eq(facilities.ownerType, query.ownerType));
13
+ if (query.ownerId)
14
+ conditions.push(eq(facilities.ownerId, query.ownerId));
15
+ if (query.parentFacilityId)
16
+ conditions.push(eq(facilities.parentFacilityId, query.parentFacilityId));
17
+ if (query.country) {
18
+ conditions.push(sql `exists (
19
+ select 1
20
+ from ${identityAddresses}
21
+ where ${identityAddresses.entityType} = ${facilityEntityType}
22
+ and ${identityAddresses.entityId} = ${facilities.id}
23
+ and ${identityAddresses.country} = ${query.country}
24
+ )`);
25
+ }
26
+ if (query.search) {
27
+ const term = `%${query.search}%`;
28
+ conditions.push(sql `(
29
+ ${facilities.name} ilike ${term}
30
+ or ${facilities.code} ilike ${term}
31
+ or ${facilities.description} ilike ${term}
32
+ or exists (
33
+ select 1
34
+ from ${identityAddresses}
35
+ where ${identityAddresses.entityType} = ${facilityEntityType}
36
+ and ${identityAddresses.entityId} = ${facilities.id}
37
+ and (
38
+ ${identityAddresses.fullText} ilike ${term}
39
+ or ${identityAddresses.line1} ilike ${term}
40
+ or ${identityAddresses.city} ilike ${term}
41
+ or ${identityAddresses.country} ilike ${term}
42
+ )
43
+ )
44
+ )`);
45
+ }
46
+ const where = conditions.length > 0 ? and(...conditions) : undefined;
47
+ const page = await paginate(db
48
+ .select()
49
+ .from(facilities)
50
+ .where(where)
51
+ .limit(query.limit)
52
+ .offset(query.offset)
53
+ .orderBy(desc(facilities.updatedAt)), db.select({ count: sql `count(*)::int` }).from(facilities).where(where), query.limit, query.offset);
54
+ return {
55
+ ...page,
56
+ data: await hydrateFacilities(db, page.data),
57
+ };
58
+ }
59
+ export async function getFacilityById(db, id) {
60
+ const [row] = await db.select().from(facilities).where(eq(facilities.id, id)).limit(1);
61
+ if (!row)
62
+ return null;
63
+ const [hydrated] = await hydrateFacilities(db, [row]);
64
+ return hydrated ?? null;
65
+ }
66
+ export async function createFacility(db, data) {
67
+ const { addressLine1, addressLine2, city, region, postalCode, country, latitude, longitude, ...facilityValues } = data;
68
+ const [row] = await db.insert(facilities).values(facilityValues).returning();
69
+ if (!row) {
70
+ throw new Error("Failed to create facility");
71
+ }
72
+ await syncFacilityAddress(db, row.id, {
73
+ addressLine1,
74
+ addressLine2,
75
+ city,
76
+ region,
77
+ postalCode,
78
+ country,
79
+ latitude,
80
+ longitude,
81
+ });
82
+ return {
83
+ ...row,
84
+ addressLine1: addressLine1 ?? null,
85
+ addressLine2: addressLine2 ?? null,
86
+ city: city ?? null,
87
+ region: region ?? null,
88
+ postalCode: postalCode ?? null,
89
+ country: country ?? null,
90
+ latitude: latitude ?? null,
91
+ longitude: longitude ?? null,
92
+ address: formatAddress({
93
+ fullText: null,
94
+ line1: addressLine1 ?? null,
95
+ line2: addressLine2 ?? null,
96
+ city: city ?? null,
97
+ region: region ?? null,
98
+ postalCode: postalCode ?? null,
99
+ country: country ?? null,
100
+ }),
101
+ };
102
+ }
103
+ export async function updateFacility(db, id, data) {
104
+ const existing = await getFacilityById(db, id);
105
+ if (!existing)
106
+ return null;
107
+ const { addressLine1, addressLine2, city, region, postalCode, country, latitude, longitude, ...facilityValues } = data;
108
+ const [row] = await db
109
+ .update(facilities)
110
+ .set({ ...facilityValues, updatedAt: new Date() })
111
+ .where(eq(facilities.id, id))
112
+ .returning();
113
+ if (!row)
114
+ return null;
115
+ await syncFacilityAddress(db, id, {
116
+ addressLine1: addressLine1 ?? existing.addressLine1,
117
+ addressLine2: addressLine2 ?? existing.addressLine2,
118
+ city: city ?? existing.city,
119
+ region: region ?? existing.region,
120
+ postalCode: postalCode ?? existing.postalCode,
121
+ country: country ?? existing.country,
122
+ latitude: latitude ?? existing.latitude,
123
+ longitude: longitude ?? existing.longitude,
124
+ });
125
+ return {
126
+ ...row,
127
+ addressLine1: addressLine1 ?? existing.addressLine1,
128
+ addressLine2: addressLine2 ?? existing.addressLine2,
129
+ city: city ?? existing.city,
130
+ region: region ?? existing.region,
131
+ postalCode: postalCode ?? existing.postalCode,
132
+ country: country ?? existing.country,
133
+ latitude: latitude ?? existing.latitude,
134
+ longitude: longitude ?? existing.longitude,
135
+ address: formatAddress({
136
+ fullText: null,
137
+ line1: addressLine1 ?? existing.addressLine1,
138
+ line2: addressLine2 ?? existing.addressLine2,
139
+ city: city ?? existing.city,
140
+ region: region ?? existing.region,
141
+ postalCode: postalCode ?? existing.postalCode,
142
+ country: country ?? existing.country,
143
+ }),
144
+ };
145
+ }
146
+ export async function deleteFacility(db, id) {
147
+ const [row] = await db
148
+ .delete(facilities)
149
+ .where(eq(facilities.id, id))
150
+ .returning({ id: facilities.id });
151
+ return row ?? null;
152
+ }
@@ -0,0 +1,168 @@
1
+ import type { InsertAddressForEntity, InsertContactPointForEntity, UpdateAddress as UpdateIdentityAddress, UpdateContactPoint as UpdateIdentityContactPoint } from "@voyantjs/identity/validation";
2
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
3
+ import type { CreateFacilityContactInput, FacilityContactListQuery, UpdateFacilityContactInput } from "./service-shared.js";
4
+ export declare function listContactPoints(db: PostgresJsDatabase, facilityId: string): Promise<{
5
+ id: string;
6
+ entityType: string;
7
+ entityId: string;
8
+ kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
9
+ label: string | null;
10
+ value: string;
11
+ normalizedValue: string | null;
12
+ isPrimary: boolean;
13
+ notes: string | null;
14
+ metadata: Record<string, unknown> | null;
15
+ createdAt: Date;
16
+ updatedAt: Date;
17
+ }[]>;
18
+ export declare function createContactPoint(db: PostgresJsDatabase, facilityId: string, data: InsertContactPointForEntity): Promise<{
19
+ value: string;
20
+ kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
21
+ entityType: string;
22
+ entityId: string;
23
+ label: string | null;
24
+ normalizedValue: string | null;
25
+ isPrimary: boolean;
26
+ notes: string | null;
27
+ metadata: Record<string, unknown> | null;
28
+ id: string;
29
+ createdAt: Date;
30
+ updatedAt: Date;
31
+ } | null>;
32
+ export declare function updateContactPoint(db: PostgresJsDatabase, id: string, data: UpdateIdentityContactPoint): Promise<{
33
+ id: string;
34
+ entityType: string;
35
+ entityId: string;
36
+ kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
37
+ label: string | null;
38
+ value: string;
39
+ normalizedValue: string | null;
40
+ isPrimary: boolean;
41
+ notes: string | null;
42
+ metadata: Record<string, unknown> | null;
43
+ createdAt: Date;
44
+ updatedAt: Date;
45
+ } | null>;
46
+ export declare function deleteContactPoint(db: PostgresJsDatabase, id: string): Promise<{
47
+ id: string;
48
+ } | null>;
49
+ export declare function listAddresses(db: PostgresJsDatabase, facilityId: string): Promise<{
50
+ id: string;
51
+ entityType: string;
52
+ entityId: string;
53
+ label: "other" | "primary" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
54
+ fullText: string | null;
55
+ line1: string | null;
56
+ line2: string | null;
57
+ city: string | null;
58
+ region: string | null;
59
+ postalCode: string | null;
60
+ country: string | null;
61
+ latitude: number | null;
62
+ longitude: number | null;
63
+ timezone: string | null;
64
+ isPrimary: boolean;
65
+ notes: string | null;
66
+ metadata: Record<string, unknown> | null;
67
+ createdAt: Date;
68
+ updatedAt: Date;
69
+ }[]>;
70
+ export declare function createAddress(db: PostgresJsDatabase, facilityId: string, data: InsertAddressForEntity): Promise<{
71
+ entityType: string;
72
+ entityId: string;
73
+ label: "other" | "primary" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
74
+ isPrimary: boolean;
75
+ notes: string | null;
76
+ metadata: Record<string, unknown> | null;
77
+ fullText: string | null;
78
+ line1: string | null;
79
+ line2: string | null;
80
+ city: string | null;
81
+ region: string | null;
82
+ postalCode: string | null;
83
+ country: string | null;
84
+ latitude: number | null;
85
+ longitude: number | null;
86
+ timezone: string | null;
87
+ id: string;
88
+ createdAt: Date;
89
+ updatedAt: Date;
90
+ } | null>;
91
+ export declare function updateAddress(db: PostgresJsDatabase, id: string, data: UpdateIdentityAddress): Promise<{
92
+ id: string;
93
+ entityType: string;
94
+ entityId: string;
95
+ label: "other" | "primary" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
96
+ fullText: string | null;
97
+ line1: string | null;
98
+ line2: string | null;
99
+ city: string | null;
100
+ region: string | null;
101
+ postalCode: string | null;
102
+ country: string | null;
103
+ latitude: number | null;
104
+ longitude: number | null;
105
+ timezone: string | null;
106
+ isPrimary: boolean;
107
+ notes: string | null;
108
+ metadata: Record<string, unknown> | null;
109
+ createdAt: Date;
110
+ updatedAt: Date;
111
+ } | null>;
112
+ export declare function deleteAddress(db: PostgresJsDatabase, id: string): Promise<{
113
+ id: string;
114
+ } | null>;
115
+ export declare function listFacilityContacts(db: PostgresJsDatabase, query: FacilityContactListQuery): Promise<{
116
+ data: {
117
+ id: string;
118
+ entityType: string;
119
+ entityId: string;
120
+ role: "other" | "primary" | "legal" | "general" | "reservations" | "operations" | "front_desk" | "sales" | "emergency" | "accounting";
121
+ name: string;
122
+ title: string | null;
123
+ email: string | null;
124
+ phone: string | null;
125
+ isPrimary: boolean;
126
+ notes: string | null;
127
+ metadata: Record<string, unknown> | null;
128
+ createdAt: Date;
129
+ updatedAt: Date;
130
+ }[];
131
+ total: number;
132
+ limit: number;
133
+ offset: number;
134
+ }>;
135
+ export declare function createFacilityContact(db: PostgresJsDatabase, facilityId: string, data: CreateFacilityContactInput): Promise<{
136
+ name: string;
137
+ email: string | null;
138
+ phone: string | null;
139
+ entityType: string;
140
+ entityId: string;
141
+ isPrimary: boolean;
142
+ notes: string | null;
143
+ metadata: Record<string, unknown> | null;
144
+ role: "other" | "primary" | "legal" | "general" | "reservations" | "operations" | "front_desk" | "sales" | "emergency" | "accounting";
145
+ title: string | null;
146
+ id: string;
147
+ createdAt: Date;
148
+ updatedAt: Date;
149
+ } | null>;
150
+ export declare function updateFacilityContact(db: PostgresJsDatabase, id: string, data: UpdateFacilityContactInput): Promise<{
151
+ id: string;
152
+ entityType: string;
153
+ entityId: string;
154
+ role: "other" | "primary" | "legal" | "general" | "reservations" | "operations" | "front_desk" | "sales" | "emergency" | "accounting";
155
+ name: string;
156
+ title: string | null;
157
+ email: string | null;
158
+ phone: string | null;
159
+ isPrimary: boolean;
160
+ notes: string | null;
161
+ metadata: Record<string, unknown> | null;
162
+ createdAt: Date;
163
+ updatedAt: Date;
164
+ } | null>;
165
+ export declare function deleteFacilityContact(db: PostgresJsDatabase, id: string): Promise<{
166
+ id: string;
167
+ } | null>;
168
+ //# sourceMappingURL=service-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-identity.d.ts","sourceRoot":"","sources":["../src/service-identity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,aAAa,IAAI,qBAAqB,EACtC,kBAAkB,IAAI,0BAA0B,EACjD,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAA;AAO5B,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;KAE3E;AAED,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,2BAA2B;;;;;;;;;;;;;UAUlC;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;UAGjC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAEpE;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;KAEvE;AAED,wBAAsB,aAAa,CACjC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;UAU7B;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;UAE5F;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAE/D;AAED,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;GAShC;AAED,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;UAajC;AAED,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;UAGjC;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAE7E"}
@@ -0,0 +1,68 @@
1
+ import { identityService } from "@voyantjs/identity/service";
2
+ import { ensureFacilityExists, facilityContactIdentitySource, facilityEntityType, } from "./service-shared.js";
3
+ export function listContactPoints(db, facilityId) {
4
+ return identityService.listContactPointsForEntity(db, facilityEntityType, facilityId);
5
+ }
6
+ export async function createContactPoint(db, facilityId, data) {
7
+ const facility = await ensureFacilityExists(db, facilityId);
8
+ if (!facility)
9
+ return null;
10
+ return identityService.createContactPoint(db, {
11
+ ...data,
12
+ entityType: facilityEntityType,
13
+ entityId: facilityId,
14
+ });
15
+ }
16
+ export function updateContactPoint(db, id, data) {
17
+ return identityService.updateContactPoint(db, id, data);
18
+ }
19
+ export function deleteContactPoint(db, id) {
20
+ return identityService.deleteContactPoint(db, id);
21
+ }
22
+ export function listAddresses(db, facilityId) {
23
+ return identityService.listAddressesForEntity(db, facilityEntityType, facilityId);
24
+ }
25
+ export async function createAddress(db, facilityId, data) {
26
+ const facility = await ensureFacilityExists(db, facilityId);
27
+ if (!facility)
28
+ return null;
29
+ return identityService.createAddress(db, {
30
+ ...data,
31
+ entityType: facilityEntityType,
32
+ entityId: facilityId,
33
+ });
34
+ }
35
+ export function updateAddress(db, id, data) {
36
+ return identityService.updateAddress(db, id, data);
37
+ }
38
+ export function deleteAddress(db, id) {
39
+ return identityService.deleteAddress(db, id);
40
+ }
41
+ export async function listFacilityContacts(db, query) {
42
+ return identityService.listNamedContacts(db, {
43
+ entityType: facilityEntityType,
44
+ entityId: query.facilityId,
45
+ role: query.role,
46
+ limit: query.limit,
47
+ offset: query.offset,
48
+ });
49
+ }
50
+ export async function createFacilityContact(db, facilityId, data) {
51
+ const facility = await ensureFacilityExists(db, facilityId);
52
+ if (!facility)
53
+ return null;
54
+ return identityService.createNamedContact(db, {
55
+ ...data,
56
+ entityType: facilityEntityType,
57
+ entityId: facilityId,
58
+ metadata: {
59
+ managedBy: facilityContactIdentitySource,
60
+ },
61
+ });
62
+ }
63
+ export async function updateFacilityContact(db, id, data) {
64
+ return identityService.updateNamedContact(db, id, data);
65
+ }
66
+ export async function deleteFacilityContact(db, id) {
67
+ return identityService.deleteNamedContact(db, id);
68
+ }
@@ -0,0 +1,97 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { CreateFacilityFeatureInput, CreateFacilityOperationScheduleInput, FacilityFeatureListQuery, FacilityOperationScheduleListQuery, UpdateFacilityFeatureInput, UpdateFacilityOperationScheduleInput } from "./service-shared.js";
3
+ export declare function listFacilityFeatures(db: PostgresJsDatabase, query: FacilityFeatureListQuery): Promise<{
4
+ data: {
5
+ id: string;
6
+ facilityId: string;
7
+ category: "other" | "service" | "amenity" | "accessibility" | "security" | "policy";
8
+ code: string | null;
9
+ name: string;
10
+ description: string | null;
11
+ valueText: string | null;
12
+ highlighted: boolean;
13
+ sortOrder: number;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ }>;
21
+ export declare function createFacilityFeature(db: PostgresJsDatabase, facilityId: string, data: CreateFacilityFeatureInput): Promise<{
22
+ name: string;
23
+ id: string;
24
+ createdAt: Date;
25
+ updatedAt: Date;
26
+ code: string | null;
27
+ description: string | null;
28
+ facilityId: string;
29
+ category: "other" | "service" | "amenity" | "accessibility" | "security" | "policy";
30
+ valueText: string | null;
31
+ highlighted: boolean;
32
+ sortOrder: number;
33
+ } | null>;
34
+ export declare function updateFacilityFeature(db: PostgresJsDatabase, id: string, data: UpdateFacilityFeatureInput): Promise<{
35
+ id: string;
36
+ facilityId: string;
37
+ category: "other" | "service" | "amenity" | "accessibility" | "security" | "policy";
38
+ code: string | null;
39
+ name: string;
40
+ description: string | null;
41
+ valueText: string | null;
42
+ highlighted: boolean;
43
+ sortOrder: number;
44
+ createdAt: Date;
45
+ updatedAt: Date;
46
+ } | null>;
47
+ export declare function deleteFacilityFeature(db: PostgresJsDatabase, id: string): Promise<{
48
+ id: string;
49
+ } | null>;
50
+ export declare function listFacilityOperationSchedules(db: PostgresJsDatabase, query: FacilityOperationScheduleListQuery): Promise<{
51
+ data: {
52
+ id: string;
53
+ facilityId: string;
54
+ dayOfWeek: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday" | null;
55
+ validFrom: string | null;
56
+ validTo: string | null;
57
+ opensAt: string | null;
58
+ closesAt: string | null;
59
+ closed: boolean;
60
+ notes: string | null;
61
+ createdAt: Date;
62
+ updatedAt: Date;
63
+ }[];
64
+ total: number;
65
+ limit: number;
66
+ offset: number;
67
+ }>;
68
+ export declare function createFacilityOperationSchedule(db: PostgresJsDatabase, facilityId: string, data: CreateFacilityOperationScheduleInput): Promise<{
69
+ notes: string | null;
70
+ id: string;
71
+ createdAt: Date;
72
+ updatedAt: Date;
73
+ facilityId: string;
74
+ dayOfWeek: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday" | null;
75
+ validFrom: string | null;
76
+ validTo: string | null;
77
+ opensAt: string | null;
78
+ closesAt: string | null;
79
+ closed: boolean;
80
+ } | null>;
81
+ export declare function updateFacilityOperationSchedule(db: PostgresJsDatabase, id: string, data: UpdateFacilityOperationScheduleInput): Promise<{
82
+ id: string;
83
+ facilityId: string;
84
+ dayOfWeek: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday" | null;
85
+ validFrom: string | null;
86
+ validTo: string | null;
87
+ opensAt: string | null;
88
+ closesAt: string | null;
89
+ closed: boolean;
90
+ notes: string | null;
91
+ createdAt: Date;
92
+ updatedAt: Date;
93
+ } | null>;
94
+ export declare function deleteFacilityOperationSchedule(db: PostgresJsDatabase, id: string): Promise<{
95
+ id: string;
96
+ } | null>;
97
+ //# sourceMappingURL=service-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-operations.d.ts","sourceRoot":"","sources":["../src/service-operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,oCAAoC,EACpC,wBAAwB,EACxB,kCAAkC,EAClC,0BAA0B,EAC1B,oCAAoC,EACrC,MAAM,qBAAqB,CAAA;AAG5B,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,wBAAwB;;;;;;;;;;;;;;;;;GAmBhC;AAED,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,0BAA0B;;;;;;;;;;;;UAUjC;AAED,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,0BAA0B;;;;;;;;;;;;UAQjC;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAM7E;AAED,wBAAsB,8BAA8B,CAClD,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,kCAAkC;;;;;;;;;;;;;;;;;GAuB1C;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,oCAAoC;;;;;;;;;;;;UAU3C;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,oCAAoC;;;;;;;;;;;;UAQ3C;AAED,wBAAsB,+BAA+B,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMvF"}