@vrplatform/kysely 1.3.45-stage.4627 → 1.3.45-stage.4628
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/main/query/index.d.ts +1 -0
- package/build/main/query/index.js +1 -0
- package/build/main/query/index.js.map +1 -1
- package/build/main/query/tenant/index.d.ts +1 -0
- package/build/main/query/tenant/index.js +18 -0
- package/build/main/query/tenant/index.js.map +1 -0
- package/build/main/query/tenant/status.d.ts +20 -0
- package/build/main/query/tenant/status.js +43 -0
- package/build/main/query/tenant/status.js.map +1 -0
- package/build/module/query/index.d.ts +1 -0
- package/build/module/query/index.js +1 -0
- package/build/module/query/index.js.map +1 -1
- package/build/module/query/tenant/index.d.ts +1 -0
- package/build/module/query/tenant/index.js +2 -0
- package/build/module/query/tenant/index.js.map +1 -0
- package/build/module/query/tenant/status.d.ts +20 -0
- package/build/module/query/tenant/status.js +38 -0
- package/build/module/query/tenant/status.js.map +1 -0
- package/package.json +1 -1
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./listing"), exports);
|
|
18
|
+
__exportStar(require("./tenant"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B","sourcesContent":["export * from './listing';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB","sourcesContent":["export * from './listing';\nexport * from './tenant';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './status';
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./status"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/tenant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB","sourcesContent":["export * from './status';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DB, ExpressionBuilder, PublicTenant } from '../../isomorphic';
|
|
2
|
+
type TenantExpressionBuilder = ExpressionBuilder<DB & {
|
|
3
|
+
tenant: PublicTenant;
|
|
4
|
+
}, 'tenant'>;
|
|
5
|
+
export declare function whereTenantActive(eb: TenantExpressionBuilder): import("kysely").ExpressionWrapper<DB & {
|
|
6
|
+
tenant: PublicTenant;
|
|
7
|
+
}, "tenant", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
8
|
+
export declare function whereTenantNotTestTeam(eb: TenantExpressionBuilder, { excludedTenantIds, testPartnerTenantId, }: {
|
|
9
|
+
excludedTenantIds: readonly [string, ...string[]];
|
|
10
|
+
testPartnerTenantId: string;
|
|
11
|
+
}): import("kysely").ExpressionWrapper<DB & {
|
|
12
|
+
tenant: PublicTenant;
|
|
13
|
+
}, "tenant", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
14
|
+
export declare function whereTenantShouldBePaid(eb: TenantExpressionBuilder, { includePartnerTeams, today, }?: {
|
|
15
|
+
includePartnerTeams?: boolean;
|
|
16
|
+
today?: Date | string;
|
|
17
|
+
}): import("kysely").ExpressionWrapper<DB & {
|
|
18
|
+
tenant: PublicTenant;
|
|
19
|
+
}, "tenant", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.whereTenantActive = whereTenantActive;
|
|
4
|
+
exports.whereTenantNotTestTeam = whereTenantNotTestTeam;
|
|
5
|
+
exports.whereTenantShouldBePaid = whereTenantShouldBePaid;
|
|
6
|
+
const utils_1 = require("@vrplatform/utils");
|
|
7
|
+
function whereTenantActive(eb) {
|
|
8
|
+
return eb.and([
|
|
9
|
+
eb('tenant.calculatedStatus', '=', 'active'),
|
|
10
|
+
eb.or([
|
|
11
|
+
eb('tenant.calculatedBillingPartnerId', 'is', null),
|
|
12
|
+
eb.exists(eb
|
|
13
|
+
.selectFrom('public.tenant as billingPartner')
|
|
14
|
+
.select('billingPartner.id')
|
|
15
|
+
.whereRef('billingPartner.id', '=', 'tenant.calculatedBillingPartnerId')
|
|
16
|
+
.where('billingPartner.calculatedStatus', '=', 'active')),
|
|
17
|
+
]),
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
function whereTenantNotTestTeam(eb, { excludedTenantIds, testPartnerTenantId, }) {
|
|
21
|
+
return eb.and([
|
|
22
|
+
eb('tenant.id', 'not in', [...excludedTenantIds]),
|
|
23
|
+
eb('tenant.partnerId', '!=', testPartnerTenantId),
|
|
24
|
+
eb.or([
|
|
25
|
+
eb('tenant.billingPartnerId', 'is', null),
|
|
26
|
+
eb('tenant.billingPartnerId', '!=', testPartnerTenantId),
|
|
27
|
+
]),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
function whereTenantShouldBePaid(eb, { includePartnerTeams = false, today = (0, utils_1.day)().yyyymmdd(), } = {}) {
|
|
31
|
+
return eb.and([
|
|
32
|
+
whereTenantActive(eb),
|
|
33
|
+
eb('tenant.isOnboarding', '=', false),
|
|
34
|
+
eb.or([
|
|
35
|
+
eb('tenant.trialUntil', '<', today),
|
|
36
|
+
eb('tenant.trialUntil', 'is', null),
|
|
37
|
+
]),
|
|
38
|
+
...(includePartnerTeams
|
|
39
|
+
? []
|
|
40
|
+
: [eb('tenant.calculatedIsBillable', '=', true)]),
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"src/","sources":["query/tenant/status.ts"],"names":[],"mappings":";;AAQA,8CAkBC;AAED,wDAkBC;AAED,0DAqBC;AArED,6CAAwC;AAQxC,SAAgB,iBAAiB,CAAC,EAA2B;IAC3D,OAAO,EAAE,CAAC,GAAG,CAAC;QACZ,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE,QAAQ,CAAC;QAC5C,EAAE,CAAC,EAAE,CAAC;YACJ,EAAE,CAAC,mCAAmC,EAAE,IAAI,EAAE,IAAI,CAAC;YACnD,EAAE,CAAC,MAAM,CACP,EAAE;iBACC,UAAU,CAAC,iCAAiC,CAAC;iBAC7C,MAAM,CAAC,mBAAmB,CAAC;iBAC3B,QAAQ,CACP,mBAAmB,EACnB,GAAG,EACH,mCAAmC,CACpC;iBACA,KAAK,CAAC,iCAAiC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAC3D;SACF,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,sBAAsB,CACpC,EAA2B,EAC3B,EACE,iBAAiB,EACjB,mBAAmB,GAIpB;IAED,OAAO,EAAE,CAAC,GAAG,CAAC;QACZ,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC;QACjD,EAAE,CAAC,kBAAkB,EAAE,IAAI,EAAE,mBAAmB,CAAC;QACjD,EAAE,CAAC,EAAE,CAAC;YACJ,EAAE,CAAC,yBAAyB,EAAE,IAAI,EAAE,IAAI,CAAC;YACzC,EAAE,CAAC,yBAAyB,EAAE,IAAI,EAAE,mBAAmB,CAAC;SACzD,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,uBAAuB,CACrC,EAA2B,EAC3B,EACE,mBAAmB,GAAG,KAAK,EAC3B,KAAK,GAAG,IAAA,WAAG,GAAE,CAAC,QAAQ,EAAE,MAItB,EAAE;IAEN,OAAO,EAAE,CAAC,GAAG,CAAC;QACZ,iBAAiB,CAAC,EAAE,CAAC;QACrB,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE,KAAK,CAAC;QACrC,EAAE,CAAC,EAAE,CAAC;YACJ,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE,KAAK,CAAC;YACnC,EAAE,CAAC,mBAAmB,EAAE,IAAI,EAAE,IAAI,CAAC;SACpC,CAAC;QACF,GAAG,CAAC,mBAAmB;YACrB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KACpD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { day } from '@vrplatform/utils';\nimport type { DB, ExpressionBuilder, PublicTenant } from '../../isomorphic';\n\ntype TenantExpressionBuilder = ExpressionBuilder<\n DB & { tenant: PublicTenant },\n 'tenant'\n>;\n\nexport function whereTenantActive(eb: TenantExpressionBuilder) {\n return eb.and([\n eb('tenant.calculatedStatus', '=', 'active'),\n eb.or([\n eb('tenant.calculatedBillingPartnerId', 'is', null),\n eb.exists(\n eb\n .selectFrom('public.tenant as billingPartner')\n .select('billingPartner.id')\n .whereRef(\n 'billingPartner.id',\n '=',\n 'tenant.calculatedBillingPartnerId'\n )\n .where('billingPartner.calculatedStatus', '=', 'active')\n ),\n ]),\n ]);\n}\n\nexport function whereTenantNotTestTeam(\n eb: TenantExpressionBuilder,\n {\n excludedTenantIds,\n testPartnerTenantId,\n }: {\n excludedTenantIds: readonly [string, ...string[]];\n testPartnerTenantId: string;\n }\n) {\n return eb.and([\n eb('tenant.id', 'not in', [...excludedTenantIds]),\n eb('tenant.partnerId', '!=', testPartnerTenantId),\n eb.or([\n eb('tenant.billingPartnerId', 'is', null),\n eb('tenant.billingPartnerId', '!=', testPartnerTenantId),\n ]),\n ]);\n}\n\nexport function whereTenantShouldBePaid(\n eb: TenantExpressionBuilder,\n {\n includePartnerTeams = false,\n today = day().yyyymmdd(),\n }: {\n includePartnerTeams?: boolean;\n today?: Date | string;\n } = {}\n) {\n return eb.and([\n whereTenantActive(eb),\n eb('tenant.isOnboarding', '=', false),\n eb.or([\n eb('tenant.trialUntil', '<', today),\n eb('tenant.trialUntil', 'is', null),\n ]),\n ...(includePartnerTeams\n ? []\n : [eb('tenant.calculatedIsBillable', '=', true)]),\n ]);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC","sourcesContent":["export * from './listing';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC","sourcesContent":["export * from './listing';\nexport * from './tenant';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './status';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/tenant/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC","sourcesContent":["export * from './status';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DB, ExpressionBuilder, PublicTenant } from '../../isomorphic';
|
|
2
|
+
type TenantExpressionBuilder = ExpressionBuilder<DB & {
|
|
3
|
+
tenant: PublicTenant;
|
|
4
|
+
}, 'tenant'>;
|
|
5
|
+
export declare function whereTenantActive(eb: TenantExpressionBuilder): import("kysely").ExpressionWrapper<DB & {
|
|
6
|
+
tenant: PublicTenant;
|
|
7
|
+
}, "tenant", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
8
|
+
export declare function whereTenantNotTestTeam(eb: TenantExpressionBuilder, { excludedTenantIds, testPartnerTenantId, }: {
|
|
9
|
+
excludedTenantIds: readonly [string, ...string[]];
|
|
10
|
+
testPartnerTenantId: string;
|
|
11
|
+
}): import("kysely").ExpressionWrapper<DB & {
|
|
12
|
+
tenant: PublicTenant;
|
|
13
|
+
}, "tenant", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
14
|
+
export declare function whereTenantShouldBePaid(eb: TenantExpressionBuilder, { includePartnerTeams, today, }?: {
|
|
15
|
+
includePartnerTeams?: boolean;
|
|
16
|
+
today?: Date | string;
|
|
17
|
+
}): import("kysely").ExpressionWrapper<DB & {
|
|
18
|
+
tenant: PublicTenant;
|
|
19
|
+
}, "tenant", import("kysely/dist/cjs/util/type-utils").SqlBool>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { day } from '@vrplatform/utils';
|
|
2
|
+
export function whereTenantActive(eb) {
|
|
3
|
+
return eb.and([
|
|
4
|
+
eb('tenant.calculatedStatus', '=', 'active'),
|
|
5
|
+
eb.or([
|
|
6
|
+
eb('tenant.calculatedBillingPartnerId', 'is', null),
|
|
7
|
+
eb.exists(eb
|
|
8
|
+
.selectFrom('public.tenant as billingPartner')
|
|
9
|
+
.select('billingPartner.id')
|
|
10
|
+
.whereRef('billingPartner.id', '=', 'tenant.calculatedBillingPartnerId')
|
|
11
|
+
.where('billingPartner.calculatedStatus', '=', 'active')),
|
|
12
|
+
]),
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
export function whereTenantNotTestTeam(eb, { excludedTenantIds, testPartnerTenantId, }) {
|
|
16
|
+
return eb.and([
|
|
17
|
+
eb('tenant.id', 'not in', [...excludedTenantIds]),
|
|
18
|
+
eb('tenant.partnerId', '!=', testPartnerTenantId),
|
|
19
|
+
eb.or([
|
|
20
|
+
eb('tenant.billingPartnerId', 'is', null),
|
|
21
|
+
eb('tenant.billingPartnerId', '!=', testPartnerTenantId),
|
|
22
|
+
]),
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
export function whereTenantShouldBePaid(eb, { includePartnerTeams = false, today = day().yyyymmdd(), } = {}) {
|
|
26
|
+
return eb.and([
|
|
27
|
+
whereTenantActive(eb),
|
|
28
|
+
eb('tenant.isOnboarding', '=', false),
|
|
29
|
+
eb.or([
|
|
30
|
+
eb('tenant.trialUntil', '<', today),
|
|
31
|
+
eb('tenant.trialUntil', 'is', null),
|
|
32
|
+
]),
|
|
33
|
+
...(includePartnerTeams
|
|
34
|
+
? []
|
|
35
|
+
: [eb('tenant.calculatedIsBillable', '=', true)]),
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"src/","sources":["query/tenant/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAQxC,MAAM,UAAU,iBAAiB,CAAC,EAA2B;IAC3D,OAAO,EAAE,CAAC,GAAG,CAAC;QACZ,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE,QAAQ,CAAC;QAC5C,EAAE,CAAC,EAAE,CAAC;YACJ,EAAE,CAAC,mCAAmC,EAAE,IAAI,EAAE,IAAI,CAAC;YACnD,EAA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AC,CAAC;KACpD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { day } from '@vrplatform/utils';\nimport type { DB, ExpressionBuilder, PublicTenant } from '../../isomorphic';\n\ntype TenantExpressionBuilder = ExpressionBuilder<\n DB & { tenant: PublicTenant },\n 'tenant'\n>;\n\nexport function whereTenantActive(eb: TenantExpressionBuilder) {\n return eb.and([\n eb('tenant.calculatedStatus', '=', 'active'),\n eb.or([\n eb('tenant.calculatedBillingPartnerId', 'is', null),\n eb.exists(\n eb\n .selectFrom('public.tenant as billingPartner')\n .select('billingPartner.id')\n .whereRef(\n 'billingPartner.id',\n '=',\n 'tenant.calculatedBillingPartnerId'\n )\n .where('billingPartner.calculatedStatus', '=', 'active')\n ),\n ]),\n ]);\n}\n\nexport function whereTenantNotTestTeam(\n eb: TenantExpressionBuilder,\n {\n excludedTenantIds,\n testPartnerTenantId,\n }: {\n excludedTenantIds: readonly [string, ...string[]];\n testPartnerTenantId: string;\n }\n) {\n return eb.and([\n eb('tenant.id', 'not in', [...excludedTenantIds]),\n eb('tenant.partnerId', '!=', testPartnerTenantId),\n eb.or([\n eb('tenant.billingPartnerId', 'is', null),\n eb('tenant.billingPartnerId', '!=', testPartnerTenantId),\n ]),\n ]);\n}\n\nexport function whereTenantShouldBePaid(\n eb: TenantExpressionBuilder,\n {\n includePartnerTeams = false,\n today = day().yyyymmdd(),\n }: {\n includePartnerTeams?: boolean;\n today?: Date | string;\n } = {}\n) {\n return eb.and([\n whereTenantActive(eb),\n eb('tenant.isOnboarding', '=', false),\n eb.or([\n eb('tenant.trialUntil', '<', today),\n eb('tenant.trialUntil', 'is', null),\n ]),\n ...(includePartnerTeams\n ? []\n : [eb('tenant.calculatedIsBillable', '=', true)]),\n ]);\n}\n"]}
|