@vrplatform/kysely 1.3.45-39513751709 → 1.3.45-39585224589

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.
@@ -0,0 +1,6 @@
1
+ import type { ControlPlaneKysely, ControlPlaneTransaction } from '../../index';
2
+ export declare function listFeatureEnabledTenantIds(controlPlane: ControlPlaneKysely | ControlPlaneTransaction, input: {
3
+ featureIds: readonly string[];
4
+ statuses?: readonly string[];
5
+ tenantIds?: readonly string[];
6
+ }): Promise<Set<string>>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listFeatureEnabledTenantIds = listFeatureEnabledTenantIds;
4
+ const utils_1 = require("@vrplatform/utils");
5
+ // Feature flags live only in the control plane. Every runtime reads them here,
6
+ // so a flag change is visible to the next read in any region.
7
+ async function listFeatureEnabledTenantIds(controlPlane, input) {
8
+ if (!input.featureIds.length || input.tenantIds?.length === 0) {
9
+ return new Set();
10
+ }
11
+ const read = async (tenantIds) => {
12
+ let query = controlPlane
13
+ .selectFrom('controlPlane.featureEnabledTeam')
14
+ .select('tenantId')
15
+ .distinct()
16
+ .where('featureId', 'in', input.featureIds);
17
+ if (input.statuses) {
18
+ query = query.where('status', 'in', input.statuses);
19
+ }
20
+ if (tenantIds) {
21
+ query = query.where('tenantId', 'in', tenantIds);
22
+ }
23
+ return await query.execute();
24
+ };
25
+ const rows = input.tenantIds
26
+ ? (await Promise.all((0, utils_1.chunkArray)([...input.tenantIds], 5000).map(read))).flat()
27
+ : await read();
28
+ return new Set(rows.map(({ tenantId }) => tenantId));
29
+ }
30
+ //# sourceMappingURL=feature-enabled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-enabled.js","sourceRoot":"src/","sources":["query/tenant/feature-enabled.ts"],"names":[],"mappings":";;AAKA,kEAiCC;AAtCD,6CAA+C;AAG/C,+EAA+E;AAC/E,8DAA8D;AACvD,KAAK,UAAU,2B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ely, ControlPlaneTransaction } from '../../index';\n\n// Feature flags live only in the control plane. Every runtime reads them here,\n// so a flag change is visible to the next read in any region.\nexport async function listFeatureEnabledTenantIds(\n controlPlane: ControlPlaneKysely | ControlPlaneTransaction,\n input: {\n featureIds: readonly string[];\n statuses?: readonly string[];\n tenantIds?: readonly string[];\n }\n) {\n if (!input.featureIds.length || input.tenantIds?.length === 0) {\n return new Set<string>();\n }\n\n const read = async (tenantIds?: readonly string[]) => {\n let query = controlPlane\n .selectFrom('controlPlane.featureEnabledTeam')\n .select('tenantId')\n .distinct()\n .where('featureId', 'in', input.featureIds);\n if (input.statuses) {\n query = query.where('status', 'in', input.statuses);\n }\n if (tenantIds) {\n query = query.where('tenantId', 'in', tenantIds);\n }\n return await query.execute();\n };\n\n const rows = input.tenantIds\n ? (\n await Promise.all(chunkArray([...input.tenantIds], 5000).map(read))\n ).flat()\n : await read();\n return new Set(rows.map(({ tenantId }) => tenantId));\n}\n"]}
@@ -1,2 +1,3 @@
1
1
  export * from './billing-partner';
2
2
  export * from './status';
3
+ export * from './feature-enabled';
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./billing-partner"), exports);
18
18
  __exportStar(require("./status"), exports);
19
+ __exportStar(require("./feature-enabled"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/tenant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,2CAAyB","sourcesContent":["export * from './billing-partner';\nexport * from './status';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/tenant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,2CAAyB;AACzB,oDAAkC","sourcesContent":["export * from './billing-partner';\nexport * from './status';\nexport * from './feature-enabled';\n"]}
@@ -1908,43 +1908,6 @@ export interface PublicEmailTemplate {
1908
1908
  export interface PublicEmailTemplateType {
1909
1909
  name: string;
1910
1910
  }
1911
- export interface PublicFeature {
1912
- createdAt: Generated<Timestamp>;
1913
- description: string | null;
1914
- id: Generated<string>;
1915
- issueUrl: string | null;
1916
- /**
1917
- * user ids of user needed to approve this feature
1918
- */
1919
- requiredApprovals: Generated<Json | null>;
1920
- status: Generated<string | null>;
1921
- tenantId: string | null;
1922
- title: string;
1923
- updatedAt: Generated<Timestamp>;
1924
- url: string | null;
1925
- }
1926
- export interface PublicFeatureApproval {
1927
- createdAt: Generated<Timestamp>;
1928
- featureId: string;
1929
- id: Generated<string>;
1930
- status: Generated<string | null>;
1931
- updatedAt: Generated<Timestamp>;
1932
- userId: string;
1933
- }
1934
- export interface PublicFeatureApprovalStatus {
1935
- name: string;
1936
- }
1937
- export interface PublicFeatureEnabledTeam {
1938
- createdAt: Generated<Timestamp>;
1939
- featureId: string;
1940
- id: Generated<string>;
1941
- status: Generated<string | null>;
1942
- tenantId: string;
1943
- updatedAt: Generated<Timestamp>;
1944
- }
1945
- export interface PublicFeatureStatus {
1946
- name: string;
1947
- }
1948
1911
  export interface PublicFileStorage {
1949
1912
  connectionId: string | null;
1950
1913
  contactId: string | null;
@@ -3076,11 +3039,6 @@ export interface DB {
3076
3039
  "public.duplicateEmails": PublicDuplicateEmails;
3077
3040
  "public.emailTemplate": PublicEmailTemplate;
3078
3041
  "public.emailTemplateType": PublicEmailTemplateType;
3079
- "public.feature": PublicFeature;
3080
- "public.featureApproval": PublicFeatureApproval;
3081
- "public.featureApprovalStatus": PublicFeatureApprovalStatus;
3082
- "public.featureEnabledTeam": PublicFeatureEnabledTeam;
3083
- "public.featureStatus": PublicFeatureStatus;
3084
3042
  "public.fileStorage": PublicFileStorage;
3085
3043
  "public.fileStorageSourceLink": PublicFileStorageSourceLink;
3086
3044
  "public.fileStorageTag": PublicFileStorageTag;