@burdenoff/microfe-bigconsole 2026.1119.10 → 2026.1121.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/dist/bigconsole/components/explore/queryAccess/GrantsPanel.d.ts +10 -0
- package/dist/bigconsole/components/explore/queryAccess/GrantsPanel.js +470 -0
- package/dist/bigconsole/components/explore/queryAccess/QueryAccessAdmin.d.ts +5 -0
- package/dist/bigconsole/components/explore/queryAccess/QueryAccessAdmin.js +228 -0
- package/dist/bigconsole/components/explore/queryAccess/QueryAccessEntry.d.ts +5 -0
- package/dist/bigconsole/components/explore/queryAccess/QueryAccessEntry.js +39 -0
- package/dist/bigconsole/components/explore/queryAccess/RelationEditor.d.ts +11 -0
- package/dist/bigconsole/components/explore/queryAccess/RelationEditor.js +279 -0
- package/dist/bigconsole/components/explore/queryAccess/shared.d.ts +16 -0
- package/dist/bigconsole/components/explore/queryAccess/shared.js +26 -0
- package/dist/bigconsole/hooks/useQueryAccess.d.ts +50 -0
- package/dist/bigconsole/hooks/useQueryAccess.js +255 -0
- package/dist/bigconsole/pages/DataSinksPage.js +547 -542
- package/dist/bigconsole/utils/queryAccess.d.ts +169 -0
- package/dist/bigconsole/utils/queryAccess.js +345 -0
- package/dist/generated/wspace-operations.d.ts +177 -0
- package/dist/generated/wspace-operations.js +944 -78
- package/dist/generated/wspace-types.d.ts +2346 -13
- package/dist/generated/wspace-types.js +9 -7
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for the query access administration screen (BOFF-15640).
|
|
3
|
+
*
|
|
4
|
+
* The governed operator API in wspace-bigconsole-svc (BOFF-15619) is the
|
|
5
|
+
* authority on every rule below: it validates each relation and grant with the
|
|
6
|
+
* query reader's own parser and answers BAD_USER_INPUT with a precise message.
|
|
7
|
+
* These helpers mirror the same rules so the form can point at a problem
|
|
8
|
+
* before the request is sent, convert between the form drafts and the API
|
|
9
|
+
* shapes, and propose field declarations from a sample of a sink's data.
|
|
10
|
+
*/
|
|
11
|
+
/** Matches the reader's `sqlName`: lowercase SQL identifier, at most 63 characters. */
|
|
12
|
+
export declare const SQL_NAME: RegExp;
|
|
13
|
+
/** Matches the reader's path segment rule. */
|
|
14
|
+
export declare const PATH_SEGMENT: RegExp;
|
|
15
|
+
/** Matches the operator API's field id rule. */
|
|
16
|
+
export declare const FIELD_ID: RegExp;
|
|
17
|
+
/** Upper bounds shared with the operator API. */
|
|
18
|
+
export declare const QUERY_ACCESS_LIMITS: {
|
|
19
|
+
readonly fields: 128;
|
|
20
|
+
readonly pathSegments: 8;
|
|
21
|
+
readonly rowValues: 128;
|
|
22
|
+
};
|
|
23
|
+
export declare const SCALAR_TYPES: readonly ["VARCHAR", "BOOLEAN", "BIGINT", "TIMESTAMPTZ"];
|
|
24
|
+
export type BaseType = (typeof SCALAR_TYPES)[number] | 'DECIMAL';
|
|
25
|
+
export type FieldAccess = 'READ' | 'REDACT';
|
|
26
|
+
/** A field the grant does not list is omitted from the viewer's schema. */
|
|
27
|
+
export type FieldDecision = FieldAccess | 'OMIT';
|
|
28
|
+
export interface RelationField {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
path: string[];
|
|
32
|
+
type: string;
|
|
33
|
+
nullable: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface QueryRelation {
|
|
36
|
+
dataSinkId: string;
|
|
37
|
+
name: string;
|
|
38
|
+
fields: RelationField[];
|
|
39
|
+
grantCount: number;
|
|
40
|
+
valid: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface QueryGrant {
|
|
43
|
+
dataSinkId: string;
|
|
44
|
+
actorId: string;
|
|
45
|
+
actorType: string;
|
|
46
|
+
allRows: boolean;
|
|
47
|
+
rowFilter?: {
|
|
48
|
+
fieldId: string;
|
|
49
|
+
values: string[];
|
|
50
|
+
} | null;
|
|
51
|
+
fields: Array<{
|
|
52
|
+
fieldId: string;
|
|
53
|
+
access: FieldAccess;
|
|
54
|
+
}>;
|
|
55
|
+
valid: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** One editable row of the relation form. `path` is dot-separated text. */
|
|
58
|
+
export interface FieldDraft {
|
|
59
|
+
key: string;
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
path: string;
|
|
63
|
+
baseType: BaseType;
|
|
64
|
+
precision: string;
|
|
65
|
+
scale: string;
|
|
66
|
+
nullable: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface RelationDraft {
|
|
69
|
+
name: string;
|
|
70
|
+
fields: FieldDraft[];
|
|
71
|
+
}
|
|
72
|
+
export interface GrantDraft {
|
|
73
|
+
actorId: string;
|
|
74
|
+
/** `all` admits every row; `filter` admits rows whose field value is listed. */
|
|
75
|
+
rows: 'all' | 'filter';
|
|
76
|
+
filterFieldId: string;
|
|
77
|
+
/** One admitted value per line. */
|
|
78
|
+
filterValues: string;
|
|
79
|
+
decisions: Record<string, FieldDecision>;
|
|
80
|
+
}
|
|
81
|
+
/** A problem found before sending, as a message key plus English fallback and parameters. */
|
|
82
|
+
export interface DraftProblem {
|
|
83
|
+
key: string;
|
|
84
|
+
fallback: string;
|
|
85
|
+
params?: Record<string, string | number>;
|
|
86
|
+
}
|
|
87
|
+
/** A stable React key for a new form row. */
|
|
88
|
+
export declare function nextDraftKey(): string;
|
|
89
|
+
export declare function isSqlName(value: string): boolean;
|
|
90
|
+
export declare function isPathSegment(value: string): boolean;
|
|
91
|
+
/** Split a dot-separated path, keeping empty segments so they are reported, not dropped. */
|
|
92
|
+
export declare function parsePath(text: string): string[];
|
|
93
|
+
export declare function formatPath(path: readonly string[]): string;
|
|
94
|
+
export declare function composeType(draft: Pick<FieldDraft, 'baseType' | 'precision' | 'scale'>): string;
|
|
95
|
+
/** Split a stored type into the form's base type and decimal parameters. Unknown types fall back to VARCHAR. */
|
|
96
|
+
export declare function splitType(type: string): Pick<FieldDraft, 'baseType' | 'precision' | 'scale'>;
|
|
97
|
+
export declare function isValidType(type: string): boolean;
|
|
98
|
+
export declare function emptyFieldDraft(): FieldDraft;
|
|
99
|
+
export declare function fieldToDraft(field: RelationField): FieldDraft;
|
|
100
|
+
/** A draft for a registered relation, or for a new one named after the sink. */
|
|
101
|
+
export declare function relationToDraft(relation: QueryRelation | undefined, sinkKeyOrName: string): RelationDraft;
|
|
102
|
+
/** Turn free text into a lowercase SQL identifier, or an empty string when nothing usable remains. */
|
|
103
|
+
export declare function toSqlName(text: string): string;
|
|
104
|
+
export declare function suggestRelationName(sinkKeyOrName: string): string;
|
|
105
|
+
/** Check a relation draft with the operator API's rules. Returns the first problem, or null. */
|
|
106
|
+
export declare function validateRelationDraft(draft: RelationDraft): DraftProblem | null;
|
|
107
|
+
/** The `BigConsoleQueryRelationInput` for a draft that passed {@link validateRelationDraft}. */
|
|
108
|
+
export declare function relationInput(draft: RelationDraft): {
|
|
109
|
+
name: string;
|
|
110
|
+
fields: RelationField[];
|
|
111
|
+
};
|
|
112
|
+
/** Records of a sample payload: a root object is one record, a root array holds one record per object. */
|
|
113
|
+
export declare function sampleRecords(sample: unknown, max?: number): Record<string, unknown>[];
|
|
114
|
+
/**
|
|
115
|
+
* Propose field declarations from sample records. Every scalar leaf reachable
|
|
116
|
+
* through objects (not arrays) becomes a field; its type is the one every
|
|
117
|
+
* non-null sample value agrees on, else VARCHAR. JSON numbers with a fraction
|
|
118
|
+
* become VARCHAR because the reader only converts exact decimal strings and
|
|
119
|
+
* safe integers; the administrator can change the type before saving. Leaves
|
|
120
|
+
* whose path breaks the reader's rules are skipped. Proposed fields are
|
|
121
|
+
* nullable, since a sample cannot prove a value is always present.
|
|
122
|
+
*/
|
|
123
|
+
export declare function inferFieldDrafts(sample: unknown): FieldDraft[];
|
|
124
|
+
/** A grant draft for an existing grant, or a new empty one (every field omitted, all rows). */
|
|
125
|
+
export declare function grantToDraft(grant: QueryGrant | undefined, fields: readonly RelationField[]): GrantDraft;
|
|
126
|
+
/** Row filter values typed one per line; blank lines are ignored and duplicates collapse. */
|
|
127
|
+
export declare function parseFilterValues(text: string): string[];
|
|
128
|
+
export declare function validateGrantDraft(draft: GrantDraft, fields: readonly RelationField[]): DraftProblem | null;
|
|
129
|
+
/** The `BigConsoleQueryGrantInput` for a draft that passed {@link validateGrantDraft}. */
|
|
130
|
+
export declare function grantInput(draft: GrantDraft, fields: readonly RelationField[]): {
|
|
131
|
+
actorId: string;
|
|
132
|
+
rowFilter: {
|
|
133
|
+
fieldId: string;
|
|
134
|
+
values: string[];
|
|
135
|
+
} | null;
|
|
136
|
+
fields: Array<{
|
|
137
|
+
fieldId: string;
|
|
138
|
+
access: FieldAccess;
|
|
139
|
+
}>;
|
|
140
|
+
};
|
|
141
|
+
export type RelationStatus = 'unregistered' | 'registered' | 'invalid';
|
|
142
|
+
export declare function relationStatus(relation: QueryRelation | undefined): RelationStatus;
|
|
143
|
+
export interface SinkSummary {
|
|
144
|
+
id: string;
|
|
145
|
+
name: string;
|
|
146
|
+
key?: string | null;
|
|
147
|
+
}
|
|
148
|
+
export interface SinkRow {
|
|
149
|
+
sink: SinkSummary;
|
|
150
|
+
relation: QueryRelation | undefined;
|
|
151
|
+
status: RelationStatus;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Join the workspace's sinks with their relations. Registered sinks come
|
|
155
|
+
* first, then by name. A relation whose sink is not in the list (deleted, or
|
|
156
|
+
* beyond the loaded pages) is still shown, under its relation name, so it can
|
|
157
|
+
* be inspected and removed.
|
|
158
|
+
*/
|
|
159
|
+
export declare function sinkRows(sinks: readonly SinkSummary[], relations: readonly QueryRelation[]): SinkRow[];
|
|
160
|
+
/** Codes whose server message is written for the administrator and is shown as it is. */
|
|
161
|
+
export declare const VERBATIM_CODES: ReadonlySet<string>;
|
|
162
|
+
/**
|
|
163
|
+
* The service's own message for BAD_USER_INPUT, NOT_FOUND and
|
|
164
|
+
* SERVICE_UNAVAILABLE, which name the offending field or member. Other
|
|
165
|
+
* failures return null so the caller can show its localized generic message.
|
|
166
|
+
*/
|
|
167
|
+
export declare function verbatimServiceMessage(error: unknown): string | null;
|
|
168
|
+
/** The first GraphQL error code reachable from an error, if any. */
|
|
169
|
+
export declare function firstErrorCode(error: unknown): string | null;
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
// src/bigconsole/utils/queryAccess.ts
|
|
2
|
+
var e = /^[a-z_][a-z0-9_]{0,62}$/, t = /^[a-zA-Z_][a-zA-Z0-9_-]{0,79}$/, n = /^[A-Za-z0-9_-]{1,80}$/, r = /^DECIMAL\(([1-9]\d?),(0|[1-9]\d?)\)$/, i = /* @__PURE__ */ new Set([
|
|
3
|
+
"__proto__",
|
|
4
|
+
"prototype",
|
|
5
|
+
"constructor"
|
|
6
|
+
]), a = {
|
|
7
|
+
fields: 128,
|
|
8
|
+
pathSegments: 8,
|
|
9
|
+
rowValues: 128
|
|
10
|
+
}, o = [
|
|
11
|
+
"VARCHAR",
|
|
12
|
+
"BOOLEAN",
|
|
13
|
+
"BIGINT",
|
|
14
|
+
"TIMESTAMPTZ"
|
|
15
|
+
], s = 0;
|
|
16
|
+
function c() {
|
|
17
|
+
return s += 1, `field-${s}`;
|
|
18
|
+
}
|
|
19
|
+
function l(t) {
|
|
20
|
+
return e.test(t) && !i.has(t);
|
|
21
|
+
}
|
|
22
|
+
function u(e) {
|
|
23
|
+
return t.test(e) && !i.has(e);
|
|
24
|
+
}
|
|
25
|
+
function d(e) {
|
|
26
|
+
let t = e.trim();
|
|
27
|
+
return t ? t.split(".").map((e) => e.trim()) : [];
|
|
28
|
+
}
|
|
29
|
+
function f(e) {
|
|
30
|
+
return e.join(".");
|
|
31
|
+
}
|
|
32
|
+
function p(e) {
|
|
33
|
+
return e.baseType === "DECIMAL" ? `DECIMAL(${e.precision.trim()},${e.scale.trim()})` : e.baseType;
|
|
34
|
+
}
|
|
35
|
+
function m(e) {
|
|
36
|
+
let t = r.exec(e);
|
|
37
|
+
return t ? {
|
|
38
|
+
baseType: "DECIMAL",
|
|
39
|
+
precision: t[1] ?? "18",
|
|
40
|
+
scale: t[2] ?? "2"
|
|
41
|
+
} : {
|
|
42
|
+
baseType: o.find((t) => t === e) ?? "VARCHAR",
|
|
43
|
+
precision: "18",
|
|
44
|
+
scale: "2"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function h(e) {
|
|
48
|
+
if (o.includes(e)) return !0;
|
|
49
|
+
let t = r.exec(e);
|
|
50
|
+
return !!t && Number(t[1]) <= 38 && Number(t[2]) <= Number(t[1]);
|
|
51
|
+
}
|
|
52
|
+
function g() {
|
|
53
|
+
return {
|
|
54
|
+
key: c(),
|
|
55
|
+
id: "",
|
|
56
|
+
name: "",
|
|
57
|
+
path: "",
|
|
58
|
+
baseType: "VARCHAR",
|
|
59
|
+
precision: "18",
|
|
60
|
+
scale: "2",
|
|
61
|
+
nullable: !0
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function _(e) {
|
|
65
|
+
return {
|
|
66
|
+
key: c(),
|
|
67
|
+
id: e.id,
|
|
68
|
+
name: e.name,
|
|
69
|
+
path: f(e.path),
|
|
70
|
+
nullable: e.nullable,
|
|
71
|
+
...m(e.type)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function v(e, t) {
|
|
75
|
+
return e ? {
|
|
76
|
+
name: e.name,
|
|
77
|
+
fields: e.fields.map(_)
|
|
78
|
+
} : {
|
|
79
|
+
name: b(t),
|
|
80
|
+
fields: [g()]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function y(e) {
|
|
84
|
+
let t = e.trim().replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
85
|
+
return t ? (/^[0-9]/.test(t) && (t = `_${t}`), t = t.slice(0, 63), l(t) ? t : "") : "";
|
|
86
|
+
}
|
|
87
|
+
function b(e) {
|
|
88
|
+
return y(e);
|
|
89
|
+
}
|
|
90
|
+
function x(e) {
|
|
91
|
+
if (!l(e.name)) return {
|
|
92
|
+
key: "bigconsole.queryAccess.problem.relationName",
|
|
93
|
+
fallback: "The relation name must be a lowercase SQL identifier: a letter or underscore, then letters, digits or underscores, at most 63 characters."
|
|
94
|
+
};
|
|
95
|
+
if (!e.fields.length) return {
|
|
96
|
+
key: "bigconsole.queryAccess.problem.noFields",
|
|
97
|
+
fallback: "Declare at least one field."
|
|
98
|
+
};
|
|
99
|
+
if (e.fields.length > a.fields) return {
|
|
100
|
+
key: "bigconsole.queryAccess.problem.tooManyFields",
|
|
101
|
+
fallback: "A relation can declare at most {{max}} fields.",
|
|
102
|
+
params: { max: a.fields }
|
|
103
|
+
};
|
|
104
|
+
let t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
105
|
+
for (let [o, s] of e.fields.entries()) {
|
|
106
|
+
let e = o + 1;
|
|
107
|
+
if (!n.test(s.id)) return {
|
|
108
|
+
key: "bigconsole.queryAccess.problem.fieldId",
|
|
109
|
+
fallback: "Field {{row}}: the ID must be 1 to 80 letters, digits, underscores or hyphens.",
|
|
110
|
+
params: { row: e }
|
|
111
|
+
};
|
|
112
|
+
if (!l(s.name)) return {
|
|
113
|
+
key: "bigconsole.queryAccess.problem.fieldName",
|
|
114
|
+
fallback: "Field {{row}}: the name must be a lowercase SQL identifier.",
|
|
115
|
+
params: { row: e }
|
|
116
|
+
};
|
|
117
|
+
let c = d(s.path);
|
|
118
|
+
if (!c.length || c.length > a.pathSegments) return {
|
|
119
|
+
key: "bigconsole.queryAccess.problem.pathLength",
|
|
120
|
+
fallback: "Field {{row}}: the path must have 1 to {{max}} segments separated by dots.",
|
|
121
|
+
params: {
|
|
122
|
+
row: e,
|
|
123
|
+
max: a.pathSegments
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
if (!c.every(u)) return {
|
|
127
|
+
key: "bigconsole.queryAccess.problem.pathSegment",
|
|
128
|
+
fallback: "Field {{row}}: each path segment must start with a letter or underscore and use only letters, digits, underscores or hyphens.",
|
|
129
|
+
params: { row: e }
|
|
130
|
+
};
|
|
131
|
+
if (!h(p(s))) return {
|
|
132
|
+
key: "bigconsole.queryAccess.problem.type",
|
|
133
|
+
fallback: "Field {{row}}: DECIMAL needs a precision from 1 to 38 and a scale no larger than the precision.",
|
|
134
|
+
params: { row: e }
|
|
135
|
+
};
|
|
136
|
+
let m = f(c);
|
|
137
|
+
if (t.has(s.id)) return {
|
|
138
|
+
key: "bigconsole.queryAccess.problem.duplicateId",
|
|
139
|
+
fallback: "Field {{row}}: the ID {{value}} is declared twice.",
|
|
140
|
+
params: {
|
|
141
|
+
row: e,
|
|
142
|
+
value: s.id
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
if (r.has(s.name)) return {
|
|
146
|
+
key: "bigconsole.queryAccess.problem.duplicateName",
|
|
147
|
+
fallback: "Field {{row}}: the name {{value}} is declared twice.",
|
|
148
|
+
params: {
|
|
149
|
+
row: e,
|
|
150
|
+
value: s.name
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
if (i.has(m)) return {
|
|
154
|
+
key: "bigconsole.queryAccess.problem.duplicatePath",
|
|
155
|
+
fallback: "Field {{row}}: the path {{value}} is declared twice.",
|
|
156
|
+
params: {
|
|
157
|
+
row: e,
|
|
158
|
+
value: m
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
t.add(s.id), r.add(s.name), i.add(m);
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
function S(e) {
|
|
166
|
+
return {
|
|
167
|
+
name: e.name,
|
|
168
|
+
fields: e.fields.map((e) => ({
|
|
169
|
+
id: e.id,
|
|
170
|
+
name: e.name,
|
|
171
|
+
path: d(e.path),
|
|
172
|
+
type: p(e),
|
|
173
|
+
nullable: e.nullable
|
|
174
|
+
}))
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function C(e) {
|
|
178
|
+
return typeof e == "boolean" ? "BOOLEAN" : typeof e == "number" ? Number.isSafeInteger(e) ? "BIGINT" : "VARCHAR" : typeof e == "string" ? /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d{1,6})?(Z|[+-]\d\d:\d\d)$/.test(e) ? "TIMESTAMPTZ" : "VARCHAR" : null;
|
|
179
|
+
}
|
|
180
|
+
function w(e, t = 50) {
|
|
181
|
+
let n = (e) => typeof e == "object" && !!e && !Array.isArray(e);
|
|
182
|
+
return Array.isArray(e) ? e.filter(n).slice(0, t) : n(e) ? [e] : [];
|
|
183
|
+
}
|
|
184
|
+
function T(e) {
|
|
185
|
+
let t = w(e), n = /* @__PURE__ */ new Map(), r = (e, t) => {
|
|
186
|
+
if (t.length > a.pathSegments) return;
|
|
187
|
+
if (typeof e == "object" && e) {
|
|
188
|
+
if (Array.isArray(e)) return;
|
|
189
|
+
for (let [n, i] of Object.entries(e)) u(n) && r(i, [...t, n]);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (!t.length) return;
|
|
193
|
+
let i = f(t), o = n.get(i) ?? {
|
|
194
|
+
path: t,
|
|
195
|
+
types: /* @__PURE__ */ new Set()
|
|
196
|
+
}, s = e == null ? null : C(e);
|
|
197
|
+
s && o.types.add(s), n.set(i, o);
|
|
198
|
+
};
|
|
199
|
+
for (let e of t) r(e, []);
|
|
200
|
+
let i = /* @__PURE__ */ new Set(), o = [];
|
|
201
|
+
for (let { path: e, types: t } of n.values()) {
|
|
202
|
+
if (o.length >= a.fields) break;
|
|
203
|
+
let n = y(e.join("_")) || "field", r = n;
|
|
204
|
+
for (let e = 2; i.has(r); e += 1) r = `${n.slice(0, 60)}_${e}`;
|
|
205
|
+
i.add(r);
|
|
206
|
+
let [s] = [...t];
|
|
207
|
+
o.push({
|
|
208
|
+
key: c(),
|
|
209
|
+
id: `f_${r}`.slice(0, 80),
|
|
210
|
+
name: r,
|
|
211
|
+
path: f(e),
|
|
212
|
+
baseType: t.size === 1 && s ? s : "VARCHAR",
|
|
213
|
+
precision: "18",
|
|
214
|
+
scale: "2",
|
|
215
|
+
nullable: !0
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return o;
|
|
219
|
+
}
|
|
220
|
+
function E(e, t) {
|
|
221
|
+
let n = {};
|
|
222
|
+
for (let e of t) n[e.id] = "OMIT";
|
|
223
|
+
if (!e) return {
|
|
224
|
+
actorId: "",
|
|
225
|
+
rows: "all",
|
|
226
|
+
filterFieldId: t[0]?.id ?? "",
|
|
227
|
+
filterValues: "",
|
|
228
|
+
decisions: n
|
|
229
|
+
};
|
|
230
|
+
for (let t of e.fields) n[t.fieldId] = t.access;
|
|
231
|
+
let r = e.allRows ? null : e.rowFilter ?? null;
|
|
232
|
+
return {
|
|
233
|
+
actorId: e.actorId,
|
|
234
|
+
rows: r ? "filter" : "all",
|
|
235
|
+
filterFieldId: r?.fieldId ?? t[0]?.id ?? "",
|
|
236
|
+
filterValues: r ? r.values.join("\n") : "",
|
|
237
|
+
decisions: n
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function D(e) {
|
|
241
|
+
return [...new Set(e.split("\n").map((e) => e.trim()).filter((e) => e.length > 0))];
|
|
242
|
+
}
|
|
243
|
+
function O(e, t) {
|
|
244
|
+
if (!e.actorId) return {
|
|
245
|
+
key: "bigconsole.queryAccess.problem.member",
|
|
246
|
+
fallback: "Choose the workspace member to grant access to."
|
|
247
|
+
};
|
|
248
|
+
let n = new Set(t.map((e) => e.id));
|
|
249
|
+
if (!Object.entries(e.decisions).filter(([e, t]) => t !== "OMIT" && n.has(e)).length) return {
|
|
250
|
+
key: "bigconsole.queryAccess.problem.noGrantFields",
|
|
251
|
+
fallback: "Give read or redacted access to at least one field."
|
|
252
|
+
};
|
|
253
|
+
if (e.rows === "filter") {
|
|
254
|
+
let n = t.find((t) => t.id === e.filterFieldId);
|
|
255
|
+
if (!n) return {
|
|
256
|
+
key: "bigconsole.queryAccess.problem.filterField",
|
|
257
|
+
fallback: "Choose a declared field for the row filter."
|
|
258
|
+
};
|
|
259
|
+
let r = D(e.filterValues);
|
|
260
|
+
if (r.length > a.rowValues) return {
|
|
261
|
+
key: "bigconsole.queryAccess.problem.tooManyValues",
|
|
262
|
+
fallback: "A row filter can list at most {{max}} values.",
|
|
263
|
+
params: { max: a.rowValues }
|
|
264
|
+
};
|
|
265
|
+
if (n.type === "BOOLEAN" && r.some((e) => e !== "true" && e !== "false")) return {
|
|
266
|
+
key: "bigconsole.queryAccess.problem.booleanValue",
|
|
267
|
+
fallback: "Values for a BOOLEAN field must be true or false."
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
function k(e, t) {
|
|
273
|
+
let n = [];
|
|
274
|
+
for (let r of t) {
|
|
275
|
+
let t = e.decisions[r.id];
|
|
276
|
+
(t === "READ" || t === "REDACT") && n.push({
|
|
277
|
+
fieldId: r.id,
|
|
278
|
+
access: t
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
actorId: e.actorId,
|
|
283
|
+
rowFilter: e.rows === "filter" ? {
|
|
284
|
+
fieldId: e.filterFieldId,
|
|
285
|
+
values: D(e.filterValues)
|
|
286
|
+
} : null,
|
|
287
|
+
fields: n
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function A(e) {
|
|
291
|
+
return e ? e.valid ? "registered" : "invalid" : "unregistered";
|
|
292
|
+
}
|
|
293
|
+
function j(e, t) {
|
|
294
|
+
let n = new Map(t.map((e) => [e.dataSinkId, e])), r = e.map((e) => {
|
|
295
|
+
let t = n.get(e.id);
|
|
296
|
+
return {
|
|
297
|
+
sink: e,
|
|
298
|
+
relation: t,
|
|
299
|
+
status: A(t)
|
|
300
|
+
};
|
|
301
|
+
}), i = new Set(e.map((e) => e.id));
|
|
302
|
+
for (let e of t) i.has(e.dataSinkId) || r.push({
|
|
303
|
+
sink: {
|
|
304
|
+
id: e.dataSinkId,
|
|
305
|
+
name: e.name
|
|
306
|
+
},
|
|
307
|
+
relation: e,
|
|
308
|
+
status: A(e)
|
|
309
|
+
});
|
|
310
|
+
let a = (e) => +(e.status === "unregistered");
|
|
311
|
+
return r.sort((e, t) => a(e) - a(t) || e.sink.name.localeCompare(t.sink.name));
|
|
312
|
+
}
|
|
313
|
+
var M = /* @__PURE__ */ new Set([
|
|
314
|
+
"BAD_USER_INPUT",
|
|
315
|
+
"NOT_FOUND",
|
|
316
|
+
"SERVICE_UNAVAILABLE"
|
|
317
|
+
]);
|
|
318
|
+
function N(e, t = 0) {
|
|
319
|
+
if (t > 4 || typeof e != "object" || !e) return [];
|
|
320
|
+
let n = e, r = (e) => Array.isArray(e) ? e.flatMap((e) => {
|
|
321
|
+
if (typeof e != "object" || !e) return [];
|
|
322
|
+
let t = e;
|
|
323
|
+
return [{
|
|
324
|
+
code: typeof t.extensions?.code == "string" ? t.extensions.code : void 0,
|
|
325
|
+
message: typeof t.message == "string" ? t.message : void 0
|
|
326
|
+
}];
|
|
327
|
+
}) : [], i = n.extensions;
|
|
328
|
+
return [
|
|
329
|
+
...r(n.errors),
|
|
330
|
+
...r(n.graphQLErrors),
|
|
331
|
+
...i && typeof i.code == "string" ? [{
|
|
332
|
+
code: i.code,
|
|
333
|
+
message: typeof n.message == "string" ? n.message : void 0
|
|
334
|
+
}] : [],
|
|
335
|
+
...N(n.cause, t + 1)
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
function P(e) {
|
|
339
|
+
for (let t of N(e)) if (t.code && M.has(t.code) && t.message) return t.message;
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
function F(e) {
|
|
343
|
+
return N(e).find((e) => e.code)?.code ?? null;
|
|
344
|
+
}
|
|
345
|
+
export { n as FIELD_ID, t as PATH_SEGMENT, a as QUERY_ACCESS_LIMITS, o as SCALAR_TYPES, e as SQL_NAME, M as VERBATIM_CODES, p as composeType, g as emptyFieldDraft, _ as fieldToDraft, F as firstErrorCode, f as formatPath, k as grantInput, E as grantToDraft, T as inferFieldDrafts, u as isPathSegment, l as isSqlName, h as isValidType, c as nextDraftKey, D as parseFilterValues, d as parsePath, S as relationInput, A as relationStatus, v as relationToDraft, w as sampleRecords, j as sinkRows, m as splitType, b as suggestRelationName, y as toSqlName, O as validateGrantDraft, x as validateRelationDraft, P as verbatimServiceMessage };
|