@vrplatform/kysely 1.3.41 → 1.3.45-4444
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/build/.data.tar +0 -0
- package/build/main/camel-case/index.js.map +1 -1
- package/build/main/control-plane/index.d.ts +142 -0
- package/build/main/control-plane/index.js +3 -0
- package/build/main/control-plane/index.js.map +1 -0
- package/build/main/error.js.map +1 -1
- package/build/main/index.d.ts +5 -3
- package/build/main/index.js +8 -10
- package/build/main/index.js.map +1 -1
- package/build/main/isomorphic.js +2 -2
- package/build/main/isomorphic.js.map +1 -1
- package/build/main/local/digest.js.map +1 -1
- package/build/main/local/generate.js.map +1 -1
- package/build/main/local/index.js.map +1 -1
- package/build/main/local/prune-pulled-schema.js.map +1 -1
- package/build/main/pganalyze-comment-plugin/comment-transformer.js +0 -1
- package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
- package/build/main/pganalyze-comment-plugin/index.js +16 -3
- package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
- package/build/main/plugins.js.map +1 -1
- package/build/main/query/listing/status.d.ts +4 -4
- package/build/main/query/listing/status.js +2 -1
- package/build/main/query/listing/status.js.map +1 -1
- package/build/main/regional.d.ts +34 -0
- package/build/main/regional.js +145 -0
- package/build/main/regional.js.map +1 -0
- package/build/main/test/index.js.map +1 -1
- package/build/main/transaction.js.map +1 -1
- package/build/main/v1.generated.d.ts +123 -1
- package/build/main/v1.generated.js.map +1 -1
- package/build/migrations/0000000000001-init.ts +5 -0
- package/build/migrations/0000000000009-drop-store-schema.ts +14 -0
- package/build/migrations/0000000000010-bank-rules.ts +190 -0
- package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +65 -0
- package/build/migrations/0000000000012-bank-rule-conditions.ts +45 -0
- package/build/migrations/0000000000013-bank-rule-name-unique.ts +15 -0
- package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +41 -0
- package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +70 -0
- package/build/migrations/0000000000016-owner-statement-draft-status.ts +22 -0
- package/build/migrations/0000000000017-tenant-migration-markers.ts +18 -0
- package/build/migrations/0000000000018-security-deposits-payable-category.ts +63 -0
- package/build/migrations/0000000000019-tenant-app-settings.ts +76 -0
- package/build/migrations/0000000000020-operating-opening-trial-balance.ts +36 -0
- package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +77 -0
- package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +30 -0
- package/build/migrations/0000000000023-journal-entry-currency-mismatch-reason.ts +14 -0
- package/build/migrations/0000000000024-listing-parent.ts +37 -0
- package/build/migrations/0000000000025-journal-entry-parent-listing.ts +26 -0
- package/build/migrations/0000000000026-booking-channel-logo-slots.ts +89 -0
- package/build/migrations/0000000000027-list-browse-performance-indexes.ts +52 -0
- package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +20 -0
- package/build/migrations/0000000000029-tenant-slug.ts +328 -0
- package/build/migrations/0000000000030-pms-accounting-windows.ts +50 -0
- package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +20 -0
- package/build/migrations/0000000000032-flow-event-listening.ts +28 -0
- package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +272 -0
- package/build/migrations/0000000000034-historic-general-ledger.ts +24 -0
- package/build/migrations/0000000000035-tenant-regional-placement.ts +37 -0
- package/build/migrations/0000000000036-control-plane-projection-events.ts +43 -0
- package/build/migrations/0000000000037-tenant-guide-onboarding.ts +21 -0
- package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +31 -0
- package/build/migrations/0000000000039-crunchy-region.ts +86 -0
- package/build/migrations/0000000000040-hostaway-region.ts +72 -0
- package/build/migrations/0000000000041-audit-tenant-fk.ts +66 -0
- package/build/migrations/0000000000042-ramp-staging-connect-params.ts +35 -0
- package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +125 -0
- package/build/migrations/0000000000044-tenant-cross-region-fks.ts +45 -0
- package/build/migrations/0000000000045-cloudflare-region-env.ts +100 -0
- package/build/migrations/0000000000046-control-plane-outbox-alias.ts +46 -0
- package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +16 -0
- package/build/migrations/0000000000047-tenant-status-backfill.ts +40 -0
- package/build/migrations/0000000000048-tenant-status-constraint.ts +24 -0
- package/build/migrations/0000000000049-health-tenant-issues.ts +69 -0
- package/build/migrations/0000000000050-partner-webhooks.ts +135 -0
- package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +42 -0
- package/build/migrations/0000000000052-feature-approval-team-enablement.ts +13 -0
- package/build/migrations/0000000000053-health-webhook-enums.ts +296 -0
- package/build/module/camel-case/index.js.map +1 -1
- package/build/module/control-plane/index.d.ts +142 -0
- package/build/module/control-plane/index.js +2 -0
- package/build/module/control-plane/index.js.map +1 -0
- package/build/module/error.js.map +1 -1
- package/build/module/index.d.ts +5 -3
- package/build/module/index.js +8 -10
- package/build/module/index.js.map +1 -1
- package/build/module/isomorphic.js.map +1 -1
- package/build/module/local/digest.js.map +1 -1
- package/build/module/local/generate.js.map +1 -1
- package/build/module/local/index.js.map +1 -1
- package/build/module/local/prune-pulled-schema.js.map +1 -1
- package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
- package/build/module/pganalyze-comment-plugin/index.js.map +1 -1
- package/build/module/plugins.js.map +1 -1
- package/build/module/query/listing/status.d.ts +4 -4
- package/build/module/query/listing/status.js +2 -1
- package/build/module/query/listing/status.js.map +1 -1
- package/build/module/regional.d.ts +34 -0
- package/build/module/regional.js +103 -0
- package/build/module/regional.js.map +1 -0
- package/build/module/test/index.js.map +1 -1
- package/build/module/transaction.js.map +1 -1
- package/build/module/v1.generated.d.ts +123 -1
- package/build/module/v1.generated.js.map +1 -1
- package/package.json +13 -4
- package/build/main/tsconfig.main.tsbuildinfo +0 -1
- package/build/module/tsconfig.esm.tsbuildinfo +0 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
5
|
+
await sql`
|
|
6
|
+
create type health.tenant_issue_code as enum (
|
|
7
|
+
'teamInactive',
|
|
8
|
+
'partnerInactive',
|
|
9
|
+
'partnerBillingInactive',
|
|
10
|
+
'brokenConnections',
|
|
11
|
+
'outdatedConnections',
|
|
12
|
+
'pmsMissingAccountingStart',
|
|
13
|
+
'operatingBankAccountsWithoutOpex',
|
|
14
|
+
'duplicatedPayments',
|
|
15
|
+
'unbalancedJournalEntries',
|
|
16
|
+
'unbalancedTransactionJournalEntries',
|
|
17
|
+
'closedPeriodUnattachedJournalEntries',
|
|
18
|
+
'missingOwnershipOrDeactivation',
|
|
19
|
+
'unpaidReservations',
|
|
20
|
+
'cancelledReservationPaidWithoutAdjustment',
|
|
21
|
+
'publishedStatementUnpaid',
|
|
22
|
+
'endedOwnershipNonZeroBalance',
|
|
23
|
+
'reservationPaymentProjectionMismatch',
|
|
24
|
+
'listingOwnershipPeriodNotFoundOnActiveJournals',
|
|
25
|
+
'reservationGuestTotalsMismatch',
|
|
26
|
+
'reservationCurrencyMismatch'
|
|
27
|
+
)
|
|
28
|
+
`.execute(db);
|
|
29
|
+
await sql`
|
|
30
|
+
create type health.tenant_issue_status as enum ('open', 'resolved')
|
|
31
|
+
`.execute(db);
|
|
32
|
+
await sql`
|
|
33
|
+
create type health.tenant_issue_severity as enum ('error', 'warning')
|
|
34
|
+
`.execute(db);
|
|
35
|
+
await sql`
|
|
36
|
+
create type health.tenant_issue_category as enum (
|
|
37
|
+
'criticalToUser',
|
|
38
|
+
'criticalToSystem'
|
|
39
|
+
)
|
|
40
|
+
`.execute(db);
|
|
41
|
+
await sql`
|
|
42
|
+
create type webhook.subscription_scope as enum ('self', 'managedTeams')
|
|
43
|
+
`.execute(db);
|
|
44
|
+
await sql`
|
|
45
|
+
create type webhook.subscription_status as enum (
|
|
46
|
+
'pending',
|
|
47
|
+
'active',
|
|
48
|
+
'disabled'
|
|
49
|
+
)
|
|
50
|
+
`.execute(db);
|
|
51
|
+
await sql`
|
|
52
|
+
create type webhook.subscription_event_type as enum (
|
|
53
|
+
'team.issues.changed'
|
|
54
|
+
)
|
|
55
|
+
`.execute(db);
|
|
56
|
+
await sql`
|
|
57
|
+
create type webhook.event_type as enum (
|
|
58
|
+
'webhook.test',
|
|
59
|
+
'team.issues.changed'
|
|
60
|
+
)
|
|
61
|
+
`.execute(db);
|
|
62
|
+
await sql`
|
|
63
|
+
create type webhook.api_version as enum ('2026-07-01')
|
|
64
|
+
`.execute(db);
|
|
65
|
+
await sql`
|
|
66
|
+
create type webhook.resource_type as enum ('webhook', 'team')
|
|
67
|
+
`.execute(db);
|
|
68
|
+
await sql`
|
|
69
|
+
create type webhook.delivery_status as enum (
|
|
70
|
+
'queued',
|
|
71
|
+
'delivering',
|
|
72
|
+
'retrying',
|
|
73
|
+
'succeeded',
|
|
74
|
+
'failed',
|
|
75
|
+
'canceled'
|
|
76
|
+
)
|
|
77
|
+
`.execute(db);
|
|
78
|
+
|
|
79
|
+
await sql`drop index health.tenant_issue_open_idx`.execute(db);
|
|
80
|
+
await sql`
|
|
81
|
+
alter table health.tenant_issue
|
|
82
|
+
drop constraint tenant_issue_status_check,
|
|
83
|
+
drop constraint tenant_issue_severity_check,
|
|
84
|
+
drop constraint tenant_issue_category_check,
|
|
85
|
+
drop constraint tenant_issue_affected_check
|
|
86
|
+
`.execute(db);
|
|
87
|
+
await sql`
|
|
88
|
+
alter table health.tenant_issue
|
|
89
|
+
alter column code type health.tenant_issue_code
|
|
90
|
+
using code::health.tenant_issue_code,
|
|
91
|
+
alter column status type health.tenant_issue_status
|
|
92
|
+
using status::health.tenant_issue_status,
|
|
93
|
+
alter column severity type health.tenant_issue_severity
|
|
94
|
+
using severity::health.tenant_issue_severity,
|
|
95
|
+
alter column category type health.tenant_issue_category
|
|
96
|
+
using category::health.tenant_issue_category
|
|
97
|
+
`.execute(db);
|
|
98
|
+
await sql`
|
|
99
|
+
alter table health.tenant_issue
|
|
100
|
+
add constraint tenant_issue_affected_check
|
|
101
|
+
check (
|
|
102
|
+
(status = 'open' and affected > 0)
|
|
103
|
+
or (status = 'resolved' and affected = 0)
|
|
104
|
+
)
|
|
105
|
+
`.execute(db);
|
|
106
|
+
await sql`
|
|
107
|
+
create index tenant_issue_open_idx
|
|
108
|
+
on health.tenant_issue (tenant_id, code)
|
|
109
|
+
where status = 'open'
|
|
110
|
+
`.execute(db);
|
|
111
|
+
|
|
112
|
+
await sql`drop index webhook.webhook_delivery_recovery_idx`.execute(db);
|
|
113
|
+
await sql`
|
|
114
|
+
alter table webhook.subscription
|
|
115
|
+
drop constraint webhook_subscription_scope_check,
|
|
116
|
+
drop constraint webhook_subscription_status_check,
|
|
117
|
+
drop constraint webhook_subscription_event_types_check,
|
|
118
|
+
alter column status drop default
|
|
119
|
+
`.execute(db);
|
|
120
|
+
await sql`
|
|
121
|
+
alter table webhook.delivery
|
|
122
|
+
drop constraint webhook_delivery_status_check,
|
|
123
|
+
alter column status drop default
|
|
124
|
+
`.execute(db);
|
|
125
|
+
await sql`
|
|
126
|
+
alter table webhook.subscription
|
|
127
|
+
alter column scope type webhook.subscription_scope
|
|
128
|
+
using scope::webhook.subscription_scope,
|
|
129
|
+
alter column status type webhook.subscription_status
|
|
130
|
+
using status::webhook.subscription_status,
|
|
131
|
+
alter column api_version type webhook.api_version
|
|
132
|
+
using api_version::webhook.api_version,
|
|
133
|
+
alter column event_types type webhook.subscription_event_type[]
|
|
134
|
+
using event_types::text::webhook.subscription_event_type[],
|
|
135
|
+
alter column status set default 'pending'
|
|
136
|
+
`.execute(db);
|
|
137
|
+
await sql`
|
|
138
|
+
alter table webhook.subscription
|
|
139
|
+
add constraint webhook_subscription_event_types_check
|
|
140
|
+
check (cardinality(event_types) > 0)
|
|
141
|
+
`.execute(db);
|
|
142
|
+
await sql`
|
|
143
|
+
alter table webhook.delivery
|
|
144
|
+
alter column event_type type webhook.event_type
|
|
145
|
+
using event_type::webhook.event_type,
|
|
146
|
+
alter column api_version type webhook.api_version
|
|
147
|
+
using api_version::webhook.api_version,
|
|
148
|
+
alter column resource_type type webhook.resource_type
|
|
149
|
+
using resource_type::webhook.resource_type,
|
|
150
|
+
alter column status type webhook.delivery_status
|
|
151
|
+
using status::webhook.delivery_status,
|
|
152
|
+
alter column status set default 'queued'
|
|
153
|
+
`.execute(db);
|
|
154
|
+
await sql`
|
|
155
|
+
create index webhook_delivery_recovery_idx
|
|
156
|
+
on webhook.delivery (status, next_attempt_at)
|
|
157
|
+
`.execute(db);
|
|
158
|
+
|
|
159
|
+
await sql`
|
|
160
|
+
do $$
|
|
161
|
+
begin
|
|
162
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
163
|
+
grant usage on type
|
|
164
|
+
health.tenant_issue_code,
|
|
165
|
+
health.tenant_issue_status,
|
|
166
|
+
health.tenant_issue_severity,
|
|
167
|
+
health.tenant_issue_category,
|
|
168
|
+
webhook.subscription_scope,
|
|
169
|
+
webhook.subscription_status,
|
|
170
|
+
webhook.subscription_event_type,
|
|
171
|
+
webhook.event_type,
|
|
172
|
+
webhook.api_version,
|
|
173
|
+
webhook.resource_type,
|
|
174
|
+
webhook.delivery_status
|
|
175
|
+
to application;
|
|
176
|
+
alter default privileges in schema health, webhook
|
|
177
|
+
grant usage on types to application;
|
|
178
|
+
end if;
|
|
179
|
+
end
|
|
180
|
+
$$;
|
|
181
|
+
`.execute(db);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
185
|
+
await sql`
|
|
186
|
+
do $$
|
|
187
|
+
begin
|
|
188
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
189
|
+
alter default privileges in schema health, webhook
|
|
190
|
+
revoke usage on types from application;
|
|
191
|
+
end if;
|
|
192
|
+
end
|
|
193
|
+
$$;
|
|
194
|
+
`.execute(db);
|
|
195
|
+
|
|
196
|
+
await sql`drop index health.tenant_issue_open_idx`.execute(db);
|
|
197
|
+
await sql`
|
|
198
|
+
alter table health.tenant_issue
|
|
199
|
+
drop constraint tenant_issue_affected_check
|
|
200
|
+
`.execute(db);
|
|
201
|
+
await sql`
|
|
202
|
+
alter table health.tenant_issue
|
|
203
|
+
alter column code type text using code::text,
|
|
204
|
+
alter column status type text using status::text,
|
|
205
|
+
alter column severity type text using severity::text,
|
|
206
|
+
alter column category type text using category::text
|
|
207
|
+
`.execute(db);
|
|
208
|
+
await sql`
|
|
209
|
+
alter table health.tenant_issue
|
|
210
|
+
add constraint tenant_issue_status_check
|
|
211
|
+
check (status in ('open', 'resolved')),
|
|
212
|
+
add constraint tenant_issue_severity_check
|
|
213
|
+
check (severity in ('error', 'warning')),
|
|
214
|
+
add constraint tenant_issue_category_check
|
|
215
|
+
check (category in ('criticalToUser', 'criticalToSystem')),
|
|
216
|
+
add constraint tenant_issue_affected_check
|
|
217
|
+
check (
|
|
218
|
+
(status = 'open' and affected > 0)
|
|
219
|
+
or (status = 'resolved' and affected = 0)
|
|
220
|
+
)
|
|
221
|
+
`.execute(db);
|
|
222
|
+
await sql`
|
|
223
|
+
create index tenant_issue_open_idx
|
|
224
|
+
on health.tenant_issue (tenant_id, code)
|
|
225
|
+
where status = 'open'
|
|
226
|
+
`.execute(db);
|
|
227
|
+
|
|
228
|
+
await sql`drop index webhook.webhook_delivery_recovery_idx`.execute(db);
|
|
229
|
+
await sql`
|
|
230
|
+
alter table webhook.subscription
|
|
231
|
+
drop constraint webhook_subscription_event_types_check,
|
|
232
|
+
alter column status drop default
|
|
233
|
+
`.execute(db);
|
|
234
|
+
await sql`
|
|
235
|
+
alter table webhook.delivery
|
|
236
|
+
alter column status drop default
|
|
237
|
+
`.execute(db);
|
|
238
|
+
await sql`
|
|
239
|
+
alter table webhook.subscription
|
|
240
|
+
alter column scope type text using scope::text,
|
|
241
|
+
alter column status type text using status::text,
|
|
242
|
+
alter column api_version type text using api_version::text,
|
|
243
|
+
alter column event_types type text[] using event_types::text::text[],
|
|
244
|
+
alter column status set default 'pending'
|
|
245
|
+
`.execute(db);
|
|
246
|
+
await sql`
|
|
247
|
+
alter table webhook.subscription
|
|
248
|
+
add constraint webhook_subscription_scope_check
|
|
249
|
+
check (scope in ('self', 'managedTeams')),
|
|
250
|
+
add constraint webhook_subscription_status_check
|
|
251
|
+
check (status in ('pending', 'active', 'disabled')),
|
|
252
|
+
add constraint webhook_subscription_event_types_check
|
|
253
|
+
check (cardinality(event_types) > 0)
|
|
254
|
+
`.execute(db);
|
|
255
|
+
await sql`
|
|
256
|
+
alter table webhook.delivery
|
|
257
|
+
alter column event_type type text using event_type::text,
|
|
258
|
+
alter column api_version type text using api_version::text,
|
|
259
|
+
alter column resource_type type text using resource_type::text,
|
|
260
|
+
alter column status type text using status::text,
|
|
261
|
+
alter column status set default 'queued'
|
|
262
|
+
`.execute(db);
|
|
263
|
+
await sql`
|
|
264
|
+
alter table webhook.delivery
|
|
265
|
+
add constraint webhook_delivery_status_check
|
|
266
|
+
check (
|
|
267
|
+
status in (
|
|
268
|
+
'queued',
|
|
269
|
+
'delivering',
|
|
270
|
+
'retrying',
|
|
271
|
+
'succeeded',
|
|
272
|
+
'failed',
|
|
273
|
+
'canceled'
|
|
274
|
+
)
|
|
275
|
+
)
|
|
276
|
+
`.execute(db);
|
|
277
|
+
await sql`
|
|
278
|
+
create index webhook_delivery_recovery_idx
|
|
279
|
+
on webhook.delivery (status, next_attempt_at)
|
|
280
|
+
`.execute(db);
|
|
281
|
+
|
|
282
|
+
await sql`
|
|
283
|
+
drop type
|
|
284
|
+
webhook.delivery_status,
|
|
285
|
+
webhook.resource_type,
|
|
286
|
+
webhook.api_version,
|
|
287
|
+
webhook.event_type,
|
|
288
|
+
webhook.subscription_event_type,
|
|
289
|
+
webhook.subscription_status,
|
|
290
|
+
webhook.subscription_scope,
|
|
291
|
+
health.tenant_issue_category,
|
|
292
|
+
health.tenant_issue_severity,
|
|
293
|
+
health.tenant_issue_status,
|
|
294
|
+
health.tenant_issue_code
|
|
295
|
+
`.execute(db);
|
|
296
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["camel-case/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,GAIhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACnD,kDAAkD;IAClD
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["camel-case/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,GAIhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACnD,kDAAkD;IAClD;QACE,KAAK,CAAC;YACJ,wBAAwB,EAAE,IAAI;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,IAAI;QAClB,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,cAAc,CAAC,IAAI;QACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,WAAW,CAAC,IAAqB;QAC/B,IAAI,CAAC,IAAI,EAAE,UAAU;YAAE,OAAO;QAE9B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YACtC,MAAM,SAAS,GAAG,CAAC,CAAC,SAAsB,CAAC;YAC3C,IAAI,CAAC,SAAS,CAAC,KAAK;gBAAE,SAAS;YAC/B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAuB,CAAC;YAEhD,0CAA0C;YAC1C,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACtC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAe,CAAC;gBAC1C,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;oBACzC,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;wBACjC,MAAM,eAAe,GAAG,CAAoB,CAAC;wBAC7C,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;oBACpC,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,SAAS;YAExC,MAAM,IAAI,WAAW,CAAC,SAAS,KAAK,CAAC,IAAI,sBAAsB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAES,MAAM,CAAC,GAAG;QAClB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG;YAAE,OAAO,GAAG,CAAC;QAEhD,MAAM,MAAM,GAAwB,EAAE,CAAC;QACvC,8GAA8G;QAC9G,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACrB,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACpC,iEAAiE;YACjE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7C,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import {\n type AliasNode,\n CamelCasePlugin,\n type IdentifierNode,\n type RawNode,\n type SelectQueryNode,\n} from 'kysely';\nimport { KyselyError } from '../error';\n\nexport class CustomCasePlugin extends CamelCasePlugin {\n // _excludedColumns: Record<string, boolean> = {};\n constructor() {\n super({\n maintainNestedObjectKeys: true,\n });\n }\n\n transformResult(args) {\n return super.transformResult(args);\n }\n\n transformQuery(args) {\n this.verifyAlias(args.node);\n return super.transformQuery(args);\n }\n\n verifyAlias(node: SelectQueryNode) {\n if (!node?.selections) return;\n\n for (const x of node.selections ?? []) {\n const selection = x.selection as AliasNode;\n if (!selection.alias) continue;\n const alias = selection.alias as IdentifierNode;\n\n // alias can be a raw node (jsonArrayFrom)\n if (selection.node.kind === 'RawNode') {\n const rawNode = selection.node as RawNode;\n for (const x of rawNode.parameters ?? []) {\n if (x.kind === 'SelectQueryNode') {\n const selectQueryNode = x as SelectQueryNode;\n this.verifyAlias(selectQueryNode);\n }\n }\n }\n\n if (!alias.name.includes('_')) continue;\n\n throw new KyselyError(`Alias ${alias.name} contains underscore`);\n }\n }\n\n protected mapRow(row) {\n if (typeof row !== 'object' || !row) return row;\n\n const newRow: Record<string, any> = {};\n // we camel case on first layer, and nested ONLY if in an array (jsonArrayFrom), NOT if it's an object (jsonb)\n for (const key of Object.keys(row)) {\n let value = row[key];\n const newKey = super.camelCase(key);\n // array CAN be non object, so we need to check the first element\n if (Array.isArray(value)) {\n value = value.map((it) => this.mapRow(it));\n }\n newRow[newKey] = value;\n }\n return newRow;\n }\n}\n"]}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ColumnType, Kysely as K } from 'kysely';
|
|
2
|
+
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
|
|
3
|
+
export type Json = JsonValue;
|
|
4
|
+
export type JsonArray = JsonValue[];
|
|
5
|
+
export type JsonObject = {
|
|
6
|
+
[x: string]: JsonValue | undefined;
|
|
7
|
+
};
|
|
8
|
+
export type JsonPrimitive = boolean | number | string | null;
|
|
9
|
+
export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
|
|
10
|
+
export type Timestamp = ColumnType<Date | string, Date | string, Date | string>;
|
|
11
|
+
export interface ControlPlaneApp {
|
|
12
|
+
authentication: Generated<Json>;
|
|
13
|
+
category: string | null;
|
|
14
|
+
color: string | null;
|
|
15
|
+
createdAt: Generated<Timestamp>;
|
|
16
|
+
icon: string | null;
|
|
17
|
+
iconRound: string | null;
|
|
18
|
+
id: Generated<string>;
|
|
19
|
+
info: Json | null;
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
version: Generated<number>;
|
|
23
|
+
}
|
|
24
|
+
export interface ControlPlaneBookingChannel {
|
|
25
|
+
channelRef: string | null;
|
|
26
|
+
color: string | null;
|
|
27
|
+
createdAt: Generated<Timestamp>;
|
|
28
|
+
icon: string | null;
|
|
29
|
+
iconProvider: string | null;
|
|
30
|
+
id: Generated<string>;
|
|
31
|
+
lastGenerateRun: Timestamp | null;
|
|
32
|
+
logo: string | null;
|
|
33
|
+
logoProvider: string | null;
|
|
34
|
+
selectedBookingChannelIconCandidateId: string | null;
|
|
35
|
+
selectedBookingChannelLogoCandidateId: string | null;
|
|
36
|
+
uniqueRef: string;
|
|
37
|
+
updatedAt: Generated<Timestamp>;
|
|
38
|
+
}
|
|
39
|
+
export interface ControlPlaneCurrency {
|
|
40
|
+
name: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ControlPlaneConnectionRoute {
|
|
43
|
+
connectionId: string;
|
|
44
|
+
createdAt: Generated<Timestamp>;
|
|
45
|
+
tenantId: string;
|
|
46
|
+
updatedAt: Generated<Timestamp>;
|
|
47
|
+
}
|
|
48
|
+
export interface ControlPlaneFeature {
|
|
49
|
+
createdAt: Generated<Timestamp>;
|
|
50
|
+
description: string | null;
|
|
51
|
+
id: Generated<string>;
|
|
52
|
+
issueUrl: string | null;
|
|
53
|
+
requiredApprovals: Generated<Json | null>;
|
|
54
|
+
status: Generated<string | null>;
|
|
55
|
+
tenantId: string | null;
|
|
56
|
+
title: string;
|
|
57
|
+
updatedAt: Generated<Timestamp>;
|
|
58
|
+
url: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface ControlPlaneFeatureEnabledTeam {
|
|
61
|
+
createdAt: Generated<Timestamp>;
|
|
62
|
+
featureId: string;
|
|
63
|
+
id: Generated<string>;
|
|
64
|
+
status: Generated<string | null>;
|
|
65
|
+
tenantId: string;
|
|
66
|
+
updatedAt: Generated<Timestamp>;
|
|
67
|
+
}
|
|
68
|
+
export interface ControlPlaneOutbox {
|
|
69
|
+
aggregateId: string;
|
|
70
|
+
aggregateType: string;
|
|
71
|
+
attempts: Generated<number>;
|
|
72
|
+
createdAt: Generated<Timestamp>;
|
|
73
|
+
dataRegion: string | null;
|
|
74
|
+
eventType: string;
|
|
75
|
+
eventVersion: number;
|
|
76
|
+
id: Generated<string>;
|
|
77
|
+
lastError: string | null;
|
|
78
|
+
payload: Generated<Json>;
|
|
79
|
+
publishedAt: Timestamp | null;
|
|
80
|
+
}
|
|
81
|
+
export interface ControlPlaneTenant {
|
|
82
|
+
billingPlan: string | null;
|
|
83
|
+
createdAt: Generated<Timestamp>;
|
|
84
|
+
dataRegion: Generated<string>;
|
|
85
|
+
id: Generated<string>;
|
|
86
|
+
name: string;
|
|
87
|
+
partnerId: string | null;
|
|
88
|
+
slug: string;
|
|
89
|
+
status: Generated<string | null>;
|
|
90
|
+
storageRealm: Generated<string>;
|
|
91
|
+
type: Generated<string | null>;
|
|
92
|
+
updatedAt: Generated<Timestamp | null>;
|
|
93
|
+
}
|
|
94
|
+
export interface ControlPlaneTenantUser {
|
|
95
|
+
createdAt: Generated<Timestamp | null>;
|
|
96
|
+
id: Generated<string>;
|
|
97
|
+
lastInvitedAt: Timestamp | null;
|
|
98
|
+
role: Generated<string | null>;
|
|
99
|
+
status: Generated<string | null>;
|
|
100
|
+
tenantId: string;
|
|
101
|
+
updatedAt: Generated<Timestamp | null>;
|
|
102
|
+
userId: string;
|
|
103
|
+
}
|
|
104
|
+
export interface ControlPlaneToken {
|
|
105
|
+
createdAt: Generated<Timestamp>;
|
|
106
|
+
expiresAt: Timestamp | null;
|
|
107
|
+
id: Generated<string>;
|
|
108
|
+
nanoId: Generated<string>;
|
|
109
|
+
payload: Generated<Json>;
|
|
110
|
+
tenantId: string | null;
|
|
111
|
+
type: string | null;
|
|
112
|
+
userId: string | null;
|
|
113
|
+
}
|
|
114
|
+
export interface ControlPlaneUser {
|
|
115
|
+
clerkId: string | null;
|
|
116
|
+
createdAt: Generated<Timestamp | null>;
|
|
117
|
+
email: string | null;
|
|
118
|
+
firstName: string | null;
|
|
119
|
+
id: Generated<string>;
|
|
120
|
+
isAdmin: Generated<boolean>;
|
|
121
|
+
lastName: string | null;
|
|
122
|
+
name: string | null;
|
|
123
|
+
partnerId: string | null;
|
|
124
|
+
status: Generated<string | null>;
|
|
125
|
+
sub: string | null;
|
|
126
|
+
type: Generated<string | null>;
|
|
127
|
+
updatedAt: Generated<Timestamp | null>;
|
|
128
|
+
}
|
|
129
|
+
export interface ControlPlaneDB {
|
|
130
|
+
'public.app': ControlPlaneApp;
|
|
131
|
+
'public.bookingChannel': ControlPlaneBookingChannel;
|
|
132
|
+
'public.connectionRoute': ControlPlaneConnectionRoute;
|
|
133
|
+
'public.currency': ControlPlaneCurrency;
|
|
134
|
+
'public.feature': ControlPlaneFeature;
|
|
135
|
+
'public.featureEnabledTeam': ControlPlaneFeatureEnabledTeam;
|
|
136
|
+
'public.controlPlaneOutbox': ControlPlaneOutbox;
|
|
137
|
+
'public.tenant': ControlPlaneTenant;
|
|
138
|
+
'public.tenantUser': ControlPlaneTenantUser;
|
|
139
|
+
'public.token': ControlPlaneToken;
|
|
140
|
+
'public.user': ControlPlaneUser;
|
|
141
|
+
}
|
|
142
|
+
export type ControlPlaneKysely = K<ControlPlaneDB>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["control-plane/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { ColumnType, Kysely as K } from 'kysely';\n\nexport type Generated<T> =\n T extends ColumnType<infer S, infer I, infer U>\n ? ColumnType<S, I | undefined, U>\n : ColumnType<T, T | undefined, T>;\n\nexport type Json = JsonValue;\n\nexport type JsonArray = JsonValue[];\n\nexport type JsonObject = {\n [x: string]: JsonValue | undefined;\n};\n\nexport type JsonPrimitive = boolean | number | string | null;\n\nexport type JsonValue = JsonArray | JsonObject | JsonPrimitive;\n\nexport type Timestamp = ColumnType<Date | string, Date | string, Date | string>;\n\nexport interface ControlPlaneApp {\n authentication: Generated<Json>;\n category: string | null;\n color: string | null;\n createdAt: Generated<Timestamp>;\n icon: string | null;\n iconRound: string | null;\n id: Generated<string>;\n info: Json | null;\n name: string;\n type: string;\n version: Generated<number>;\n}\n\nexport interface ControlPlaneBookingChannel {\n channelRef: string | null;\n color: string | null;\n createdAt: Generated<Timestamp>;\n icon: string | null;\n iconProvider: string | null;\n id: Generated<string>;\n lastGenerateRun: Timestamp | null;\n logo: string | null;\n logoProvider: string | null;\n selectedBookingChannelIconCandidateId: string | null;\n selectedBookingChannelLogoCandidateId: string | null;\n uniqueRef: string;\n updatedAt: Generated<Timestamp>;\n}\n\nexport interface ControlPlaneCurrency {\n name: string;\n}\n\nexport interface ControlPlaneConnectionRoute {\n connectionId: string;\n createdAt: Generated<Timestamp>;\n tenantId: string;\n updatedAt: Generated<Timestamp>;\n}\n\nexport interface ControlPlaneFeature {\n createdAt: Generated<Timestamp>;\n description: string | null;\n id: Generated<string>;\n issueUrl: string | null;\n requiredApprovals: Generated<Json | null>;\n status: Generated<string | null>;\n tenantId: string | null;\n title: string;\n updatedAt: Generated<Timestamp>;\n url: string | null;\n}\n\nexport interface ControlPlaneFeatureEnabledTeam {\n createdAt: Generated<Timestamp>;\n featureId: string;\n id: Generated<string>;\n status: Generated<string | null>;\n tenantId: string;\n updatedAt: Generated<Timestamp>;\n}\n\nexport interface ControlPlaneOutbox {\n aggregateId: string;\n aggregateType: string;\n attempts: Generated<number>;\n createdAt: Generated<Timestamp>;\n dataRegion: string | null;\n eventType: string;\n eventVersion: number;\n id: Generated<string>;\n lastError: string | null;\n payload: Generated<Json>;\n publishedAt: Timestamp | null;\n}\n\nexport interface ControlPlaneTenant {\n billingPlan: string | null;\n createdAt: Generated<Timestamp>;\n dataRegion: Generated<string>;\n id: Generated<string>;\n name: string;\n partnerId: string | null;\n slug: string;\n status: Generated<string | null>;\n storageRealm: Generated<string>;\n type: Generated<string | null>;\n updatedAt: Generated<Timestamp | null>;\n}\n\nexport interface ControlPlaneTenantUser {\n createdAt: Generated<Timestamp | null>;\n id: Generated<string>;\n lastInvitedAt: Timestamp | null;\n role: Generated<string | null>;\n status: Generated<string | null>;\n tenantId: string;\n updatedAt: Generated<Timestamp | null>;\n userId: string;\n}\n\nexport interface ControlPlaneToken {\n createdAt: Generated<Timestamp>;\n expiresAt: Timestamp | null;\n id: Generated<string>;\n nanoId: Generated<string>;\n payload: Generated<Json>;\n tenantId: string | null;\n type: string | null;\n userId: string | null;\n}\n\nexport interface ControlPlaneUser {\n clerkId: string | null;\n createdAt: Generated<Timestamp | null>;\n email: string | null;\n firstName: string | null;\n id: Generated<string>;\n isAdmin: Generated<boolean>;\n lastName: string | null;\n name: string | null;\n partnerId: string | null;\n status: Generated<string | null>;\n sub: string | null;\n type: Generated<string | null>;\n updatedAt: Generated<Timestamp | null>;\n}\n\nexport interface ControlPlaneDB {\n 'public.app': ControlPlaneApp;\n 'public.bookingChannel': ControlPlaneBookingChannel;\n 'public.connectionRoute': ControlPlaneConnectionRoute;\n 'public.currency': ControlPlaneCurrency;\n 'public.feature': ControlPlaneFeature;\n 'public.featureEnabledTeam': ControlPlaneFeatureEnabledTeam;\n 'public.controlPlaneOutbox': ControlPlaneOutbox;\n 'public.tenant': ControlPlaneTenant;\n 'public.tenantUser': ControlPlaneTenantUser;\n 'public.token': ControlPlaneToken;\n 'public.user': ControlPlaneUser;\n}\n\nexport type ControlPlaneKysely = K<ControlPlaneDB>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF","sourcesContent":["export class KyselyError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'KyselyError';\n }\n}\n"]}
|
package/build/module/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Kysely as K, LogConfig } from 'kysely';
|
|
2
|
-
import { type Sql } from 'postgres';
|
|
2
|
+
import postgres, { type Sql } from 'postgres';
|
|
3
3
|
export type { Insertable, LogEvent } from 'kysely';
|
|
4
4
|
export * from './error';
|
|
5
5
|
export * from './isomorphic';
|
|
6
6
|
export * from './query';
|
|
7
|
+
export * from './regional';
|
|
7
8
|
export * from './transaction';
|
|
8
9
|
import type { DB } from './v1.generated';
|
|
9
10
|
type KyselyOpts = {
|
|
@@ -12,6 +13,7 @@ type KyselyOpts = {
|
|
|
12
13
|
};
|
|
13
14
|
type PgOpt = {
|
|
14
15
|
forceDisableSSL?: boolean;
|
|
16
|
+
probe?: false;
|
|
15
17
|
retries?: false | number;
|
|
16
18
|
};
|
|
17
19
|
export type Kysely = K<DB>;
|
|
@@ -20,12 +22,12 @@ export type Postgres = Sql;
|
|
|
20
22
|
* @deprecated This method is deprecated in favor of the useAsyncKysely method.
|
|
21
23
|
*/
|
|
22
24
|
export declare function useKysely(postgres: Sql, options?: KyselyOpts): K<DB>;
|
|
23
|
-
export declare function useAsyncPostgres(connectionString: string, opt?: PgOpt): Promise<Sql<{}>>;
|
|
25
|
+
export declare function useAsyncPostgres(connectionString: string, opt?: PgOpt): Promise<postgres.Sql<{}>>;
|
|
24
26
|
export declare function useAsyncKysely(connectionString: string, opt?: PgOpt & KyselyOpts): Promise<K<DB>>;
|
|
25
27
|
/**
|
|
26
28
|
* @deprecated This method is deprecated in favor of the useAsyncKysely method.
|
|
27
29
|
*/
|
|
28
|
-
export declare function usePostgres(connectionString?: string, opt?: Pick<PgOpt, 'forceDisableSSL'>): Sql<{}>;
|
|
30
|
+
export declare function usePostgres(connectionString?: string, opt?: Pick<PgOpt, 'forceDisableSSL'>): postgres.Sql<{}>;
|
|
29
31
|
export declare function forceCloseAllPostgres(timeoutMs?: number): Promise<void>;
|
|
30
32
|
export declare class DatabaseError extends Error {
|
|
31
33
|
constructor(message: string, cause: any);
|
package/build/module/index.js
CHANGED
|
@@ -6,9 +6,10 @@ import { getKysely } from './plugins';
|
|
|
6
6
|
export * from './error';
|
|
7
7
|
export * from './isomorphic';
|
|
8
8
|
export * from './query';
|
|
9
|
+
export * from './regional';
|
|
9
10
|
export * from './transaction';
|
|
10
11
|
import { parseDuration } from '@vrplatform/utils';
|
|
11
|
-
const retryableMessages = ['CONNECTION_CLOSED'];
|
|
12
|
+
const retryableMessages = ['CONNECTION_CLOSED', 'CONNECT_TIMEOUT'];
|
|
12
13
|
/**
|
|
13
14
|
* @deprecated This method is deprecated in favor of the useAsyncKysely method.
|
|
14
15
|
*/
|
|
@@ -50,7 +51,7 @@ export function useKysely(postgres, options) {
|
|
|
50
51
|
let _connections = [];
|
|
51
52
|
export async function useAsyncPostgres(connectionString, opt) {
|
|
52
53
|
const delayMs = 2500;
|
|
53
|
-
const retries = opt?.retries === false ? 0 : opt?.retries || 3;
|
|
54
|
+
const retries = opt?.probe === false ? 1 : opt?.retries === false ? 0 : opt?.retries || 3;
|
|
54
55
|
const ssl = opt?.forceDisableSSL !== true;
|
|
55
56
|
const url = new URL(connectionString);
|
|
56
57
|
console.debug(`Creating Postgres connection with ${retries} retries and ssl=${ssl} and port=${url.port}`);
|
|
@@ -67,15 +68,12 @@ export async function useAsyncPostgres(connectionString, opt) {
|
|
|
67
68
|
connect_timeout: 10,
|
|
68
69
|
idle_timeout: 60,
|
|
69
70
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// connect 30s, idle 60s, max lifetime 45min, statement 60s, lock 10s, log_min_duration 20s, log_lock_waits off
|
|
73
|
-
await sql `set statement_timeout to '30s';`;
|
|
74
|
-
await sql `set lock_timeout to '10s';`;
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
console.warn('Failed to set statement timeout, continuing', e);
|
|
71
|
+
if (opt?.probe !== false) {
|
|
72
|
+
await sql `select 1`;
|
|
78
73
|
}
|
|
74
|
+
// statement_timeout/lock_timeout are role-level settings on the cluster
|
|
75
|
+
// (ALTER ROLE application SET ...) so they cover every pooled
|
|
76
|
+
// connection; per-session SETs here only ever applied to one of them
|
|
79
77
|
_connections.push(sql);
|
|
80
78
|
return sql;
|
|
81
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,QAAsB,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,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xD,CAAC,CAAC;IACH,YAAY,GAAG,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAE,KAAU;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["import { backOff } from 'exponential-backoff';\nimport type { Kysely as K, LogConfig } from 'kysely';\nimport { PostgresJSDialect } from 'kysely-postgres-js';\nimport postgres, { type Sql } from 'postgres';\nimport { KyselyError } from './error';\nimport { getKysely } from './plugins';\n\nexport type { Insertable, LogEvent } from 'kysely';\nexport * from './error';\nexport * from './isomorphic';\nexport * from './query';\nexport * from './regional';\nexport * from './transaction';\n\nimport { parseDuration } from '@vrplatform/utils';\nimport type { DB } from './v1.generated';\n\ntype KyselyOpts = {\n repositoryName?: string;\n log?: true | LogConfig;\n};\n\ntype PgOpt = {\n forceDisableSSL?: boolean;\n probe?: false;\n retries?: false | number;\n};\n\nconst retryableMessages = ['CONNECTION_CLOSED', 'CONNECT_TIMEOUT'];\n\nexport type Kysely = K<DB>;\nexport type Postgres = Sql;\n/**\n * @deprecated This method is deprecated in favor of the useAsyncKysely method.\n */\nexport function useKysely(postgres: Sql, options?: KyselyOpts) {\n console.debug('Creating Kysely instance');\n const kysely = getKysely(\n new PostgresJSDialect({\n postgres,\n onReserveConnection: async (connection) => {\n const executeQuery = connection.executeQuery.bind(connection);\n connection.executeQuery = (arg) =>\n backOff(async () => await executeQuery(arg), {\n numOfAttempts: 3,\n startingDelay: parseDuration('1s'),\n maxDelay: parseDuration('5s'),\n retry: (error) => {\n const message =\n error instanceof Error ? error.message : String(error);\n if (retryableMessages.some((m) => message?.includes(m))) {\n return true;\n }\n return false;\n },\n });\n },\n }),\n {\n repositoryName: options?.repositoryName,\n log: options?.log,\n }\n );\n kysely.destroy = async () => {\n console.debug('Closing Kysely connection');\n await Promise.race([\n postgres.end({ timeout: 5000 }).catch(() => undefined),\n new Promise((res) => setTimeout(res, 6000)),\n ]);\n const index = _connections.indexOf(postgres);\n if (index !== -1) _connections.splice(index, 1);\n };\n\n return kysely;\n}\n\nlet _connections: postgres.Sql[] = [];\nexport async function useAsyncPostgres(connectionString: string, opt?: PgOpt) {\n const delayMs = 2500;\n const retries =\n opt?.probe === false ? 1 : opt?.retries === false ? 0 : opt?.retries || 3;\n const ssl = opt?.forceDisableSSL !== true;\n const url = new URL(connectionString);\n\n console.debug(\n `Creating Postgres connection with ${retries} retries and ssl=${ssl} and port=${url.port}`\n );\n if (_connections.length > 0)\n console.warn(`We already have ${_connections.length} Postgres connections`);\n\n for (let attempt = 1; attempt <= retries; attempt++) {\n try {\n const sql = postgres(connectionString, {\n ssl: ssl ? 'require' : false,\n // connect_timeout: 10\n // idle_timeout: 10\n // enable prepare statements, pgbouncer on crunchy allows for prepared statements\n prepare: true,\n connect_timeout: 10,\n idle_timeout: 60,\n });\n\n if (opt?.probe !== false) {\n await sql`select 1`;\n }\n // statement_timeout/lock_timeout are role-level settings on the cluster\n // (ALTER ROLE application SET ...) so they cover every pooled\n // connection; per-session SETs here only ever applied to one of them\n\n _connections.push(sql);\n return sql;\n } catch (err) {\n if (attempt === retries) throw err;\n console.warn(\n `Postgres connection failed (attempt ${attempt}), retrying...`\n );\n console.error('error', err);\n await new Promise((res) => setTimeout(res, delayMs));\n }\n }\n throw new KyselyError('Unable to connect to Postgres');\n}\n\nexport async function useAsyncKysely(\n connectionString: string,\n opt?: PgOpt & KyselyOpts\n) {\n const sql = await useAsyncPostgres(connectionString, opt);\n return useKysely(sql, opt);\n}\n\n/**\n * @deprecated This method is deprecated in favor of the useAsyncKysely method.\n */\nexport function usePostgres(\n connectionString?: string,\n opt?: Pick<PgOpt, 'forceDisableSSL'>\n) {\n if (!connectionString) throw new KyselyError('No connection string');\n const ssl = opt?.forceDisableSSL !== true;\n const url = new URL(connectionString);\n console.debug(\n `Creating sync Postgres connection with ssl=${ssl} and port=${url.port}`\n );\n const pg = postgres(connectionString, {\n ssl: ssl ? 'require' : false,\n });\n _connections.push(pg);\n return pg;\n}\n\nexport async function forceCloseAllPostgres(timeoutMs = 5000) {\n await Promise.race([\n Promise.all(\n _connections.map((pg) =>\n pg.end({ timeout: timeoutMs }).catch(() => undefined)\n )\n ),\n new Promise((res) => setTimeout(res, timeoutMs + 1000)),\n ]);\n _connections = [];\n}\n\nexport class DatabaseError extends Error {\n constructor(message: string, cause: any) {\n super(message);\n this.cause = cause;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isomorphic.js","sourceRoot":"src/","sources":["isomorphic.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,cAAc,gBAAgB,CAAC;AAM/B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAE,KAAU
|
|
1
|
+
{"version":3,"file":"isomorphic.js","sourceRoot":"src/","sources":["isomorphic.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,cAAc,gBAAgB,CAAC;AAM/B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAE,KAAU;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type {\n ControlledTransaction as CT,\n Kysely as K,\n Transaction as T,\n} from 'kysely';\n\nexport type {\n ColumnType,\n Expression,\n ExpressionBuilder,\n ExpressionOrFactory,\n Generated,\n Insertable,\n JSONColumnType,\n KyselyPlugin,\n Nullable,\n OperandExpression,\n PluginTransformQueryArgs,\n PluginTransformResultArgs,\n QueryResult,\n RootOperationNode,\n Selectable,\n SelectQueryBuilder,\n SqlBool,\n UnknownRow,\n Updateable,\n} from 'kysely';\nexport { jsonArrayFrom } from 'kysely/helpers/postgres';\nexport * from './v1.generated';\n\nimport type { DB } from './v1.generated';\n\nexport type Transaction = T<DB>;\nexport type ControlledTransaction<S extends string[] = string[]> = CT<DB, S>;\nexport { sql } from 'kysely';\n\nexport type Kysely = K<DB>;\n\nexport class DatabaseError extends Error {\n constructor(message: string, cause: any) {\n super(message);\n this.cause = cause;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest.js","sourceRoot":"src/","sources":["local/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc
|
|
1
|
+
{"version":3,"file":"digest.js","sourceRoot":"src/","sources":["local/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc;IACvD,IAAI,CAAC;QACH,MAAM,GAAG,CAAA,6BAA6B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,CAAA;;;;;;;;;KASR,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,MAAc;IAC/D,IAAI,CAAC;QACH,MAAM,GAAG,CAAA,4BAA4B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,CAAA;;;;;;;;;;;;;;;;;;KAkBR,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["import { type Kysely, sql } from '../isomorphic';\n\nexport async function ensureDigestFunction(kysely: Kysely) {\n try {\n await sql`select digest('', 'sha256')`.execute(kysely);\n } catch {\n await sql`\n create or replace function digest(input text, algo text)\n returns bytea\n language sql\n immutable\n strict\n as $$\n select '\\\\x0000000000000000000000000000000000000000000000000000000000000000'::bytea;\n $$;\n `.execute(kysely);\n }\n}\n\nexport async function ensureGenRandomBytesFunction(kysely: Kysely) {\n try {\n await sql`select gen_random_bytes(1)`.execute(kysely);\n } catch {\n await sql`\n create or replace function gen_random_bytes(p_len integer)\n returns bytea\n language sql\n stable\n strict\n as $$\n select substring(\n decode(\n repeat(\n md5(random()::text || now()::text),\n ((p_len + 15) / 16)\n ),\n 'hex'\n )\n from 1 for p_len\n );\n $$;\n `.execute(kysely);\n }\n}\n"]}
|