@vrplatform/kysely 1.3.45-stage.6066 → 1.3.45-stage.607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/build/.data.tar +0 -0
  2. package/build/main/control-plane/index.d.ts +312 -0
  3. package/build/main/control-plane/index.js.map +1 -1
  4. package/build/main/index.d.ts +13 -2
  5. package/build/main/index.js +217 -23
  6. package/build/main/index.js.map +1 -1
  7. package/build/main/local/generate.js +2 -0
  8. package/build/main/local/generate.js.map +1 -1
  9. package/build/main/local/index.js +110 -8
  10. package/build/main/local/index.js.map +1 -1
  11. package/build/main/postgres-error.d.ts +3 -3
  12. package/build/main/postgres-error.js +4 -3
  13. package/build/main/postgres-error.js.map +1 -1
  14. package/build/main/query/listing/status.js +2 -6
  15. package/build/main/query/listing/status.js.map +1 -1
  16. package/build/main/query/tenant/status.d.ts +1 -1
  17. package/build/main/query/tenant/status.js +6 -4
  18. package/build/main/query/tenant/status.js.map +1 -1
  19. package/build/main/regional.d.ts +1 -0
  20. package/build/main/regional.js +1 -0
  21. package/build/main/regional.js.map +1 -1
  22. package/build/main/test/index.d.ts +23 -3
  23. package/build/main/test/index.js +35 -13
  24. package/build/main/test/index.js.map +1 -1
  25. package/build/main/v1.generated.d.ts +560 -8
  26. package/build/main/v1.generated.js.map +1 -1
  27. package/build/migrations-v2/0000000000015-durable-flow-events.ts +163 -0
  28. package/build/migrations-v2/0000000000016-billing-listing-facts.ts +539 -0
  29. package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
  30. package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
  31. package/build/migrations-v2/0000000000017-webhook-secret-reencryption-failures.ts +18 -0
  32. package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
  33. package/build/migrations-v2/0000000000018-durable-flow-event-sensitive-input.ts +28 -0
  34. package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
  35. package/build/migrations-v2/0000000000019-asynchronous-operations.ts +736 -0
  36. package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
  37. package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
  38. package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
  39. package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
  40. package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
  41. package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
  42. package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
  43. package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
  44. package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
  45. package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
  46. package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
  47. package/build/migrations-v2/0000000000031-ui-permission-role-simplification.ts +70 -0
  48. package/build/migrations-v2/0000000000032-tenant-delete-ownership-cascades.ts +44 -0
  49. package/build/migrations-v2/0000000000033-reservation-issue-seed-bucket-index.ts +19 -0
  50. package/build/migrations-v2/0000000000034-retire-recent-classification-indexes.ts +29 -0
  51. package/build/migrations-v2/0000000000035-core-change-autovacuum.ts +24 -0
  52. package/build/migrations-v2/0000000000036-journal-entry-inactive-reason-constraint.ts +33 -0
  53. package/build/migrations-v2/0000000000037-journal-entry-inactive-reasons.ts +19 -0
  54. package/build/migrations-v2/0000000000038-journal-entry-group-inactive-reason.ts +14 -0
  55. package/build/migrations-v2/0000000000039-reservation-guest-breakdown.ts +19 -0
  56. package/build/migrations-v2/0000000000040-csv-import-source-identity-index.ts +23 -0
  57. package/build/migrations-v2/0000000000041-payment-returns.ts +38 -0
  58. package/build/migrations-v2/0000000000042-operation-resource-types.ts +609 -0
  59. package/build/migrations-v2/0000000000043-reservation-journal-freshness.ts +149 -0
  60. package/build/migrations-v2/0000000000044-reservation-journal-freshness-backfill.ts +254 -0
  61. package/build/migrations-v2/0000000000045-reservation-journal-freshness-revision-repair.ts +83 -0
  62. package/build/migrations-v2/0000000000046-materialized-reservation-journal-operations.ts +709 -0
  63. package/build/migrations-v2/0000000000047-public-audit-completion.ts +77 -0
  64. package/build/migrations-v2/0000000000048-reservation-journal-full-refresh-repair.ts +136 -0
  65. package/build/migrations-v2/0000000000049-queued-journal-operation-failures.ts +60 -0
  66. package/build/migrations-v2/0000000000050-connection-oauth-state.ts +43 -0
  67. package/build/migrations-v2/0000000000051-owner-statement-email-delivery.ts +134 -0
  68. package/build/migrations-v2/0000000000052-fee-journal-lock-skip-operations.ts +59 -0
  69. package/build/migrations-v2/0000000000053-fee-journal-lock-skip-null-attempt.ts +44 -0
  70. package/build/migrations-v2/0000000000054-journal-refresh-issue-codes.ts +16 -0
  71. package/build/migrations-v2/0000000000055-tenant-billing-subscription.ts +8 -0
  72. package/build/module/control-plane/index.d.ts +312 -0
  73. package/build/module/control-plane/index.js.map +1 -1
  74. package/build/module/index.d.ts +13 -2
  75. package/build/module/index.js +219 -24
  76. package/build/module/index.js.map +1 -1
  77. package/build/module/local/generate.js +2 -0
  78. package/build/module/local/generate.js.map +1 -1
  79. package/build/module/local/index.js +110 -8
  80. package/build/module/local/index.js.map +1 -1
  81. package/build/module/postgres-error.d.ts +3 -3
  82. package/build/module/postgres-error.js +4 -3
  83. package/build/module/postgres-error.js.map +1 -1
  84. package/build/module/query/listing/status.js +2 -6
  85. package/build/module/query/listing/status.js.map +1 -1
  86. package/build/module/query/tenant/status.d.ts +1 -1
  87. package/build/module/query/tenant/status.js +6 -4
  88. package/build/module/query/tenant/status.js.map +1 -1
  89. package/build/module/regional.d.ts +1 -0
  90. package/build/module/regional.js +1 -0
  91. package/build/module/regional.js.map +1 -1
  92. package/build/module/test/index.d.ts +23 -3
  93. package/build/module/test/index.js +34 -13
  94. package/build/module/test/index.js.map +1 -1
  95. package/build/module/v1.generated.d.ts +560 -8
  96. package/build/module/v1.generated.js.map +1 -1
  97. package/package.json +4 -2
