weave-typescript 0.38.0 → 0.39.0

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.
@@ -1392,7 +1392,14 @@ exports.RetrievedThread = {
1392
1392
  },
1393
1393
  };
1394
1394
  function createBaseDocumentSearchFilters() {
1395
- return { tags: [], restrictedTags: [], scopes: [], uploadedAfter: undefined, uploadedBefore: undefined };
1395
+ return {
1396
+ tags: [],
1397
+ restrictedTags: [],
1398
+ scopes: [],
1399
+ uploadedAfter: undefined,
1400
+ uploadedBefore: undefined,
1401
+ restrictedGroupIds: [],
1402
+ };
1396
1403
  }
1397
1404
  exports.DocumentSearchFilters = {
1398
1405
  encode(message, writer = new wire_1.BinaryWriter()) {
@@ -1413,6 +1420,9 @@ exports.DocumentSearchFilters = {
1413
1420
  if (message.uploadedBefore !== undefined) {
1414
1421
  timestamp_pb_1.Timestamp.encode(toTimestamp(message.uploadedBefore), writer.uint32(42).fork()).join();
1415
1422
  }
1423
+ for (const v of message.restrictedGroupIds) {
1424
+ writer.uint32(50).string(v);
1425
+ }
1416
1426
  return writer;
1417
1427
  },
1418
1428
  decode(input, length) {
@@ -1464,6 +1474,13 @@ exports.DocumentSearchFilters = {
1464
1474
  message.uploadedBefore = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1465
1475
  continue;
1466
1476
  }
1477
+ case 6: {
1478
+ if (tag !== 50) {
1479
+ break;
1480
+ }
1481
+ message.restrictedGroupIds.push(reader.string());
1482
+ continue;
1483
+ }
1467
1484
  }
1468
1485
  if ((tag & 7) === 4 || tag === 0) {
1469
1486
  break;
@@ -1491,10 +1508,15 @@ exports.DocumentSearchFilters = {
1491
1508
  : isSet(object.uploaded_before)
1492
1509
  ? fromJsonTimestamp(object.uploaded_before)
1493
1510
  : undefined,
1511
+ restrictedGroupIds: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.restrictedGroupIds)
1512
+ ? object.restrictedGroupIds.map((e) => globalThis.String(e))
1513
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.restricted_group_ids)
1514
+ ? object.restricted_group_ids.map((e) => globalThis.String(e))
1515
+ : [],
1494
1516
  };
1495
1517
  },
