@burdenoff/be-sdk 2026.1005.1 → 2026.1008.1
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/README.md +64 -0
- package/dist/auth/index.d.ts +2 -2
- package/dist/{chunk-FA5ROGTS.js → chunk-CYY4VIRK.js} +257 -131
- package/dist/chunk-CYY4VIRK.js.map +1 -0
- package/dist/{chunk-CVMQRWCB.js → chunk-EOHPDXXW.js} +7 -3
- package/dist/chunk-EOHPDXXW.js.map +1 -0
- package/dist/feature-flags/index.d.ts +3 -3
- package/dist/{index-Daj7nq9V.d.ts → index-Dl8EAdYu.d.ts} +10 -2
- package/dist/{index-Drvw0QPe.d.ts → index-Rc5EphmY.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/lake/index.d.ts +59 -0
- package/dist/lake/index.js +253 -0
- package/dist/lake/index.js.map +1 -0
- package/dist/prisma/index.d.ts +2 -2
- package/dist/prisma/index.js +2 -2
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +1 -1
- package/dist/{types-Biv0uaJk.d.ts → types-C-6m9NoG.d.ts} +1 -1
- package/dist/{workspace-extension-DlxYz3P4.d.ts → workspace-extension-DiNiTLa3.d.ts} +29 -1
- package/package.json +7 -3
- package/dist/chunk-CVMQRWCB.js.map +0 -1
- package/dist/chunk-FA5ROGTS.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { i as Cache } from './index-Cx5I3ydM.js';
|
|
|
24
24
|
export { i as Middleware } from './index-DSOpj8DI.js';
|
|
25
25
|
export { i as Observability } from './index-4gKQKZ2B.js';
|
|
26
26
|
export { i as GraphQL } from './index-joONjwLt.js';
|
|
27
|
-
export { i as Prisma } from './index-
|
|
27
|
+
export { i as Prisma } from './index-Dl8EAdYu.js';
|
|
28
28
|
export { i as Utils } from './index-PaojfSdd.js';
|
|
29
29
|
export { i as I18n, I as I18nCapableContext, T as Translator, c as createTranslator, g as getLanguage, a as getLocale, h as hasI18n, t } from './index-D4l1u8VR.js';
|
|
30
30
|
export { i as Export } from './index-B4ciT3OZ.js';
|
|
@@ -34,20 +34,20 @@ export { i as Instrumentation } from './index-Dvv6irk0.js';
|
|
|
34
34
|
export { i as Layer } from './index-BCUkR8sC.js';
|
|
35
35
|
export { i as Crypto } from './index-e_18DzAg.js';
|
|
36
36
|
export { i as Gateway } from './index-Dy6neH2G.js';
|
|
37
|
-
export { i as FeatureFlags } from './index-
|
|
37
|
+
export { i as FeatureFlags } from './index-Rc5EphmY.js';
|
|
38
38
|
export { i as Captcha, R as RecaptchaVerifyOptions, a as RecaptchaVerifyResult, b as isCaptchaEnabled, v as verifyCaptcha, c as verifyCaptchaIfEnabled } from './index-B70b5mYS.js';
|
|
39
39
|
export { i as Platform } from './index-PJZzGd8r.js';
|
|
40
40
|
export { N as NAME_MAX_LENGTH, a as NAME_MIN_LENGTH, b as NameErrorCode, c as NameValidationResult, U as USERNAME_MAX_LENGTH, d as USERNAME_MIN_LENGTH, e as UserFieldError, f as UserFieldKey, g as UserFieldsValidationResult, h as UsernameErrorCode, i as UsernameValidationResult, V as ValidatedUserFields, j as Validation, l as lengthInCodePoints, v as validateName, k as validateUserFields, m as validateUsername } from './index-B2jIInhp.js';
|
|
41
41
|
export { E as EmitGeneration, P as PRODUCT_RENAMES, a as PRODUCT_RENAME_EMIT, b as PRODUCT_SLUG_ALIASES, i as ProductAlias, c as ProductRename, R as RENAME_CONCERNS, d as RenameConcern, e as billingIdVariants, f as emitBillingId, g as emitName, h as emitProductSlug, j as emitQuotaKey, k as emitRbacResource, l as emitTemplateKey, m as isLegacyName, n as isSameBillingId, o as isSameGraphQLName, p as isSameName, q as isSameProductSlug, r as isSameQuotaKey, s as isSameRbacResource, t as isSameTemplateKey, u as nameVariants, v as normalizeBillingId, w as normalizeGraphQLName, x as normalizeProductSlug, y as normalizeQuotaKey, z as normalizeRbacResource, A as normalizeTemplateKey, B as productSlugVariants, C as quotaKeyVariants, D as rbacResourceVariants, F as readRenamedEnv, G as templateKeyVariants, H as toCurrentName, I as toLegacyName } from './index-BuAj5nXg.js';
|
|
42
42
|
export { C as CircuitBreakerConfig, h as DEFAULT_CIRCUIT_BREAKER_CONFIG, i as DEFAULT_GATEWAY_RETRY_CONFIG, D as DEFAULT_GATEWAY_ROUTING, b as DEFAULT_LAYER_RESOURCES, c as DEFAULT_LAYER_STREAMS, f as GatewayRequestHeaders, g as GatewayRetryConfig, G as GatewayRoutingConfig, L as LayerConfig, a as LayerFullConfig, d as LayerGatewayConfig, e as LayerResourceUrls, S as ServiceLayer } from './layer-GNAVXBMf.js';
|
|
43
43
|
export { S as ShutdownDisposable, d as disposeAll, g as getRegisteredDisposableCount, r as registerDisposable, u as unregisterDisposable } from './shutdown-registry-CW9LryO8.js';
|
|
44
|
-
import './types-
|
|
44
|
+
import './types-C-6m9NoG.js';
|
|
45
45
|
import 'graphql';
|
|
46
46
|
import 'graphql-yoga';
|
|
47
47
|
import './client-CCXpAZ2r.js';
|
|
48
48
|
import '@prisma/adapter-pg';
|
|
49
49
|
import 'pg';
|
|
50
|
-
import './workspace-extension-
|
|
50
|
+
import './workspace-extension-DiNiTLa3.js';
|
|
51
51
|
import './types-C8TbSdEj.js';
|
|
52
52
|
import 'graphql-request';
|
|
53
53
|
import '@envelop/core';
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
export { sharing_exports as Sharing } from './chunk-DS3YMJ4X.js';
|
|
1
2
|
export { TemporalClient, TemporalClientFactory, TemporalModule, TemporalWorker, TemporalWorkerFactory, TemporalWorkerManager } from './chunk-YNDJQRI3.js';
|
|
2
3
|
import { ActivityModule, UsageModule, TrackerModule } from './chunk-NCC5UN3L.js';
|
|
3
4
|
export { ActivityModule, TrackerModule, UsageModule } from './chunk-NCC5UN3L.js';
|
|
4
5
|
export { NAME_MAX_LENGTH, NAME_MIN_LENGTH, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, validation_exports as Validation, lengthInCodePoints, validateName, validateUserFields, validateUsername } from './chunk-AHEXIONU.js';
|
|
6
|
+
export { observability_exports as Observability } from './chunk-VAT66FJA.js';
|
|
5
7
|
export { platform_exports as Platform } from './chunk-Z5BURBFZ.js';
|
|
6
|
-
export { prisma_exports as Prisma } from './chunk-
|
|
8
|
+
export { prisma_exports as Prisma } from './chunk-EOHPDXXW.js';
|
|
7
9
|
export { PRODUCT_RENAMES, PRODUCT_RENAME_EMIT, PRODUCT_SLUG_ALIASES, product_alias_exports as ProductAlias, RENAME_CONCERNS, billingIdVariants, emitBillingId, emitName, emitProductSlug, emitQuotaKey, emitRbacResource, emitTemplateKey, isLegacyName, isSameBillingId, isSameGraphQLName, isSameName, isSameProductSlug, isSameQuotaKey, isSameRbacResource, isSameTemplateKey, nameVariants, normalizeBillingId, normalizeGraphQLName, normalizeProductSlug, normalizeQuotaKey, normalizeRbacResource, normalizeTemplateKey, productSlugVariants, quotaKeyVariants, rbacResourceVariants, readRenamedEnv, templateKeyVariants, toCurrentName, toLegacyName } from './chunk-OBBCR6WY.js';
|
|
8
10
|
import { RBACModule } from './chunk-5JNHVKHG.js';
|
|
9
11
|
export { RBACModule, createRBACDirective, createRBACDirectiveForLayer, createRBACDirectiveFromEnv } from './chunk-5JNHVKHG.js';
|
|
10
|
-
import './chunk-
|
|
11
|
-
export { sharing_exports as Sharing } from './chunk-DS3YMJ4X.js';
|
|
12
|
+
import './chunk-CYY4VIRK.js';
|
|
12
13
|
export { instrumentation_exports as Instrumentation } from './chunk-E5DTAGCA.js';
|
|
13
14
|
export { middleware_exports as Middleware } from './chunk-ELU7VL3E.js';
|
|
14
15
|
import { TenantNotificationsModule, NotificationsModule } from './chunk-INAZ3PKF.js';
|
|
15
16
|
export { tenant_notifications_exports as Notifications, NotificationsModule } from './chunk-INAZ3PKF.js';
|
|
16
|
-
export { observability_exports as Observability } from './chunk-VAT66FJA.js';
|
|
17
17
|
export { export_exports as Export } from './chunk-RFXAHMY4.js';
|
|
18
18
|
export { feature_flags_exports as FeatureFlags } from './chunk-UNASM5VJ.js';
|
|
19
19
|
import { GraphModule } from './chunk-VVBA3LQV.js';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Pool } from 'pg';
|
|
2
|
+
|
|
3
|
+
type DatasetLifecycle = 'provisioning' | 'ready' | 'archived';
|
|
4
|
+
type DatasetRepresentation = 'legacy_payload' | 'typed_table';
|
|
5
|
+
type DatasetClassification = 'L1_PUBLIC' | 'L2_INTERNAL' | 'L3_CONFIDENTIAL' | 'L4_REGULATED';
|
|
6
|
+
interface LakeDataset {
|
|
7
|
+
datasetId: string;
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
datasetKey: string;
|
|
10
|
+
ownerProduct: string;
|
|
11
|
+
sourceProduct: string;
|
|
12
|
+
metadataSchema: string;
|
|
13
|
+
dataPath: string;
|
|
14
|
+
representation: DatasetRepresentation;
|
|
15
|
+
typedTable: string | null;
|
|
16
|
+
rowProductColumn: string | null;
|
|
17
|
+
schemaVersion: number;
|
|
18
|
+
classification: DatasetClassification;
|
|
19
|
+
lifecycle: DatasetLifecycle;
|
|
20
|
+
lastCommittedVersion: number;
|
|
21
|
+
}
|
|
22
|
+
interface RegisterLakeDatasetInput extends Omit<LakeDataset, 'lifecycle' | 'lastCommittedVersion'> {
|
|
23
|
+
lifecycle?: DatasetLifecycle;
|
|
24
|
+
lastCommittedVersion?: number;
|
|
25
|
+
}
|
|
26
|
+
declare function validateLakeDatasetIdentity(dataset: Pick<LakeDataset, 'datasetId' | 'workspaceId' | 'datasetKey' | 'ownerProduct' | 'sourceProduct' | 'metadataSchema' | 'dataPath' | 'typedTable' | 'rowProductColumn' | 'representation'>): void;
|
|
27
|
+
declare class LakeDatasetRegistry {
|
|
28
|
+
private readonly db;
|
|
29
|
+
private readonly approvedView;
|
|
30
|
+
constructor(db: Pool, approvedView?: 'shared_lake_timecampus_approved' | null);
|
|
31
|
+
private approvedSource;
|
|
32
|
+
private approvalPredicate;
|
|
33
|
+
private approvalCheck;
|
|
34
|
+
getApprovedById(workspaceId: string, productId: string, datasetId: string): Promise<LakeDataset | null>;
|
|
35
|
+
getApprovedByKey(workspaceId: string, productId: string, datasetKey: string): Promise<LakeDataset | null>;
|
|
36
|
+
listApproved(workspaceId: string, productId: string, limit?: number): Promise<LakeDataset[]>;
|
|
37
|
+
registerLegacy(input: RegisterLakeDatasetInput, actorId: string): Promise<void>;
|
|
38
|
+
registerTyped(input: RegisterLakeDatasetInput, actorId: string): Promise<void>;
|
|
39
|
+
grantConsumer(datasetId: string, productId: string, actorId: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface LakeReadExecutor {
|
|
43
|
+
queryReadOnly(dataset: LakeDataset, sql: string, parameters: readonly (string | number)[]): Promise<Record<string, unknown>[]>;
|
|
44
|
+
}
|
|
45
|
+
interface LakeReadPage {
|
|
46
|
+
datasetId: string;
|
|
47
|
+
schemaVersion: number;
|
|
48
|
+
lastCommittedVersion: number;
|
|
49
|
+
rows: Record<string, unknown>[];
|
|
50
|
+
}
|
|
51
|
+
declare class AuthorizedLakeReader {
|
|
52
|
+
private readonly registry;
|
|
53
|
+
private readonly executor;
|
|
54
|
+
private readonly productId;
|
|
55
|
+
constructor(registry: LakeDatasetRegistry, executor: LakeReadExecutor, productId: string);
|
|
56
|
+
readRows(workspaceId: string, datasetId: string, limit?: number, offset?: number): Promise<LakeReadPage | null>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { AuthorizedLakeReader, type DatasetClassification, type DatasetLifecycle, type DatasetRepresentation, type LakeDataset, LakeDatasetRegistry, type LakeReadExecutor, type LakeReadPage, type RegisterLakeDatasetInput, validateLakeDatasetIdentity };
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { __name } from '../chunk-XE4OXN2W.js';
|
|
2
|
+
|
|
3
|
+
// src/lake/dataset-registry.ts
|
|
4
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5
|
+
var PRODUCT_RE = /^[a-z][a-z0-9-]{0,63}$/;
|
|
6
|
+
var KEY_RE = /^[^\x00-\x1f\x7f]{1,100}$/;
|
|
7
|
+
var TABLE_RE = /^[a-z][a-z0-9_]{0,62}$/;
|
|
8
|
+
function validateLakeDatasetIdentity(dataset) {
|
|
9
|
+
if (!UUID_RE.test(dataset.datasetId) || !UUID_RE.test(dataset.workspaceId)) throw new Error("Invalid dataset identity");
|
|
10
|
+
if (!KEY_RE.test(dataset.datasetKey)) throw new Error("Invalid dataset key");
|
|
11
|
+
if (!PRODUCT_RE.test(dataset.ownerProduct) || !PRODUCT_RE.test(dataset.sourceProduct)) {
|
|
12
|
+
throw new Error("Invalid dataset product");
|
|
13
|
+
}
|
|
14
|
+
const expectedSchema = `dl_${dataset.datasetId.replaceAll("-", "_")}`;
|
|
15
|
+
if (dataset.metadataSchema !== expectedSchema) throw new Error("Dataset catalog schema does not match its ID");
|
|
16
|
+
const path = new URL(dataset.dataPath);
|
|
17
|
+
if (path.protocol !== "s3:" || !path.hostname || path.pathname !== `/datasinks/${dataset.datasetId}/`) {
|
|
18
|
+
throw new Error("Dataset S3 path does not match its ID");
|
|
19
|
+
}
|
|
20
|
+
if (dataset.representation === "typed_table") {
|
|
21
|
+
if (!dataset.typedTable || !TABLE_RE.test(dataset.typedTable)) throw new Error("Invalid typed table");
|
|
22
|
+
if (dataset.rowProductColumn !== "product_id") throw new Error("Typed shared tables must use product_id");
|
|
23
|
+
} else if (dataset.typedTable || dataset.rowProductColumn) {
|
|
24
|
+
throw new Error("Legacy payload datasets cannot declare a typed table");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
__name(validateLakeDatasetIdentity, "validateLakeDatasetIdentity");
|
|
28
|
+
function toDataset(row) {
|
|
29
|
+
const dataset = {
|
|
30
|
+
datasetId: String(row["dataset_id"]),
|
|
31
|
+
workspaceId: String(row["workspace_id"]),
|
|
32
|
+
datasetKey: String(row["dataset_key"]),
|
|
33
|
+
ownerProduct: String(row["owner_product"]),
|
|
34
|
+
sourceProduct: String(row["source_product"]),
|
|
35
|
+
metadataSchema: String(row["metadata_schema"]),
|
|
36
|
+
dataPath: String(row["data_path"]),
|
|
37
|
+
representation: row["representation"],
|
|
38
|
+
typedTable: row["typed_table"] === null ? null : String(row["typed_table"]),
|
|
39
|
+
rowProductColumn: row["row_product_column"] === null ? null : String(row["row_product_column"]),
|
|
40
|
+
schemaVersion: Number(row["schema_version"]),
|
|
41
|
+
classification: row["classification"],
|
|
42
|
+
lifecycle: row["lifecycle"],
|
|
43
|
+
lastCommittedVersion: Number(row["last_committed_version"])
|
|
44
|
+
};
|
|
45
|
+
validateLakeDatasetIdentity(dataset);
|
|
46
|
+
return dataset;
|
|
47
|
+
}
|
|
48
|
+
__name(toDataset, "toDataset");
|
|
49
|
+
var LakeDatasetRegistry = class {
|
|
50
|
+
static {
|
|
51
|
+
__name(this, "LakeDatasetRegistry");
|
|
52
|
+
}
|
|
53
|
+
db;
|
|
54
|
+
approvedView;
|
|
55
|
+
constructor(db, approvedView = null) {
|
|
56
|
+
this.db = db;
|
|
57
|
+
this.approvedView = approvedView;
|
|
58
|
+
}
|
|
59
|
+
approvedSource() {
|
|
60
|
+
return this.approvedView ? `${this.approvedView} d` : "shared_lake_datasets d JOIN shared_lake_dataset_consumers c ON c.dataset_id = d.dataset_id";
|
|
61
|
+
}
|
|
62
|
+
approvalPredicate() {
|
|
63
|
+
return this.approvedView ? "d.product_id" : "c.product_id";
|
|
64
|
+
}
|
|
65
|
+
approvalCheck() {
|
|
66
|
+
return this.approvedView ? "" : "AND c.can_read = true";
|
|
67
|
+
}
|
|
68
|
+
async getApprovedById(workspaceId, productId, datasetId) {
|
|
69
|
+
if (!UUID_RE.test(workspaceId) || !UUID_RE.test(datasetId) || !PRODUCT_RE.test(productId)) return null;
|
|
70
|
+
const result = await this.db.query(`SELECT d.* FROM ${this.approvedSource()}
|
|
71
|
+
WHERE d.workspace_id = $1::uuid AND d.dataset_id = $2::uuid
|
|
72
|
+
AND ${this.approvalPredicate()} = $3 ${this.approvalCheck()} AND d.lifecycle = 'ready'`, [
|
|
73
|
+
workspaceId,
|
|
74
|
+
datasetId,
|
|
75
|
+
productId
|
|
76
|
+
]);
|
|
77
|
+
return result.rows[0] ? toDataset(result.rows[0]) : null;
|
|
78
|
+
}
|
|
79
|
+
async getApprovedByKey(workspaceId, productId, datasetKey) {
|
|
80
|
+
if (!UUID_RE.test(workspaceId) || !PRODUCT_RE.test(productId) || !KEY_RE.test(datasetKey)) return null;
|
|
81
|
+
const result = await this.db.query(`SELECT d.* FROM ${this.approvedSource()}
|
|
82
|
+
WHERE d.workspace_id = $1::uuid AND d.dataset_key = $2
|
|
83
|
+
AND ${this.approvalPredicate()} = $3 ${this.approvalCheck()} AND d.lifecycle = 'ready'`, [
|
|
84
|
+
workspaceId,
|
|
85
|
+
datasetKey,
|
|
86
|
+
productId
|
|
87
|
+
]);
|
|
88
|
+
return result.rows[0] ? toDataset(result.rows[0]) : null;
|
|
89
|
+
}
|
|
90
|
+
async listApproved(workspaceId, productId, limit = 100) {
|
|
91
|
+
if (!UUID_RE.test(workspaceId) || !PRODUCT_RE.test(productId)) return [];
|
|
92
|
+
const result = await this.db.query(`SELECT d.* FROM ${this.approvedSource()}
|
|
93
|
+
WHERE d.workspace_id = $1::uuid AND ${this.approvalPredicate()} = $2
|
|
94
|
+
${this.approvalCheck()} AND d.lifecycle = 'ready'
|
|
95
|
+
ORDER BY d.dataset_key ASC LIMIT $3`, [
|
|
96
|
+
workspaceId,
|
|
97
|
+
productId,
|
|
98
|
+
Math.min(Math.max(limit, 1), 1e3)
|
|
99
|
+
]);
|
|
100
|
+
return result.rows.map((row) => toDataset(row));
|
|
101
|
+
}
|
|
102
|
+
/** BigConsole's legacy sink registration: stable datasetId=sinkId and same Parquet prefix. */
|
|
103
|
+
async registerLegacy(input, actorId) {
|
|
104
|
+
validateLakeDatasetIdentity(input);
|
|
105
|
+
if (input.representation !== "legacy_payload" || input.ownerProduct !== "bigconsole") {
|
|
106
|
+
throw new Error("Only BigConsole legacy sinks may use registerLegacy");
|
|
107
|
+
}
|
|
108
|
+
const client = await this.db.connect();
|
|
109
|
+
try {
|
|
110
|
+
await client.query("BEGIN");
|
|
111
|
+
const written = await client.query(`INSERT INTO shared_lake_datasets
|
|
112
|
+
(dataset_id, workspace_id, dataset_key, owner_product, source_product,
|
|
113
|
+
metadata_schema, data_path, representation, typed_table, row_product_column,
|
|
114
|
+
schema_version, classification, lifecycle, last_committed_version, created_by, updated_by)
|
|
115
|
+
VALUES ($1::uuid,$2::uuid,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$15)
|
|
116
|
+
ON CONFLICT (dataset_id) DO UPDATE SET
|
|
117
|
+
dataset_key=EXCLUDED.dataset_key, metadata_schema=EXCLUDED.metadata_schema,
|
|
118
|
+
data_path=EXCLUDED.data_path, classification=EXCLUDED.classification,
|
|
119
|
+
lifecycle=EXCLUDED.lifecycle,
|
|
120
|
+
last_committed_version=GREATEST(shared_lake_datasets.last_committed_version, EXCLUDED.last_committed_version),
|
|
121
|
+
updated_by=EXCLUDED.updated_by, updated_at=now()
|
|
122
|
+
WHERE shared_lake_datasets.workspace_id=EXCLUDED.workspace_id
|
|
123
|
+
AND shared_lake_datasets.owner_product=EXCLUDED.owner_product
|
|
124
|
+
AND shared_lake_datasets.representation='legacy_payload'
|
|
125
|
+
RETURNING dataset_id`, [
|
|
126
|
+
input.datasetId,
|
|
127
|
+
input.workspaceId,
|
|
128
|
+
input.datasetKey,
|
|
129
|
+
input.ownerProduct,
|
|
130
|
+
input.sourceProduct,
|
|
131
|
+
input.metadataSchema,
|
|
132
|
+
input.dataPath,
|
|
133
|
+
input.representation,
|
|
134
|
+
null,
|
|
135
|
+
null,
|
|
136
|
+
input.schemaVersion,
|
|
137
|
+
input.classification,
|
|
138
|
+
input.lifecycle ?? "ready",
|
|
139
|
+
input.lastCommittedVersion ?? 0,
|
|
140
|
+
actorId
|
|
141
|
+
]);
|
|
142
|
+
if (written.rowCount !== 1) throw new Error("Dataset identity conflicts with another owner or workspace");
|
|
143
|
+
await client.query(`INSERT INTO shared_lake_dataset_consumers (dataset_id, product_id, can_read, can_write, granted_by)
|
|
144
|
+
VALUES ($1::uuid, 'bigconsole', true, true, $2)
|
|
145
|
+
ON CONFLICT (dataset_id, product_id) DO NOTHING`, [
|
|
146
|
+
input.datasetId,
|
|
147
|
+
actorId
|
|
148
|
+
]);
|
|
149
|
+
await client.query("COMMIT");
|
|
150
|
+
} catch (error) {
|
|
151
|
+
await client.query("ROLLBACK");
|
|
152
|
+
throw error;
|
|
153
|
+
} finally {
|
|
154
|
+
client.release();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** Operator-only registration after the typed table and its physical grants exist. */
|
|
158
|
+
async registerTyped(input, actorId) {
|
|
159
|
+
validateLakeDatasetIdentity(input);
|
|
160
|
+
if (input.representation !== "typed_table" || !input.typedTable) throw new Error("A typed table is required");
|
|
161
|
+
const result = await this.db.query(`INSERT INTO shared_lake_datasets
|
|
162
|
+
(dataset_id, workspace_id, dataset_key, owner_product, source_product, metadata_schema,
|
|
163
|
+
data_path, representation, typed_table, row_product_column, schema_version,
|
|
164
|
+
classification, lifecycle, last_committed_version, created_by, updated_by)
|
|
165
|
+
VALUES ($1::uuid,$2::uuid,$3,$4,$5,$6,$7,'typed_table',$8,'product_id',$9,$10,$11,$12,$13,$13)
|
|
166
|
+
ON CONFLICT (dataset_id) DO UPDATE SET
|
|
167
|
+
representation='typed_table', typed_table=EXCLUDED.typed_table,
|
|
168
|
+
row_product_column='product_id', source_product=EXCLUDED.source_product,
|
|
169
|
+
schema_version=EXCLUDED.schema_version,
|
|
170
|
+
classification=EXCLUDED.classification, lifecycle=EXCLUDED.lifecycle,
|
|
171
|
+
last_committed_version=GREATEST(shared_lake_datasets.last_committed_version, EXCLUDED.last_committed_version),
|
|
172
|
+
updated_by=EXCLUDED.updated_by, updated_at=now()
|
|
173
|
+
WHERE shared_lake_datasets.workspace_id=EXCLUDED.workspace_id
|
|
174
|
+
AND shared_lake_datasets.owner_product=EXCLUDED.owner_product
|
|
175
|
+
AND shared_lake_datasets.dataset_key=EXCLUDED.dataset_key
|
|
176
|
+
AND shared_lake_datasets.metadata_schema=EXCLUDED.metadata_schema
|
|
177
|
+
AND shared_lake_datasets.data_path=EXCLUDED.data_path
|
|
178
|
+
RETURNING dataset_id`, [
|
|
179
|
+
input.datasetId,
|
|
180
|
+
input.workspaceId,
|
|
181
|
+
input.datasetKey,
|
|
182
|
+
input.ownerProduct,
|
|
183
|
+
input.sourceProduct,
|
|
184
|
+
input.metadataSchema,
|
|
185
|
+
input.dataPath,
|
|
186
|
+
input.typedTable,
|
|
187
|
+
input.schemaVersion,
|
|
188
|
+
input.classification,
|
|
189
|
+
input.lifecycle ?? "provisioning",
|
|
190
|
+
input.lastCommittedVersion ?? 0,
|
|
191
|
+
actorId
|
|
192
|
+
]);
|
|
193
|
+
if (result.rowCount !== 1) throw new Error("Typed dataset identity conflicts with existing routing");
|
|
194
|
+
}
|
|
195
|
+
/** Catalog grant is activated only after PostgreSQL and S3 grants are applied. */
|
|
196
|
+
async grantConsumer(datasetId, productId, actorId) {
|
|
197
|
+
if (!UUID_RE.test(datasetId) || !PRODUCT_RE.test(productId)) throw new Error("Invalid consumer grant");
|
|
198
|
+
const result = await this.db.query(`INSERT INTO shared_lake_dataset_consumers (dataset_id, product_id, can_read, can_write, granted_by)
|
|
199
|
+
SELECT d.dataset_id, $2, true, false, $3 FROM shared_lake_datasets d
|
|
200
|
+
WHERE d.dataset_id=$1::uuid AND d.representation='typed_table' AND d.lifecycle='ready'
|
|
201
|
+
ON CONFLICT (dataset_id, product_id) DO UPDATE SET
|
|
202
|
+
can_read=true, can_write=false, granted_by=EXCLUDED.granted_by, updated_at=now()
|
|
203
|
+
RETURNING dataset_id`, [
|
|
204
|
+
datasetId,
|
|
205
|
+
productId,
|
|
206
|
+
actorId
|
|
207
|
+
]);
|
|
208
|
+
if (result.rowCount !== 1) throw new Error("Only ready typed datasets may be shared");
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/lake/authorized-reader.ts
|
|
213
|
+
var AuthorizedLakeReader = class {
|
|
214
|
+
static {
|
|
215
|
+
__name(this, "AuthorizedLakeReader");
|
|
216
|
+
}
|
|
217
|
+
registry;
|
|
218
|
+
executor;
|
|
219
|
+
productId;
|
|
220
|
+
constructor(registry, executor, productId) {
|
|
221
|
+
this.registry = registry;
|
|
222
|
+
this.executor = executor;
|
|
223
|
+
this.productId = productId;
|
|
224
|
+
}
|
|
225
|
+
async readRows(workspaceId, datasetId, limit = 100, offset = 0) {
|
|
226
|
+
const dataset = await this.registry.getApprovedById(workspaceId, this.productId, datasetId);
|
|
227
|
+
if (!dataset) return null;
|
|
228
|
+
if (dataset.representation !== "typed_table" || !dataset.typedTable || dataset.rowProductColumn !== "product_id") {
|
|
229
|
+
throw new Error("Dataset does not have an approved typed table");
|
|
230
|
+
}
|
|
231
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 1e3 || !Number.isInteger(offset) || offset < 0 || offset > 1e4) {
|
|
232
|
+
throw new Error("Invalid lake page");
|
|
233
|
+
}
|
|
234
|
+
const rows = await this.executor.queryReadOnly(dataset, `SELECT * FROM lake.${dataset.typedTable}
|
|
235
|
+
WHERE workspace_id = ? AND (product_id = ? OR product_id IS NULL)
|
|
236
|
+
LIMIT ? OFFSET ?`, [
|
|
237
|
+
workspaceId,
|
|
238
|
+
this.productId,
|
|
239
|
+
limit,
|
|
240
|
+
offset
|
|
241
|
+
]);
|
|
242
|
+
return {
|
|
243
|
+
datasetId: dataset.datasetId,
|
|
244
|
+
schemaVersion: dataset.schemaVersion,
|
|
245
|
+
lastCommittedVersion: dataset.lastCommittedVersion,
|
|
246
|
+
rows
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export { AuthorizedLakeReader, LakeDatasetRegistry, validateLakeDatasetIdentity };
|
|
252
|
+
//# sourceMappingURL=index.js.map
|
|
253
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lake/dataset-registry.ts","../../src/lake/authorized-reader.ts"],"names":["UUID_RE","PRODUCT_RE","KEY_RE","TABLE_RE","validateLakeDatasetIdentity","dataset","test","datasetId","workspaceId","Error","datasetKey","ownerProduct","sourceProduct","expectedSchema","replaceAll","metadataSchema","path","URL","dataPath","protocol","hostname","pathname","representation","typedTable","rowProductColumn","toDataset","row","String","schemaVersion","Number","classification","lifecycle","lastCommittedVersion","LakeDatasetRegistry","db","approvedView","approvedSource","approvalPredicate","approvalCheck","getApprovedById","productId","result","query","rows","getApprovedByKey","listApproved","limit","Math","min","max","map","registerLegacy","input","actorId","client","connect","written","rowCount","error","release","registerTyped","grantConsumer","AuthorizedLakeReader","registry","executor","readRows","offset","isInteger","queryReadOnly"],"mappings":";;;AA4BA,IAAMA,OAAAA,GAAU,iEAAA;AAChB,IAAMC,UAAAA,GAAa,wBAAA;AACnB,IAAMC,MAAAA,GAAS,2BAAA;AACf,IAAMC,QAAAA,GAAW,wBAAA;AAEV,SAASC,4BACdC,OAAAA,EAYC;AAED,EAAA,IAAI,CAACL,OAAAA,CAAQM,IAAAA,CAAKD,OAAAA,CAAQE,SAAS,CAAA,IAAK,CAACP,OAAAA,CAAQM,IAAAA,CAAKD,QAAQG,WAAW,CAAA,EACvE,MAAM,IAAIC,MAAM,0BAAA,CAAA;AAClB,EAAA,IAAI,CAACP,OAAOI,IAAAA,CAAKD,OAAAA,CAAQK,UAAU,CAAA,EAAG,MAAM,IAAID,KAAAA,CAAM,qBAAA,CAAA;AACtD,EAAA,IAAI,CAACR,UAAAA,CAAWK,IAAAA,CAAKD,OAAAA,CAAQM,YAAY,CAAA,IAAK,CAACV,UAAAA,C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;AACA,IAAA,IACE,CAACoB,MAAAA,CAAOsC,SAAAA,CAAUrB,KAAAA,CAAAA,IAClBA,QAAQ,CAAA,IACRA,KAAAA,GAAQ,GAAA,IACR,CAACjB,OAAOsC,SAAAA,CAAUD,MAAAA,KAClBA,MAAAA,GAAS,CAAA,IACTA,SAAS,GAAA,EACT;AACA,MAAA,MAAM,IAAIzD,MAAM,mBAAA,CAAA;AAClB,IAAA;AACA,IAAA,MAAMkC,IAAAA,GAAO,MAAM,IAAA,CAAKqB,QAAAA,CAASI,cAC/B/D,OAAAA,EACA,CAAA,mBAAA,EAAsBA,QAAQkB,UAAU;;AAGxC,wBAAA,CAAA,EAAA;AAACf,MAAAA,WAAAA;MAAa,IAAA,CAAKgC,SAAAA;AAAWM,MAAAA,KAAAA;AAAOoB,MAAAA;AAAO,KAAA,CAAA;AAE9C,IAAA,OAAO;AACL3D,MAAAA,SAAAA,EAAWF,OAAAA,CAAQE,SAAAA;AACnBqB,MAAAA,aAAAA,EAAevB,OAAAA,CAAQuB,aAAAA;AACvBI,MAAAA,oBAAAA,EAAsB3B,OAAAA,CAAQ2B,oBAAAA;AAC9BW,MAAAA;AACF,KAAA;AACF,EAAA;AACF","file":"index.js","sourcesContent":["import type { Pool } from 'pg';\n\nexport type DatasetLifecycle = 'provisioning' | 'ready' | 'archived';\nexport type DatasetRepresentation = 'legacy_payload' | 'typed_table';\nexport type DatasetClassification = 'L1_PUBLIC' | 'L2_INTERNAL' | 'L3_CONFIDENTIAL' | 'L4_REGULATED';\n\nexport interface LakeDataset {\n datasetId: string;\n workspaceId: string;\n datasetKey: string;\n ownerProduct: string;\n sourceProduct: string;\n metadataSchema: string;\n dataPath: string;\n representation: DatasetRepresentation;\n typedTable: string | null;\n rowProductColumn: string | null;\n schemaVersion: number;\n classification: DatasetClassification;\n lifecycle: DatasetLifecycle;\n lastCommittedVersion: number;\n}\n\nexport interface RegisterLakeDatasetInput extends Omit<LakeDataset, 'lifecycle' | 'lastCommittedVersion'> {\n lifecycle?: DatasetLifecycle;\n lastCommittedVersion?: number;\n}\n\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst PRODUCT_RE = /^[a-z][a-z0-9-]{0,63}$/;\nconst KEY_RE = /^[^\\x00-\\x1f\\x7f]{1,100}$/;\nconst TABLE_RE = /^[a-z][a-z0-9_]{0,62}$/;\n\nexport function validateLakeDatasetIdentity(\n dataset: Pick<\n LakeDataset,\n | 'datasetId'\n | 'workspaceId'\n | 'datasetKey'\n | 'ownerProduct'\n | 'sourceProduct'\n | 'metadataSchema'\n | 'dataPath'\n | 'typedTable'\n | 'rowProductColumn'\n | 'representation'\n >\n): void {\n if (!UUID_RE.test(dataset.datasetId) || !UUID_RE.test(dataset.workspaceId))\n throw new Error('Invalid dataset identity');\n if (!KEY_RE.test(dataset.datasetKey)) throw new Error('Invalid dataset key');\n if (!PRODUCT_RE.test(dataset.ownerProduct) || !PRODUCT_RE.test(dataset.sourceProduct)) {\n throw new Error('Invalid dataset product');\n }\n const expectedSchema = `dl_${dataset.datasetId.replaceAll('-', '_')}`;\n if (dataset.metadataSchema !== expectedSchema) throw new Error('Dataset catalog schema does not match its ID');\n const path = new URL(dataset.dataPath);\n if (path.protocol !== 's3:' || !path.hostname || path.pathname !== `/datasinks/${dataset.datasetId}/`) {\n throw new Error('Dataset S3 path does not match its ID');\n }\n if (dataset.representation === 'typed_table') {\n if (!dataset.typedTable || !TABLE_RE.test(dataset.typedTable)) throw new Error('Invalid typed table');\n if (dataset.rowProductColumn !== 'product_id') throw new Error('Typed shared tables must use product_id');\n } else if (dataset.typedTable || dataset.rowProductColumn) {\n throw new Error('Legacy payload datasets cannot declare a typed table');\n }\n}\n\nfunction toDataset(row: Record<string, unknown>): LakeDataset {\n const dataset: LakeDataset = {\n datasetId: String(row['dataset_id']),\n workspaceId: String(row['workspace_id']),\n datasetKey: String(row['dataset_key']),\n ownerProduct: String(row['owner_product']),\n sourceProduct: String(row['source_product']),\n metadataSchema: String(row['metadata_schema']),\n dataPath: String(row['data_path']),\n representation: row['representation'] as DatasetRepresentation,\n typedTable: row['typed_table'] === null ? null : String(row['typed_table']),\n rowProductColumn: row['row_product_column'] === null ? null : String(row['row_product_column']),\n schemaVersion: Number(row['schema_version']),\n classification: row['classification'] as DatasetClassification,\n lifecycle: row['lifecycle'] as DatasetLifecycle,\n lastCommittedVersion: Number(row['last_committed_version']),\n };\n validateLakeDatasetIdentity(dataset);\n return dataset;\n}\n\n/** Registry is the authorization source. DataSinkLakeDataset remains an ingest watermark only. */\nexport class LakeDatasetRegistry {\n constructor(\n private readonly db: Pool,\n private readonly approvedView: 'shared_lake_timecampus_approved' | null = null\n ) {}\n\n private approvedSource(): string {\n return this.approvedView\n ? `${this.approvedView} d`\n : 'shared_lake_datasets d JOIN shared_lake_dataset_consumers c ON c.dataset_id = d.dataset_id';\n }\n\n private approvalPredicate(): string {\n return this.approvedView ? 'd.product_id' : 'c.product_id';\n }\n\n private approvalCheck(): string {\n return this.approvedView ? '' : 'AND c.can_read = true';\n }\n\n async getApprovedById(workspaceId: string, productId: string, datasetId: string): Promise<LakeDataset | null> {\n if (!UUID_RE.test(workspaceId) || !UUID_RE.test(datasetId) || !PRODUCT_RE.test(productId)) return null;\n const result = await this.db.query(\n `SELECT d.* FROM ${this.approvedSource()}\n WHERE d.workspace_id = $1::uuid AND d.dataset_id = $2::uuid\n AND ${this.approvalPredicate()} = $3 ${this.approvalCheck()} AND d.lifecycle = 'ready'`,\n [workspaceId, datasetId, productId]\n );\n return result.rows[0] ? toDataset(result.rows[0] as Record<string, unknown>) : null;\n }\n\n async getApprovedByKey(workspaceId: string, productId: string, datasetKey: string): Promise<LakeDataset | null> {\n if (!UUID_RE.test(workspaceId) || !PRODUCT_RE.test(productId) || !KEY_RE.test(datasetKey)) return null;\n const result = await this.db.query(\n `SELECT d.* FROM ${this.approvedSource()}\n WHERE d.workspace_id = $1::uuid AND d.dataset_key = $2\n AND ${this.approvalPredicate()} = $3 ${this.approvalCheck()} AND d.lifecycle = 'ready'`,\n [workspaceId, datasetKey, productId]\n );\n return result.rows[0] ? toDataset(result.rows[0] as Record<string, unknown>) : null;\n }\n\n async listApproved(workspaceId: string, productId: string, limit = 100): Promise<LakeDataset[]> {\n if (!UUID_RE.test(workspaceId) || !PRODUCT_RE.test(productId)) return [];\n const result = await this.db.query(\n `SELECT d.* FROM ${this.approvedSource()}\n WHERE d.workspace_id = $1::uuid AND ${this.approvalPredicate()} = $2\n ${this.approvalCheck()} AND d.lifecycle = 'ready'\n ORDER BY d.dataset_key ASC LIMIT $3`,\n [workspaceId, productId, Math.min(Math.max(limit, 1), 1000)]\n );\n return result.rows.map((row: Record<string, unknown>) => toDataset(row));\n }\n\n /** BigConsole's legacy sink registration: stable datasetId=sinkId and same Parquet prefix. */\n async registerLegacy(input: RegisterLakeDatasetInput, actorId: string): Promise<void> {\n validateLakeDatasetIdentity(input);\n if (input.representation !== 'legacy_payload' || input.ownerProduct !== 'bigconsole') {\n throw new Error('Only BigConsole legacy sinks may use registerLegacy');\n }\n const client = await this.db.connect();\n try {\n await client.query('BEGIN');\n const written = await client.query(\n `INSERT INTO shared_lake_datasets\n (dataset_id, workspace_id, dataset_key, owner_product, source_product,\n metadata_schema, data_path, representation, typed_table, row_product_column,\n schema_version, classification, lifecycle, last_committed_version, created_by, updated_by)\n VALUES ($1::uuid,$2::uuid,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$15)\n ON CONFLICT (dataset_id) DO UPDATE SET\n dataset_key=EXCLUDED.dataset_key, metadata_schema=EXCLUDED.metadata_schema,\n data_path=EXCLUDED.data_path, classification=EXCLUDED.classification,\n lifecycle=EXCLUDED.lifecycle,\n last_committed_version=GREATEST(shared_lake_datasets.last_committed_version, EXCLUDED.last_committed_version),\n updated_by=EXCLUDED.updated_by, updated_at=now()\n WHERE shared_lake_datasets.workspace_id=EXCLUDED.workspace_id\n AND shared_lake_datasets.owner_product=EXCLUDED.owner_product\n AND shared_lake_datasets.representation='legacy_payload'\n RETURNING dataset_id`,\n [\n input.datasetId,\n input.workspaceId,\n input.datasetKey,\n input.ownerProduct,\n input.sourceProduct,\n input.metadataSchema,\n input.dataPath,\n input.representation,\n null,\n null,\n input.schemaVersion,\n input.classification,\n input.lifecycle ?? 'ready',\n input.lastCommittedVersion ?? 0,\n actorId,\n ]\n );\n if (written.rowCount !== 1) throw new Error('Dataset identity conflicts with another owner or workspace');\n await client.query(\n `INSERT INTO shared_lake_dataset_consumers (dataset_id, product_id, can_read, can_write, granted_by)\n VALUES ($1::uuid, 'bigconsole', true, true, $2)\n ON CONFLICT (dataset_id, product_id) DO NOTHING`,\n [input.datasetId, actorId]\n );\n await client.query('COMMIT');\n } catch (error) {\n await client.query('ROLLBACK');\n throw error;\n } finally {\n client.release();\n }\n }\n\n /** Operator-only registration after the typed table and its physical grants exist. */\n async registerTyped(input: RegisterLakeDatasetInput, actorId: string): Promise<void> {\n validateLakeDatasetIdentity(input);\n if (input.representation !== 'typed_table' || !input.typedTable) throw new Error('A typed table is required');\n const result = await this.db.query(\n `INSERT INTO shared_lake_datasets\n (dataset_id, workspace_id, dataset_key, owner_product, source_product, metadata_schema,\n data_path, representation, typed_table, row_product_column, schema_version,\n classification, lifecycle, last_committed_version, created_by, updated_by)\n VALUES ($1::uuid,$2::uuid,$3,$4,$5,$6,$7,'typed_table',$8,'product_id',$9,$10,$11,$12,$13,$13)\n ON CONFLICT (dataset_id) DO UPDATE SET\n representation='typed_table', typed_table=EXCLUDED.typed_table,\n row_product_column='product_id', source_product=EXCLUDED.source_product,\n schema_version=EXCLUDED.schema_version,\n classification=EXCLUDED.classification, lifecycle=EXCLUDED.lifecycle,\n last_committed_version=GREATEST(shared_lake_datasets.last_committed_version, EXCLUDED.last_committed_version),\n updated_by=EXCLUDED.updated_by, updated_at=now()\n WHERE shared_lake_datasets.workspace_id=EXCLUDED.workspace_id\n AND shared_lake_datasets.owner_product=EXCLUDED.owner_product\n AND shared_lake_datasets.dataset_key=EXCLUDED.dataset_key\n AND shared_lake_datasets.metadata_schema=EXCLUDED.metadata_schema\n AND shared_lake_datasets.data_path=EXCLUDED.data_path\n RETURNING dataset_id`,\n [\n input.datasetId,\n input.workspaceId,\n input.datasetKey,\n input.ownerProduct,\n input.sourceProduct,\n input.metadataSchema,\n input.dataPath,\n input.typedTable,\n input.schemaVersion,\n input.classification,\n input.lifecycle ?? 'provisioning',\n input.lastCommittedVersion ?? 0,\n actorId,\n ]\n );\n if (result.rowCount !== 1) throw new Error('Typed dataset identity conflicts with existing routing');\n }\n\n /** Catalog grant is activated only after PostgreSQL and S3 grants are applied. */\n async grantConsumer(datasetId: string, productId: string, actorId: string): Promise<void> {\n if (!UUID_RE.test(datasetId) || !PRODUCT_RE.test(productId)) throw new Error('Invalid consumer grant');\n const result = await this.db.query(\n `INSERT INTO shared_lake_dataset_consumers (dataset_id, product_id, can_read, can_write, granted_by)\n SELECT d.dataset_id, $2, true, false, $3 FROM shared_lake_datasets d\n WHERE d.dataset_id=$1::uuid AND d.representation='typed_table' AND d.lifecycle='ready'\n ON CONFLICT (dataset_id, product_id) DO UPDATE SET\n can_read=true, can_write=false, granted_by=EXCLUDED.granted_by, updated_at=now()\n RETURNING dataset_id`,\n [datasetId, productId, actorId]\n );\n if (result.rowCount !== 1) throw new Error('Only ready typed datasets may be shared');\n }\n}\n","import type { LakeDataset, LakeDatasetRegistry } from './dataset-registry.js';\n\n/** An adapter attaches and queries exactly one approved schema atomically. */\nexport interface LakeReadExecutor {\n queryReadOnly(\n dataset: LakeDataset,\n sql: string,\n parameters: readonly (string | number)[]\n ): Promise<Record<string, unknown>[]>;\n}\n\nexport interface LakeReadPage {\n datasetId: string;\n schemaVersion: number;\n lastCommittedVersion: number;\n rows: Record<string, unknown>[];\n}\n\n/**\n * A typed dataset is safe to expose only after registry grant + workspace\n * checks. The row predicate is mandatory even when the dataset is shared.\n * `product_id IS NULL` denotes intentionally shared rows.\n */\nexport class AuthorizedLakeReader {\n constructor(\n private readonly registry: LakeDatasetRegistry,\n private readonly executor: LakeReadExecutor,\n private readonly productId: string\n ) {}\n\n async readRows(workspaceId: string, datasetId: string, limit = 100, offset = 0): Promise<LakeReadPage | null> {\n const dataset = await this.registry.getApprovedById(workspaceId, this.productId, datasetId);\n if (!dataset) return null;\n if (dataset.representation !== 'typed_table' || !dataset.typedTable || dataset.rowProductColumn !== 'product_id') {\n throw new Error('Dataset does not have an approved typed table');\n }\n if (\n !Number.isInteger(limit) ||\n limit < 1 ||\n limit > 1000 ||\n !Number.isInteger(offset) ||\n offset < 0 ||\n offset > 10000\n ) {\n throw new Error('Invalid lake page');\n }\n const rows = await this.executor.queryReadOnly(\n dataset,\n `SELECT * FROM lake.${dataset.typedTable}\n WHERE workspace_id = ? AND (product_id = ? OR product_id IS NULL)\n LIMIT ? OFFSET ?`,\n [workspaceId, this.productId, limit, offset]\n );\n return {\n datasetId: dataset.datasetId,\n schemaVersion: dataset.schemaVersion,\n lastCommittedVersion: dataset.lastCommittedVersion,\n rows,\n };\n }\n}\n"]}
|
package/dist/prisma/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { C as ContextFilterInput, a as ContextWhereCondition, D as DatabaseClient, b as DatabaseClientConfig, F as FieldExtractionOptions, c as FieldExtractionResult, I as InputJsonValue, J as JsonValue, M as ModelFieldsMap, O as OperationContext, P as PoolTuningEnv, d as PrismaJsonFilter, e as buildContextWhereClause, f as buildContextWhereConditions, g as checkDatabaseHealth, h as contextMatches, j as createContextFromSDK, k as createDatabaseClient, l as createDatabaseClientFromEnv, m as extractFieldsFromModel, n as getAllModelNames, o as getDatabaseManager, p as getDatabaseProductName, q as getDatabaseStats, r as getDatabaseVersion, s as getDb, t as getModelFields, u as hasModel, v as initializeDatabase, w as initializeDatabaseWithConfig, x as isDatabaseInitialized, y as loadGeneratedFields, z as mergeContext, A as parseContext, B as resetDatabaseManager, E as resolvePoolTuningFromEnv, G as testConnection, H as toContextJson } from '../index-
|
|
1
|
+
export { C as ContextFilterInput, a as ContextWhereCondition, D as DatabaseClient, b as DatabaseClientConfig, F as FieldExtractionOptions, c as FieldExtractionResult, I as InputJsonValue, J as JsonValue, M as ModelFieldsMap, O as OperationContext, P as PoolTuningEnv, d as PrismaJsonFilter, e as buildContextWhereClause, f as buildContextWhereConditions, g as checkDatabaseHealth, h as contextMatches, j as createContextFromSDK, k as createDatabaseClient, l as createDatabaseClientFromEnv, m as extractFieldsFromModel, n as getAllModelNames, o as getDatabaseManager, p as getDatabaseProductName, q as getDatabaseStats, r as getDatabaseVersion, s as getDb, t as getModelFields, u as hasModel, v as initializeDatabase, w as initializeDatabaseWithConfig, x as isDatabaseInitialized, y as loadGeneratedFields, z as mergeContext, A as parseContext, B as resetDatabaseManager, E as resolvePoolTuningFromEnv, G as testConnection, H as toContextJson } from '../index-Dl8EAdYu.js';
|
|
2
2
|
export { C as ConnectionState, d as DatabaseHealth, D as DatabaseReturnType, P as PrismaClientBase, c as PrismaClientConfig, a as PrismaClientConstructorOptions, b as PrismaClientWrapper, e as PrismaEvent, f as PrismaLogDefinition, g as PrismaLogEvent, h as PrismaLogLevel, i as PrismaQueryEvent, j as PrismaTransactionOptions, k as configurePrismaLogging, l as createConnectionPool, m as createPrismaAdapter, n as createPrismaClient, o as ensureServiceApplicationName, p as installAcquireRetry, q as isTransientAcquireError } from '../client-CCXpAZ2r.js';
|
|
3
|
-
export { a as WorkspaceContext, W as WorkspaceExtensionConfig, b as addWorkspaceExtension, d as defaultWorkspaceExtensionConfig, g as getWorkspaceContext, i as injectCreateFields,
|
|
3
|
+
export { C as CallerTransaction, P as PrismaQueryInternalParams, R as RawPrismaForCallerTransaction, T as TransactionContextStatement, a as WorkspaceContext, W as WorkspaceExtensionConfig, b as addWorkspaceExtension, c as buildTransactionContextStatement, d as defaultWorkspaceExtensionConfig, g as getCallerTransaction, e as getWorkspaceContext, i as injectCreateFields, f as injectWhereWorkspaceId, m as maybeSetRlsGuc, h as maybeTagConnection, r as resetCallerTransactionStateForTests, j as runOperationInCallerTransaction, k as runOperationWithRlsGuc, s as setWorkspaceContext, w as withWorkspaceContext, l as withWorkspaceContextSync } from '../workspace-extension-DiNiTLa3.js';
|
|
4
4
|
import '../prisma-extension-krXnYnrN.js';
|
|
5
5
|
import '@prisma/adapter-pg';
|
|
6
6
|
import 'pg';
|
package/dist/prisma/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { buildContextWhereClause, buildContextWhereConditions, checkDatabaseHealth, contextMatches, createContextFromSDK, createDatabaseClient, createDatabaseClientFromEnv, extractFieldsFromModel, getAllModelNames, getDatabaseManager, getDatabaseProductName, getDatabaseStats, getDatabaseVersion, getDb, getModelFields, hasModel, initializeDatabase, initializeDatabaseWithConfig, isDatabaseInitialized, loadGeneratedFields, mergeContext, parseContext, resetDatabaseManager, resolvePoolTuningFromEnv, testConnection, toContextJson } from '../chunk-
|
|
1
|
+
export { buildContextWhereClause, buildContextWhereConditions, checkDatabaseHealth, contextMatches, createContextFromSDK, createDatabaseClient, createDatabaseClientFromEnv, extractFieldsFromModel, getAllModelNames, getDatabaseManager, getDatabaseProductName, getDatabaseStats, getDatabaseVersion, getDb, getModelFields, hasModel, initializeDatabase, initializeDatabaseWithConfig, isDatabaseInitialized, loadGeneratedFields, mergeContext, parseContext, resetDatabaseManager, resolvePoolTuningFromEnv, testConnection, toContextJson } from '../chunk-EOHPDXXW.js';
|
|
2
2
|
import '../chunk-OBBCR6WY.js';
|
|
3
|
-
export { addWorkspaceExtension, defaultWorkspaceExtensionConfig, getWorkspaceContext, injectCreateFields, injectWhereWorkspaceId, maybeSetRlsGuc, maybeTagConnection, runOperationWithRlsGuc, setWorkspaceContext, withWorkspaceContext, withWorkspaceContextSync } from '../chunk-
|
|
3
|
+
export { addWorkspaceExtension, buildTransactionContextStatement, defaultWorkspaceExtensionConfig, getCallerTransaction, getWorkspaceContext, injectCreateFields, injectWhereWorkspaceId, maybeSetRlsGuc, maybeTagConnection, resetCallerTransactionStateForTests, runOperationInCallerTransaction, runOperationWithRlsGuc, setWorkspaceContext, withWorkspaceContext, withWorkspaceContextSync } from '../chunk-CYY4VIRK.js';
|
|
4
4
|
export { PrismaClientWrapper, configurePrismaLogging, createConnectionPool, createPrismaAdapter, createPrismaClient, ensureServiceApplicationName, installAcquireRetry, isTransientAcquireError } from '../chunk-L5TDUAFN.js';
|
|
5
5
|
import '../chunk-3AEU6G6V.js';
|
|
6
6
|
import '../chunk-MLBNB5DB.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WorkspaceSecret, I as IActor, J as JWTPayload, S as ServerDefinition, a as ServerInstance, b as ITenant, G as GraphQLContext, Y as YogaPlugin } from '../types-
|
|
2
|
-
export { A as ActorProvenance, C as ConsentContext, E as ElysiaApp, c as IContextFilterInput, d as IOperationContext, e as IOrganization, f as IProduct, g as IProject, h as ITracking, i as IWorkspace, M as ModuleGraphConfig, P as PrismaClientConstructor, R as RESTEndpoint, j as ServerConfig, k as ServerI18nConfig, l as ServerInfo, V as VerifiedDelegationContext, m as WspaceGraphQLContext } from '../types-
|
|
1
|
+
import { W as WorkspaceSecret, I as IActor, J as JWTPayload, S as ServerDefinition, a as ServerInstance, b as ITenant, G as GraphQLContext, Y as YogaPlugin } from '../types-C-6m9NoG.js';
|
|
2
|
+
export { A as ActorProvenance, C as ConsentContext, E as ElysiaApp, c as IContextFilterInput, d as IOperationContext, e as IOrganization, f as IProduct, g as IProject, h as ITracking, i as IWorkspace, M as ModuleGraphConfig, P as PrismaClientConstructor, R as RESTEndpoint, j as ServerConfig, k as ServerI18nConfig, l as ServerInfo, V as VerifiedDelegationContext, m as WspaceGraphQLContext } from '../types-C-6m9NoG.js';
|
|
3
3
|
import * as jose from 'jose';
|
|
4
4
|
import { VerifyOptions } from 'jsonwebtoken';
|
|
5
5
|
import { I as I18n } from '../i18n-DrdPTann.js';
|
|
@@ -7,7 +7,7 @@ import { GraphQLError } from 'graphql';
|
|
|
7
7
|
export { I as I18nContext, L as LocaleCode } from '../types-C8TbSdEj.js';
|
|
8
8
|
export { P as PrismaClientBase } from '../client-CCXpAZ2r.js';
|
|
9
9
|
import 'graphql-yoga';
|
|
10
|
-
import '../workspace-extension-
|
|
10
|
+
import '../workspace-extension-DiNiTLa3.js';
|
|
11
11
|
import '@prisma/adapter-pg';
|
|
12
12
|
import 'pg';
|
|
13
13
|
|
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHumanReadableErrorPlugin, formatHttpError, normalizeGraphQLResponse, createHttpErrorResponse } from '../chunk-6GL4SLU7.js';
|
|
2
2
|
export { UserFacingGraphQLError, createHttpErrorResponse, createHumanReadableErrorPlugin, createWorkspaceGuardPlugin, formatHttpError, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, toUserFacingGraphQLError } from '../chunk-6GL4SLU7.js';
|
|
3
3
|
import { getWorkspaceQuotaRegistry } from '../chunk-WTEHAVBX.js';
|
|
4
|
-
import { setWorkspaceContext } from '../chunk-
|
|
4
|
+
import { setWorkspaceContext } from '../chunk-CYY4VIRK.js';
|
|
5
5
|
import { I18n } from '../chunk-EBDHIL7V.js';
|
|
6
6
|
import { getMetricsRegistry } from '../chunk-AWPNRV3L.js';
|
|
7
7
|
import { ContextManager } from '../chunk-RZOFS2BQ.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { PubSub } from 'graphql-yoga';
|
|
3
3
|
import { P as PrismaClientBase, a as PrismaClientConstructorOptions } from './client-CCXpAZ2r.js';
|
|
4
|
-
import { W as WorkspaceExtensionConfig } from './workspace-extension-
|
|
4
|
+
import { W as WorkspaceExtensionConfig } from './workspace-extension-DiNiTLa3.js';
|
|
5
5
|
import { I as I18nContext, L as LocaleCode } from './types-C8TbSdEj.js';
|
|
6
6
|
|
|
7
7
|
type ActorProvenance = 'direct_human' | 'delegated' | 'non_human' | 'unknown';
|
|
@@ -46,6 +46,34 @@ type RawPrismaForRlsTransaction = {
|
|
|
46
46
|
$transaction: <TResult>(fn: (tx: PrismaTxForRlsGuc) => Promise<TResult>) => Promise<TResult>;
|
|
47
47
|
};
|
|
48
48
|
declare function runOperationWithRlsGuc<TResult>(rootClient: RawPrismaForRlsTransaction, wsCtx: WorkspaceContext, model: string, operation: string, args: unknown): Promise<TResult>;
|
|
49
|
+
interface PrismaQueryInternalParams {
|
|
50
|
+
transaction?: unknown;
|
|
51
|
+
}
|
|
52
|
+
type CallerTransaction = {
|
|
53
|
+
kind: 'itx';
|
|
54
|
+
id: string;
|
|
55
|
+
descriptor: object;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'batch';
|
|
58
|
+
};
|
|
59
|
+
declare function getCallerTransaction(internalParams: PrismaQueryInternalParams | undefined): CallerTransaction | undefined;
|
|
60
|
+
interface TransactionContextStatement {
|
|
61
|
+
sql: string;
|
|
62
|
+
params: string[];
|
|
63
|
+
key: string;
|
|
64
|
+
}
|
|
65
|
+
declare function buildTransactionContextStatement(wsCtx: WorkspaceContext, config: Pick<Required<WorkspaceExtensionConfig>, 'enableRlsGucTagging' | 'enableApplicationNameTagging'>): TransactionContextStatement | undefined;
|
|
66
|
+
type PendingRawStatement = PromiseLike<number> & {
|
|
67
|
+
requestTransaction?: (transaction: object) => PromiseLike<unknown>;
|
|
68
|
+
};
|
|
69
|
+
type RawPrismaForCallerTransaction = {
|
|
70
|
+
$executeRawUnsafe: (query: string, ...values: unknown[]) => PendingRawStatement;
|
|
71
|
+
};
|
|
72
|
+
declare function runOperationInCallerTransaction<TResult>(rawPrisma: RawPrismaForCallerTransaction, transaction: {
|
|
73
|
+
id: string;
|
|
74
|
+
descriptor: object;
|
|
75
|
+
}, wsCtx: WorkspaceContext, config: Pick<Required<WorkspaceExtensionConfig>, 'enableRlsGucTagging' | 'enableApplicationNameTagging'>, run: () => Promise<TResult>): Promise<TResult>;
|
|
76
|
+
declare function resetCallerTransactionStateForTests(): void;
|
|
49
77
|
declare function addWorkspaceExtension<T>(baseClient: T, config?: WorkspaceExtensionConfig): T;
|
|
50
78
|
|
|
51
|
-
export { type WorkspaceExtensionConfig as W, type WorkspaceContext as a, addWorkspaceExtension as b,
|
|
79
|
+
export { type CallerTransaction as C, type PrismaQueryInternalParams as P, type RawPrismaForCallerTransaction as R, type TransactionContextStatement as T, type WorkspaceExtensionConfig as W, type WorkspaceContext as a, addWorkspaceExtension as b, buildTransactionContextStatement as c, defaultWorkspaceExtensionConfig as d, getWorkspaceContext as e, injectWhereWorkspaceId as f, getCallerTransaction as g, maybeTagConnection as h, injectCreateFields as i, runOperationInCallerTransaction as j, runOperationWithRlsGuc as k, withWorkspaceContextSync as l, maybeSetRlsGuc as m, resetCallerTransactionStateForTests as r, setWorkspaceContext as s, withWorkspaceContext as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/be-sdk",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1008.1",
|
|
4
4
|
"description": "Backend SDK for Burdenoff products providing unified access to notifications, RBAC, activity tracking, usage monitoring, and more",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -71,13 +71,15 @@
|
|
|
71
71
|
"LICENSE"
|
|
72
72
|
],
|
|
73
73
|
"scripts": {
|
|
74
|
+
"lake:registry:migrate": "bunx prisma migrate deploy --config prisma.lake.config.ts",
|
|
75
|
+
"lake:grant:timecampus": "bun scripts/lake-grant-timecampus.ts",
|
|
74
76
|
"deps:check": "bun scripts/deps-mode.ts check",
|
|
75
77
|
"deps:npm": "bun scripts/deps-mode.ts npm",
|
|
76
78
|
"deps:status": "bun scripts/deps-mode.ts status",
|
|
77
79
|
"deps:workspace": "bun scripts/deps-mode.ts workspace",
|
|
78
80
|
"dev": "tsx watch ./src/index.ts",
|
|
79
|
-
"build": "bash scripts/with-private-swc-cache.sh env NODE_OPTIONS=--max-old-space-size=4096 tsup src/index.ts src/init/index.ts src/logger/index.ts src/cache/index.ts src/database/index.ts src/event-queue/index.ts src/lifecycle/index.ts src/graph/index.ts src/middleware/index.ts src/observability/index.ts src/graphql/index.ts src/graphql/services/index.ts src/prisma/index.ts src/utils/index.ts src/notifications/index.ts src/tracker/index.ts src/export/index.ts src/dataloader/index.ts src/prisma/generator/index.ts src/server/index.ts src/i18n/index.ts src/instrumentation/index.ts src/rbac/index.ts src/temporal/index.ts src/client/internal-client.ts src/layer/index.ts src/gateway/index.ts src/gateway/security/index.ts src/crypto/index.ts src/feature-flags/index.ts src/telemetry/index.ts src/auth/index.ts src/captcha/index.ts src/metrics/index.ts src/platform/index.ts src/resource-caps/index.ts src/sharding/index.ts src/sharing/index.ts src/validation/index.ts src/product-alias/index.ts --format esm --dts --clean --shims && bun run pack:tgz",
|
|
80
|
-
"build:watch": "bash scripts/with-private-swc-cache.sh tsup src/index.ts src/init/index.ts src/logger/index.ts src/cache/index.ts src/database/index.ts src/event-queue/index.ts src/lifecycle/index.ts src/graph/index.ts src/middleware/index.ts src/observability/index.ts src/graphql/index.ts src/graphql/services/index.ts src/prisma/index.ts src/utils/index.ts src/notifications/index.ts src/tracker/index.ts src/export/index.ts src/dataloader/index.ts src/prisma/generator/index.ts src/server/index.ts src/i18n/index.ts src/instrumentation/index.ts src/rbac/index.ts src/temporal/index.ts src/client/internal-client.ts src/layer/index.ts src/gateway/index.ts src/gateway/security/index.ts src/crypto/index.ts src/feature-flags/index.ts src/telemetry/index.ts src/auth/index.ts src/captcha/index.ts src/metrics/index.ts src/platform/index.ts src/resource-caps/index.ts src/sharding/index.ts src/sharing/index.ts src/validation/index.ts src/product-alias/index.ts --format esm --dts --watch --shims",
|
|
81
|
+
"build": "bash scripts/with-private-swc-cache.sh env NODE_OPTIONS=--max-old-space-size=4096 tsup src/index.ts src/init/index.ts src/logger/index.ts src/cache/index.ts src/database/index.ts src/event-queue/index.ts src/lifecycle/index.ts src/graph/index.ts src/middleware/index.ts src/observability/index.ts src/graphql/index.ts src/graphql/services/index.ts src/prisma/index.ts src/utils/index.ts src/notifications/index.ts src/tracker/index.ts src/export/index.ts src/dataloader/index.ts src/prisma/generator/index.ts src/server/index.ts src/i18n/index.ts src/instrumentation/index.ts src/rbac/index.ts src/temporal/index.ts src/client/internal-client.ts src/layer/index.ts src/gateway/index.ts src/gateway/security/index.ts src/crypto/index.ts src/feature-flags/index.ts src/telemetry/index.ts src/auth/index.ts src/captcha/index.ts src/metrics/index.ts src/platform/index.ts src/resource-caps/index.ts src/sharding/index.ts src/sharing/index.ts src/validation/index.ts src/product-alias/index.ts src/lake/index.ts --format esm --dts --clean --shims && bun run pack:tgz",
|
|
82
|
+
"build:watch": "bash scripts/with-private-swc-cache.sh tsup src/index.ts src/init/index.ts src/logger/index.ts src/cache/index.ts src/database/index.ts src/event-queue/index.ts src/lifecycle/index.ts src/graph/index.ts src/middleware/index.ts src/observability/index.ts src/graphql/index.ts src/graphql/services/index.ts src/prisma/index.ts src/utils/index.ts src/notifications/index.ts src/tracker/index.ts src/export/index.ts src/dataloader/index.ts src/prisma/generator/index.ts src/server/index.ts src/i18n/index.ts src/instrumentation/index.ts src/rbac/index.ts src/temporal/index.ts src/client/internal-client.ts src/layer/index.ts src/gateway/index.ts src/gateway/security/index.ts src/crypto/index.ts src/feature-flags/index.ts src/telemetry/index.ts src/auth/index.ts src/captcha/index.ts src/metrics/index.ts src/platform/index.ts src/resource-caps/index.ts src/sharding/index.ts src/sharing/index.ts src/validation/index.ts src/product-alias/index.ts src/lake/index.ts --format esm --dts --watch --shims",
|
|
81
83
|
"typecheck": "bash scripts/build-limits.sh tsc --noEmit",
|
|
82
84
|
"lint": "eslint ./src",
|
|
83
85
|
"lint:sanity": "if [ \"${CI:-}\" = \"true\" ]; then bun run lint; else bun run lint -- --cache --cache-location .eslintcache; fi",
|
|
@@ -87,6 +89,7 @@
|
|
|
87
89
|
"test": "bun test 2>/dev/null || echo 'No tests found or tests passed'",
|
|
88
90
|
"test:watch": "bun test --watch",
|
|
89
91
|
"test:coverage": "bun test --coverage",
|
|
92
|
+
"test:live-pg": "bunx prisma generate --schema tests/live-pg/rls-transactions/schema.prisma && bun test tests/live-pg",
|
|
90
93
|
"test:ci": "if ls src/**/*.test.ts 1>/dev/null 2>&1; then bun test; else echo 'No test files found, skipping'; fi",
|
|
91
94
|
"audit": "bun audit",
|
|
92
95
|
"sanity": "bash scripts/build-limits.sh --gate bash -c 'bun run format:check && bun run lint:sanity && bun run typecheck && bun run build && bun run test:ci && bun run audit'",
|
|
@@ -234,6 +237,7 @@
|
|
|
234
237
|
"access": "public"
|
|
235
238
|
},
|
|
236
239
|
"overrides": {
|
|
240
|
+
"@graphql-tools/utils": "12.0.3",
|
|
237
241
|
"hono": "4.13.12",
|
|
238
242
|
"valibot": "1.5.0",
|
|
239
243
|
"protobufjs": "7.6.6",
|