@vrplatform/kysely 1.3.45-stage.5710 → 1.3.45-stage.573

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 (116) hide show
  1. package/build/.data.tar +0 -0
  2. package/build/main/control-plane/index.d.ts +331 -16
  3. package/build/main/control-plane/index.js +61 -0
  4. package/build/main/control-plane/index.js.map +1 -1
  5. package/build/main/index.d.ts +17 -4
  6. package/build/main/index.js +220 -25
  7. package/build/main/index.js.map +1 -1
  8. package/build/main/isomorphic.d.ts +4 -2
  9. package/build/main/isomorphic.js.map +1 -1
  10. package/build/main/local/digest.d.ts +3 -3
  11. package/build/main/local/digest.js.map +1 -1
  12. package/build/main/local/generate.js +2 -0
  13. package/build/main/local/generate.js.map +1 -1
  14. package/build/main/local/index.d.ts +5 -1
  15. package/build/main/local/index.js +316 -6
  16. package/build/main/local/index.js.map +1 -1
  17. package/build/main/postgres-error.d.ts +3 -3
  18. package/build/main/postgres-error.js +4 -3
  19. package/build/main/postgres-error.js.map +1 -1
  20. package/build/main/query/listing/status.js +2 -6
  21. package/build/main/query/listing/status.js.map +1 -1
  22. package/build/main/query/tenant/status.d.ts +5 -8
  23. package/build/main/query/tenant/status.js +16 -20
  24. package/build/main/query/tenant/status.js.map +1 -1
  25. package/build/main/regional.d.ts +7 -1
  26. package/build/main/regional.js +14 -9
  27. package/build/main/regional.js.map +1 -1
  28. package/build/main/test/index.d.ts +25 -7
  29. package/build/main/test/index.js +35 -13
  30. package/build/main/test/index.js.map +1 -1
  31. package/build/main/transaction.d.ts +3 -3
  32. package/build/main/transaction.js.map +1 -1
  33. package/build/main/v1.generated.d.ts +559 -6
  34. package/build/main/v1.generated.js.map +1 -1
  35. package/build/migrations-v2/0000000000010-bank-rule-application-bank-record-delete-cascade.ts +26 -0
  36. package/build/migrations-v2/0000000000011-guest-balance-journal-entry-lookup-index.ts +25 -0
  37. package/build/migrations-v2/0000000000012-trial-free-analytics-billing-status.ts +72 -0
  38. package/build/migrations-v2/0000000000013-ui-permission-bundles.ts +45 -0
  39. package/build/migrations-v2/0000000000014-ui-permission-bundle-top-up.ts +32 -0
  40. package/build/migrations-v2/0000000000015-durable-flow-events.ts +163 -0
  41. package/build/migrations-v2/0000000000016-billing-listing-facts.ts +539 -0
  42. package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
  43. package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
  44. package/build/migrations-v2/0000000000017-webhook-secret-reencryption-failures.ts +18 -0
  45. package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
  46. package/build/migrations-v2/0000000000018-durable-flow-event-sensitive-input.ts +28 -0
  47. package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
  48. package/build/migrations-v2/0000000000019-asynchronous-operations.ts +736 -0
  49. package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
  50. package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
  51. package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
  52. package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
  53. package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
  54. package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
  55. package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
  56. package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
  57. package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
  58. package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
  59. package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
  60. package/build/migrations-v2/0000000000031-ui-permission-role-simplification.ts +70 -0
  61. package/build/migrations-v2/0000000000032-tenant-delete-ownership-cascades.ts +44 -0
  62. package/build/migrations-v2/0000000000033-reservation-issue-seed-bucket-index.ts +19 -0
  63. package/build/migrations-v2/0000000000034-retire-recent-classification-indexes.ts +29 -0
  64. package/build/migrations-v2/0000000000035-core-change-autovacuum.ts +24 -0
  65. package/build/migrations-v2/0000000000036-journal-entry-inactive-reason-constraint.ts +33 -0
  66. package/build/migrations-v2/0000000000037-journal-entry-inactive-reasons.ts +19 -0
  67. package/build/migrations-v2/0000000000038-journal-entry-group-inactive-reason.ts +14 -0
  68. package/build/migrations-v2/0000000000039-reservation-guest-breakdown.ts +19 -0
  69. package/build/migrations-v2/0000000000040-csv-import-source-identity-index.ts +23 -0
  70. package/build/migrations-v2/0000000000041-payment-returns.ts +38 -0
  71. package/build/migrations-v2/0000000000042-operation-resource-types.ts +609 -0
  72. package/build/migrations-v2/0000000000043-reservation-journal-freshness.ts +149 -0
  73. package/build/migrations-v2/0000000000044-reservation-journal-freshness-backfill.ts +254 -0
  74. package/build/migrations-v2/0000000000045-reservation-journal-freshness-revision-repair.ts +83 -0
  75. package/build/migrations-v2/0000000000046-materialized-reservation-journal-operations.ts +709 -0
  76. package/build/migrations-v2/0000000000047-public-audit-completion.ts +77 -0
  77. package/build/migrations-v2/0000000000048-reservation-journal-full-refresh-repair.ts +136 -0
  78. package/build/migrations-v2/0000000000049-queued-journal-operation-failures.ts +60 -0
  79. package/build/migrations-v2/0000000000050-connection-oauth-state.ts +43 -0
  80. package/build/migrations-v2/0000000000051-owner-statement-email-delivery.ts +134 -0
  81. package/build/migrations-v2/0000000000052-fee-journal-lock-skip-operations.ts +59 -0
  82. package/build/migrations-v2/0000000000053-fee-journal-lock-skip-null-attempt.ts +44 -0
  83. package/build/module/control-plane/index.d.ts +331 -16
  84. package/build/module/control-plane/index.js +49 -1
  85. package/build/module/control-plane/index.js.map +1 -1
  86. package/build/module/index.d.ts +17 -4
  87. package/build/module/index.js +222 -26
  88. package/build/module/index.js.map +1 -1
  89. package/build/module/isomorphic.d.ts +4 -2
  90. package/build/module/isomorphic.js.map +1 -1
  91. package/build/module/local/digest.d.ts +3 -3
  92. package/build/module/local/digest.js.map +1 -1
  93. package/build/module/local/generate.js +2 -0
  94. package/build/module/local/generate.js.map +1 -1
  95. package/build/module/local/index.d.ts +5 -1
  96. package/build/module/local/index.js +317 -7
  97. package/build/module/local/index.js.map +1 -1
  98. package/build/module/postgres-error.d.ts +3 -3
  99. package/build/module/postgres-error.js +4 -3
  100. package/build/module/postgres-error.js.map +1 -1
  101. package/build/module/query/listing/status.js +2 -6
  102. package/build/module/query/listing/status.js.map +1 -1
  103. package/build/module/query/tenant/status.d.ts +5 -8
  104. package/build/module/query/tenant/status.js +16 -20
  105. package/build/module/query/tenant/status.js.map +1 -1
  106. package/build/module/regional.d.ts +7 -1
  107. package/build/module/regional.js +14 -9
  108. package/build/module/regional.js.map +1 -1
  109. package/build/module/test/index.d.ts +25 -7
  110. package/build/module/test/index.js +35 -14
  111. package/build/module/test/index.js.map +1 -1
  112. package/build/module/transaction.d.ts +3 -3
  113. package/build/module/transaction.js.map +1 -1
  114. package/build/module/v1.generated.d.ts +559 -6
  115. package/build/module/v1.generated.js.map +1 -1
  116. package/package.json +3 -2