1496
1518
  toJSON(message) {
1497
- var _a, _b, _c;
1519
+ var _a, _b, _c, _d;
1498
1520
  const obj = {};
1499
1521
  if ((_a = message.tags) === null || _a === void 0 ? void 0 : _a.length) {
1500
1522
  obj.tags = message.tags;
@@ -1511,20 +1533,24 @@ exports.DocumentSearchFilters = {
1511
1533
  if (message.uploadedBefore !== undefined) {
1512
1534
  obj.uploadedBefore = message.uploadedBefore.toISOString();
1513
1535
  }
1536
+ if ((_d = message.restrictedGroupIds) === null || _d === void 0 ? void 0 : _d.length) {
1537
+ obj.restrictedGroupIds = message.restrictedGroupIds;
1538
+ }
1514
1539
  return obj;
1515
1540
  },
1516
1541
  create(base) {
1517
1542
  return exports.DocumentSearchFilters.fromPartial(base !== null && base !== void 0 ? base : {});
1518
1543
  },
1519
1544
  fromPartial(object) {
1520
- var _a, _b, _c;
1521
- var _d, _e;
1545
+ var _a, _b, _c, _d;
1546
+ var _e, _f;
1522
1547
  const message = createBaseDocumentSearchFilters();
1523
1548
  message.tags = ((_a = object.tags) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
1524
1549
  message.restrictedTags = ((_b = object.restrictedTags) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
1525
1550
  message.scopes = ((_c = object.scopes) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
1526
- message.uploadedAfter = (_d = object.uploadedAfter) !== null && _d !== void 0 ? _d : undefined;
1527
- message.uploadedBefore = (_e = object.uploadedBefore) !== null && _e !== void 0 ? _e : undefined;
1551
+ message.uploadedAfter = (_e = object.uploadedAfter) !== null && _e !== void 0 ? _e : undefined;
1552
+ message.uploadedBefore = (_f = object.uploadedBefore) !== null && _f !== void 0 ? _f : undefined;
1553
+ message.restrictedGroupIds = ((_d = object.restrictedGroupIds) === null || _d === void 0 ? void 0 : _d.map((e) => e)) || [];
1528
1554
  return message;
1529
1555
  },
1530
1556
  };
@@ -1664,6 +1690,7 @@ function createBaseRetrievedDocument() {
1664
1690
  matchedThreadCount: 0,
1665
1691
  snippets: [],
1666
1692
  uploadedAt: undefined,
1693
+ restrictedGroups: [],
1667
1694
  };
1668
1695
  }
1669
1696
  exports.RetrievedDocument = {
@@ -1698,6 +1725,9 @@ exports.RetrievedDocument = {
1698
1725
  if (message.uploadedAt !== undefined) {
1699
1726
  timestamp_pb_1.Timestamp.encode(toTimestamp(message.uploadedAt), writer.uint32(82).fork()).join();
1700
1727
  }
1728
+ for (const v of message.restrictedGroups) {
1729
+ ingestion_pb_1.RestrictedGroup.encode(v, writer.uint32(90).fork()).join();
1730
+ }
1701
1731
  return writer;
1702
1732
  },
1703
1733
  decode(input, length) {
@@ -1777,6 +1807,13 @@ exports.RetrievedDocument = {
1777
1807
  message.uploadedAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1778
1808
  continue;
1779
1809
  }
1810
+ case 11: {
1811
+ if (tag !== 90) {
1812
+ break;
1813
+ }
1814
+ message.restrictedGroups.push(ingestion_pb_1.RestrictedGroup.decode(reader, reader.uint32()));
1815
+ continue;
1816
+ }
1780
1817
  }
1781
1818
  if ((tag & 7) === 4 || tag === 0) {
1782
1819
  break;
@@ -1823,10 +1860,15 @@ exports.RetrievedDocument = {
1823
1860
  : isSet(object.uploaded_at)
1824
1861
  ? fromJsonTimestamp(object.uploaded_at)
1825
1862
  : undefined,
1863
+ restrictedGroups: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.restrictedGroups)
1864
+ ? object.restrictedGroups.map((e) => ingestion_pb_1.RestrictedGroup.fromJSON(e))
1865
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.restricted_groups)
1866
+ ? object.restricted_groups.map((e) => ingestion_pb_1.RestrictedGroup.fromJSON(e))
1867
+ : [],
1826
1868
  };
1827
1869
  },
1828
1870
  toJSON(message) {
1829
- var _a, _b, _c;
1871
+ var _a, _b, _c, _d;
1830
1872
  const obj = {};
1831
1873
  if (message.documentId !== "") {
1832
1874
  obj.documentId = message.documentId;
@@ -1858,25 +1900,29 @@ exports.RetrievedDocument = {
1858
1900
  if (message.uploadedAt !== undefined) {
1859
1901
  obj.uploadedAt = message.uploadedAt.toISOString();
1860
1902
  }
1903
+ if ((_d = message.restrictedGroups) === null || _d === void 0 ? void 0 : _d.length) {
1904
+ obj.restrictedGroups = message.restrictedGroups.map((e) => ingestion_pb_1.RestrictedGroup.toJSON(e));
1905
+ }
1861
1906
  return obj;
1862
1907
  },
1863
1908
  create(base) {
1864
1909
  return exports.RetrievedDocument.fromPartial(base !== null && base !== void 0 ? base : {});
1865
1910
  },
1866
1911
  fromPartial(object) {
1867
- var _a, _b, _c;
1868
- var _d, _e, _f, _g, _h, _j, _k;
1912
+ var _a, _b, _c, _d;
1913
+ var _e, _f, _g, _h, _j, _k, _l;
1869
1914
  const message = createBaseRetrievedDocument();
1870
- message.documentId = (_d = object.documentId) !== null && _d !== void 0 ? _d : "";
1871
- message.documentName = (_e = object.documentName) !== null && _e !== void 0 ? _e : "";
1872
- message.mimeType = (_f = object.mimeType) !== null && _f !== void 0 ? _f : "";
1873
- message.scope = (_g = object.scope) !== null && _g !== void 0 ? _g : 0;
1915
+ message.documentId = (_e = object.documentId) !== null && _e !== void 0 ? _e : "";
1916
+ message.documentName = (_f = object.documentName) !== null && _f !== void 0 ? _f : "";
1917
+ message.mimeType = (_g = object.mimeType) !== null && _g !== void 0 ? _g : "";
1918
+ message.scope = (_h = object.scope) !== null && _h !== void 0 ? _h : 0;
1874
1919
  message.tags = ((_a = object.tags) === null || _a === void 0 ? void 0 : _a.map((e) => ingestion_pb_1.DocumentTag.fromPartial(e))) || [];
1875
1920
  message.sensitivityTags = ((_b = object.sensitivityTags) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
1876
- message.score = (_h = object.score) !== null && _h !== void 0 ? _h : 0;
1877
- message.matchedThreadCount = (_j = object.matchedThreadCount) !== null && _j !== void 0 ? _j : 0;
1921
+ message.score = (_j = object.score) !== null && _j !== void 0 ? _j : 0;
1922
+ message.matchedThreadCount = (_k = object.matchedThreadCount) !== null && _k !== void 0 ? _k : 0;
1878
1923
  message.snippets = ((_c = object.snippets) === null || _c === void 0 ? void 0 : _c.map((e) => exports.DocumentSearchSnippet.fromPartial(e))) || [];
1879
- message.uploadedAt = (_k = object.uploadedAt) !== null && _k !== void 0 ? _k : undefined;
1924
+ message.uploadedAt = (_l = object.uploadedAt) !== null && _l !== void 0 ? _l : undefined;
1925
+ message.restrictedGroups = ((_d = object.restrictedGroups) === null || _d === void 0 ? void 0 : _d.map((e) => ingestion_pb_1.RestrictedGroup.fromPartial(e))) || [];
1880
1926
  return message;
1881
1927
  },
1882
1928
  };
@@ -180,7 +180,7 @@ export interface ListConceptClustersByParentAndRealmRow {
180
180
  updatedAt: Date;
181
181
  }
182
182
  export declare function listConceptClustersByParentAndRealm(client: Client, args: ListConceptClustersByParentAndRealmArgs): Promise<ListConceptClustersByParentAndRealmRow[]>;
183
- export declare const listApprovedThreadsForConsolidationQuery = "-- name: ListApprovedThreadsForConsolidation :many\nSELECT\n t.id,\n t.organization_id,\n t.document_id,\n t.ingestion_run_id,\n t.text,\n t.knowledge_type,\n t.embedding::text AS embedding_text,\n t.approved_at,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN 'KNOWLEDGE_REALM_KIND_ORG'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN 'KNOWLEDGE_REALM_KIND_TAG'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN 'KNOWLEDGE_REALM_KIND_USER'::text\n END AS realm_kind,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN ''::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN COALESCE(d.sensitivity_tags[1], ''::text)\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN d.uploaded_by_user_id::text\n END AS realm_key\nFROM weave.threads t\nJOIN weave.documents d ON d.id = t.document_id\nWHERE t.organization_id = $1\n AND t.retrieval_status = 'THREAD_RETRIEVAL_STATUS_APPROVED'\n AND t.embedding IS NOT NULL\nORDER BY t.approved_at DESC, t.id ASC\nLIMIT $3 OFFSET $2";
183
+ export declare const listApprovedThreadsForConsolidationQuery = "-- name: ListApprovedThreadsForConsolidation :many\nSELECT\n t.id,\n t.organization_id,\n t.document_id,\n t.ingestion_run_id,\n t.text,\n t.knowledge_type,\n t.embedding::text AS embedding_text,\n t.approved_at,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN 'KNOWLEDGE_REALM_KIND_ORG'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN 'KNOWLEDGE_REALM_KIND_RESTRICTED_GROUP'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN 'KNOWLEDGE_REALM_KIND_USER'::text\n END AS realm_kind,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN ''::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN drg.restricted_group_id::text\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN d.uploaded_by_user_id::text\n END AS realm_key\nFROM weave.threads t\nJOIN weave.documents d ON d.id = t.document_id\nLEFT JOIN weave.document_restricted_groups drg\n ON drg.organization_id = d.organization_id\n AND drg.document_id = d.id\n AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\nWHERE t.organization_id = $1\n AND t.retrieval_status = 'THREAD_RETRIEVAL_STATUS_APPROVED'\n AND t.embedding IS NOT NULL\n AND (d.scope <> 'DOCUMENT_SCOPE_RESTRICTED' OR drg.restricted_group_id IS NOT NULL)\nORDER BY t.approved_at DESC, t.id ASC\nLIMIT $3 OFFSET $2";
184
184
  export interface ListApprovedThreadsForConsolidationArgs {
185
185
  organizationId: string;
186
186
  pageOffset: string;
@@ -199,7 +199,7 @@ export interface ListApprovedThreadsForConsolidationRow {
199
199
  realmKey: string | null;
200
200
  }
201
201
  export declare function listApprovedThreadsForConsolidation(client: Client, args: ListApprovedThreadsForConsolidationArgs): Promise<ListApprovedThreadsForConsolidationRow[]>;
202
- export declare const assignThreadsToClusterQuery = "-- name: AssignThreadsToCluster :execrows\nUPDATE weave.threads AS t\nSET cluster_id = cc.id\nFROM weave.concept_clusters cc,\n weave.documents d\nWHERE t.organization_id = $1\n AND t.id = ANY($2::uuid[])\n AND cc.organization_id = t.organization_id\n AND cc.id = $3\n AND d.id = t.document_id\n AND (\n (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_ORG'\n AND cc.realm_key = ''\n AND d.scope = 'DOCUMENT_SCOPE_ORG')\n OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_TAG'\n AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n AND cardinality(d.sensitivity_tags) = 1\n AND cc.realm_key = d.sensitivity_tags[1])\n OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_USER'\n AND d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n AND cc.realm_key = d.uploaded_by_user_id::text)\n )";
202
+ export declare const assignThreadsToClusterQuery = "-- name: AssignThreadsToCluster :execrows\nUPDATE weave.threads AS t\nSET cluster_id = cc.id\nFROM weave.concept_clusters cc,\n weave.documents d\nWHERE t.organization_id = $1\n AND t.id = ANY($2::uuid[])\n AND cc.organization_id = t.organization_id\n AND cc.id = $3\n AND d.id = t.document_id\n AND (\n (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_ORG'\n AND cc.realm_key = ''\n AND d.scope = 'DOCUMENT_SCOPE_ORG')\n OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_RESTRICTED_GROUP'\n AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n AND EXISTS (\n SELECT 1\n FROM weave.document_restricted_groups drg\n WHERE drg.organization_id = d.organization_id\n AND drg.document_id = d.id\n AND drg.restricted_group_id::text = cc.realm_key\n ))\n OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_USER'\n AND d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n AND cc.realm_key = d.uploaded_by_user_id::text)\n )";
203
203
  export interface AssignThreadsToClusterArgs {
204
204
  organizationId: string;
205
205
  threadIds: string[];
@@ -401,7 +401,7 @@ SELECT
401
401
  WHEN d.scope = 'DOCUMENT_SCOPE_ORG'
402
402
  THEN 'KNOWLEDGE_REALM_KIND_ORG'::text
403
403
  WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'
404
- THEN 'KNOWLEDGE_REALM_KIND_TAG'::text
404
+ THEN 'KNOWLEDGE_REALM_KIND_RESTRICTED_GROUP'::text
405
405
  WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'
406
406
  THEN 'KNOWLEDGE_REALM_KIND_USER'::text
407
407
  END AS realm_kind,
@@ -409,15 +409,20 @@ SELECT
409
409
  WHEN d.scope = 'DOCUMENT_SCOPE_ORG'
410
410
  THEN ''::text
411
411
  WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'
412
- THEN COALESCE(d.sensitivity_tags[1], ''::text)
412
+ THEN drg.restricted_group_id::text
413
413
  WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'
414
414
  THEN d.uploaded_by_user_id::text
415
415
  END AS realm_key
416
416
  FROM weave.threads t
417
417
  JOIN weave.documents d ON d.id = t.document_id
418
+ LEFT JOIN weave.document_restricted_groups drg
419
+ ON drg.organization_id = d.organization_id
420
+ AND drg.document_id = d.id
421
+ AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'
418
422
  WHERE t.organization_id = $1
419
423
  AND t.retrieval_status = 'THREAD_RETRIEVAL_STATUS_APPROVED'
420
424
  AND t.embedding IS NOT NULL
425
+ AND (d.scope <> 'DOCUMENT_SCOPE_RESTRICTED' OR drg.restricted_group_id IS NOT NULL)
421
426
  ORDER BY t.approved_at DESC, t.id ASC
422
427
  LIMIT $3 OFFSET $2`;
423
428
  async function listApprovedThreadsForConsolidation(client, args) {
@@ -455,10 +460,15 @@ WHERE t.organization_id = $1
455
460
  (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_ORG'
456
461
  AND cc.realm_key = ''
457
462
  AND d.scope = 'DOCUMENT_SCOPE_ORG')
458
- OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_TAG'
463
+ OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_RESTRICTED_GROUP'
459
464
  AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'
460
- AND cardinality(d.sensitivity_tags) = 1
461
- AND cc.realm_key = d.sensitivity_tags[1])
465
+ AND EXISTS (
466
+ SELECT 1
467
+ FROM weave.document_restricted_groups drg
468
+ WHERE drg.organization_id = d.organization_id
469
+ AND drg.document_id = d.id
470
+ AND drg.restricted_group_id::text = cc.realm_key
471
+ ))
462
472
  OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_USER'
463
473
  AND d.scope = 'DOCUMENT_SCOPE_PRIVATE'
464
474
  AND cc.realm_key = d.uploaded_by_user_id::text)
@@ -2,10 +2,9 @@ import { QueryArrayConfig, QueryArrayResult } from "pg";
2
2
  interface Client {
3
3
  query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
4
4
  }
5
- export declare const setDocumentSecurityQuery = "-- name: SetDocumentSecurity :one\nUPDATE weave.documents\nSET\n scope = $1,\n sensitivity_tags = $2,\n updated_at = now()\nWHERE organization_id = $3\n AND id = $4\nRETURNING\n id,\n organization_id,\n filename,\n mime_type,\n parser_name,\n fingerprint,\n storage_ref,\n status,\n scope,\n sensitivity_tags,\n uploaded_by_user_id,\n uploaded_at,\n updated_at,\n page_count,\n char_count,\n metadata";
5
+ export declare const setDocumentSecurityQuery = "-- name: SetDocumentSecurity :one\nUPDATE weave.documents\nSET\n scope = $1,\n updated_at = now()\nWHERE organization_id = $2\n AND id = $3\nRETURNING\n id,\n organization_id,\n filename,\n mime_type,\n parser_name,\n fingerprint,\n storage_ref,\n status,\n scope,\n uploaded_by_user_id,\n uploaded_at,\n updated_at,\n page_count,\n char_count,\n metadata";
6
6
  export interface SetDocumentSecurityArgs {
7
7
  scope: string;
8
- sensitivityTags: string[];
9
8
  organizationId: string;
10
9
  documentId: string;
11
10
  }
@@ -19,7 +18,6 @@ export interface SetDocumentSecurityRow {
19
18
  storageRef: string;
20
19
  status: string;
21
20
  scope: string;
22
- sensitivityTags: string[];
23
21
  uploadedByUserId: string;
24
22
  uploadedAt: Date;
25
23
  updatedAt: Date;
@@ -28,101 +26,254 @@ export interface SetDocumentSecurityRow {
28
26
  metadata: any;
29
27
  }
30
28
  export declare function setDocumentSecurity(client: Client, args: SetDocumentSecurityArgs): Promise<SetDocumentSecurityRow | null>;
31
- export declare const upsertOrganizationSensitivityTagQuery = "-- name: UpsertOrganizationSensitivityTag :one\nINSERT INTO weave.org_sensitivity_tags (\n organization_id,\n slug,\n label,\n description,\n extraction_hint,\n active\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6\n)\nON CONFLICT (organization_id, slug) DO UPDATE\nSET\n label = EXCLUDED.label,\n description = EXCLUDED.description,\n extraction_hint = EXCLUDED.extraction_hint,\n active = EXCLUDED.active,\n updated_at = now()\nRETURNING\n organization_id,\n slug,\n label,\n description,\n extraction_hint,\n active,\n created_at,\n updated_at";
32
- export interface UpsertOrganizationSensitivityTagArgs {
29
+ export declare const listRestrictedGroupsQuery = "-- name: ListRestrictedGroups :many\nSELECT\n id,\n organization_id,\n slug,\n name,\n description,\n active,\n created_at,\n updated_at\nFROM weave.restricted_groups\nWHERE organization_id = $1\nORDER BY name ASC, slug ASC";
30
+ export interface ListRestrictedGroupsArgs {
31
+ organizationId: string;
32
+ }
33
+ export interface ListRestrictedGroupsRow {
34
+ id: string;
33
35
  organizationId: string;
34
36
  slug: string;
35
- label: string;
37
+ name: string;
36
38
  description: string;
37
- extractionHint: string;
38
39
  active: boolean;
40
+ createdAt: Date;
41
+ updatedAt: Date;
39
42
  }
40
- export interface UpsertOrganizationSensitivityTagRow {
43
+ export declare function listRestrictedGroups(client: Client, args: ListRestrictedGroupsArgs): Promise<ListRestrictedGroupsRow[]>;
44
+ export declare const getRestrictedGroupQuery = "-- name: GetRestrictedGroup :one\nSELECT\n id,\n organization_id,\n slug,\n name,\n description,\n active,\n created_at,\n updated_at\nFROM weave.restricted_groups\nWHERE organization_id = $1\n AND id = $2";
45
+ export interface GetRestrictedGroupArgs {
46
+ organizationId: string;
47
+ restrictedGroupId: string;
48
+ }
49
+ export interface GetRestrictedGroupRow {
50
+ id: string;
41
51
  organizationId: string;
42
52
  slug: string;
43
- label: string;
53
+ name: string;
44
54
  description: string;
45
- extractionHint: string;
46
55
  active: boolean;
47
56
  createdAt: Date;
48
57
  updatedAt: Date;
49
58
  }
50
- export declare function upsertOrganizationSensitivityTag(client: Client, args: UpsertOrganizationSensitivityTagArgs): Promise<UpsertOrganizationSensitivityTagRow | null>;
51
- export declare const listOrganizationSensitivityTagsQuery = "-- name: ListOrganizationSensitivityTags :many\nSELECT\n organization_id,\n slug,\n label,\n description,\n extraction_hint,\n active,\n created_at,\n updated_at\nFROM weave.org_sensitivity_tags\nWHERE organization_id = $1\nORDER BY slug ASC";
52
- export interface ListOrganizationSensitivityTagsArgs {
59
+ export declare function getRestrictedGroup(client: Client, args: GetRestrictedGroupArgs): Promise<GetRestrictedGroupRow | null>;
60
+ export declare const getRestrictedGroupBySlugQuery = "-- name: GetRestrictedGroupBySlug :one\nSELECT\n id,\n organization_id,\n slug,\n name,\n description,\n active,\n created_at,\n updated_at\nFROM weave.restricted_groups\nWHERE organization_id = $1\n AND slug = $2";
61
+ export interface GetRestrictedGroupBySlugArgs {
53
62
  organizationId: string;
63
+ slug: string;
54
64
  }
55
- export interface ListOrganizationSensitivityTagsRow {
65
+ export interface GetRestrictedGroupBySlugRow {
66
+ id: string;
56
67
  organizationId: string;
57
68
  slug: string;
58
- label: string;
69
+ name: string;
59
70
  description: string;
60
- extractionHint: string;
61
71
  active: boolean;
62
72
  createdAt: Date;
63
73
  updatedAt: Date;
64
74
  }
65
- export declare function listOrganizationSensitivityTags(client: Client, args: ListOrganizationSensitivityTagsArgs): Promise<ListOrganizationSensitivityTagsRow[]>;
66
- export declare const listActiveOrganizationSensitivityTagsQuery = "-- name: ListActiveOrganizationSensitivityTags :many\nSELECT\n organization_id,\n slug,\n label,\n description,\n extraction_hint,\n active,\n created_at,\n updated_at\nFROM weave.org_sensitivity_tags\nWHERE organization_id = $1\n AND active = TRUE\nORDER BY slug ASC";
67
- export interface ListActiveOrganizationSensitivityTagsArgs {
75
+ export declare function getRestrictedGroupBySlug(client: Client, args: GetRestrictedGroupBySlugArgs): Promise<GetRestrictedGroupBySlugRow | null>;
76
+ export declare const upsertRestrictedGroupQuery = "-- name: UpsertRestrictedGroup :one\nINSERT INTO weave.restricted_groups (\n id,\n organization_id,\n slug,\n name,\n description,\n active\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6\n)\nON CONFLICT (organization_id, slug) DO UPDATE\nSET\n name = EXCLUDED.name,\n description = EXCLUDED.description,\n active = EXCLUDED.active,\n updated_at = now()\nRETURNING\n id,\n organization_id,\n slug,\n name,\n description,\n active,\n created_at,\n updated_at";
77
+ export interface UpsertRestrictedGroupArgs {
78
+ id: string;
68
79
  organizationId: string;
80
+ slug: string;
81
+ name: string;
82
+ description: string;
83
+ active: boolean;
69
84
  }
70
- export interface ListActiveOrganizationSensitivityTagsRow {
85
+ export interface UpsertRestrictedGroupRow {
86
+ id: string;
71
87
  organizationId: string;
72
88
  slug: string;
73
- label: string;
89
+ name: string;
74
90
  description: string;
75
- extractionHint: string;
76
91
  active: boolean;
77
92
  createdAt: Date;
78
93
  updatedAt: Date;
79
94
  }
80
- export declare function listActiveOrganizationSensitivityTags(client: Client, args: ListActiveOrganizationSensitivityTagsArgs): Promise<ListActiveOrganizationSensitivityTagsRow[]>;
81
- export declare const deactivateOrganizationSensitivityTagQuery = "-- name: DeactivateOrganizationSensitivityTag :one\nUPDATE weave.org_sensitivity_tags\nSET\n active = FALSE,\n updated_at = now()\nWHERE organization_id = $1\n AND slug = $2\nRETURNING\n organization_id,\n slug,\n label,\n description,\n extraction_hint,\n active,\n created_at,\n updated_at";
82
- export interface DeactivateOrganizationSensitivityTagArgs {
83
- organizationId: string;
95
+ export declare function upsertRestrictedGroup(client: Client, args: UpsertRestrictedGroupArgs): Promise<UpsertRestrictedGroupRow | null>;
96
+ export declare const updateRestrictedGroupQuery = "-- name: UpdateRestrictedGroup :one\nUPDATE weave.restricted_groups\nSET\n slug = $1,\n name = $2,\n description = $3,\n active = $4,\n updated_at = now()\nWHERE organization_id = $5\n AND id = $6\nRETURNING\n id,\n organization_id,\n slug,\n name,\n description,\n active,\n created_at,\n updated_at";
97
+ export interface UpdateRestrictedGroupArgs {
84
98
  slug: string;
99
+ name: string;
100
+ description: string;
101
+ active: boolean;
102
+ organizationId: string;
103
+ restrictedGroupId: string;
85
104
  }
86
- export interface DeactivateOrganizationSensitivityTagRow {
105
+ export interface UpdateRestrictedGroupRow {
106
+ id: string;
87
107
  organizationId: string;
88
108
  slug: string;
89
- label: string;
109
+ name: string;
90
110
  description: string;
91
- extractionHint: string;
92
111
  active: boolean;
93
112
  createdAt: Date;
94
113
  updatedAt: Date;
95
114
  }
96
- export declare function deactivateOrganizationSensitivityTag(client: Client, args: DeactivateOrganizationSensitivityTagArgs): Promise<DeactivateOrganizationSensitivityTagRow | null>;
97
- export declare const grantUserSensitivityClearanceQuery = "-- name: GrantUserSensitivityClearance :one\nINSERT INTO weave.user_sensitivity_clearances (\n organization_id,\n user_id,\n sensitivity_tag_slug\n) VALUES (\n $1,\n $2,\n $3\n)\nON CONFLICT (organization_id, user_id, sensitivity_tag_slug) DO UPDATE\nSET\n sensitivity_tag_slug = EXCLUDED.sensitivity_tag_slug\nRETURNING\n organization_id,\n user_id,\n sensitivity_tag_slug,\n created_at";
98
- export interface GrantUserSensitivityClearanceArgs {
115
+ export declare function updateRestrictedGroup(client: Client, args: UpdateRestrictedGroupArgs): Promise<UpdateRestrictedGroupRow | null>;
116
+ export declare const deleteRestrictedGroupQuery = "-- name: DeleteRestrictedGroup :execrows\nDELETE FROM weave.restricted_groups\nWHERE organization_id = $1\n AND id = $2";
117
+ export interface DeleteRestrictedGroupArgs {
99
118
  organizationId: string;
100
- userId: string;
101
- sensitivityTagSlug: string;
119
+ restrictedGroupId: string;
102
120
  }
103
- export interface GrantUserSensitivityClearanceRow {
121
+ export declare const countRestrictedGroupDocumentsQuery = "-- name: CountRestrictedGroupDocuments :one\nSELECT COUNT(DISTINCT document_id)::int AS document_count\nFROM weave.document_restricted_groups\nWHERE organization_id = $1\n AND restricted_group_id = $2";
122
+ export interface CountRestrictedGroupDocumentsArgs {
104
123
  organizationId: string;
124
+ restrictedGroupId: string;
125
+ }
126
+ export interface CountRestrictedGroupDocumentsRow {
127
+ documentCount: number;
128
+ }
129
+ export declare function countRestrictedGroupDocuments(client: Client, args: CountRestrictedGroupDocumentsArgs): Promise<CountRestrictedGroupDocumentsRow | null>;
130
+ export declare const countRestrictedGroupUsersQuery = "-- name: CountRestrictedGroupUsers :one\nSELECT COUNT(*)::int AS user_count\nFROM weave.restricted_group_user_memberships\nWHERE organization_id = $1\n AND restricted_group_id = $2";
131
+ export interface CountRestrictedGroupUsersArgs {
132
+ organizationId: string;
133
+ restrictedGroupId: string;
134
+ }
135
+ export interface CountRestrictedGroupUsersRow {
136
+ userCount: number;
137
+ }
138
+ export declare function countRestrictedGroupUsers(client: Client, args: CountRestrictedGroupUsersArgs): Promise<CountRestrictedGroupUsersRow | null>;
139
+ export declare const countRestrictedGroupTeamsQuery = "-- name: CountRestrictedGroupTeams :one\nSELECT COUNT(*)::int AS team_count\nFROM weave.restricted_group_team_memberships\nWHERE organization_id = $1\n AND restricted_group_id = $2";
140
+ export interface CountRestrictedGroupTeamsArgs {
141
+ organizationId: string;
142
+ restrictedGroupId: string;
143
+ }
144
+ export interface CountRestrictedGroupTeamsRow {
145
+ teamCount: number;
146
+ }
147
+ export declare function countRestrictedGroupTeams(client: Client, args: CountRestrictedGroupTeamsArgs): Promise<CountRestrictedGroupTeamsRow | null>;
148
+ export declare const listRestrictedGroupUserMembershipsQuery = "-- name: ListRestrictedGroupUserMemberships :many\nSELECT\n organization_id,\n restricted_group_id,\n user_id,\n created_at\nFROM weave.restricted_group_user_memberships\nWHERE organization_id = $1\n AND restricted_group_id = $2\nORDER BY created_at ASC, user_id ASC";
149
+ export interface ListRestrictedGroupUserMembershipsArgs {
150
+ organizationId: string;
151
+ restrictedGroupId: string;
152
+ }
153
+ export interface ListRestrictedGroupUserMembershipsRow {
154
+ organizationId: string;
155
+ restrictedGroupId: string;
105
156
  userId: string;
106
- sensitivityTagSlug: string;
107
157
  createdAt: Date;
108
158
  }
109
- export declare function grantUserSensitivityClearance(client: Client, args: GrantUserSensitivityClearanceArgs): Promise<GrantUserSensitivityClearanceRow | null>;
110
- export declare const revokeUserSensitivityClearanceQuery = "-- name: RevokeUserSensitivityClearance :execrows\nDELETE FROM weave.user_sensitivity_clearances\nWHERE organization_id = $1\n AND user_id = $2\n AND sensitivity_tag_slug = $3";
111
- export interface RevokeUserSensitivityClearanceArgs {
159
+ export declare function listRestrictedGroupUserMemberships(client: Client, args: ListRestrictedGroupUserMembershipsArgs): Promise<ListRestrictedGroupUserMembershipsRow[]>;
160
+ export declare const deleteRestrictedGroupUserMembershipsQuery = "-- name: DeleteRestrictedGroupUserMemberships :execrows\nDELETE FROM weave.restricted_group_user_memberships\nWHERE organization_id = $1\n AND restricted_group_id = $2";
161
+ export interface DeleteRestrictedGroupUserMembershipsArgs {
112
162
  organizationId: string;
113
- userId: string;
114
- sensitivityTagSlug: string;
163
+ restrictedGroupId: string;
115
164
  }
116
- export declare const listUserSensitivityClearancesQuery = "-- name: ListUserSensitivityClearances :many\nSELECT\n organization_id,\n user_id,\n sensitivity_tag_slug,\n created_at\nFROM weave.user_sensitivity_clearances\nWHERE organization_id = $1\n AND user_id = $2\nORDER BY sensitivity_tag_slug ASC";
117
- export interface ListUserSensitivityClearancesArgs {
165
+ export declare const addRestrictedGroupUserMembershipQuery = "-- name: AddRestrictedGroupUserMembership :one\nINSERT INTO weave.restricted_group_user_memberships (\n organization_id,\n restricted_group_id,\n user_id\n) VALUES (\n $1,\n $2,\n $3\n)\nON CONFLICT DO NOTHING\nRETURNING organization_id, restricted_group_id, user_id, created_at";
166
+ export interface AddRestrictedGroupUserMembershipArgs {
118
167
  organizationId: string;
168
+ restrictedGroupId: string;
119
169
  userId: string;
120
170
  }
121
- export interface ListUserSensitivityClearancesRow {
171
+ export interface AddRestrictedGroupUserMembershipRow {
122
172
  organizationId: string;
173
+ restrictedGroupId: string;
123
174
  userId: string;
124
- sensitivityTagSlug: string;
125
175
  createdAt: Date;
126
176
  }
127
- export declare function listUserSensitivityClearances(client: Client, args: ListUserSensitivityClearancesArgs): Promise<ListUserSensitivityClearancesRow[]>;
177
+ export declare function addRestrictedGroupUserMembership(client: Client, args: AddRestrictedGroupUserMembershipArgs): Promise<AddRestrictedGroupUserMembershipRow | null>;
178
+ export declare const listRestrictedGroupTeamMembershipsQuery = "-- name: ListRestrictedGroupTeamMemberships :many\nSELECT\n organization_id,\n restricted_group_id,\n org_team_id,\n created_at\nFROM weave.restricted_group_team_memberships\nWHERE organization_id = $1\n AND restricted_group_id = $2\nORDER BY created_at ASC, org_team_id ASC";
179
+ export interface ListRestrictedGroupTeamMembershipsArgs {
180
+ organizationId: string;
181
+ restrictedGroupId: string;
182
+ }
183
+ export interface ListRestrictedGroupTeamMembershipsRow {
184
+ organizationId: string;
185
+ restrictedGroupId: string;
186
+ orgTeamId: string;
187
+ createdAt: Date;
188
+ }
189
+ export declare function listRestrictedGroupTeamMemberships(client: Client, args: ListRestrictedGroupTeamMembershipsArgs): Promise<ListRestrictedGroupTeamMembershipsRow[]>;
190
+ export declare const deleteRestrictedGroupTeamMembershipsQuery = "-- name: DeleteRestrictedGroupTeamMemberships :execrows\nDELETE FROM weave.restricted_group_team_memberships\nWHERE organization_id = $1\n AND restricted_group_id = $2";
191
+ export interface DeleteRestrictedGroupTeamMembershipsArgs {
192
+ organizationId: string;
193
+ restrictedGroupId: string;
194
+ }
195
+ export declare const addRestrictedGroupTeamMembershipQuery = "-- name: AddRestrictedGroupTeamMembership :one\nINSERT INTO weave.restricted_group_team_memberships (\n organization_id,\n restricted_group_id,\n org_team_id\n) VALUES (\n $1,\n $2,\n $3\n)\nON CONFLICT DO NOTHING\nRETURNING organization_id, restricted_group_id, org_team_id, created_at";
196
+ export interface AddRestrictedGroupTeamMembershipArgs {
197
+ organizationId: string;
198
+ restrictedGroupId: string;
199
+ orgTeamId: string;
200
+ }
201
+ export interface AddRestrictedGroupTeamMembershipRow {
202
+ organizationId: string;
203
+ restrictedGroupId: string;
204
+ orgTeamId: string;
205
+ createdAt: Date;
206
+ }
207
+ export declare function addRestrictedGroupTeamMembership(client: Client, args: AddRestrictedGroupTeamMembershipArgs): Promise<AddRestrictedGroupTeamMembershipRow | null>;
208
+ export declare const listDocumentRestrictedGroupsQuery = "-- name: ListDocumentRestrictedGroups :many\nSELECT\n rg.id,\n rg.organization_id,\n rg.slug,\n rg.name,\n rg.description,\n rg.active,\n rg.created_at,\n rg.updated_at\nFROM weave.document_restricted_groups drg\nJOIN weave.restricted_groups rg\n ON rg.organization_id = drg.organization_id\n AND rg.id = drg.restricted_group_id\nWHERE drg.organization_id = $1\n AND drg.document_id = $2\nORDER BY rg.name ASC, rg.slug ASC";
209
+ export interface ListDocumentRestrictedGroupsArgs {
210
+ organizationId: string;
211
+ documentId: string;
212
+ }
213
+ export interface ListDocumentRestrictedGroupsRow {
214
+ id: string;
215
+ organizationId: string;
216
+ slug: string;
217
+ name: string;
218
+ description: string;
219
+ active: boolean;
220
+ createdAt: Date;
221
+ updatedAt: Date;
222
+ }
223
+ export declare function listDocumentRestrictedGroups(client: Client, args: ListDocumentRestrictedGroupsArgs): Promise<ListDocumentRestrictedGroupsRow[]>;
224
+ export declare const listDocumentRestrictedGroupsByDocumentIDsQuery = "-- name: ListDocumentRestrictedGroupsByDocumentIDs :many\nSELECT\n drg.document_id,\n rg.id,\n rg.organization_id,\n rg.slug,\n rg.name,\n rg.description,\n rg.active,\n rg.created_at,\n rg.updated_at\nFROM weave.document_restricted_groups drg\nJOIN weave.restricted_groups rg\n ON rg.organization_id = drg.organization_id\n AND rg.id = drg.restricted_group_id\nWHERE drg.organization_id = $1\n AND drg.document_id = ANY($2::uuid[])\nORDER BY drg.document_id ASC, rg.name ASC, rg.slug ASC";
225
+ export interface ListDocumentRestrictedGroupsByDocumentIDsArgs {
226
+ organizationId: string;
227
+ documentIds: string[];
228
+ }
229
+ export interface ListDocumentRestrictedGroupsByDocumentIDsRow {
230
+ documentId: string;
231
+ id: string;
232
+ organizationId: string;
233
+ slug: string;
234
+ name: string;
235
+ description: string;
236
+ active: boolean;
237
+ createdAt: Date;
238
+ updatedAt: Date;
239
+ }
240
+ export declare function listDocumentRestrictedGroupsByDocumentIDs(client: Client, args: ListDocumentRestrictedGroupsByDocumentIDsArgs): Promise<ListDocumentRestrictedGroupsByDocumentIDsRow[]>;
241
+ export declare const deleteDocumentRestrictedGroupsQuery = "-- name: DeleteDocumentRestrictedGroups :execrows\nDELETE FROM weave.document_restricted_groups\nWHERE organization_id = $1\n AND document_id = $2";
242
+ export interface DeleteDocumentRestrictedGroupsArgs {
243
+ organizationId: string;
244
+ documentId: string;
245
+ }
246
+ export declare const deleteDocumentRestrictedGroupsByGroupQuery = "-- name: DeleteDocumentRestrictedGroupsByGroup :execrows\nDELETE FROM weave.document_restricted_groups\nWHERE organization_id = $1\n AND restricted_group_id = $2";
247
+ export interface DeleteDocumentRestrictedGroupsByGroupArgs {
248
+ organizationId: string;
249
+ restrictedGroupId: string;
250
+ }
251
+ export declare const addDocumentRestrictedGroupQuery = "-- name: AddDocumentRestrictedGroup :one\nINSERT INTO weave.document_restricted_groups (\n organization_id,\n document_id,\n restricted_group_id\n) VALUES (\n $1,\n $2,\n $3\n)\nON CONFLICT DO NOTHING\nRETURNING organization_id, document_id, restricted_group_id, created_at";
252
+ export interface AddDocumentRestrictedGroupArgs {
253
+ organizationId: string;
254
+ documentId: string;
255
+ restrictedGroupId: string;
256
+ }
257
+ export interface AddDocumentRestrictedGroupRow {
258
+ organizationId: string;
259
+ documentId: string;
260
+ restrictedGroupId: string;
261
+ createdAt: Date;
262
+ }
263
+ export declare function addDocumentRestrictedGroup(client: Client, args: AddDocumentRestrictedGroupArgs): Promise<AddDocumentRestrictedGroupRow | null>;
264
+ export declare const addDocumentRestrictedGroupsForDocumentsQuery = "-- name: AddDocumentRestrictedGroupsForDocuments :execrows\nINSERT INTO weave.document_restricted_groups (\n organization_id,\n document_id,\n restricted_group_id\n)\nSELECT\n $1,\n document_id,\n restricted_group_id\nFROM unnest($2::uuid[]) AS document_id\nCROSS JOIN unnest($3::uuid[]) AS restricted_group_id\nON CONFLICT DO NOTHING";
265
+ export interface AddDocumentRestrictedGroupsForDocumentsArgs {
266
+ organizationId: string;
267
+ documentIds: string[];
268
+ restrictedGroupIds: string[];
269
+ }
270
+ export declare const listDocumentIDsByRestrictedGroupQuery = "-- name: ListDocumentIDsByRestrictedGroup :many\nSELECT DISTINCT document_id\nFROM weave.document_restricted_groups\nWHERE organization_id = $1\n AND restricted_group_id = $2\nORDER BY document_id ASC";
271
+ export interface ListDocumentIDsByRestrictedGroupArgs {
272
+ organizationId: string;
273
+ restrictedGroupId: string;
274
+ }
275
+ export interface ListDocumentIDsByRestrictedGroupRow {
276
+ documentId: string;
277
+ }
278
+ export declare function listDocumentIDsByRestrictedGroup(client: Client, args: ListDocumentIDsByRestrictedGroupArgs): Promise<ListDocumentIDsByRestrictedGroupRow[]>;
128
279
  export {};