@@ -0,0 +1,40 @@
1
+ import { type Kysely, sql } from 'kysely';
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await sql`set local lock_timeout = '5s'`.execute(db);
5
+ await sql`
6
+ alter table health.accounting_integrity_run
7
+ add column definition_version_id uuid,
8
+ add column definition_artifact_hash text,
9
+ add column definition_template_id text,
10
+ add column definition_template_version integer,
11
+ add column operator_definition_version integer,
12
+ add constraint accounting_integrity_run_definition_artifact_check check (
13
+ (
14
+ definition_version_id is null and
15
+ definition_artifact_hash is null and
16
+ definition_template_id is null and
17
+ definition_template_version is null and
18
+ operator_definition_version is null
19
+ ) or (
20
+ definition_version_id is not null and
21
+ definition_artifact_hash is not null and
22
+ definition_template_id is not null and
23
+ definition_template_version > 0 and
24
+ operator_definition_version > 0
25
+ )
26
+ )
27
+ `.execute(db);
28
+ }
29
+
30
+ export async function down(db: Kysely<unknown>): Promise<void> {
31
+ await sql`
32
+ alter table health.accounting_integrity_run
33
+ drop constraint accounting_integrity_run_definition_artifact_check,
34
+ drop column operator_definition_version,
35
+ drop column definition_template_version,
36
+ drop column definition_template_id,
37
+ drop column definition_artifact_hash,
38
+ drop column definition_version_id
39
+ `.execute(db);
40
+ }
@@ -0,0 +1,49 @@
1
+ import { type Kysely, sql } from 'kysely';
2
+
3
+ export async function up(db: Kysely<unknown>): Promise<void> {
4
+ await sql`set local lock_timeout = '5s'`.execute(db);
5
+ await sql`
6
+ alter table health.accounting_integrity_case
7
+ drop constraint accounting_integrity_case_review_metadata_check,
8
+ add constraint accounting_integrity_case_review_metadata_check check (
9
+ (
10
+ reviewed_by is null and reviewed_at is null and
11
+ review_rationale is null
12
+ ) or (
13
+ reviewed_by is not null and reviewed_at is not null and
14
+ nullif(trim(review_rationale), '') is not null
15
+ )
16
+ )
17
+ `.execute(db);
18
+ }
19
+
20
+ export async function down(db: Kysely<unknown>): Promise<void> {
21
+ await sql`
22
+ update health.accounting_integrity_case
23
+ set reviewed_by = null, reviewed_at = null, review_rationale = null
24
+ where review_status = 'unreviewed'
25
+ `.execute(db);
26
+ await sql`
27
+ update health.accounting_integrity_case
28
+ set
29
+ reviewed_by = coalesce(reviewed_by, 'legacy-monitoring'),
30
+ reviewed_at = coalesce(reviewed_at, last_changed_at),
31
+ review_rationale = coalesce(
32
+ nullif(trim(review_rationale), ''),
33
+ 'Migrated from compatibility review state.'
34
+ )
35
+ where review_status <> 'unreviewed'
36
+ `.execute(db);
37
+ await sql`
38
+ alter table health.accounting_integrity_case
39
+ drop constraint accounting_integrity_case_review_metadata_check,
40
+ add constraint accounting_integrity_case_review_metadata_check check (
41
+ (review_status = 'unreviewed' and reviewed_by is null and
42
+ reviewed_at is null and review_rationale is null)
43
+ or
44
+ (review_status <> 'unreviewed' and reviewed_by is not null and
45
+ reviewed_at is not null and nullif(trim(review_rationale), '')
46
+ is not null)
47
+ )
48
+ `.execute(db);
49
+ }
@@ -0,0 +1,70 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`
7
+ alter table public.tenant_user
8
+ disable trigger set_public_tenant_user_updated_at
9
+ `.execute(db);
10
+ await sql`
11
+ update public.tenant_user as tenant_user
12
+ set permission_bundles = (
13
+ select array_agg(mapped.bundle order by mapped.first_ordinal)
14
+ from (
15
+ select
16
+ case existing.bundle
17
+ when 'ui:accounting:v1' then 'ui:standard-member:v1'
18
+ when 'ui:owner-statements:v1' then 'ui:operations:v1'
19
+ when 'ui:reports-viewer:v1' then 'ui:read-only:v1'
20
+ else existing.bundle
21
+ end as bundle,
22
+ min(existing.ordinality) as first_ordinal
23
+ from unnest(tenant_user.permission_bundles)
24
+ with ordinality as existing(bundle, ordinality)
25
+ group by
26
+ case existing.bundle
27
+ when 'ui:accounting:v1' then 'ui:standard-member:v1'
28
+ when 'ui:owner-statements:v1' then 'ui:operations:v1'
29
+ when 'ui:reports-viewer:v1' then 'ui:read-only:v1'
30
+ else existing.bundle
31
+ end
32
+ ) as mapped
33
+ )
34
+ where tenant_user.permission_bundles && array[
35
+ 'ui:accounting:v1',
36
+ 'ui:owner-statements:v1',
37
+ 'ui:reports-viewer:v1'
38
+ ]::text[]
39
+ `.execute(db);
40
+ await sql`
41
+ alter table public.tenant_user
42
+ enable trigger set_public_tenant_user_updated_at
43
+ `.execute(db);
44
+ await sql`alter table public.tenant disable trigger user`.execute(db);
45
+ await sql`
46
+ update public.tenant as tenant
47
+ set partner_denied_permissions = (
48
+ select array_agg(rewritten.permission order by rewritten.first_ordinal)
49
+ from (
50
+ select
51
+ permission,
52
+ min(ordinality) as first_ordinal
53
+ from unnest(
54
+ array_remove(tenant.partner_denied_permissions, 'transactions:write')
55
+ || array[
56
+ 'transactions:deposits:write',
57
+ 'transactions:expenses:write',
58
+ 'transactions:transfers:write',
59
+ 'transactions:payouts:write'
60
+ ]::text[]
61
+ ) with ordinality as expanded(permission, ordinality)
62
+ group by permission
63
+ ) as rewritten
64
+ )
65
+ where 'transactions:write' = any(tenant.partner_denied_permissions)
66
+ `.execute(db);
67
+ await sql`alter table public.tenant enable trigger user`.execute(db);
68
+ }
69
+
70
+ export async function down(_db: Kysely<unknown>): Promise<void> {}
@@ -0,0 +1,44 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`
6
+ alter table public.connection
7
+ drop constraint connection_tenant_id_fkey,
8
+ add constraint connection_tenant_id_fkey
9
+ foreign key (tenant_id)
10
+ references public.tenant(id)
11
+ on update restrict
12
+ on delete cascade
13
+ `.execute(db);
14
+ await sql`
15
+ alter table accounting.account_reservation_line_type
16
+ drop constraint account_reservation_line_type_account_id_fkey,
17
+ add constraint account_reservation_line_type_account_id_fkey
18
+ foreign key (account_id)
19
+ references accounting.account(id)
20
+ on update restrict
21
+ on delete cascade
22
+ `.execute(db);
23
+ }
24
+
25
+ export async function down(db: Kysely<unknown>): Promise<void> {
26
+ await sql`
27
+ alter table accounting.account_reservation_line_type
28
+ drop constraint account_reservation_line_type_account_id_fkey,
29
+ add constraint account_reservation_line_type_account_id_fkey
30
+ foreign key (account_id)
31
+ references accounting.account(id)
32
+ on update restrict
33
+ on delete restrict
34
+ `.execute(db);
35
+ await sql`
36
+ alter table public.connection
37
+ drop constraint connection_tenant_id_fkey,
38
+ add constraint connection_tenant_id_fkey
39
+ foreign key (tenant_id)
40
+ references public.tenant(id)
41
+ on update restrict
42
+ on delete restrict
43
+ `.execute(db);
44
+ }
@@ -0,0 +1,19 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`
6
+ create index if not exists reservation_issue_seed_bucket_idx
7
+ on public.reservation (
8
+ (get_byte(uuid_send(id), 15) % 60),
9
+ id
10
+ )
11
+ include (tenant_id)
12
+ `.execute(db);
13
+ }
14
+
15
+ export async function down(db: Kysely<unknown>): Promise<void> {
16
+ await sql`
17
+ drop index if exists public.reservation_issue_seed_bucket_idx
18
+ `.execute(db);
19
+ }
@@ -0,0 +1,29 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`
6
+ drop index if exists public.payment_line_recent_classification_idx
7
+ `.execute(db);
8
+ await sql`
9
+ drop index if exists
10
+ accounting.transaction_line_recent_classification_idx
11
+ `.execute(db);
12
+ }
13
+
14
+ export async function down(db: Kysely<unknown>): Promise<void> {
15
+ await sql`
16
+ create index if not exists payment_line_recent_classification_idx
17
+ on public.payment_line (updated_at, type2)
18
+ include (payment_id, reservation_id)
19
+ where type2 is not null and type2 != 'deviation'
20
+ `.execute(db);
21
+ await sql`
22
+ create index if not exists transaction_line_recent_classification_idx
23
+ on accounting.transaction_line (
24
+ updated_at,
25
+ match_line_type_classification
26
+ )
27
+ where match_line_type_classification is not null
28
+ `.execute(db);
29
+ }
@@ -0,0 +1,24 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`set local statement_timeout = '60s'`.execute(db);
7
+ await sql`
8
+ alter table core.change set (
9
+ autovacuum_vacuum_scale_factor = 0.001,
10
+ autovacuum_analyze_scale_factor = 0.001
11
+ )
12
+ `.execute(db);
13
+ }
14
+
15
+ export async function down(db: Kysely<unknown>): Promise<void> {
16
+ await sql`set local lock_timeout = '5s'`.execute(db);
17
+ await sql`set local statement_timeout = '60s'`.execute(db);
18
+ await sql`
19
+ alter table core.change reset (
20
+ autovacuum_vacuum_scale_factor,
21
+ autovacuum_analyze_scale_factor
22
+ )
23
+ `.execute(db);
24
+ }
@@ -0,0 +1,33 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`set local statement_timeout = '60s'`.execute(db);
7
+ await sql`
8
+ alter table accounting.journal_entry
9
+ add constraint journal_entry_inactive_reason_status_check
10
+ check (
11
+ (
12
+ status = 'inactive'
13
+ and inactive_reason is not null
14
+ )
15
+ or
16
+ (
17
+ status <> 'inactive'
18
+ and inactive_reason is null
19
+ )
20
+ ) not valid
21
+ `.execute(db);
22
+ await sql`
23
+ alter table accounting.journal_entry
24
+ validate constraint journal_entry_inactive_reason_status_check
25
+ `.execute(db);
26
+ }
27
+
28
+ export async function down(db: Kysely<unknown>): Promise<void> {
29
+ await sql`
30
+ alter table accounting.journal_entry
31
+ drop constraint if exists journal_entry_inactive_reason_status_check
32
+ `.execute(db);
33
+ }
@@ -0,0 +1,19 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`
6
+ alter type accounting.journal_entry_inactive_reason
7
+ add value if not exists 'historicalLedger'
8
+ before 'unknownInactiveReason'
9
+ `.execute(db);
10
+ await sql`
11
+ alter type accounting.journal_entry_inactive_reason
12
+ add value if not exists 'listingOwnershipPeriodNotFound'
13
+ before 'unknownInactiveReason'
14
+ `.execute(db);
15
+ }
16
+
17
+ export async function down(_db: Kysely<unknown>): Promise<void> {
18
+ // PostgreSQL enum values cannot be removed safely without rebuilding the type.
19
+ }
@@ -0,0 +1,14 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`
6
+ alter type accounting.journal_entry_inactive_reason
7
+ add value if not exists 'unbalancedGroupInactiveLeg'
8
+ before 'unknownInactiveReason'
9
+ `.execute(db);
10
+ }
11
+
12
+ export async function down(_db: Kysely<unknown>): Promise<void> {
13
+ // PostgreSQL enum values cannot be removed safely without rebuilding the type.
14
+ }
@@ -0,0 +1,19 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '180s'`.execute(db);
6
+ await sql`
7
+ alter table public.reservation
8
+ add column adults integer,
9
+ add column children integer
10
+ `.execute(db);
11
+ }
12
+
13
+ export async function down(db: Kysely<unknown>): Promise<void> {
14
+ await sql`
15
+ alter table public.reservation
16
+ drop column children,
17
+ drop column adults
18
+ `.execute(db);
19
+ }
@@ -0,0 +1,23 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`
6
+ create index sync_csv_import_source_identity_idx
7
+ on core.sync (
8
+ tenant_id,
9
+ (params ->> 'resource'),
10
+ ((params -> 'targetIdentity') ->> 'type'),
11
+ ((params -> 'targetIdentity') ->> 'id'),
12
+ (params ->> 'sourceHash'),
13
+ created_at desc
14
+ )
15
+ where params @> '{"category":"csvImportV2"}'::jsonb
16
+ `.execute(db);
17
+ }
18
+
19
+ export async function down(db: Kysely<unknown>): Promise<void> {
20
+ await sql`
21
+ drop index core.sync_csv_import_source_identity_idx
22
+ `.execute(db);
23
+ }
@@ -0,0 +1,38 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<unknown>): Promise<void> {
5
+ await sql`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`set local statement_timeout = '60s'`.execute(db);
7
+ await sql`
8
+ alter table accounting.transaction
9
+ add column returned_from_transaction_id uuid null
10
+ references accounting.transaction (id) on delete restrict,
11
+ add column return_effective_at timestamptz null,
12
+ add constraint transaction_payment_return_shape_check check (
13
+ (returned_from_transaction_id is null) = (return_effective_at is null)
14
+ and returned_from_transaction_id is distinct from id
15
+ and (
16
+ returned_from_transaction_id is null
17
+ or (type = 'payout' and cent_total > 0)
18
+ )
19
+ )
20
+ `.execute(db);
21
+ await sql`
22
+ create index transaction_returned_from_idx
23
+ on accounting.transaction (tenant_id, returned_from_transaction_id)
24
+ where returned_from_transaction_id is not null
25
+ `.execute(db);
26
+ }
27
+
28
+ export async function down(db: Kysely<unknown>): Promise<void> {
29
+ await sql`
30
+ drop index accounting.transaction_returned_from_idx
31
+ `.execute(db);
32
+ await sql`
33
+ alter table accounting.transaction
34
+ drop constraint transaction_payment_return_shape_check,
35
+ drop column return_effective_at,
36
+ drop column returned_from_transaction_id
37
+ `.execute(db);
38
+ }