@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
|
@@ -3,22 +3,22 @@ export declare function whereListingIsInactive(eb: ExpressionBuilder<DB & {
|
|
|
3
3
|
l: PublicListing;
|
|
4
4
|
}, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
|
|
5
5
|
l: PublicListing;
|
|
6
|
-
}, "l", import("kysely").SqlBool>;
|
|
6
|
+
}, "l", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
7
7
|
export declare function whereListingIsActive(eb: ExpressionBuilder<DB & {
|
|
8
8
|
l: PublicListing;
|
|
9
9
|
}, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
|
|
10
10
|
l: PublicListing;
|
|
11
|
-
}, "l", import("kysely").SqlBool>;
|
|
11
|
+
}, "l", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
12
12
|
export declare function selectListingIsInactive(eb: ExpressionBuilder<DB & {
|
|
13
13
|
l: PublicListing;
|
|
14
14
|
}, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
|
|
15
15
|
l: PublicListing;
|
|
16
|
-
}, "l", import("kysely").SqlBool>;
|
|
16
|
+
}, "l", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
17
17
|
export declare function selectListingIsActive(eb: ExpressionBuilder<DB & {
|
|
18
18
|
l: PublicListing;
|
|
19
19
|
}, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
|
|
20
20
|
l: PublicListing;
|
|
21
|
-
}, "l", import("kysely").SqlBool>;
|
|
21
|
+
}, "l", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
22
22
|
export declare function selectListingStatus(eb: ExpressionBuilder<DB & {
|
|
23
23
|
l: PublicListing;
|
|
24
24
|
}, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
|
|
@@ -6,6 +6,7 @@ exports.selectListingIsInactive = selectListingIsInactive;
|
|
|
6
6
|
exports.selectListingIsActive = selectListingIsActive;
|
|
7
7
|
exports.selectListingStatus = selectListingStatus;
|
|
8
8
|
const utils_1 = require("@vrplatform/utils");
|
|
9
|
+
const isomorphic_1 = require("../../isomorphic");
|
|
9
10
|
function hasActiveTenant(eb) {
|
|
10
11
|
return eb.exists(eb
|
|
11
12
|
.selectFrom('public.tenant as tenant')
|
|
@@ -24,7 +25,7 @@ function hasInactiveOwnership(eb, today) {
|
|
|
24
25
|
return eb.exists(eb
|
|
25
26
|
.selectFrom('public.listingOwnershipPeriod as lop')
|
|
26
27
|
.select('lop.id')
|
|
27
|
-
.
|
|
28
|
+
.where('lop.listingId', '=', (0, isomorphic_1.sql) `coalesce(${isomorphic_1.sql.ref('l.parentId')}, ${isomorphic_1.sql.ref('l.id')})`)
|
|
28
29
|
.whereRef('lop.tenantId', '=', 'l.tenantId')
|
|
29
30
|
.where('lop.setListingInactive', '=', true)
|
|
30
31
|
.where((eb2) => eb2.or([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"src/","sources":["query/listing/status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"src/","sources":["query/listing/status.ts"],"names":[],"mappings":";;AA4DA,wDAKC;AAED,oDAQC;AAED,0DAKC;AAED,sDAKC;AAED,kDAUC;AArGD,6CAAwC;AAExC,iDAAuC;AAEvC,SAAS,eAAe,CACtB,EAAqD;IAErD,OAAO,EAAE,CAAC,MAAM,CACd,EAAE;SACC,UAAU,CAAC,yBAAyB,CAAC;SACrC,QAAQ,CACP,iCAAiC,EACjC,mBAAmB,EACnB,mCAAmC,CACpC;SACA,MAAM,CAAC,WAAW,CAAC;SACnB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE,YAAY,CAAC;SACxC,KAAK,CAAC,yBAAyB,EAAE,GAAG,EAAE,QAAQ,CAAC;SAC/C,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CACb,GAAG,CAAC,EAAE,CAAC;QACL,GAAG,CAAC,mCAAmC,EAAE,IAAI,EAAE,IAAI,CAAC;QACpD,GAAG,CAAC,iCAAiC,EAAE,GAAG,EAAE,QAAQ,CAAC;KACtD,CAAC,CACH;SACA,KAAK,CAAC,CAAC,CAAC,CACZ,CAAC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eAAe,CAAC,EAAE,CAAC;QACnB,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,uBAAuB,CACrC,EAAqD,EACrD,QAAgB,IAAA,WAAG,GAAE,CAAC,QAAQ,EAAE;IAEhC,OAAO,sBAAsB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,qBAAqB,CACnC,EAAqD,EACrD,QAAgB,IAAA,WAAG,GAAE,CAAC,QAAQ,EAAE;IAEhC,OAAO,oBAAoB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,mBAAmB,CACjC,EAAqD,EACrD,QAAgB,IAAA,WAAG,GAAE,CAAC,QAAQ,EAAE;IAEhC,OAAO,EAAE;SACN,IAAI,EAAE;SACN,IAAI,CAAC,sBAAsB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SACvC,IAAI,CAAC,UAAU,CAAC;SAChB,IAAI,CAAC,QAAQ,CAAC;SACd,GAAG,EAAE,CAAC;AACX,CAAC","sourcesContent":["import { day } from '@vrplatform/utils';\nimport type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';\nimport { sql } from '../../isomorphic';\n\nfunction hasActiveTenant(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>\n) {\n return eb.exists(\n eb\n .selectFrom('public.tenant as tenant')\n .leftJoin(\n 'public.tenant as billingPartner',\n 'billingPartner.id',\n 'tenant.calculatedBillingPartnerId'\n )\n .select('tenant.id')\n .whereRef('tenant.id', '=', 'l.tenantId')\n .where('tenant.calculatedStatus', '=', 'active')\n .where((eb2) =>\n eb2.or([\n eb2('tenant.calculatedBillingPartnerId', 'is', null),\n eb2('billingPartner.calculatedStatus', '=', 'active'),\n ])\n )\n .limit(1)\n );\n}\n\nfunction hasInactiveOwnership(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string\n) {\n const onDate = day(today).toDate();\n return eb.exists(\n eb\n .selectFrom('public.listingOwnershipPeriod as lop')\n .select('lop.id')\n .where(\n 'lop.listingId',\n '=',\n sql<string>`coalesce(${sql.ref('l.parentId')}, ${sql.ref('l.id')})`\n )\n .whereRef('lop.tenantId', '=', 'l.tenantId')\n .where('lop.setListingInactive', '=', true)\n .where((eb2) =>\n eb2.or([\n eb2.and([\n eb2('lop.startAt', '<=', onDate),\n eb2('lop.endAt', '>=', onDate),\n ]),\n eb2.and([\n eb2('lop.startAt', '<=', onDate),\n eb2('lop.endAt', 'is', null),\n ]),\n ])\n )\n .limit(1)\n );\n}\n\nexport function whereListingIsInactive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return hasInactiveOwnership(eb, today);\n}\n\nexport function whereListingIsActive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return eb.and([\n hasActiveTenant(eb),\n eb.not(whereListingIsInactive(eb, today)),\n ]);\n}\n\nexport function selectListingIsInactive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return whereListingIsInactive(eb, today);\n}\n\nexport function selectListingIsActive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return whereListingIsActive(eb, today);\n}\n\nexport function selectListingStatus(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return eb\n .case()\n .when(whereListingIsInactive(eb, today))\n .then('inactive')\n .else('active')\n .end();\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Kysely } from './index';
|
|
2
|
+
export declare const tenantDataRegions: readonly ["ap", "crunchy", "eu", "hostaway", "us"];
|
|
3
|
+
export type TenantDataRegion = (typeof tenantDataRegions)[number];
|
|
4
|
+
export type RegionEnvironment = Record<string, string | undefined>;
|
|
5
|
+
export declare function assertTenantDataRegion(value: string | undefined): asserts value is TenantDataRegion;
|
|
6
|
+
export declare function resolveTenantDatabaseUrl(dataRegion: TenantDataRegion, env: RegionEnvironment): string;
|
|
7
|
+
export declare function resolveTenantApiBaseUrl(dataRegion: TenantDataRegion, env: RegionEnvironment): string;
|
|
8
|
+
export declare function resolveConfiguredTenantDataRegions(env: RegionEnvironment): ("ap" | "crunchy" | "eu" | "hostaway" | "us")[];
|
|
9
|
+
type UseAsyncRegionalKysely = (connectionString: string, options?: {
|
|
10
|
+
repositoryName?: string;
|
|
11
|
+
probe?: false;
|
|
12
|
+
}) => Promise<Kysely>;
|
|
13
|
+
export declare function useTenantDatabaseKysely(dataRegion: TenantDataRegion, repositoryName: string, env: RegionEnvironment, options?: {
|
|
14
|
+
useAsyncKysely?: UseAsyncRegionalKysely;
|
|
15
|
+
probe?: false;
|
|
16
|
+
}): Promise<Kysely>;
|
|
17
|
+
export type RegionRunError = {
|
|
18
|
+
dataRegion: TenantDataRegion;
|
|
19
|
+
error: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Run a job once per configured tenant data region with per-region error
|
|
23
|
+
* isolation: one region's outage must not stall the others (regions iterate
|
|
24
|
+
* in a fixed order, so a failing first region would otherwise starve the
|
|
25
|
+
* rest on every attempt). Throws only when every configured region failed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function forEachConfiguredRegion<T>(run: (dataRegion: TenantDataRegion) => Promise<T>, env: RegionEnvironment): Promise<{
|
|
28
|
+
results: {
|
|
29
|
+
dataRegion: TenantDataRegion;
|
|
30
|
+
result: T;
|
|
31
|
+
}[];
|
|
32
|
+
errors: RegionRunError[];
|
|
33
|
+
}>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.tenantDataRegions = void 0;
|
|
37
|
+
exports.assertTenantDataRegion = assertTenantDataRegion;
|
|
38
|
+
exports.resolveTenantDatabaseUrl = resolveTenantDatabaseUrl;
|
|
39
|
+
exports.resolveTenantApiBaseUrl = resolveTenantApiBaseUrl;
|
|
40
|
+
exports.resolveConfiguredTenantDataRegions = resolveConfiguredTenantDataRegions;
|
|
41
|
+
exports.useTenantDatabaseKysely = useTenantDatabaseKysely;
|
|
42
|
+
exports.forEachConfiguredRegion = forEachConfiguredRegion;
|
|
43
|
+
// The tenant-data-region contract lives here — the region set plus how a
|
|
44
|
+
// region resolves to its database url, API base url, and how to fan a job out
|
|
45
|
+
// across regions. Every runtime resolves regions through these functions;
|
|
46
|
+
// @vrplatform/common re-exports them for app-facing imports, and the trigger
|
|
47
|
+
// runtime wraps them only to default `env` to process.env.
|
|
48
|
+
//
|
|
49
|
+
// Region → resource keys are derived from the region name
|
|
50
|
+
// (`DATABASE_URL_VRTRUST_<REGION>`, `API_BASE_URL_<REGION>`), so adding a
|
|
51
|
+
// region means extending this array plus its env values and migrations — not
|
|
52
|
+
// editing per-region branches.
|
|
53
|
+
exports.tenantDataRegions = [
|
|
54
|
+
'ap',
|
|
55
|
+
'crunchy',
|
|
56
|
+
'eu',
|
|
57
|
+
'hostaway',
|
|
58
|
+
'us',
|
|
59
|
+
];
|
|
60
|
+
function assertTenantDataRegion(value) {
|
|
61
|
+
if (!exports.tenantDataRegions.includes(value)) {
|
|
62
|
+
throw new Error(`Missing or invalid tenant data region: ${value ?? ''}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function databaseUrlEnvKey(dataRegion) {
|
|
66
|
+
return `DATABASE_URL_VRTRUST_${dataRegion.toUpperCase()}`;
|
|
67
|
+
}
|
|
68
|
+
function apiBaseUrlEnvKey(dataRegion) {
|
|
69
|
+
return `API_BASE_URL_${dataRegion.toUpperCase()}`;
|
|
70
|
+
}
|
|
71
|
+
function resolveTenantDatabaseUrl(dataRegion, env) {
|
|
72
|
+
const databaseUrl = env[databaseUrlEnvKey(dataRegion)];
|
|
73
|
+
if (!databaseUrl) {
|
|
74
|
+
throw new Error(`Missing database url for ${dataRegion}`);
|
|
75
|
+
}
|
|
76
|
+
return databaseUrl;
|
|
77
|
+
}
|
|
78
|
+
function resolveTenantApiBaseUrl(dataRegion, env) {
|
|
79
|
+
const key = apiBaseUrlEnvKey(dataRegion);
|
|
80
|
+
const baseUrl = env[key];
|
|
81
|
+
if (!baseUrl) {
|
|
82
|
+
throw new Error(`Missing ${key}`);
|
|
83
|
+
}
|
|
84
|
+
return baseUrl;
|
|
85
|
+
}
|
|
86
|
+
function resolveConfiguredTenantDataRegions(env) {
|
|
87
|
+
const configured = exports.tenantDataRegions.filter((region) => Boolean(env[databaseUrlEnvKey(region)]));
|
|
88
|
+
if (!configured.length) {
|
|
89
|
+
throw new Error('No tenant data region database urls configured');
|
|
90
|
+
}
|
|
91
|
+
// Two regions sharing one URL means every region-fan-out job scans the
|
|
92
|
+
// same physical DB twice (e.g. a stale dashboard env var re-merged into a
|
|
93
|
+
// deploy). Regions must stay unset until they point at distinct databases.
|
|
94
|
+
const regionsByUrl = new Map();
|
|
95
|
+
for (const region of configured) {
|
|
96
|
+
const url = env[databaseUrlEnvKey(region)];
|
|
97
|
+
regionsByUrl.set(url, [...(regionsByUrl.get(url) ?? []), region]);
|
|
98
|
+
}
|
|
99
|
+
for (const aliased of regionsByUrl.values()) {
|
|
100
|
+
if (aliased.length > 1) {
|
|
101
|
+
throw new Error(`Tenant data regions ${aliased.join(', ')} share the same database url; ` +
|
|
102
|
+
'each configured region must point at a distinct database');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return configured;
|
|
106
|
+
}
|
|
107
|
+
async function defaultUseAsyncKysely(connectionString, options) {
|
|
108
|
+
const { useAsyncKysely } = await Promise.resolve().then(() => __importStar(require('./index')));
|
|
109
|
+
return await useAsyncKysely(connectionString, options);
|
|
110
|
+
}
|
|
111
|
+
async function useTenantDatabaseKysely(dataRegion, repositoryName, env, options = {}) {
|
|
112
|
+
const open = options.useAsyncKysely ?? defaultUseAsyncKysely;
|
|
113
|
+
return await open(resolveTenantDatabaseUrl(dataRegion, env), {
|
|
114
|
+
repositoryName,
|
|
115
|
+
probe: options.probe,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Run a job once per configured tenant data region with per-region error
|
|
120
|
+
* isolation: one region's outage must not stall the others (regions iterate
|
|
121
|
+
* in a fixed order, so a failing first region would otherwise starve the
|
|
122
|
+
* rest on every attempt). Throws only when every configured region failed.
|
|
123
|
+
*/
|
|
124
|
+
async function forEachConfiguredRegion(run, env) {
|
|
125
|
+
const results = [];
|
|
126
|
+
const errors = [];
|
|
127
|
+
for (const dataRegion of resolveConfiguredTenantDataRegions(env)) {
|
|
128
|
+
try {
|
|
129
|
+
results.push({ dataRegion, result: await run(dataRegion) });
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
errors.push({
|
|
133
|
+
dataRegion,
|
|
134
|
+
error: error instanceof Error ? error.message : String(error),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (!results.length && errors.length) {
|
|
139
|
+
throw new Error(`All configured tenant data regions failed: ${errors
|
|
140
|
+
.map((regionError) => `${regionError.dataRegion}: ${regionError.error}`)
|
|
141
|
+
.join('; ')}`);
|
|
142
|
+
}
|
|
143
|
+
return { results, errors };
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=regional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regional.js","sourceRoot":"src/","sources":["regional.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,wDAMC;AAUD,4DASC;AAED,0DAUC;AAED,gFA2BC;AAkBD,0DAWC;AAaD,0DA8BC;AA/JD,yEAAyE;AACzE,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,2DAA2D;AAC3D,EAAE;AACF,0DAA0D;AAC1D,0EAA0E;AAC1E,6EAA6E;AAC7E,+BAA+B;AAClB,QAAA,iBAAiB,GAAG;IAC/B,IAAI;IACJ,SAAS;IACT,IAAI;IACJ,UAAU;IACV,IAAI;CACI,CAAC;AAKX,SAAgB,sBAAsB,CACpC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GAAiD,EACjD,GAAsB;IAKtB,MAAM,OAAO,GAAkD,EAAE,CAAC;IAClE,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,KAAK,MAAM,UAAU,IAAI,kCAAkC,CAAC,GAAG,CAAC,EAAE,CAAC;QACjE,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC9D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC;gBACV,UAAU;gBACV,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,8CAA8C,MAAM;aACjD,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC,UAAU,KAAK,WAAW,CAAC,KAAK,EAAE,CAAC;aACvE,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import type { Kysely } from './index';\n\n// The tenant-data-region contract lives here — the region set plus how a\n// region resolves to its database url, API base url, and how to fan a job out\n// across regions. Every runtime resolves regions through these functions;\n// @vrplatform/common re-exports them for app-facing imports, and the trigger\n// runtime wraps them only to default `env` to process.env.\n//\n// Region → resource keys are derived from the region name\n// (`DATABASE_URL_VRTRUST_<REGION>`, `API_BASE_URL_<REGION>`), so adding a\n// region means extending this array plus its env values and migrations — not\n// editing per-region branches.\nexport const tenantDataRegions = [\n 'ap',\n 'crunchy',\n 'eu',\n 'hostaway',\n 'us',\n] as const;\nexport type TenantDataRegion = (typeof tenantDataRegions)[number];\n\nexport type RegionEnvironment = Record<string, string | undefined>;\n\nexport function assertTenantDataRegion(\n value: string | undefined\n): asserts value is TenantDataRegion {\n if (!tenantDataRegions.includes(value as TenantDataRegion)) {\n throw new Error(`Missing or invalid tenant data region: ${value ?? ''}`);\n }\n}\n\nfunction databaseUrlEnvKey(dataRegion: TenantDataRegion) {\n return `DATABASE_URL_VRTRUST_${dataRegion.toUpperCase()}`;\n}\n\nfunction apiBaseUrlEnvKey(dataRegion: TenantDataRegion) {\n return `API_BASE_URL_${dataRegion.toUpperCase()}`;\n}\n\nexport function resolveTenantDatabaseUrl(\n dataRegion: TenantDataRegion,\n env: RegionEnvironment\n) {\n const databaseUrl = env[databaseUrlEnvKey(dataRegion)];\n if (!databaseUrl) {\n throw new Error(`Missing database url for ${dataRegion}`);\n }\n return databaseUrl;\n}\n\nexport function resolveTenantApiBaseUrl(\n dataRegion: TenantDataRegion,\n env: RegionEnvironment\n) {\n const key = apiBaseUrlEnvKey(dataRegion);\n const baseUrl = env[key];\n if (!baseUrl) {\n throw new Error(`Missing ${key}`);\n }\n return baseUrl;\n}\n\nexport function resolveConfiguredTenantDataRegions(env: RegionEnvironment) {\n const configured = tenantDataRegions.filter((region) =>\n Boolean(env[databaseUrlEnvKey(region)])\n );\n\n if (!configured.length) {\n throw new Error('No tenant data region database urls configured');\n }\n\n // Two regions sharing one URL means every region-fan-out job scans the\n // same physical DB twice (e.g. a stale dashboard env var re-merged into a\n // deploy). Regions must stay unset until they point at distinct databases.\n const regionsByUrl = new Map<string, TenantDataRegion[]>();\n for (const region of configured) {\n const url = env[databaseUrlEnvKey(region)]!;\n regionsByUrl.set(url, [...(regionsByUrl.get(url) ?? []), region]);\n }\n for (const aliased of regionsByUrl.values()) {\n if (aliased.length > 1) {\n throw new Error(\n `Tenant data regions ${aliased.join(', ')} share the same database url; ` +\n 'each configured region must point at a distinct database'\n );\n }\n }\n\n return configured;\n}\n\ntype UseAsyncRegionalKysely = (\n connectionString: string,\n options?: {\n repositoryName?: string;\n probe?: false;\n }\n) => Promise<Kysely>;\n\nasync function defaultUseAsyncKysely(\n connectionString: string,\n options?: Parameters<UseAsyncRegionalKysely>[1]\n) {\n const { useAsyncKysely } = await import('./index');\n return await useAsyncKysely(connectionString, options);\n}\n\nexport async function useTenantDatabaseKysely(\n dataRegion: TenantDataRegion,\n repositoryName: string,\n env: RegionEnvironment,\n options: { useAsyncKysely?: UseAsyncRegionalKysely; probe?: false } = {}\n) {\n const open = options.useAsyncKysely ?? defaultUseAsyncKysely;\n return await open(resolveTenantDatabaseUrl(dataRegion, env), {\n repositoryName,\n probe: options.probe,\n });\n}\n\nexport type RegionRunError = {\n dataRegion: TenantDataRegion;\n error: string;\n};\n\n/**\n * Run a job once per configured tenant data region with per-region error\n * isolation: one region's outage must not stall the others (regions iterate\n * in a fixed order, so a failing first region would otherwise starve the\n * rest on every attempt). Throws only when every configured region failed.\n */\nexport async function forEachConfiguredRegion<T>(\n run: (dataRegion: TenantDataRegion) => Promise<T>,\n env: RegionEnvironment\n): Promise<{\n results: { dataRegion: TenantDataRegion; result: T }[];\n errors: RegionRunError[];\n}> {\n const results: { dataRegion: TenantDataRegion; result: T }[] = [];\n const errors: RegionRunError[] = [];\n\n for (const dataRegion of resolveConfiguredTenantDataRegions(env)) {\n try {\n results.push({ dataRegion, result: await run(dataRegion) });\n } catch (error) {\n errors.push({\n dataRegion,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n if (!results.length && errors.length) {\n throw new Error(\n `All configured tenant data regions failed: ${errors\n .map((regionError) => `${regionError.dataRegion}: ${regionError.error}`)\n .join('; ')}`\n );\n }\n\n return { results, errors };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":";;AA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AAE,CAAC;gBACjC,OAAO,KAAK,IAAI,EAAE;oBAChB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;gBACzB,CAAC,CAAC;YACJ,CAAC;YACD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;gBACvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;KACF,CACY,CAAC;AAClB,CAAC","sourcesContent":["import { afterAll } from 'bun:test';\nimport type { Kysely } from 'kysely';\nimport { type UseLocalKyselyOptions, useLocalKysely } from '../local';\nimport type { DB } from '../v1.generated';\n\ndeclare global {\n // Shared Kysely instance for test processes that run multiple files in one Bun process.\n // This must be process-global to allow cross-file reuse.\n var __vrplatform_testSharedKysely:\n | Promise<Kysely<DB>>\n | Kysely<DB>\n | undefined;\n}\n\n/**\n * @deprecated Use `useLocalKyselyResource` instead.\n */\nexport async function useTestKysely(\n cleanupStrategy: 'afterAll',\n args?: UseLocalKyselyOptions\n) {\n const kysely = await useLocalKysely(args);\n\n if (cleanupStrategy === 'afterAll')\n afterAll(async () => {\n await kysely.destroy();\n });\n\n return {\n kysely,\n };\n}\n\nexport async function useTestAutoCleanupKysely(args?: UseLocalKyselyOptions) {\n if (process.env.VR_TEST_SHARED_KYSELY === '1') {\n const existing = globalThis.__vrplatform_testSharedKysely;\n if (!existing) {\n const created = useLocalKysely(args);\n globalThis.__vrplatform_testSharedKysely = created;\n return created;\n }\n return await existing;\n }\n\n const kysely = await useLocalKysely(args);\n\n afterAll(async () => {\n await kysely.destroy();\n });\n\n return kysely;\n}\n\ntype ReturnType = Kysely<DB> & {\n [Symbol.dispose]: () => Promise<void>;\n};\n\nexport async function useLocalKyselyResource(\n args?: UseLocalKyselyOptions\n): Promise<ReturnType> {\n const kysely = await useLocalKysely(args);\n\n return new Proxy(\n {},\n {\n get(_target, prop) {\n // somehow not working if using Symbol.dispose\n if (prop === Symbol.asyncDispose) {\n return async () => {\n await kysely.destroy();\n };\n }\n if (prop === 'kysely') {\n return kysely;\n }\n if (typeof kysely[prop] === 'function') {\n return kysely[prop].bind(kysely);\n }\n return kysely[prop];\n },\n }\n ) as ReturnType;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"src/","sources":["transaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"src/","sources":["transaction.ts"],"names":[],"mappings":";;AASA,kDAIC;AAED,gEAEC;AAYD,gEAMC;AAED,oEAMC;AAED,kEAMC;AAnDD,6CAKsB;AAItB,SAAgB,mBAAmB,CACjC,EAA8B;IAE9B,OAAO,EAAE,EAAE,aAAa,KAAK,IAAI,CAAC;AACpC,CAAC;AAEM,KAAK,UAAU,0BAA0B,CAAC,EAAU;IACzD,OAAO,EAAE,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,CAAC;AACzC,CAAC;AAED,uEAAuE;AACvE,kDAAkD;AAClD,SAAS,mBAAmB,CAC1B,GAAgB,EAChB,OAAoE,EACpE,aAAqB;IAErB,OAAO,gBAAG,CAAC,GAAG,CAAC,GAAG,OAAO,IAAI,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC7D,CAAC;AAEM,KAAK,UAAU,0BAA0B,CAC9C,GAAsB,EACtB,aAAqB;IAErB,MAAM,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC;AACb,CAAC;AAEM,KAAK,UAAU,4BAA4B,CAChD,GAAsB,EACtB,aAAqB;IAErB,MAAM,mBAAmB,CAAC,GAAG,EAAE,uBAAuB,EAAE,aAAa,CAAC,CAAC;IACvE,OAAO,GAAG,CAAC;AACb,CAAC;AAEM,KAAK,UAAU,2BAA2B,CAC/C,GAAsB,EACtB,aAAqB;IAErB,MAAM,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC;IACnE,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {\n type ControlledTransaction,\n type Kysely,\n sql,\n type Transaction,\n} from './isomorphic';\n\nexport type ActiveTransaction = Transaction | ControlledTransaction;\n\nexport function isActiveTransaction(\n db: Kysely | ActiveTransaction\n): db is ActiveTransaction {\n return db?.isTransaction === true;\n}\n\nexport async function startControlledTransaction(db: Kysely) {\n return db.startTransaction().execute();\n}\n\n// Our dialect stack supports controlled transactions, but not Kysely's\n// savepoint commands consistently across drivers.\nfunction runSavepointCommand(\n trx: Transaction,\n command: 'savepoint' | 'rollback to savepoint' | 'release savepoint',\n savepointName: string\n) {\n return sql.raw(`${command} ${savepointName}`).execute(trx);\n}\n\nexport async function createTransactionSavepoint(\n trx: ActiveTransaction,\n savepointName: string\n): Promise<ActiveTransaction> {\n await runSavepointCommand(trx, 'savepoint', savepointName);\n return trx;\n}\n\nexport async function rollbackTransactionSavepoint(\n trx: ActiveTransaction,\n savepointName: string\n): Promise<ActiveTransaction> {\n await runSavepointCommand(trx, 'rollback to savepoint', savepointName);\n return trx;\n}\n\nexport async function releaseTransactionSavepoint(\n trx: ActiveTransaction,\n savepointName: string\n): Promise<ActiveTransaction> {\n await runSavepointCommand(trx, 'release savepoint', savepointName);\n return trx;\n}\n"]}
|
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
* Please do not edit it manually.
|
|
4
4
|
*/
|
|
5
5
|
import type { ColumnType } from "kysely";
|
|
6
|
-
export type AccountingJournalEntryInactiveReason = "cancelledReservationLine" | "generalLedgerStartAt" | "inactiveAccount" | "listingInactive" | "nonPostingAccount" | "reservationGeneralLedgerStatusInactive" | "transactionInactive" | "unknownInactiveReason";
|
|
6
|
+
export type AccountingJournalEntryInactiveReason = "cancelledReservationLine" | "currencyMismatch" | "generalLedgerStartAt" | "inactiveAccount" | "listingInactive" | "nonPostingAccount" | "reservationGeneralLedgerStatusInactive" | "transactionInactive" | "unknownInactiveReason";
|
|
7
7
|
export type AccountingJournalEntryLedger = "historical" | "operating" | "trust";
|
|
8
8
|
export type AccountingTransactionAttachmentStatus = "attached" | "deleting" | "ready" | "uploading";
|
|
9
9
|
export type AuditActionActorType = "automation" | "sync" | "system" | "user";
|
|
10
10
|
export type AuditEffectAttemptStatus = "completed" | "failed" | "running" | "skipped_locked";
|
|
11
11
|
export type AuditEffectStatus = "claimed" | "completed" | "dead_letter" | "failed" | "pending" | "running";
|
|
12
12
|
export type AuditJournalDeltaOperation = "delete" | "insert" | "update";
|
|
13
|
+
export type HealthTenantIssueCategory = "criticalToSystem" | "criticalToUser";
|
|
14
|
+
export type HealthTenantIssueCode = "brokenConnections" | "cancelledReservationPaidWithoutAdjustment" | "closedPeriodUnattachedJournalEntries" | "duplicatedPayments" | "endedOwnershipNonZeroBalance" | "listingOwnershipPeriodNotFoundOnActiveJournals" | "missingOwnershipOrDeactivation" | "operatingBankAccountsWithoutOpex" | "outdatedConnections" | "partnerBillingInactive" | "partnerInactive" | "pmsMissingAccountingStart" | "publishedStatementUnpaid" | "reservationCurrencyMismatch" | "reservationGuestTotalsMismatch" | "reservationPaymentProjectionMismatch" | "teamInactive" | "unbalancedJournalEntries" | "unbalancedTransactionJournalEntries" | "unpaidReservations";
|
|
15
|
+
export type HealthTenantIssueSeverity = "error" | "warning";
|
|
16
|
+
export type HealthTenantIssueStatus = "open" | "resolved";
|
|
13
17
|
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
|
|
14
18
|
export type Int8 = ColumnType<string, bigint | number | string, bigint | number | string>;
|
|
15
19
|
export type Json = JsonValue;
|
|
@@ -22,6 +26,13 @@ export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
|
|
|
22
26
|
export type Numeric = ColumnType<string, number | string, number | string>;
|
|
23
27
|
export type PublicFlowType = "pull" | "push";
|
|
24
28
|
export type PublicRecurringFeeConditionOperator = "<" | "<=" | "=" | ">" | ">=";
|
|
29
|
+
export type WebhookApiVersion = "2026-07-01";
|
|
30
|
+
export type WebhookDeliveryStatus = "canceled" | "delivering" | "failed" | "queued" | "retrying" | "succeeded";
|
|
31
|
+
export type WebhookEventType = "team.issues.changed" | "webhook.test";
|
|
32
|
+
export type WebhookResourceType = "team" | "webhook";
|
|
33
|
+
export type WebhookSubscriptionEventType = "team.issues.changed";
|
|
34
|
+
export type WebhookSubscriptionScope = "managedTeams" | "self";
|
|
35
|
+
export type WebhookSubscriptionStatus = "active" | "disabled" | "pending";
|
|
25
36
|
export type Timestamp = ColumnType<Date | string, Date | string, Date | string>;
|
|
26
37
|
export interface AccountingAccount {
|
|
27
38
|
bankingCategory: string | null;
|
|
@@ -36,6 +47,8 @@ export interface AccountingAccount {
|
|
|
36
47
|
createdAt: Generated<Timestamp | null>;
|
|
37
48
|
id: Generated<string>;
|
|
38
49
|
offsetAccountId: string | null;
|
|
50
|
+
openingTrialBalanceCombinedCentTotal: Generated<Int8>;
|
|
51
|
+
openingTrialBalanceUpdatedAt: Timestamp | null;
|
|
39
52
|
status: Generated<string>;
|
|
40
53
|
tenantId: string | null;
|
|
41
54
|
title: string;
|
|
@@ -240,6 +253,7 @@ export interface AccountingContact {
|
|
|
240
253
|
is1099PostalDelivery: Generated<boolean>;
|
|
241
254
|
name: string;
|
|
242
255
|
phone: string | null;
|
|
256
|
+
rampLast4Digits: string | null;
|
|
243
257
|
/**
|
|
244
258
|
* Human-readable system ID (CNT-XXX-XXXX-XXX).
|
|
245
259
|
*/
|
|
@@ -278,6 +292,7 @@ export interface AccountingJournalEntry {
|
|
|
278
292
|
lineUniqueRef: string | null;
|
|
279
293
|
listingId: string | null;
|
|
280
294
|
listingOwnershipPeriodId: string | null;
|
|
295
|
+
parentListingId: string | null;
|
|
281
296
|
party: string | null;
|
|
282
297
|
recurringFeeId: string | null;
|
|
283
298
|
recurringFeeListingSubscriptionId: string | null;
|
|
@@ -579,6 +594,7 @@ export interface CoreChangeType {
|
|
|
579
594
|
export interface CoreFlow {
|
|
580
595
|
appId: string;
|
|
581
596
|
description: string | null;
|
|
597
|
+
eventListening: Generated<Json>;
|
|
582
598
|
id: Generated<string>;
|
|
583
599
|
isPublic: Generated<boolean>;
|
|
584
600
|
leftType: string | null;
|
|
@@ -890,7 +906,10 @@ export interface PublicBookingChannel {
|
|
|
890
906
|
iconProvider: string | null;
|
|
891
907
|
id: Generated<string>;
|
|
892
908
|
lastGenerateRun: Timestamp | null;
|
|
909
|
+
logo: string | null;
|
|
910
|
+
logoProvider: string | null;
|
|
893
911
|
selectedBookingChannelIconCandidateId: string | null;
|
|
912
|
+
selectedBookingChannelLogoCandidateId: string | null;
|
|
894
913
|
uniqueRef: string;
|
|
895
914
|
updatedAt: Generated<Timestamp>;
|
|
896
915
|
}
|
|
@@ -901,12 +920,16 @@ export interface PublicBookingChannelIconCandidate {
|
|
|
901
920
|
comment: string | null;
|
|
902
921
|
createdAt: Generated<Timestamp>;
|
|
903
922
|
externalIcon: string | null;
|
|
923
|
+
height: number | null;
|
|
904
924
|
id: Generated<string>;
|
|
905
925
|
provider: Generated<string>;
|
|
906
926
|
source: string | null;
|
|
907
927
|
updatedAt: Generated<Timestamp>;
|
|
928
|
+
width: number | null;
|
|
908
929
|
}
|
|
909
930
|
export interface PublicConnection {
|
|
931
|
+
accountingEndAt: Timestamp | null;
|
|
932
|
+
accountingStartAt: Timestamp | null;
|
|
910
933
|
appId: string;
|
|
911
934
|
backendVersion: number | null;
|
|
912
935
|
createdAt: Generated<Timestamp>;
|
|
@@ -1053,6 +1076,7 @@ export interface PublicListing {
|
|
|
1053
1076
|
metadata: Generated<Json | null>;
|
|
1054
1077
|
name: string | null;
|
|
1055
1078
|
ownerContactId: string | null;
|
|
1079
|
+
parentId: string | null;
|
|
1056
1080
|
pmsAddressData: Json | null;
|
|
1057
1081
|
pmsStatus: string | null;
|
|
1058
1082
|
/**
|
|
@@ -1590,6 +1614,7 @@ export interface PublicTenant {
|
|
|
1590
1614
|
addressCountry: string | null;
|
|
1591
1615
|
addressLine1: string | null;
|
|
1592
1616
|
addressPostcode: string | null;
|
|
1617
|
+
appSettings: Json | null;
|
|
1593
1618
|
billingAddressData: Json | null;
|
|
1594
1619
|
billingAddressId: string | null;
|
|
1595
1620
|
billingCustomerId: string | null;
|
|
@@ -1612,10 +1637,12 @@ export interface PublicTenant {
|
|
|
1612
1637
|
companyName: string | null;
|
|
1613
1638
|
companyTaxCode: string | null;
|
|
1614
1639
|
createdAt: Generated<Timestamp>;
|
|
1640
|
+
dataRegion: Generated<string>;
|
|
1615
1641
|
defaultCurrency: string | null;
|
|
1616
1642
|
defaultRevenueRecognition: string | null;
|
|
1617
1643
|
email: string | null;
|
|
1618
1644
|
featureFlags: Generated<Json | null>;
|
|
1645
|
+
guideOnboarding: Json | null;
|
|
1619
1646
|
historicalStatementsImportedAt: Timestamp | null;
|
|
1620
1647
|
id: Generated<string>;
|
|
1621
1648
|
intercomId: string | null;
|
|
@@ -1635,10 +1662,12 @@ export interface PublicTenant {
|
|
|
1635
1662
|
settingsData: Json | null;
|
|
1636
1663
|
setup: Json | null;
|
|
1637
1664
|
setupCompleted: Generated<boolean | null>;
|
|
1665
|
+
slug: Generated<string>;
|
|
1638
1666
|
statementAddressData: Json | null;
|
|
1639
1667
|
statementAddressId: string | null;
|
|
1640
1668
|
statementStartAt: Timestamp | null;
|
|
1641
1669
|
status: Generated<string | null>;
|
|
1670
|
+
storageRealm: Generated<string>;
|
|
1642
1671
|
stripeId: string | null;
|
|
1643
1672
|
stripeSubscriptionItemId: string | null;
|
|
1644
1673
|
supportEmail: string | null;
|
|
@@ -1761,6 +1790,93 @@ export interface PublicWebhook {
|
|
|
1761
1790
|
types2: string[] | null;
|
|
1762
1791
|
url: string;
|
|
1763
1792
|
}
|
|
1793
|
+
export interface HealthTenantIssue {
|
|
1794
|
+
affected: number;
|
|
1795
|
+
category: HealthTenantIssueCategory;
|
|
1796
|
+
code: HealthTenantIssueCode;
|
|
1797
|
+
contentHash: string;
|
|
1798
|
+
context: Json;
|
|
1799
|
+
createdAt: Generated<Timestamp>;
|
|
1800
|
+
firstSeenAt: Timestamp;
|
|
1801
|
+
id: Generated<string>;
|
|
1802
|
+
lastChangedAt: Timestamp;
|
|
1803
|
+
message: string;
|
|
1804
|
+
openedAt: Timestamp;
|
|
1805
|
+
resolvedAt: Timestamp | null;
|
|
1806
|
+
severity: HealthTenantIssueSeverity;
|
|
1807
|
+
snapshotVersion: Int8;
|
|
1808
|
+
status: HealthTenantIssueStatus;
|
|
1809
|
+
tenantId: string;
|
|
1810
|
+
updatedAt: Generated<Timestamp>;
|
|
1811
|
+
version: Int8;
|
|
1812
|
+
}
|
|
1813
|
+
export interface HealthTenantIssueSnapshot {
|
|
1814
|
+
computedAt: Timestamp | null;
|
|
1815
|
+
contentHash: string | null;
|
|
1816
|
+
createdAt: Generated<Timestamp>;
|
|
1817
|
+
dirtyAt: Generated<Timestamp>;
|
|
1818
|
+
tenantId: string;
|
|
1819
|
+
updatedAt: Generated<Timestamp>;
|
|
1820
|
+
version: Generated<Int8>;
|
|
1821
|
+
}
|
|
1822
|
+
export interface WebhookDelivery {
|
|
1823
|
+
apiVersion: WebhookApiVersion;
|
|
1824
|
+
attemptCount: Generated<number>;
|
|
1825
|
+
body: string;
|
|
1826
|
+
claimedAt: Timestamp | null;
|
|
1827
|
+
claimedBy: string | null;
|
|
1828
|
+
createdAt: Generated<Timestamp>;
|
|
1829
|
+
deliveredAt: Timestamp | null;
|
|
1830
|
+
eventType: WebhookEventType;
|
|
1831
|
+
failedAt: Timestamp | null;
|
|
1832
|
+
id: Generated<string>;
|
|
1833
|
+
lastErrorCode: string | null;
|
|
1834
|
+
nextAttemptAt: Generated<Timestamp>;
|
|
1835
|
+
resourceId: string | null;
|
|
1836
|
+
resourceType: WebhookResourceType | null;
|
|
1837
|
+
sourceEventKey: string;
|
|
1838
|
+
sourceTenantId: string | null;
|
|
1839
|
+
status: Generated<WebhookDeliveryStatus>;
|
|
1840
|
+
subscriptionId: string;
|
|
1841
|
+
updatedAt: Generated<Timestamp>;
|
|
1842
|
+
}
|
|
1843
|
+
export interface WebhookDeliveryAttempt {
|
|
1844
|
+
attemptNumber: number;
|
|
1845
|
+
createdAt: Generated<Timestamp>;
|
|
1846
|
+
deliveryId: string;
|
|
1847
|
+
durationMs: number;
|
|
1848
|
+
errorClass: string | null;
|
|
1849
|
+
finishedAt: Timestamp;
|
|
1850
|
+
id: Generated<string>;
|
|
1851
|
+
responseExcerpt: string | null;
|
|
1852
|
+
responseStatus: number | null;
|
|
1853
|
+
startedAt: Timestamp;
|
|
1854
|
+
subscriptionSecretId: string;
|
|
1855
|
+
}
|
|
1856
|
+
export interface WebhookSubscription {
|
|
1857
|
+
apiVersion: WebhookApiVersion;
|
|
1858
|
+
createdAt: Generated<Timestamp>;
|
|
1859
|
+
description: string | null;
|
|
1860
|
+
disabledAt: Timestamp | null;
|
|
1861
|
+
eventTypes: WebhookSubscriptionEventType[];
|
|
1862
|
+
id: Generated<string>;
|
|
1863
|
+
ownerTenantId: string;
|
|
1864
|
+
scope: WebhookSubscriptionScope;
|
|
1865
|
+
status: Generated<WebhookSubscriptionStatus>;
|
|
1866
|
+
updatedAt: Generated<Timestamp>;
|
|
1867
|
+
url: string;
|
|
1868
|
+
verifiedAt: Timestamp | null;
|
|
1869
|
+
}
|
|
1870
|
+
export interface WebhookSubscriptionSecret {
|
|
1871
|
+
activeFrom: Generated<Timestamp>;
|
|
1872
|
+
createdAt: Generated<Timestamp>;
|
|
1873
|
+
encryptedSecret: string;
|
|
1874
|
+
encryptionKeyId: string;
|
|
1875
|
+
expiresAt: Timestamp | null;
|
|
1876
|
+
id: Generated<string>;
|
|
1877
|
+
revokedAt: Timestamp | null;
|
|
1878
|
+
subscriptionId: string;
|
|
1879
|
+
}
|
|
1764
1880
|
export interface TrackingEvent {
|
|
1765
1881
|
createdAt: Generated<Timestamp>;
|
|
1766
1882
|
id: Generated<string>;
|
|
@@ -1891,6 +2007,8 @@ export interface DB {
|
|
|
1891
2007
|
"core.syncStatus": CoreSyncStatus;
|
|
1892
2008
|
"core.syncSubtask": CoreSyncSubtask;
|
|
1893
2009
|
"core.syncType": CoreSyncType;
|
|
2010
|
+
"health.tenantIssue": HealthTenantIssue;
|
|
2011
|
+
"health.tenantIssueSnapshot": HealthTenantIssueSnapshot;
|
|
1894
2012
|
"hdbCatalog.eventInvocationLogs": HdbCatalogEventInvocationLogs;
|
|
1895
2013
|
"hdbCatalog.eventLog": HdbCatalogEventLog;
|
|
1896
2014
|
"hdbCatalog.hdbActionLog": HdbCatalogHdbActionLog;
|
|
@@ -1986,4 +2104,8 @@ export interface DB {
|
|
|
1986
2104
|
"tracking.metricCache": TrackingMetricCache;
|
|
1987
2105
|
"tracking.monitorConnection": TrackingMonitorConnection;
|
|
1988
2106
|
"tracking.monitorConnectionState": TrackingMonitorConnectionState;
|
|
2107
|
+
"webhook.delivery": WebhookDelivery;
|
|
2108
|
+
"webhook.deliveryAttempt": WebhookDeliveryAttempt;
|
|
2109
|
+
"webhook.subscription": WebhookSubscription;
|
|
2110
|
+
"webhook.subscriptionSecret": WebhookSubscriptionSecret;
|
|
1989
2111
|
}
|