@vrplatform/kysely 1.2.18 → 1.2.20
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/index.d.ts +4 -1
- package/build/main/index.js +24 -7
- package/build/main/index.js.map +1 -1
- package/build/main/local.js +1 -2
- package/build/main/local.js.map +1 -1
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/main/v0.generated.d.ts +73 -2
- package/build/main/v0.generated.js.map +1 -1
- package/build/main/v1.generated.d.ts +162 -162
- package/build/main/v1.generated.js.map +1 -1
- package/build/module/index.d.ts +4 -1
- package/build/module/index.js +22 -6
- package/build/module/index.js.map +1 -1
- package/build/module/local.js +1 -2
- package/build/module/local.js.map +1 -1
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/build/module/v0.generated.d.ts +73 -2
- package/build/module/v0.generated.js.map +1 -1
- package/build/module/v1.generated.d.ts +162 -162
- package/build/module/v1.generated.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +31 -13
- package/src/local.ts +1 -3
- package/src/v0.generated.ts +78 -2
- package/src/v1.generated.ts +167 -163
- package/build/main/db.generated.d.ts +0 -1923
- package/build/main/db.generated.js +0 -7
- package/build/main/db.generated.js.map +0 -1
- package/build/module/db.generated.d.ts +0 -1923
- package/build/module/db.generated.js +0 -6
- package/build/module/db.generated.js.map +0 -1
package/build/.data.tar
CHANGED
|
Binary file
|
package/build/main/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Kysely as K } from 'kysely';
|
|
2
2
|
import postgres, { type Sql } from 'postgres';
|
|
3
|
+
export type { ColumnType, Expression, ExpressionBuilder, ExpressionOrFactory, Generated, Insertable, JSONColumnType, OperandExpression, Selectable, SqlBool, Updateable, } from 'kysely';
|
|
3
4
|
export * from './v1.generated';
|
|
4
|
-
export type { ColumnType, Generated, Insertable, JSONColumnType, Selectable, Updateable, ExpressionOrFactory, OperandExpression, ExpressionBuilder, SqlBool, Expression, } from 'kysely';
|
|
5
5
|
import type { DB } from './v1.generated';
|
|
6
6
|
export { sql } from 'kysely';
|
|
7
7
|
export type Kysely = K<DB>;
|
|
8
8
|
export type Postgres = Sql;
|
|
9
9
|
export declare function useKysely(postgres: Sql): K<DB>;
|
|
10
10
|
export declare function usePostgres(connectionString: string, ssl?: boolean): postgres.Sql<{}>;
|
|
11
|
+
export declare class DatabaseError extends Error {
|
|
12
|
+
constructor(message: string, cause: any);
|
|
13
|
+
}
|
|
11
14
|
export declare function withStack<T>(a: Promise<T>): Promise<T>;
|
package/build/main/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.sql = void 0;
|
|
20
|
+
exports.DatabaseError = exports.sql = void 0;
|
|
21
21
|
exports.useKysely = useKysely;
|
|
22
22
|
exports.usePostgres = usePostgres;
|
|
23
23
|
exports.withStack = withStack;
|
|
@@ -38,21 +38,38 @@ function useKysely(postgres) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function usePostgres(connectionString, ssl) {
|
|
41
|
-
return (0, postgres_1.default)(connectionString, {
|
|
41
|
+
return (0, postgres_1.default)(connectionString, {
|
|
42
|
+
ssl: ssl ? 'prefer' : false,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
class DatabaseError extends Error {
|
|
46
|
+
constructor(message, cause) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.cause = cause;
|
|
49
|
+
}
|
|
42
50
|
}
|
|
51
|
+
exports.DatabaseError = DatabaseError;
|
|
52
|
+
const dirname = typeof __dirname === 'string' ? (0, node_path_1.join)(__dirname, '../../..') : '';
|
|
43
53
|
async function withStack(a) {
|
|
44
|
-
|
|
54
|
+
// skip if we can't get the stack, probably in a worker
|
|
55
|
+
if (!dirname)
|
|
56
|
+
return await a;
|
|
45
57
|
const now = performance.now();
|
|
46
|
-
const error = new
|
|
47
|
-
const stack = error.stack
|
|
48
|
-
const firstLine =
|
|
58
|
+
const error = new DatabaseError('Error in execute', undefined);
|
|
59
|
+
const stack = error.stack?.split('\n').slice(3) || undefined;
|
|
60
|
+
const firstLine = stack?.length && stack[0]?.includes('(') && dirname
|
|
61
|
+
? (0, node_path_1.relative)(dirname, stack[0].split('(')[1].split(')')[0])
|
|
62
|
+
: undefined;
|
|
49
63
|
try {
|
|
50
64
|
const result = await a;
|
|
51
65
|
console.log(`[${firstLine}] Execution time: ${Math.round(performance.now() - now)}ms`);
|
|
52
66
|
return result;
|
|
53
67
|
}
|
|
54
68
|
catch (e) {
|
|
55
|
-
|
|
69
|
+
if (stack)
|
|
70
|
+
error.stack = stack.join('\n').trim();
|
|
71
|
+
else
|
|
72
|
+
error.stack = e.stack;
|
|
56
73
|
// error.cause = e;
|
|
57
74
|
error.message = e.message;
|
|
58
75
|
const serialized = (0, utils_1.serializeError)(e);
|
package/build/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,8BAOC;AAED,kCAIC;AAYD,8BA+BC;AAnFD,4CAAkD;AAClD,mCAAsD;AACtD,2DAAuD;AACvD,wDAA8C;AAe9C,iDAA+B;AAE/B,yCAA2C;AAG3C,iCAA6B;AAApB,6FAAA,GAAG,OAAA;AAIZ,SAAgB,SAAS,CAAC,QAAa;IACrC,OAAO,IAAI,eAAC,CAAK;QACf,OAAO,EAAE,IAAI,sCAAiB,CAAC;YAC7B,QAAQ;SACT,CAAC;QACF,OAAO,EAAE,CAAC,IAAI,wBAAe,EAAE,CAAC;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,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC;QACvB,OAAO,CAAC,GAAG,CACT,IAAI,SAAS,qBAAqB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,CAC1E,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,KAAK;YAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;;YAC5C,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QAC3B,mBAAmB;QACnB,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;QAC1B,MAAM,UAAU,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC,KAAK,CAAC;QACxB,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,qBAAqB,SAAS,EAAE,EAAE,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAC,CAAC;QACvE,OAAO,CAAC,GAAG,CACT,IAAI,SAAS,qBAAqB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,CAC1E,CAAC;QACF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { serializeError } from '@finalytic/utils';\nimport { CamelCasePlugin, Kysely as K } from 'kysely';\nimport { PostgresJSDialect } from 'kysely-postgres-js';\nimport postgres, { type Sql } from 'postgres';\n\nexport type {\n ColumnType,\n Expression,\n ExpressionBuilder,\n ExpressionOrFactory,\n Generated,\n Insertable,\n JSONColumnType,\n OperandExpression,\n Selectable,\n SqlBool,\n Updateable,\n} from 'kysely';\nexport * from './v1.generated';\n\nimport { join, relative } from 'node:path';\nimport type { DB } from './v1.generated';\n\nexport { sql } from 'kysely';\n\nexport type Kysely = K<DB>;\nexport type Postgres = Sql;\nexport function useKysely(postgres: Sql) {\n return new K<DB>({\n dialect: new PostgresJSDialect({\n postgres,\n }),\n plugins: [new CamelCasePlugin()],\n });\n}\n\nexport function usePostgres(connectionString: string, ssl?: boolean) {\n return postgres(connectionString, {\n ssl: ssl ? 'prefer' : false,\n });\n}\n\nexport class DatabaseError extends Error {\n constructor(message: string, cause: any) {\n super(message);\n this.cause = cause;\n }\n}\n\nconst dirname =\n typeof __dirname === 'string' ? join(__dirname, '../../..') : '';\n\nexport async function withStack<T>(a: Promise<T>) {\n // skip if we can't get the stack, probably in a worker\n if (!dirname) return await a;\n\n const now = performance.now();\n const error = new DatabaseError('Error in execute', undefined);\n const stack = error.stack?.split('\\n').slice(3) || undefined;\n const firstLine =\n stack?.length && stack[0]?.includes('(') && dirname\n ? relative(dirname, stack[0].split('(')[1].split(')')[0])\n : undefined;\n try {\n const result = await a;\n console.log(\n `[${firstLine}] Execution time: ${Math.round(performance.now() - now)}ms`\n );\n return result;\n } catch (e: any) {\n if (stack) error.stack = stack.join('\\n').trim();\n else error.stack = e.stack;\n // error.cause = e;\n error.message = e.message;\n const serialized = serializeError(e);\n delete serialized.stack;\n error.cause = serialized;\n console.error(`Error in execute: ${firstLine}`, serializeError(error));\n console.log(\n `[${firstLine}] Execution time: ${Math.round(performance.now() - now)}ms`\n );\n throw error;\n }\n}\n"]}
|
package/build/main/local.js
CHANGED
|
@@ -43,9 +43,8 @@ const path = __importStar(require("node:path"));
|
|
|
43
43
|
const node_path_1 = require("node:path");
|
|
44
44
|
const pglite_1 = require("@electric-sql/pglite");
|
|
45
45
|
const kysely_1 = require("kysely");
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
const kysely_pglite_1 = require("kysely-pglite");
|
|
48
46
|
const kysely_codegen_1 = __importDefault(require("kysely-codegen"));
|
|
47
|
+
const kysely_pglite_1 = require("kysely-pglite");
|
|
49
48
|
const root = (0, node_path_1.join)(__dirname, '..');
|
|
50
49
|
async function migrate(client) {
|
|
51
50
|
console.log('migrating pglite ....');
|
package/build/main/local.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"src/","sources":["local.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"src/","sources":["local.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,wCA8BC;AAlHD,qCAAyC;AACzC,+CAA0C;AAC1C,gDAAkC;AAClC,yCAAiC;AACjC,iDAA8C;AAC9C,mCAKgB;AAChB,oEAAqC;AACrC,iDAA6C;AAG7C,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACnC,KAAK,UAAU,OAAO,CAAC,MAAc;IACnC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC3C,IAAI,KAAK,EAAE,MAAM,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAA,gBAAI,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,MAAmB;IAC9C,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,iBAAQ,CAAC;QAC5B,EAAE,EAAE,MAAM;QACV,oBAAoB,EAAE,MAAM;QAC5B,kBAAkB,EAAE,kBAAkB;QACtC,sBAAsB,EAAE,uBAAuB;QAC/C,QAAQ,EAAE,IAAI,8BAAqB,CAAC;YACl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AAC;IAEH,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,CAAC,OAAO,GAAG,KAAK,IAAI,EAAE;QAC1B,IAAI,WAAW;YAAE,OAAO;QACxB,WAAW,GAAG,IAAI,CAAC;QACnB,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACtC,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CACT,uBAAuB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,CACvE,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IAE9E,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport { exists } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { join } from 'node:path';\nimport { PGlite } from '@electric-sql/pglite';\nimport {\n CamelCasePlugin,\n FileMigrationProvider,\n Kysely,\n Migrator,\n} from 'kysely';\nimport codegen from 'kysely-codegen';\nimport { KyselyPGlite } from 'kysely-pglite';\nimport type { DB } from './v1.generated';\n\nconst root = join(__dirname, '..');\nasync function migrate(client: PGlite) {\n console.log('migrating pglite ....');\n const glob = new Bun.Glob('initial/*.sql');\n for await (const migration of glob.scan(root)) {\n await client.exec(await Bun.file(join(root, migration)).text());\n }\n}\n\nasync function migrateKysely(kysely: Kysely<any>) {\n console.log('init migrating kysely ....');\n const migrator = new Migrator({\n db: kysely,\n migrationTableSchema: 'core',\n migrationTableName: 'kysely_migration',\n migrationLockTableName: 'kysely_migration_lock',\n provider: new FileMigrationProvider({\n fs,\n path,\n // This needs to be an absolute path.\n migrationFolder: path.join(root, 'migrations'),\n }),\n });\n\n console.log('migrating kysely ....');\n const { error, results } = await migrator.migrateToLatest();\n\n for (const it of results ?? []) {\n if (it.status === 'Success') {\n console.log(`migration \"${it.migrationName}\" was executed successfully`);\n } else if (it.status === 'Error') {\n console.error(`failed to execute migration \"${it.migrationName}\"`);\n }\n }\n\n if (error) {\n console.error('failed to migrate');\n console.error(error);\n process.exit(1);\n }\n}\n\nconst dumpPath = join(root, '.data.tar');\nconst dumpFile = (async () => {\n const dataExists = await exists(dumpPath);\n if (!dataExists) {\n console.log('Creating initial dump');\n const main = new PGlite();\n await migrate(main);\n const { dialect } = new KyselyPGlite(main);\n const kysely = new Kysely<DB>({\n dialect,\n plugins: [new CamelCasePlugin()],\n });\n await migrateKysely(kysely);\n await codegen.generate({\n db: kysely,\n outFile: path.join(root, 'src/v1.generated.ts'),\n defaultSchemas: ['xxx'],\n camelCase: true,\n dialect: codegen.getDialect('postgres'),\n });\n const content = await main.dumpDataDir('none');\n await Bun.write(dumpPath, content);\n return content;\n }\n return Bun.file(dumpPath);\n})();\n\nexport async function useLocalKysely() {\n let isDestroyed = false;\n const now = performance.now();\n\n const dump = await dumpFile;\n\n const pglite = new PGlite({ loadDataDir: dump });\n // warm up\n await pglite.sql`SELECT 1`;\n const { dialect } = new KyselyPGlite(pglite);\n const kysely = new Kysely<DB>({\n dialect,\n plugins: [new CamelCasePlugin()],\n });\n\n const originalDestroy = kysely.destroy.bind(kysely);\n kysely.destroy = async () => {\n if (isDestroyed) return;\n isDestroyed = true;\n const destroyTime = performance.now();\n await originalDestroy().catch(() => undefined);\n await pglite.close().catch(() => undefined);\n console.log(\n `Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`\n );\n };\n\n console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);\n\n return kysely;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/index.ts","../../src/local.ts","../../src/test.ts","../../src/v0.generated.ts","../../src/v1.generated.ts"],"version":"5.
|
|
1
|
+
{"root":["../../src/index.ts","../../src/local.ts","../../src/test.ts","../../src/v0.generated.ts","../../src/v1.generated.ts"],"version":"5.9.2"}
|
|
@@ -13,6 +13,7 @@ export type JsonObject = {
|
|
|
13
13
|
export type JsonPrimitive = boolean | number | string | null;
|
|
14
14
|
export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
|
|
15
15
|
export type Numeric = ColumnType<string, number | string, number | string>;
|
|
16
|
+
export type StoreEffectStatus = "claimed" | "completed" | "dead_letter" | "failed" | "pending" | "running";
|
|
16
17
|
export type Timestamp = ColumnType<Date, Date | string, Date | string>;
|
|
17
18
|
export interface AccountingAccount {
|
|
18
19
|
bankingCategory: string | null;
|
|
@@ -178,6 +179,7 @@ export interface AccountingJournalEntry {
|
|
|
178
179
|
entityType: string | null;
|
|
179
180
|
id: Generated<string>;
|
|
180
181
|
lineId: string | null;
|
|
182
|
+
lineUniqueRef: string | null;
|
|
181
183
|
listingId: string | null;
|
|
182
184
|
listingOwnershipPeriodId: string | null;
|
|
183
185
|
party: string | null;
|
|
@@ -880,6 +882,7 @@ export interface PublicFeatureStatus {
|
|
|
880
882
|
}
|
|
881
883
|
export interface PublicFileStorage {
|
|
882
884
|
connectionId: string | null;
|
|
885
|
+
contactId: string | null;
|
|
883
886
|
createdAt: Generated<Timestamp>;
|
|
884
887
|
endDate: Timestamp | null;
|
|
885
888
|
extension: string | null;
|
|
@@ -931,6 +934,7 @@ export interface PublicListing {
|
|
|
931
934
|
beds: number | null;
|
|
932
935
|
calculatedStatus: Generated<string | null>;
|
|
933
936
|
calculatedTitle: Generated<string | null>;
|
|
937
|
+
calculatedTitleNew: Generated<string | null>;
|
|
934
938
|
centExpenseReserve: number | null;
|
|
935
939
|
/**
|
|
936
940
|
* Starting balance for tax statements
|
|
@@ -994,14 +998,19 @@ export interface PublicListingOwnerRole {
|
|
|
994
998
|
name: string;
|
|
995
999
|
}
|
|
996
1000
|
export interface PublicListingOwnershipPeriod {
|
|
1001
|
+
businessModel: Generated<string | null>;
|
|
997
1002
|
createdAt: Generated<Timestamp>;
|
|
998
1003
|
endAt: Timestamp | null;
|
|
999
1004
|
id: Generated<string>;
|
|
1000
1005
|
listingId: string;
|
|
1006
|
+
setListingInactive: Generated<boolean | null>;
|
|
1001
1007
|
startAt: Generated<Timestamp | null>;
|
|
1002
1008
|
tenantId: string;
|
|
1003
1009
|
updatedAt: Generated<Timestamp>;
|
|
1004
1010
|
}
|
|
1011
|
+
export interface PublicListingOwnershipPeriodBusinessModel {
|
|
1012
|
+
name: string;
|
|
1013
|
+
}
|
|
1005
1014
|
export interface PublicListingOwnershipPeriodMember {
|
|
1006
1015
|
contactId: string | null;
|
|
1007
1016
|
createdAt: Generated<Timestamp | null>;
|
|
@@ -1255,10 +1264,10 @@ export interface PublicPgpodmanStatus {
|
|
|
1255
1264
|
status: string | null;
|
|
1256
1265
|
}
|
|
1257
1266
|
export interface PublicPgStatStatements {
|
|
1258
|
-
blkReadTime: number | null;
|
|
1259
|
-
blkWriteTime: number | null;
|
|
1260
1267
|
calls: Int8 | null;
|
|
1261
1268
|
dbid: number | null;
|
|
1269
|
+
jitDeformCount: Int8 | null;
|
|
1270
|
+
jitDeformTime: number | null;
|
|
1262
1271
|
jitEmissionCount: Int8 | null;
|
|
1263
1272
|
jitEmissionTime: number | null;
|
|
1264
1273
|
jitFunctions: Int8 | null;
|
|
@@ -1267,24 +1276,30 @@ export interface PublicPgStatStatements {
|
|
|
1267
1276
|
jitInliningTime: number | null;
|
|
1268
1277
|
jitOptimizationCount: Int8 | null;
|
|
1269
1278
|
jitOptimizationTime: number | null;
|
|
1279
|
+
localBlkReadTime: number | null;
|
|
1270
1280
|
localBlksDirtied: Int8 | null;
|
|
1271
1281
|
localBlksHit: Int8 | null;
|
|
1272
1282
|
localBlksRead: Int8 | null;
|
|
1273
1283
|
localBlksWritten: Int8 | null;
|
|
1284
|
+
localBlkWriteTime: number | null;
|
|
1274
1285
|
maxExecTime: number | null;
|
|
1275
1286
|
maxPlanTime: number | null;
|
|
1276
1287
|
meanExecTime: number | null;
|
|
1277
1288
|
meanPlanTime: number | null;
|
|
1278
1289
|
minExecTime: number | null;
|
|
1290
|
+
minmaxStatsSince: Timestamp | null;
|
|
1279
1291
|
minPlanTime: number | null;
|
|
1280
1292
|
plans: Int8 | null;
|
|
1281
1293
|
query: string | null;
|
|
1282
1294
|
queryid: Int8 | null;
|
|
1283
1295
|
rows: Int8 | null;
|
|
1296
|
+
sharedBlkReadTime: number | null;
|
|
1284
1297
|
sharedBlksDirtied: Int8 | null;
|
|
1285
1298
|
sharedBlksHit: Int8 | null;
|
|
1286
1299
|
sharedBlksRead: Int8 | null;
|
|
1287
1300
|
sharedBlksWritten: Int8 | null;
|
|
1301
|
+
sharedBlkWriteTime: number | null;
|
|
1302
|
+
statsSince: Timestamp | null;
|
|
1288
1303
|
stddevExecTime: number | null;
|
|
1289
1304
|
stddevPlanTime: number | null;
|
|
1290
1305
|
tempBlkReadTime: number | null;
|
|
@@ -1373,6 +1388,8 @@ export interface PublicReservation {
|
|
|
1373
1388
|
connectionId: string | null;
|
|
1374
1389
|
createdAt: Generated<Timestamp | null>;
|
|
1375
1390
|
currency: string | null;
|
|
1391
|
+
deduplicationRef: string | null;
|
|
1392
|
+
generalLedgerPostingAt: Timestamp | null;
|
|
1376
1393
|
guestName: string | null;
|
|
1377
1394
|
guests: number | null;
|
|
1378
1395
|
id: Generated<string>;
|
|
@@ -1481,6 +1498,9 @@ export interface PublicSetting {
|
|
|
1481
1498
|
value: string | null;
|
|
1482
1499
|
}
|
|
1483
1500
|
export interface PublicSource {
|
|
1501
|
+
/**
|
|
1502
|
+
* deprecated
|
|
1503
|
+
*/
|
|
1484
1504
|
appId: string | null;
|
|
1485
1505
|
code: string | null;
|
|
1486
1506
|
connectionId: string | null;
|
|
@@ -1492,7 +1512,13 @@ export interface PublicSource {
|
|
|
1492
1512
|
indexedJson: Json | null;
|
|
1493
1513
|
isArchived: Generated<boolean | null>;
|
|
1494
1514
|
json: Json | null;
|
|
1515
|
+
/**
|
|
1516
|
+
* deprecated
|
|
1517
|
+
*/
|
|
1495
1518
|
listingConnectionId: string | null;
|
|
1519
|
+
/**
|
|
1520
|
+
* deprecated
|
|
1521
|
+
*/
|
|
1496
1522
|
listingId: string | null;
|
|
1497
1523
|
modifiedAt: Timestamp | null;
|
|
1498
1524
|
parentId: string | null;
|
|
@@ -1701,6 +1727,47 @@ export interface PublicWebhook {
|
|
|
1701
1727
|
types2: string[] | null;
|
|
1702
1728
|
url: string;
|
|
1703
1729
|
}
|
|
1730
|
+
export interface StoreDispatchedAction {
|
|
1731
|
+
actionType: string;
|
|
1732
|
+
apiEndpoint: string | null;
|
|
1733
|
+
createdAt: Generated<Timestamp>;
|
|
1734
|
+
id: Generated<string>;
|
|
1735
|
+
message: string | null;
|
|
1736
|
+
payload: Json | null;
|
|
1737
|
+
requestR2Link: string | null;
|
|
1738
|
+
sequence: Generated<number>;
|
|
1739
|
+
tenantId: string;
|
|
1740
|
+
userId: string | null;
|
|
1741
|
+
}
|
|
1742
|
+
export interface StoreEffectQueue {
|
|
1743
|
+
claimedAt: Timestamp | null;
|
|
1744
|
+
claimedBy: string | null;
|
|
1745
|
+
completedAt: Timestamp | null;
|
|
1746
|
+
createdAt: Generated<Timestamp>;
|
|
1747
|
+
dispatchedActionId: string;
|
|
1748
|
+
effectType: string;
|
|
1749
|
+
id: Generated<string>;
|
|
1750
|
+
lastAttemptAt: Timestamp | null;
|
|
1751
|
+
lastError: string | null;
|
|
1752
|
+
maxRetries: Generated<number>;
|
|
1753
|
+
payload: Json;
|
|
1754
|
+
priority: Generated<number>;
|
|
1755
|
+
retryCount: Generated<number>;
|
|
1756
|
+
sequence: Generated<number>;
|
|
1757
|
+
status: Generated<StoreEffectStatus>;
|
|
1758
|
+
tenantId: string;
|
|
1759
|
+
}
|
|
1760
|
+
export interface StoreMutationLog {
|
|
1761
|
+
changeRecord: Json;
|
|
1762
|
+
createdAt: Generated<Timestamp>;
|
|
1763
|
+
dispatchedActionId: string;
|
|
1764
|
+
effectId: string | null;
|
|
1765
|
+
id: Generated<string>;
|
|
1766
|
+
mutatedEntityId: string;
|
|
1767
|
+
mutatedEntityType: string;
|
|
1768
|
+
mutationOp: string;
|
|
1769
|
+
tenantId: string;
|
|
1770
|
+
}
|
|
1704
1771
|
export interface TrackingEvent {
|
|
1705
1772
|
createdAt: Generated<Timestamp>;
|
|
1706
1773
|
id: Generated<string>;
|
|
@@ -1859,6 +1926,7 @@ export interface DB {
|
|
|
1859
1926
|
"public.listingOwner": PublicListingOwner;
|
|
1860
1927
|
"public.listingOwnerRole": PublicListingOwnerRole;
|
|
1861
1928
|
"public.listingOwnershipPeriod": PublicListingOwnershipPeriod;
|
|
1929
|
+
"public.listingOwnershipPeriodBusinessModel": PublicListingOwnershipPeriodBusinessModel;
|
|
1862
1930
|
"public.listingOwnershipPeriodMember": PublicListingOwnershipPeriodMember;
|
|
1863
1931
|
"public.listingPmsStatus": PublicListingPmsStatus;
|
|
1864
1932
|
"public.listingStatus": PublicListingStatus;
|
|
@@ -1913,6 +1981,9 @@ export interface DB {
|
|
|
1913
1981
|
"public.viewWebhookEvents": PublicViewWebhookEvents;
|
|
1914
1982
|
"public.viewWebhookEventsGroupedByDate": PublicViewWebhookEventsGroupedByDate;
|
|
1915
1983
|
"public.webhook": PublicWebhook;
|
|
1984
|
+
"store.dispatchedAction": StoreDispatchedAction;
|
|
1985
|
+
"store.effectQueue": StoreEffectQueue;
|
|
1986
|
+
"store.mutationLog": StoreMutationLog;
|
|
1916
1987
|
"tracking.event": TrackingEvent;
|
|
1917
1988
|
"tracking.intercomConversation": TrackingIntercomConversation;
|
|
1918
1989
|
"tracking.intercomConversationUser": TrackingIntercomConversationUser;
|