@profitstudio/booking-engine 0.0.0-stage → 2.0.0-beta.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/CHANGELOG.md +562 -0
- package/LICENSE +21 -0
- package/README.md +18 -2
- package/THIRD_PARTY_NOTICES.md +41 -0
- package/bin/booking-engine.mjs +575 -0
- package/bin/connect.mjs +408 -0
- package/bin/photos.mjs +82 -0
- package/dist/admin/BookingAdmin.d.ts +22 -0
- package/dist/admin/BookingAdmin.js +337 -0
- package/dist/admin/admin.css +1423 -0
- package/dist/admin/alerts.d.ts +10 -0
- package/dist/admin/alerts.js +11 -0
- package/dist/admin/booking-detail.d.ts +37 -0
- package/dist/admin/booking-detail.js +149 -0
- package/dist/admin/content-inputs.d.ts +15 -0
- package/dist/admin/content-inputs.js +105 -0
- package/dist/admin/context.d.ts +37 -0
- package/dist/admin/context.js +8 -0
- package/dist/admin/drawer.d.ts +14 -0
- package/dist/admin/drawer.js +56 -0
- package/dist/admin/feedback.d.ts +32 -0
- package/dist/admin/feedback.js +70 -0
- package/dist/admin/fields.d.ts +27 -0
- package/dist/admin/fields.js +146 -0
- package/dist/admin/fonts/OFL-Geist-Mono.txt +93 -0
- package/dist/admin/fonts/OFL-Geist.txt +93 -0
- package/dist/admin/fonts/geist-latin-wght-normal.woff2 +0 -0
- package/dist/admin/fonts/geist-mono-latin-wght-normal.woff2 +0 -0
- package/dist/admin/icons.d.ts +66 -0
- package/dist/admin/icons.js +72 -0
- package/dist/admin/image-upload.d.ts +58 -0
- package/dist/admin/image-upload.js +111 -0
- package/dist/admin/index.d.ts +6 -0
- package/dist/admin/index.js +6 -0
- package/dist/admin/lucide.generated.d.ts +521 -0
- package/dist/admin/lucide.generated.js +76 -0
- package/dist/admin/sections/BookingsSection.d.ts +1 -0
- package/dist/admin/sections/BookingsSection.js +137 -0
- package/dist/admin/sections/EmailSection.d.ts +8 -0
- package/dist/admin/sections/EmailSection.js +182 -0
- package/dist/admin/sections/HoursSection.d.ts +1 -0
- package/dist/admin/sections/HoursSection.js +110 -0
- package/dist/admin/sections/OverviewSection.d.ts +1 -0
- package/dist/admin/sections/OverviewSection.js +427 -0
- package/dist/admin/sections/ServicesSection.d.ts +1 -0
- package/dist/admin/sections/ServicesSection.js +236 -0
- package/dist/admin/sections/SettingsSection.d.ts +10 -0
- package/dist/admin/sections/SettingsSection.js +96 -0
- package/dist/admin/sections/WebsiteSection.d.ts +1 -0
- package/dist/admin/sections/WebsiteSection.js +228 -0
- package/dist/admin/sections.d.ts +22 -0
- package/dist/admin/sections.js +29 -0
- package/dist/admin/setup.d.ts +1 -0
- package/dist/admin/setup.js +45 -0
- package/dist/admin/today.d.ts +43 -0
- package/dist/admin/today.js +115 -0
- package/dist/admin/ui.d.ts +134 -0
- package/dist/admin/ui.js +220 -0
- package/dist/calendar.d.ts +64 -0
- package/dist/calendar.js +139 -0
- package/dist/client.d.ts +147 -0
- package/dist/client.js +507 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.js +120 -0
- package/dist/content/image.d.ts +20 -0
- package/dist/content/image.js +90 -0
- package/dist/content/resolve.d.ts +12 -0
- package/dist/content/resolve.js +73 -0
- package/dist/content/schema.d.ts +119 -0
- package/dist/content/schema.js +53 -0
- package/dist/content/store.d.ts +48 -0
- package/dist/content/store.js +123 -0
- package/dist/content/validate.d.ts +33 -0
- package/dist/content/validate.js +177 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +94 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.js +7 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/presets/hair-salon.d.ts +8 -0
- package/dist/presets/hair-salon.js +94 -0
- package/dist/presets/index.d.ts +5 -0
- package/dist/presets/index.js +6 -0
- package/dist/preview.d.ts +18 -0
- package/dist/preview.js +134 -0
- package/dist/semver.d.ts +16 -0
- package/dist/semver.js +55 -0
- package/dist/time.d.ts +31 -0
- package/dist/time.js +138 -0
- package/dist/types.d.ts +477 -0
- package/dist/types.js +3 -0
- package/dist/vite.d.ts +52 -0
- package/dist/vite.js +150 -0
- package/docs/BUILD-A-SITE.md +203 -0
- package/docs/EMAIL-SETUP.md +224 -0
- package/docs/INTEGRATION.md +1109 -0
- package/engine.manifest.json +90 -0
- package/functions/booking-mailer/deno.json +6 -0
- package/functions/booking-mailer/index.ts +44 -0
- package/functions/booking-mailer/mailer.js +156 -0
- package/functions/booking-mailer/providers/index.js +42 -0
- package/functions/booking-mailer/providers/resend.js +75 -0
- package/functions/booking-mailer/templates.js +345 -0
- package/migrations/0001_core.sql +1673 -0
- package/migrations/0002_security_hardening.sql +711 -0
- package/migrations/0003_private_definers_and_holds.sql +808 -0
- package/migrations/0004_verified_requests.sql +1702 -0
- package/migrations/0005_scoped_mailer_credential.sql +347 -0
- package/migrations/0006_trusted_client_ip.sql +56 -0
- package/migrations/0007_site_content.sql +380 -0
- package/migrations/0008_service_images_opening_times.sql +328 -0
- package/package.json +85 -4
- package/templates/BOOKING_ENGINE.md +61 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
-- ============================================================================
|
|
2
|
+
-- Profit Studio Booking Engine — migration 0007_site_content
|
|
3
|
+
-- Engine schema version: 2.0.0-alpha.7
|
|
4
|
+
--
|
|
5
|
+
-- ENGINE-OWNED FILE. Do not edit. `booking-engine doctor` reports changes.
|
|
6
|
+
--
|
|
7
|
+
-- Owner customization (Phase 3, docs/adr/0004-site-content.md):
|
|
8
|
+
-- 1. Website content the owner edits in the dashboard: one document of
|
|
9
|
+
-- values keyed by field id. Each website declares its own fields (with
|
|
10
|
+
-- types and defaults) in its code; the engine stores values only, so every
|
|
11
|
+
-- AI-generated site keeps its own design.
|
|
12
|
+
-- 2. A draft and a published copy: visitors only ever read the published
|
|
13
|
+
-- one; signed-in admins can preview the draft before publishing.
|
|
14
|
+
-- 3. Images in the Supabase Storage bucket `booking-site-media`: public to
|
|
15
|
+
-- read, uploaded and deleted by admins only; images only, 5 MB at most.
|
|
16
|
+
--
|
|
17
|
+
-- No booking, customer or settings data changes.
|
|
18
|
+
-- ============================================================================
|
|
19
|
+
|
|
20
|
+
do $$
|
|
21
|
+
declare
|
|
22
|
+
v text;
|
|
23
|
+
begin
|
|
24
|
+
select e.schema_version into v from booking.engine_info e where e.id;
|
|
25
|
+
if v is distinct from '2.0.0-alpha.6' then
|
|
26
|
+
raise exception 'Booking Engine 0007_site_content expects schema 2.0.0-alpha.6, found %', coalesce(v, 'none');
|
|
27
|
+
end if;
|
|
28
|
+
end
|
|
29
|
+
$$;
|
|
30
|
+
|
|
31
|
+
-- ----------------------------------------------------------------------------
|
|
32
|
+
-- Schema
|
|
33
|
+
-- ----------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
create table booking.site_content (
|
|
36
|
+
id boolean primary key default true check (id),
|
|
37
|
+
draft jsonb not null default '{}'::jsonb check (jsonb_typeof(draft) = 'object'),
|
|
38
|
+
published jsonb not null default '{}'::jsonb check (jsonb_typeof(published) = 'object'),
|
|
39
|
+
draft_revision integer not null default 0,
|
|
40
|
+
published_version integer not null default 0,
|
|
41
|
+
draft_updated_at timestamptz,
|
|
42
|
+
published_at timestamptz,
|
|
43
|
+
updated_by uuid
|
|
44
|
+
);
|
|
45
|
+
insert into booking.site_content default values;
|
|
46
|
+
comment on table booking.site_content is
|
|
47
|
+
'Website content values (field id → value) edited in the dashboard. Visitors read only `published`; `draft` is for signed-in admins (preview). Field definitions live in each website''s code.';
|
|
48
|
+
|
|
49
|
+
-- ----------------------------------------------------------------------------
|
|
50
|
+
-- Validation. Generic on purpose: the website's own schema (types, lengths,
|
|
51
|
+
-- links, colours) is checked by the dashboard and again when the website reads
|
|
52
|
+
-- the values. The database guarantees shapes and sizes only.
|
|
53
|
+
-- ----------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
-- An image value: { path, alt, width?, height? }, path inside the media bucket.
|
|
56
|
+
create function booking.site_image_ok(p_image jsonb)
|
|
57
|
+
returns boolean
|
|
58
|
+
language sql
|
|
59
|
+
immutable
|
|
60
|
+
set search_path = ''
|
|
61
|
+
as $$
|
|
62
|
+
select jsonb_typeof(p_image) = 'object'
|
|
63
|
+
and not exists (select 1 from jsonb_object_keys(p_image) k where k not in ('path', 'alt', 'width', 'height'))
|
|
64
|
+
and jsonb_typeof(p_image -> 'path') = 'string'
|
|
65
|
+
and (p_image ->> 'path') ~ '^site/[a-z0-9][a-z0-9._-]{0,120}$'
|
|
66
|
+
and position('..' in (p_image ->> 'path')) = 0
|
|
67
|
+
and coalesce(jsonb_typeof(p_image -> 'alt'), 'string') = 'string'
|
|
68
|
+
and char_length(coalesce(p_image ->> 'alt', '')) <= 300
|
|
69
|
+
and coalesce(jsonb_typeof(p_image -> 'width'), 'number') = 'number'
|
|
70
|
+
and coalesce(jsonb_typeof(p_image -> 'height'), 'number') = 'number';
|
|
71
|
+
$$;
|
|
72
|
+
|
|
73
|
+
-- A value: text (≤ 5000 characters, no control characters except line breaks
|
|
74
|
+
-- and tabs), true/false, null, an image, or — at the top level only — a list
|
|
75
|
+
-- of up to 50 items, each with up to 20 such values.
|
|
76
|
+
create function booking.site_content_value_ok(p_value jsonb, p_allow_list boolean)
|
|
77
|
+
returns boolean
|
|
78
|
+
language plpgsql
|
|
79
|
+
immutable
|
|
80
|
+
set search_path = ''
|
|
81
|
+
as $$
|
|
82
|
+
declare
|
|
83
|
+
v_item jsonb;
|
|
84
|
+
v_key text;
|
|
85
|
+
v_inner jsonb;
|
|
86
|
+
v_count integer;
|
|
87
|
+
begin
|
|
88
|
+
case jsonb_typeof(p_value)
|
|
89
|
+
when 'string' then
|
|
90
|
+
return char_length(p_value #>> '{}') <= 5000
|
|
91
|
+
and (p_value #>> '{}') !~ '[\x01-\x08\x0b\x0c\x0e-\x1f\x7f]';
|
|
92
|
+
when 'boolean', 'null' then
|
|
93
|
+
return true;
|
|
94
|
+
when 'object' then
|
|
95
|
+
return booking.site_image_ok(p_value);
|
|
96
|
+
when 'array' then
|
|
97
|
+
if not p_allow_list or jsonb_array_length(p_value) > 50 then
|
|
98
|
+
return false;
|
|
99
|
+
end if;
|
|
100
|
+
for v_item in select e from jsonb_array_elements(p_value) e loop
|
|
101
|
+
if jsonb_typeof(v_item) <> 'object' then
|
|
102
|
+
return false;
|
|
103
|
+
end if;
|
|
104
|
+
v_count := 0;
|
|
105
|
+
for v_key, v_inner in select k, v from jsonb_each(v_item) as t(k, v) loop
|
|
106
|
+
v_count := v_count + 1;
|
|
107
|
+
if v_count > 20 or v_key !~ '^[a-zA-Z][a-zA-Z0-9_]{0,31}$' or not booking.site_content_value_ok(v_inner, false) then
|
|
108
|
+
return false;
|
|
109
|
+
end if;
|
|
110
|
+
end loop;
|
|
111
|
+
end loop;
|
|
112
|
+
return true;
|
|
113
|
+
else
|
|
114
|
+
return false;
|
|
115
|
+
end case;
|
|
116
|
+
end;
|
|
117
|
+
$$;
|
|
118
|
+
|
|
119
|
+
-- Null when the document is valid; otherwise the offending field id.
|
|
120
|
+
create function booking.site_content_problem(p_values jsonb)
|
|
121
|
+
returns text
|
|
122
|
+
language plpgsql
|
|
123
|
+
immutable
|
|
124
|
+
set search_path = ''
|
|
125
|
+
as $$
|
|
126
|
+
declare
|
|
127
|
+
v_key text;
|
|
128
|
+
v_value jsonb;
|
|
129
|
+
v_count integer := 0;
|
|
130
|
+
begin
|
|
131
|
+
if p_values is null or jsonb_typeof(p_values) <> 'object' or octet_length(p_values::text) > 200000 then
|
|
132
|
+
return 'values';
|
|
133
|
+
end if;
|
|
134
|
+
for v_key, v_value in select k, v from jsonb_each(p_values) as t(k, v) loop
|
|
135
|
+
v_count := v_count + 1;
|
|
136
|
+
if v_count > 300
|
|
137
|
+
or char_length(v_key) > 64
|
|
138
|
+
or v_key !~ '^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9_-]+){0,4}$'
|
|
139
|
+
or not booking.site_content_value_ok(v_value, true) then
|
|
140
|
+
return v_key;
|
|
141
|
+
end if;
|
|
142
|
+
end loop;
|
|
143
|
+
return null;
|
|
144
|
+
end;
|
|
145
|
+
$$;
|
|
146
|
+
|
|
147
|
+
-- ----------------------------------------------------------------------------
|
|
148
|
+
-- Public read: the published copy only (never the draft).
|
|
149
|
+
-- ----------------------------------------------------------------------------
|
|
150
|
+
|
|
151
|
+
create function booking.published_site_content()
|
|
152
|
+
returns jsonb
|
|
153
|
+
language sql
|
|
154
|
+
stable
|
|
155
|
+
security definer
|
|
156
|
+
set search_path = ''
|
|
157
|
+
as $$
|
|
158
|
+
select jsonb_build_object(
|
|
159
|
+
'version', c.published_version,
|
|
160
|
+
'publishedAt', booking.iso(c.published_at),
|
|
161
|
+
'values', c.published)
|
|
162
|
+
from booking.site_content c
|
|
163
|
+
where c.id;
|
|
164
|
+
$$;
|
|
165
|
+
|
|
166
|
+
create function public.booking_get_site_content()
|
|
167
|
+
returns jsonb
|
|
168
|
+
language sql
|
|
169
|
+
stable
|
|
170
|
+
security invoker
|
|
171
|
+
set search_path = ''
|
|
172
|
+
as $$
|
|
173
|
+
select booking.published_site_content();
|
|
174
|
+
$$;
|
|
175
|
+
comment on function public.booking_get_site_content() is
|
|
176
|
+
'Published website content: { version, publishedAt, values }. Contains only what the owner published; no booking or customer data.';
|
|
177
|
+
|
|
178
|
+
-- ----------------------------------------------------------------------------
|
|
179
|
+
-- Admin: read both copies, save the draft, publish, discard.
|
|
180
|
+
-- ----------------------------------------------------------------------------
|
|
181
|
+
|
|
182
|
+
create function booking.site_content_json(c booking.site_content)
|
|
183
|
+
returns jsonb
|
|
184
|
+
language sql
|
|
185
|
+
stable
|
|
186
|
+
set search_path = ''
|
|
187
|
+
as $$
|
|
188
|
+
select jsonb_build_object(
|
|
189
|
+
'draft', c.draft,
|
|
190
|
+
'published', c.published,
|
|
191
|
+
'draftRevision', c.draft_revision,
|
|
192
|
+
'version', c.published_version,
|
|
193
|
+
'draftUpdatedAt', booking.iso(c.draft_updated_at),
|
|
194
|
+
'publishedAt', booking.iso(c.published_at),
|
|
195
|
+
'hasUnpublishedChanges', c.draft is distinct from c.published);
|
|
196
|
+
$$;
|
|
197
|
+
|
|
198
|
+
create function public.booking_admin_get_site_content()
|
|
199
|
+
returns jsonb
|
|
200
|
+
language plpgsql
|
|
201
|
+
stable
|
|
202
|
+
security invoker
|
|
203
|
+
set search_path = ''
|
|
204
|
+
as $$
|
|
205
|
+
declare
|
|
206
|
+
c booking.site_content;
|
|
207
|
+
begin
|
|
208
|
+
perform booking.require_admin();
|
|
209
|
+
select * into c from booking.site_content s where s.id;
|
|
210
|
+
return booking.site_content_json(c);
|
|
211
|
+
end;
|
|
212
|
+
$$;
|
|
213
|
+
|
|
214
|
+
-- Saves the whole draft. p_base_revision is the draftRevision the editor
|
|
215
|
+
-- started from: another admin's newer save is never overwritten (CONFLICT).
|
|
216
|
+
create function public.booking_admin_save_site_content(p_values jsonb, p_base_revision integer)
|
|
217
|
+
returns jsonb
|
|
218
|
+
language plpgsql
|
|
219
|
+
volatile
|
|
220
|
+
security invoker
|
|
221
|
+
set search_path = ''
|
|
222
|
+
as $$
|
|
223
|
+
declare
|
|
224
|
+
v_uid uuid := booking.require_admin();
|
|
225
|
+
v_problem text := booking.site_content_problem(p_values);
|
|
226
|
+
c booking.site_content;
|
|
227
|
+
begin
|
|
228
|
+
if v_problem is not null then
|
|
229
|
+
perform booking.raise_error('INVALID_INPUT', v_problem);
|
|
230
|
+
end if;
|
|
231
|
+
update booking.site_content s
|
|
232
|
+
set draft = p_values,
|
|
233
|
+
draft_revision = s.draft_revision + 1,
|
|
234
|
+
draft_updated_at = now(),
|
|
235
|
+
updated_by = v_uid
|
|
236
|
+
where s.id and s.draft_revision = coalesce(p_base_revision, s.draft_revision)
|
|
237
|
+
returning * into c;
|
|
238
|
+
if not found then
|
|
239
|
+
perform booking.raise_error('CONFLICT', 'draftRevision');
|
|
240
|
+
end if;
|
|
241
|
+
return booking.site_content_json(c);
|
|
242
|
+
end;
|
|
243
|
+
$$;
|
|
244
|
+
|
|
245
|
+
-- The draft becomes what visitors see.
|
|
246
|
+
create function public.booking_admin_publish_site_content(p_base_revision integer)
|
|
247
|
+
returns jsonb
|
|
248
|
+
language plpgsql
|
|
249
|
+
volatile
|
|
250
|
+
security invoker
|
|
251
|
+
set search_path = ''
|
|
252
|
+
as $$
|
|
253
|
+
declare
|
|
254
|
+
v_uid uuid := booking.require_admin();
|
|
255
|
+
c booking.site_content;
|
|
256
|
+
begin
|
|
257
|
+
update booking.site_content s
|
|
258
|
+
set published = s.draft,
|
|
259
|
+
published_version = s.published_version + 1,
|
|
260
|
+
published_at = now(),
|
|
261
|
+
updated_by = v_uid
|
|
262
|
+
where s.id and s.draft_revision = coalesce(p_base_revision, s.draft_revision)
|
|
263
|
+
returning * into c;
|
|
264
|
+
if not found then
|
|
265
|
+
perform booking.raise_error('CONFLICT', 'draftRevision');
|
|
266
|
+
end if;
|
|
267
|
+
return booking.site_content_json(c);
|
|
268
|
+
end;
|
|
269
|
+
$$;
|
|
270
|
+
|
|
271
|
+
-- The draft goes back to what is published.
|
|
272
|
+
create function public.booking_admin_discard_site_content_draft()
|
|
273
|
+
returns jsonb
|
|
274
|
+
language plpgsql
|
|
275
|
+
volatile
|
|
276
|
+
security invoker
|
|
277
|
+
set search_path = ''
|
|
278
|
+
as $$
|
|
279
|
+
declare
|
|
280
|
+
v_uid uuid := booking.require_admin();
|
|
281
|
+
c booking.site_content;
|
|
282
|
+
begin
|
|
283
|
+
update booking.site_content s
|
|
284
|
+
set draft = s.published,
|
|
285
|
+
draft_revision = s.draft_revision + 1,
|
|
286
|
+
draft_updated_at = now(),
|
|
287
|
+
updated_by = v_uid
|
|
288
|
+
where s.id
|
|
289
|
+
returning * into c;
|
|
290
|
+
return booking.site_content_json(c);
|
|
291
|
+
end;
|
|
292
|
+
$$;
|
|
293
|
+
|
|
294
|
+
-- ----------------------------------------------------------------------------
|
|
295
|
+
-- Media: a public Storage bucket that only admins can write to.
|
|
296
|
+
-- Skipped (with a notice) in databases without Supabase Storage.
|
|
297
|
+
-- ----------------------------------------------------------------------------
|
|
298
|
+
|
|
299
|
+
do $$
|
|
300
|
+
begin
|
|
301
|
+
if to_regclass('storage.buckets') is null or to_regclass('storage.objects') is null then
|
|
302
|
+
raise notice 'Booking Engine 0007: no Supabase Storage here; website images stay unavailable until it exists.';
|
|
303
|
+
return;
|
|
304
|
+
end if;
|
|
305
|
+
insert into storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
|
|
306
|
+
values ('booking-site-media', 'booking-site-media', true, 5242880,
|
|
307
|
+
array['image/jpeg', 'image/png', 'image/webp', 'image/avif'])
|
|
308
|
+
on conflict (id) do update
|
|
309
|
+
set public = true,
|
|
310
|
+
file_size_limit = excluded.file_size_limit,
|
|
311
|
+
allowed_mime_types = excluded.allowed_mime_types;
|
|
312
|
+
-- Reading files needs no policy (public bucket, public URLs). Listing,
|
|
313
|
+
-- uploading and deleting are for admins only. No update policy: files are
|
|
314
|
+
-- never overwritten — a replacement is a new file with a new name.
|
|
315
|
+
execute $policy$
|
|
316
|
+
create policy booking_site_media_admin_read on storage.objects
|
|
317
|
+
for select to authenticated
|
|
318
|
+
using (bucket_id = 'booking-site-media' and (select booking.is_admin()))
|
|
319
|
+
$policy$;
|
|
320
|
+
execute $policy$
|
|
321
|
+
create policy booking_site_media_admin_insert on storage.objects
|
|
322
|
+
for insert to authenticated
|
|
323
|
+
with check (bucket_id = 'booking-site-media' and (select booking.is_admin()))
|
|
324
|
+
$policy$;
|
|
325
|
+
execute $policy$
|
|
326
|
+
create policy booking_site_media_admin_delete on storage.objects
|
|
327
|
+
for delete to authenticated
|
|
328
|
+
using (bucket_id = 'booking-site-media' and (select booking.is_admin()))
|
|
329
|
+
$policy$;
|
|
330
|
+
end
|
|
331
|
+
$$;
|
|
332
|
+
|
|
333
|
+
-- ----------------------------------------------------------------------------
|
|
334
|
+
-- RLS and privileges
|
|
335
|
+
-- ----------------------------------------------------------------------------
|
|
336
|
+
|
|
337
|
+
alter table booking.site_content enable row level security;
|
|
338
|
+
create policy site_content_admin_read on booking.site_content
|
|
339
|
+
for select to authenticated using ((select booking.is_admin()));
|
|
340
|
+
create policy site_content_admin_update on booking.site_content
|
|
341
|
+
for update to authenticated using ((select booking.is_admin())) with check ((select booking.is_admin()));
|
|
342
|
+
|
|
343
|
+
revoke all on booking.site_content from public, anon, authenticated, service_role;
|
|
344
|
+
grant select on booking.site_content to authenticated;
|
|
345
|
+
grant update (draft, published, draft_revision, published_version, draft_updated_at, published_at, updated_by)
|
|
346
|
+
on booking.site_content to authenticated;
|
|
347
|
+
|
|
348
|
+
revoke execute on all functions in schema booking from public;
|
|
349
|
+
revoke all on function
|
|
350
|
+
booking.site_image_ok(jsonb),
|
|
351
|
+
booking.site_content_value_ok(jsonb, boolean),
|
|
352
|
+
booking.site_content_problem(jsonb),
|
|
353
|
+
booking.published_site_content(),
|
|
354
|
+
booking.site_content_json(booking.site_content),
|
|
355
|
+
public.booking_get_site_content(),
|
|
356
|
+
public.booking_admin_get_site_content(),
|
|
357
|
+
public.booking_admin_save_site_content(jsonb, integer),
|
|
358
|
+
public.booking_admin_publish_site_content(integer),
|
|
359
|
+
public.booking_admin_discard_site_content_draft()
|
|
360
|
+
from public, anon, authenticated, service_role;
|
|
361
|
+
|
|
362
|
+
-- Visitors: the published copy.
|
|
363
|
+
grant execute on function
|
|
364
|
+
public.booking_get_site_content(),
|
|
365
|
+
booking.published_site_content()
|
|
366
|
+
to anon, authenticated;
|
|
367
|
+
|
|
368
|
+
-- Admins.
|
|
369
|
+
grant execute on function
|
|
370
|
+
public.booking_admin_get_site_content(),
|
|
371
|
+
public.booking_admin_save_site_content(jsonb, integer),
|
|
372
|
+
public.booking_admin_publish_site_content(integer),
|
|
373
|
+
public.booking_admin_discard_site_content_draft(),
|
|
374
|
+
booking.site_content_json(booking.site_content),
|
|
375
|
+
booking.site_content_problem(jsonb),
|
|
376
|
+
booking.site_content_value_ok(jsonb, boolean),
|
|
377
|
+
booking.site_image_ok(jsonb)
|
|
378
|
+
to authenticated;
|
|
379
|
+
|
|
380
|
+
update booking.engine_info set schema_version = '2.0.0-alpha.7', updated_at = now() where id;
|