@tearleads/client-sdk 0.1.212 → 0.1.214
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/client/containerContents/documentDiscovery.js +2 -2
- package/client/containerContents/documentDiscovery.js.map +1 -1
- package/client/organizations/organizationReadModels.js +3 -3
- package/client/organizations/organizationReadModels.js.map +1 -1
- package/data/persistence/documents/documentDiscoveryEvidencePersistence.d.ts +11 -2
- package/data/persistence/documents/documentDiscoveryEvidencePersistence.js +89 -77
- package/data/persistence/documents/documentDiscoveryEvidencePersistence.js.map +1 -1
- package/data/persistence/organizations/organizationPresentationDenialPersistence.js +0 -43
- package/data/persistence/organizations/organizationPresentationDenialPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelMemberLoad.d.ts +7 -2
- package/data/persistence/organizations/organizationReadModelMemberLoad.js +22 -27
- package/data/persistence/organizations/organizationReadModelMemberLoad.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelPersistence.js +38 -81
- package/data/persistence/organizations/organizationReadModelPersistence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelPurge.js +0 -38
- package/data/persistence/organizations/organizationReadModelPurge.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelRepository.js +264 -0
- package/data/persistence/organizations/organizationReadModelRepository.js.map +1 -0
- package/package.json +1 -1
- package/workflows/container-contents/documentDiscovery/documentDiscoveryEvidence.js.map +1 -1
- package/workflows/organizations/groupNames/currentOrganizationGroupNames.js +6 -2
- package/workflows/organizations/groupNames/currentOrganizationGroupNames.js.map +1 -1
- package/workflows/organizations/index.d.ts +0 -1
- package/workflows/organizations/index.js +0 -1
- package/workflows/organizations/index.js.map +1 -1
- package/workflows/organizations/policyHistory/policyHistoryAccessDenial.js +7 -4
- package/workflows/organizations/policyHistory/policyHistoryAccessDenial.js.map +1 -1
- package/workflows/organizations/readModel/dataUsageReadModel.js +2 -2
- package/workflows/organizations/readModel/dataUsageReadModel.js.map +1 -1
- package/workflows/organizations/readModel/listLocalOrganizations.js +4 -2
- package/workflows/organizations/readModel/listLocalOrganizations.js.map +1 -1
- package/workflows/organizations/readModel/localReadModelDetails.js +8 -9
- package/workflows/organizations/readModel/localReadModelDetails.js.map +1 -1
- package/workflows/organizations/readModel/organizationPresentationAccessState.js +2 -2
- package/workflows/organizations/readModel/organizationPresentationAccessState.js.map +1 -1
- package/workflows/organizations/readModel/readModelProjection.d.ts +1 -1
- package/workflows/organizations/readModel/readModelProjection.js +12 -13
- package/workflows/organizations/readModel/readModelProjection.js.map +1 -1
- package/data/persistence/organizations/organizationAccessRevocationPersistence.js +0 -49
- package/data/persistence/organizations/organizationAccessRevocationPersistence.js.map +0 -1
- package/data/persistence/organizations/organizationGroupNamePersistence.js +0 -33
- package/data/persistence/organizations/organizationGroupNamePersistence.js.map +0 -1
- package/data/persistence/organizations/organizationProfileDocumentPointers.js +0 -32
- package/data/persistence/organizations/organizationProfileDocumentPointers.js.map +0 -1
- package/data/persistence/organizations/organizationReadModelCursorPersistence.d.ts +0 -15
- package/data/persistence/organizations/organizationReadModelCursorPersistence.js +0 -25
- package/data/persistence/organizations/organizationReadModelCursorPersistence.js.map +0 -1
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { and, eq } from "drizzle-orm";
|
|
2
|
-
import { getOrCreatePrincipalPolicyCoordinator } from "../../principals/principalPolicyCoordinator.js";
|
|
3
|
-
import { organizationReadModelTables } from "../../sqlite/schema/index.js";
|
|
4
|
-
import { organizationDataUsageTables } from "../../sqlite/schema/organizationDataUsageSchema.js";
|
|
5
|
-
import { organizationReadModelRequesters } from "../../sqlite/schema/organizationReadModelSchema.js";
|
|
6
|
-
import { getClientSQLitePersistenceRuntime } from "../../sqlite/sqlitePersistenceRuntime.js";
|
|
7
|
-
import { ensureSqlTables } from "../../sqlite/sqlTableSchema.js";
|
|
8
|
-
import { purgeOrganizationDataUsageProjectionInTransaction } from "./organizationDataUsagePersistence.js";
|
|
9
|
-
import { purgeOrganizationReadModelProjectionInTransaction } from "./organizationReadModelPurge.js";
|
|
10
|
-
const organizationAccessProjectionTables = [
|
|
11
|
-
...organizationReadModelTables,
|
|
12
|
-
...organizationDataUsageTables,
|
|
13
|
-
];
|
|
14
|
-
/**
|
|
15
|
-
* Purge one requester's access to an organization's presentation projections
|
|
16
|
-
* after the server denied that requester. The denial is requester-scoped: the
|
|
17
|
-
* shared read-model rows stay while another local identity in the same
|
|
18
|
-
* database still holds a requester row, and organization-wide rows fall with
|
|
19
|
-
* the last requester.
|
|
20
|
-
*/
|
|
21
|
-
export async function purgeOrganizationAccessProjection(input) {
|
|
22
|
-
await ensureSqlTables(input.execSql, organizationAccessProjectionTables);
|
|
23
|
-
await getClientSQLitePersistenceRuntime(input.execSql).transaction(async (tx) => {
|
|
24
|
-
await tx
|
|
25
|
-
.delete(organizationReadModelRequesters)
|
|
26
|
-
.where(and(eq(organizationReadModelRequesters.organizationId, input.organizationId), eq(organizationReadModelRequesters.userId, input.requesterUserId)))
|
|
27
|
-
.run();
|
|
28
|
-
const [remainingRequester] = await tx
|
|
29
|
-
.select({ userId: organizationReadModelRequesters.userId })
|
|
30
|
-
.from(organizationReadModelRequesters)
|
|
31
|
-
.where(eq(organizationReadModelRequesters.organizationId, input.organizationId))
|
|
32
|
-
.limit(1);
|
|
33
|
-
if (!remainingRequester) {
|
|
34
|
-
await purgeOrganizationReadModelProjectionInTransaction({
|
|
35
|
-
organizationId: input.organizationId,
|
|
36
|
-
tx,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
await purgeOrganizationDataUsageProjectionInTransaction({
|
|
40
|
-
organizationId: input.organizationId,
|
|
41
|
-
requesterUserId: input.requesterUserId,
|
|
42
|
-
tx,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
// A denial is a realtime-hinted access change: in-flight operations recover
|
|
46
|
-
// the organization's directory again instead of reusing their memo.
|
|
47
|
-
getOrCreatePrincipalPolicyCoordinator(input.execSql).invalidateRecovery(input.organizationId);
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=organizationAccessRevocationPersistence.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizationAccessRevocationPersistence.js","sourceRoot":"","sources":["organizationAccessRevocationPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,qCAAqC,EAAE,MAAM,6CAA6C,CAAC;AACpG,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,+BAA+B,EAAE,MAAM,iDAAiD,CAAC;AAClG,OAAO,EAAE,iCAAiC,EAAE,MAAM,uCAAuC,CAAC;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,iDAAiD,EAAE,MAAM,oCAAoC,CAAC;AACvG,OAAO,EAAE,iDAAiD,EAAE,MAAM,8BAA8B,CAAC;AAEjG,MAAM,kCAAkC,GAAG;IACzC,GAAG,2BAA2B;IAC9B,GAAG,2BAA2B;CAC/B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAIvD;IACC,MAAM,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;IACzE,MAAM,iCAAiC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,CAChE,KAAK,EAAE,EAAE,EAAE,EAAE;QACX,MAAM,EAAE;aACL,MAAM,CAAC,+BAA+B,CAAC;aACvC,KAAK,CACJ,GAAG,CACD,EAAE,CACA,+BAA+B,CAAC,cAAc,EAC9C,KAAK,CAAC,cAAc,CACrB,EACD,EAAE,CAAC,+BAA+B,CAAC,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,CAClE,CACF;aACA,GAAG,EAAE,CAAC;QACT,MAAM,CAAC,kBAAkB,CAAC,GAAG,MAAM,EAAE;aAClC,MAAM,CAAC,EAAE,MAAM,EAAE,+BAA+B,CAAC,MAAM,EAAE,CAAC;aAC1D,IAAI,CAAC,+BAA+B,CAAC;aACrC,KAAK,CACJ,EAAE,CACA,+BAA+B,CAAC,cAAc,EAC9C,KAAK,CAAC,cAAc,CACrB,CACF;aACA,KAAK,CAAC,CAAC,CAAC,CAAC;QACZ,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,MAAM,iDAAiD,CAAC;gBACtD,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,EAAE;aACH,CAAC,CAAC;QACL,CAAC;QACD,MAAM,iDAAiD,CAAC;YACtD,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,EAAE;SACH,CAAC,CAAC;IACL,CAAC,CACF,CAAC;IACF,4EAA4E;IAC5E,oEAAoE;IACpE,qCAAqC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,kBAAkB,CACrE,KAAK,CAAC,cAAc,CACrB,CAAC;AACJ,CAAC","sourcesContent":["import { and, eq } from \"drizzle-orm\";\nimport { getOrCreatePrincipalPolicyCoordinator } from \"../../principals/principalPolicyCoordinator\";\nimport { organizationReadModelTables } from \"../../sqlite/schema\";\nimport { organizationDataUsageTables } from \"../../sqlite/schema/organizationDataUsageSchema\";\nimport { organizationReadModelRequesters } from \"../../sqlite/schema/organizationReadModelSchema\";\nimport { getClientSQLitePersistenceRuntime } from \"../../sqlite/sqlitePersistenceRuntime\";\nimport type { ExecSql } from \"../../sqlite/sqlSchema\";\nimport { ensureSqlTables } from \"../../sqlite/sqlTableSchema\";\nimport { purgeOrganizationDataUsageProjectionInTransaction } from \"./organizationDataUsagePersistence\";\nimport { purgeOrganizationReadModelProjectionInTransaction } from \"./organizationReadModelPurge\";\n\nconst organizationAccessProjectionTables = [\n ...organizationReadModelTables,\n ...organizationDataUsageTables,\n];\n\n/**\n * Purge one requester's access to an organization's presentation projections\n * after the server denied that requester. The denial is requester-scoped: the\n * shared read-model rows stay while another local identity in the same\n * database still holds a requester row, and organization-wide rows fall with\n * the last requester.\n */\nexport async function purgeOrganizationAccessProjection(input: {\n readonly execSql: ExecSql;\n readonly organizationId: string;\n readonly requesterUserId: string;\n}): Promise<void> {\n await ensureSqlTables(input.execSql, organizationAccessProjectionTables);\n await getClientSQLitePersistenceRuntime(input.execSql).transaction(\n async (tx) => {\n await tx\n .delete(organizationReadModelRequesters)\n .where(\n and(\n eq(\n organizationReadModelRequesters.organizationId,\n input.organizationId,\n ),\n eq(organizationReadModelRequesters.userId, input.requesterUserId),\n ),\n )\n .run();\n const [remainingRequester] = await tx\n .select({ userId: organizationReadModelRequesters.userId })\n .from(organizationReadModelRequesters)\n .where(\n eq(\n organizationReadModelRequesters.organizationId,\n input.organizationId,\n ),\n )\n .limit(1);\n if (!remainingRequester) {\n await purgeOrganizationReadModelProjectionInTransaction({\n organizationId: input.organizationId,\n tx,\n });\n }\n await purgeOrganizationDataUsageProjectionInTransaction({\n organizationId: input.organizationId,\n requesterUserId: input.requesterUserId,\n tx,\n });\n },\n );\n // A denial is a realtime-hinted access change: in-flight operations recover\n // the organization's directory again instead of reusing their memo.\n getOrCreatePrincipalPolicyCoordinator(input.execSql).invalidateRecovery(\n input.organizationId,\n );\n}\n"]}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { and, eq } from "drizzle-orm";
|
|
2
|
-
import { organizationReadModelTables } from "../../sqlite/schema/index.js";
|
|
3
|
-
import { organizationReadModelGroups } from "../../sqlite/schema/organizationReadModelSchema.js";
|
|
4
|
-
import { getClientSQLitePersistenceRuntime } from "../../sqlite/sqlitePersistenceRuntime.js";
|
|
5
|
-
import { ensureSqlTables } from "../../sqlite/sqlSchema.js";
|
|
6
|
-
export async function loadOrganizationGroupDisplayNames(execSql, organizationId) {
|
|
7
|
-
await ensureSqlTables(execSql, organizationReadModelTables);
|
|
8
|
-
const { db } = getClientSQLitePersistenceRuntime(execSql);
|
|
9
|
-
const rows = await db
|
|
10
|
-
.select({
|
|
11
|
-
groupId: organizationReadModelGroups.groupId,
|
|
12
|
-
name: organizationReadModelGroups.name,
|
|
13
|
-
})
|
|
14
|
-
.from(organizationReadModelGroups)
|
|
15
|
-
.where(eq(organizationReadModelGroups.organizationId, organizationId));
|
|
16
|
-
return new Map(rows
|
|
17
|
-
.filter((row) => row.name.length > 0)
|
|
18
|
-
.map((row) => [row.groupId, row.name]));
|
|
19
|
-
}
|
|
20
|
-
/** Local display cache only: these labels never enter a server request. */
|
|
21
|
-
export async function saveOrganizationGroupDisplayNames(input) {
|
|
22
|
-
await ensureSqlTables(input.execSql, organizationReadModelTables);
|
|
23
|
-
await getClientSQLitePersistenceRuntime(input.execSql).guardedTransaction(async (tx) => {
|
|
24
|
-
for (const group of input.names) {
|
|
25
|
-
await tx
|
|
26
|
-
.update(organizationReadModelGroups)
|
|
27
|
-
.set({ name: group.name })
|
|
28
|
-
.where(and(eq(organizationReadModelGroups.organizationId, input.organizationId), eq(organizationReadModelGroups.groupId, group.groupId), eq(organizationReadModelGroups.stateHash, group.stateHash)))
|
|
29
|
-
.run();
|
|
30
|
-
}
|
|
31
|
-
}, input.stillCurrent);
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=organizationGroupNamePersistence.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizationGroupNamePersistence.js","sourceRoot":"","sources":["organizationGroupNamePersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,iCAAiC,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EAAgB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEvE,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,OAAgB,EAChB,cAAsB;IAEtB,MAAM,eAAe,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC;IAC5D,MAAM,EAAE,EAAE,EAAE,GAAG,iCAAiC,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,MAAM,EAAE;SAClB,MAAM,CAAC;QACN,OAAO,EAAE,2BAA2B,CAAC,OAAO;QAC5C,IAAI,EAAE,2BAA2B,CAAC,IAAI;KACvC,CAAC;SACD,IAAI,CAAC,2BAA2B,CAAC;SACjC,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;IACzE,OAAO,IAAI,GAAG,CACZ,IAAI;SACD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACpC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAKvD;IACC,MAAM,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC;IAClE,MAAM,iCAAiC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,kBAAkB,CACvE,KAAK,EAAE,EAAE,EAAE,EAAE;QACX,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,MAAM,EAAE;iBACL,MAAM,CAAC,2BAA2B,CAAC;iBACnC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;iBACzB,KAAK,CACJ,GAAG,CACD,EAAE,CACA,2BAA2B,CAAC,cAAc,EAC1C,KAAK,CAAC,cAAc,CACrB,EACD,EAAE,CAAC,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EACtD,EAAE,CAAC,2BAA2B,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAC3D,CACF;iBACA,GAAG,EAAE,CAAC;QACX,CAAC;IACH,CAAC,EACD,KAAK,CAAC,YAAY,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { and, eq } from \"drizzle-orm\";\nimport { organizationReadModelTables } from \"../../sqlite/schema\";\nimport { organizationReadModelGroups } from \"../../sqlite/schema/organizationReadModelSchema\";\nimport { getClientSQLitePersistenceRuntime } from \"../../sqlite/sqlitePersistenceRuntime\";\nimport { type ExecSql, ensureSqlTables } from \"../../sqlite/sqlSchema\";\n\nexport async function loadOrganizationGroupDisplayNames(\n execSql: ExecSql,\n organizationId: string,\n): Promise<ReadonlyMap<string, string>> {\n await ensureSqlTables(execSql, organizationReadModelTables);\n const { db } = getClientSQLitePersistenceRuntime(execSql);\n const rows = await db\n .select({\n groupId: organizationReadModelGroups.groupId,\n name: organizationReadModelGroups.name,\n })\n .from(organizationReadModelGroups)\n .where(eq(organizationReadModelGroups.organizationId, organizationId));\n return new Map(\n rows\n .filter((row) => row.name.length > 0)\n .map((row) => [row.groupId, row.name]),\n );\n}\n\n/** Local display cache only: these labels never enter a server request. */\nexport async function saveOrganizationGroupDisplayNames(input: {\n execSql: ExecSql;\n organizationId: string;\n names: readonly { groupId: string; name: string; stateHash: string }[];\n stillCurrent: () => boolean;\n}): Promise<void> {\n await ensureSqlTables(input.execSql, organizationReadModelTables);\n await getClientSQLitePersistenceRuntime(input.execSql).guardedTransaction(\n async (tx) => {\n for (const group of input.names) {\n await tx\n .update(organizationReadModelGroups)\n .set({ name: group.name })\n .where(\n and(\n eq(\n organizationReadModelGroups.organizationId,\n input.organizationId,\n ),\n eq(organizationReadModelGroups.groupId, group.groupId),\n eq(organizationReadModelGroups.stateHash, group.stateHash),\n ),\n )\n .run();\n }\n },\n input.stillCurrent,\n );\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { organizationReadModelTables } from "../../sqlite/schema/index.js";
|
|
2
|
-
import { organizationReadModelState } from "../../sqlite/schema/organizationReadModelSchema.js";
|
|
3
|
-
import { getClientSQLitePersistenceRuntime } from "../../sqlite/sqlitePersistenceRuntime.js";
|
|
4
|
-
import { ensureSqlTables } from "../../sqlite/sqlSchema.js";
|
|
5
|
-
/**
|
|
6
|
-
* Every locally projected organization's pointer to its organization_profile
|
|
7
|
-
* document, keyed by organization id.
|
|
8
|
-
*
|
|
9
|
-
* This is the only container-independent handle on that document. Callers that
|
|
10
|
-
* need an org's display name from local state cannot rely on where the document
|
|
11
|
-
* is linked: the provisioner writes it under a deterministic local alias into
|
|
12
|
-
* the organization-metadata container, while a device that only *synced* it
|
|
13
|
-
* (identity recovery, another member) keys it under the server documentId in
|
|
14
|
-
* whichever container the grant arrived through.
|
|
15
|
-
*
|
|
16
|
-
* The local schema stores only the current read-model contract, so every state
|
|
17
|
-
* row is eligible to provide its profile-document pointer.
|
|
18
|
-
*/
|
|
19
|
-
export async function loadOrganizationProfileDocumentIds(execSql) {
|
|
20
|
-
await ensureSqlTables(execSql, organizationReadModelTables);
|
|
21
|
-
const { db } = getClientSQLitePersistenceRuntime(execSql);
|
|
22
|
-
const rows = await db
|
|
23
|
-
.select({
|
|
24
|
-
organizationId: organizationReadModelState.organizationId,
|
|
25
|
-
profileDocumentId: organizationReadModelState.profileDocumentId,
|
|
26
|
-
})
|
|
27
|
-
.from(organizationReadModelState);
|
|
28
|
-
return new Map(rows.flatMap((row) => row.profileDocumentId
|
|
29
|
-
? [[row.organizationId, row.profileDocumentId]]
|
|
30
|
-
: []));
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=organizationProfileDocumentPointers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizationProfileDocumentPointers.js","sourceRoot":"","sources":["organizationProfileDocumentPointers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,iCAAiC,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EAAgB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,OAAgB;IAEhB,MAAM,eAAe,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC;IAC5D,MAAM,EAAE,EAAE,EAAE,GAAG,iCAAiC,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,MAAM,EAAE;SAClB,MAAM,CAAC;QACN,cAAc,EAAE,0BAA0B,CAAC,cAAc;QACzD,iBAAiB,EAAE,0BAA0B,CAAC,iBAAiB;KAChE,CAAC;SACD,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAEpC,OAAO,IAAI,GAAG,CACZ,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CACnB,GAAG,CAAC,iBAAiB;QACnB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/C,CAAC,CAAC,EAAE,CACP,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { organizationReadModelTables } from \"../../sqlite/schema\";\nimport { organizationReadModelState } from \"../../sqlite/schema/organizationReadModelSchema\";\nimport { getClientSQLitePersistenceRuntime } from \"../../sqlite/sqlitePersistenceRuntime\";\nimport { type ExecSql, ensureSqlTables } from \"../../sqlite/sqlSchema\";\n\n/**\n * Every locally projected organization's pointer to its organization_profile\n * document, keyed by organization id.\n *\n * This is the only container-independent handle on that document. Callers that\n * need an org's display name from local state cannot rely on where the document\n * is linked: the provisioner writes it under a deterministic local alias into\n * the organization-metadata container, while a device that only *synced* it\n * (identity recovery, another member) keys it under the server documentId in\n * whichever container the grant arrived through.\n *\n * The local schema stores only the current read-model contract, so every state\n * row is eligible to provide its profile-document pointer.\n */\nexport async function loadOrganizationProfileDocumentIds(\n execSql: ExecSql,\n): Promise<Map<string, string>> {\n await ensureSqlTables(execSql, organizationReadModelTables);\n const { db } = getClientSQLitePersistenceRuntime(execSql);\n const rows = await db\n .select({\n organizationId: organizationReadModelState.organizationId,\n profileDocumentId: organizationReadModelState.profileDocumentId,\n })\n .from(organizationReadModelState);\n\n return new Map(\n rows.flatMap((row) =>\n row.profileDocumentId\n ? [[row.organizationId, row.profileDocumentId]]\n : [],\n ),\n );\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ExecSql } from "../../sqlite/sqlSchema.js";
|
|
2
|
-
/**
|
|
3
|
-
* The cursor this requester has applied, or null when it holds none. The
|
|
4
|
-
* organization row's cursor is shared: another identity on this device may
|
|
5
|
-
* have advanced it while this requester's own fields (for example
|
|
6
|
-
* `isOrgAdmin`) still reflect an older response. Only the requester's own
|
|
7
|
-
* applied cursor, while it is still the stored projection's cursor, proves
|
|
8
|
-
* this requester is current. Realtime hints compare against it so a hint for
|
|
9
|
-
* a cursor already applied costs no read.
|
|
10
|
-
*/
|
|
11
|
-
export declare function loadAppliedOrganizationReadModelCursor(input: {
|
|
12
|
-
readonly execSql: ExecSql;
|
|
13
|
-
readonly organizationId: string;
|
|
14
|
-
readonly requesterUserId: string;
|
|
15
|
-
}): Promise<string | null>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { and, eq } from "drizzle-orm";
|
|
2
|
-
import { organizationReadModelTables } from "../../sqlite/schema/index.js";
|
|
3
|
-
import { organizationReadModelRequesters, organizationReadModelState, } from "../../sqlite/schema/organizationReadModelSchema.js";
|
|
4
|
-
import { getClientSQLitePersistenceRuntime } from "../../sqlite/sqlitePersistenceRuntime.js";
|
|
5
|
-
import { ensureSqlTables } from "../../sqlite/sqlSchema.js";
|
|
6
|
-
/**
|
|
7
|
-
* The cursor this requester has applied, or null when it holds none. The
|
|
8
|
-
* organization row's cursor is shared: another identity on this device may
|
|
9
|
-
* have advanced it while this requester's own fields (for example
|
|
10
|
-
* `isOrgAdmin`) still reflect an older response. Only the requester's own
|
|
11
|
-
* applied cursor, while it is still the stored projection's cursor, proves
|
|
12
|
-
* this requester is current. Realtime hints compare against it so a hint for
|
|
13
|
-
* a cursor already applied costs no read.
|
|
14
|
-
*/
|
|
15
|
-
export async function loadAppliedOrganizationReadModelCursor(input) {
|
|
16
|
-
await ensureSqlTables(input.execSql, organizationReadModelTables);
|
|
17
|
-
const [row] = await getClientSQLitePersistenceRuntime(input.execSql)
|
|
18
|
-
.db.select({ cursor: organizationReadModelRequesters.appliedCursor })
|
|
19
|
-
.from(organizationReadModelRequesters)
|
|
20
|
-
.innerJoin(organizationReadModelState, and(eq(organizationReadModelState.organizationId, organizationReadModelRequesters.organizationId), eq(organizationReadModelState.cursor, organizationReadModelRequesters.appliedCursor)))
|
|
21
|
-
.where(and(eq(organizationReadModelRequesters.organizationId, input.organizationId), eq(organizationReadModelRequesters.userId, input.requesterUserId)))
|
|
22
|
-
.limit(1);
|
|
23
|
-
return row?.cursor ?? null;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=organizationReadModelCursorPersistence.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organizationReadModelCursorPersistence.js","sourceRoot":"","sources":["organizationReadModelCursorPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EAAgB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAAC,KAI5D;IACC,MAAM,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC;IAClE,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,iCAAiC,CAAC,KAAK,CAAC,OAAO,CAAC;SACjE,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,+BAA+B,CAAC,aAAa,EAAE,CAAC;SACpE,IAAI,CAAC,+BAA+B,CAAC;SACrC,SAAS,CACR,0BAA0B,EAC1B,GAAG,CACD,EAAE,CACA,0BAA0B,CAAC,cAAc,EACzC,+BAA+B,CAAC,cAAc,CAC/C,EACD,EAAE,CACA,0BAA0B,CAAC,MAAM,EACjC,+BAA+B,CAAC,aAAa,CAC9C,CACF,CACF;SACA,KAAK,CACJ,GAAG,CACD,EAAE,CACA,+BAA+B,CAAC,cAAc,EAC9C,KAAK,CAAC,cAAc,CACrB,EACD,EAAE,CAAC,+BAA+B,CAAC,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,CAClE,CACF;SACA,KAAK,CAAC,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC;AAC7B,CAAC","sourcesContent":["import { and, eq } from \"drizzle-orm\";\nimport { organizationReadModelTables } from \"../../sqlite/schema\";\nimport {\n organizationReadModelRequesters,\n organizationReadModelState,\n} from \"../../sqlite/schema/organizationReadModelSchema\";\nimport { getClientSQLitePersistenceRuntime } from \"../../sqlite/sqlitePersistenceRuntime\";\nimport { type ExecSql, ensureSqlTables } from \"../../sqlite/sqlSchema\";\n\n/**\n * The cursor this requester has applied, or null when it holds none. The\n * organization row's cursor is shared: another identity on this device may\n * have advanced it while this requester's own fields (for example\n * `isOrgAdmin`) still reflect an older response. Only the requester's own\n * applied cursor, while it is still the stored projection's cursor, proves\n * this requester is current. Realtime hints compare against it so a hint for\n * a cursor already applied costs no read.\n */\nexport async function loadAppliedOrganizationReadModelCursor(input: {\n readonly execSql: ExecSql;\n readonly organizationId: string;\n readonly requesterUserId: string;\n}): Promise<string | null> {\n await ensureSqlTables(input.execSql, organizationReadModelTables);\n const [row] = await getClientSQLitePersistenceRuntime(input.execSql)\n .db.select({ cursor: organizationReadModelRequesters.appliedCursor })\n .from(organizationReadModelRequesters)\n .innerJoin(\n organizationReadModelState,\n and(\n eq(\n organizationReadModelState.organizationId,\n organizationReadModelRequesters.organizationId,\n ),\n eq(\n organizationReadModelState.cursor,\n organizationReadModelRequesters.appliedCursor,\n ),\n ),\n )\n .where(\n and(\n eq(\n organizationReadModelRequesters.organizationId,\n input.organizationId,\n ),\n eq(organizationReadModelRequesters.userId, input.requesterUserId),\n ),\n )\n .limit(1);\n return row?.cursor ?? null;\n}\n"]}
|