@@ -0,0 +1,32 @@
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 = case
13
+ when tenant_user.role = 'admin' and tenant.type = 'partner'
14
+ then array['ui:team-admin:v1', 'ui:partner-admin:v1']::text[]
15
+ when tenant_user.role = 'admin'
16
+ then array['ui:team-admin:v1']::text[]
17
+ when tenant_user.role = 'user'
18
+ then array['ui:accounting:v1']::text[]
19
+ else tenant_user.permission_bundles
20
+ end
21
+ from public.tenant as tenant
22
+ where tenant.id = tenant_user.tenant_id
23
+ and cardinality(tenant_user.permission_bundles) = 0
24
+ and tenant_user.role in ('admin', 'user')
25
+ `.execute(db);
26
+ await sql`
27
+ alter table public.tenant_user
28
+ enable trigger set_public_tenant_user_updated_at
29
+ `.execute(db);
30
+ }
31
+
32
+ export async function down(_db: Kysely<unknown>): Promise<void> {}
@@ -0,0 +1,163 @@
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 type core.flow_event_status as enum (
7
+ 'pending', 'processing', 'succeeded', 'dead', 'canceled'
8
+ )
9
+ `.execute(db);
10
+ await sql`
11
+ create type core.flow_event_operation_action as enum (
12
+ 'replay', 'abandon'
13
+ )
14
+ `.execute(db);
15
+
16
+ await sql`
17
+ create table core.flow_event (
18
+ id uuid primary key default gen_random_uuid(),
19
+ tenant_id uuid not null,
20
+ event_type text not null,
21
+ entity_type text not null,
22
+ entity_id uuid not null,
23
+ data jsonb not null default '{}'::jsonb,
24
+ sync_id uuid,
25
+ target_connection_id uuid,
26
+ target_flow_id uuid,
27
+ status core.flow_event_status not null default 'pending',
28
+ available_at timestamptz not null default now(),
29
+ claimed_at timestamptz,
30
+ claimed_by text,
31
+ attempts integer not null default 0,
32
+ max_attempts integer not null default 10,
33
+ completed_at timestamptz,
34
+ last_error_code text,
35
+ last_error_details jsonb,
36
+ created_at timestamptz not null default now(),
37
+ updated_at timestamptz not null default now(),
38
+ constraint flow_event_attempts_check check (attempts >= 0),
39
+ constraint flow_event_max_attempts_check check (max_attempts > 0),
40
+ constraint flow_event_target_check check (
41
+ target_connection_id is not null
42
+ or target_flow_id is null
43
+ )
44
+ )
45
+ `.execute(db);
46
+
47
+ await sql`
48
+ create table core.flow_event_delivery (
49
+ id uuid primary key default gen_random_uuid(),
50
+ event_id uuid not null
51
+ references core.flow_event(id) on delete cascade,
52
+ tenant_id uuid not null,
53
+ connection_id uuid not null,
54
+ flow_id uuid not null,
55
+ status core.flow_event_status not null default 'pending',
56
+ available_at timestamptz not null default now(),
57
+ claimed_at timestamptz,
58
+ claimed_by text,
59
+ attempts integer not null default 0,
60
+ max_attempts integer not null default 10,
61
+ trigger_run_id text,
62
+ completed_at timestamptz,
63
+ last_error_code text,
64
+ last_error_details jsonb,
65
+ created_at timestamptz not null default now(),
66
+ updated_at timestamptz not null default now(),
67
+ constraint flow_event_delivery_attempts_check check (attempts >= 0),
68
+ constraint flow_event_delivery_max_attempts_check
69
+ check (max_attempts > 0),
70
+ constraint flow_event_delivery_listener_key
71
+ unique (event_id, connection_id, flow_id)
72
+ )
73
+ `.execute(db);
74
+
75
+ await sql`
76
+ create table core.flow_event_secret (
77
+ event_id uuid primary key
78
+ references core.flow_event(id) on delete cascade,
79
+ encryption_key_id text not null,
80
+ encrypted_payload text not null,
81
+ expires_at timestamptz not null,
82
+ created_at timestamptz not null default now()
83
+ )
84
+ `.execute(db);
85
+ await sql`
86
+ create table core.flow_event_operation (
87
+ id uuid primary key default gen_random_uuid(),
88
+ event_id uuid not null references core.flow_event(id) on delete cascade,
89
+ action core.flow_event_operation_action not null,
90
+ actor text not null,
91
+ reason_code text not null,
92
+ previous_status core.flow_event_status not null,
93
+ created_at timestamptz not null default now()
94
+ )
95
+ `.execute(db);
96
+
97
+ await sql`
98
+ create index flow_event_pending_idx
99
+ on core.flow_event (available_at, created_at, id)
100
+ where status = 'pending'
101
+ `.execute(db);
102
+ await sql`
103
+ create index flow_event_stale_claim_idx
104
+ on core.flow_event (claimed_at, id)
105
+ where status = 'processing'
106
+ `.execute(db);
107
+ await sql`
108
+ create index flow_event_tenant_history_idx
109
+ on core.flow_event (tenant_id, created_at desc, id desc)
110
+ `.execute(db);
111
+ await sql`
112
+ create index flow_event_sync_idx
113
+ on core.flow_event (tenant_id, sync_id)
114
+ where sync_id is not null
115
+ `.execute(db);
116
+ await sql`
117
+ create index flow_event_delivery_pending_idx
118
+ on core.flow_event_delivery (available_at, created_at, id)
119
+ where status = 'pending'
120
+ `.execute(db);
121
+ await sql`
122
+ create index flow_event_delivery_stale_claim_idx
123
+ on core.flow_event_delivery (claimed_at, id)
124
+ where status = 'processing'
125
+ `.execute(db);
126
+ await sql`
127
+ create index flow_event_delivery_event_idx
128
+ on core.flow_event_delivery (event_id, status, id)
129
+ `.execute(db);
130
+ await sql`
131
+ create index flow_event_secret_expiry_idx
132
+ on core.flow_event_secret (expires_at, event_id)
133
+ `.execute(db);
134
+ await sql`
135
+ create index flow_event_operation_history_idx
136
+ on core.flow_event_operation (event_id, created_at desc, id desc)
137
+ `.execute(db);
138
+
139
+ await sql`
140
+ do $$
141
+ begin
142
+ if exists (select 1 from pg_roles where rolname = 'application') then
143
+ grant usage on schema core to application;
144
+ grant select, insert, update, delete
145
+ on core.flow_event,
146
+ core.flow_event_delivery,
147
+ core.flow_event_operation,
148
+ core.flow_event_secret
149
+ to application;
150
+ end if;
151
+ end
152
+ $$
153
+ `.execute(db);
154
+ }
155
+
156
+ export async function down(db: Kysely<unknown>): Promise<void> {
157
+ await sql`drop table if exists core.flow_event_operation`.execute(db);
158
+ await sql`drop table if exists core.flow_event_secret`.execute(db);
159
+ await sql`drop table if exists core.flow_event_delivery`.execute(db);
160
+ await sql`drop table if exists core.flow_event`.execute(db);
161
+ await sql`drop type if exists core.flow_event_operation_action`.execute(db);
162
+ await sql`drop type if exists core.flow_event_status`.execute(db);
163
+ }