@ai-matrx/associations 0.14.79 → 0.14.81

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.
@@ -1,4 +1,4 @@
1
- import { E as EntityOverlayMap, a as EntityTypeToken, b as EntityOverlayEntry, c as ErrorSink, A as AssociationsRpcError, d as AssociationsDataSource, e as AssociationsIdentity, f as AssociationTargetType, g as AssociationsRpcResult, h as AssociationEdge, i as AssociationTargetEdge, j as AssociationSourceEdge, C as CategoryDimension, P as PlatformCategory, U as UserStateKind, k as UserEntityState, l as CommentAnchor, m as PlatformComment, n as AssociationsEntry, o as CategoriesEntry, p as CommentsEntry, q as AssociationsConfig } from '../results-DS6_WIIP.cjs';
1
+ import { E as EntityOverlayMap, a as EntityTypeToken, b as EntityOverlayEntry, c as ErrorSink, A as AssociationsRpcError, d as AssociationsDataSource, e as AssociationsIdentity, f as AssociationTargetType, g as AssociationsRpcResult, h as AssociationEdge, i as AssociationTargetEdge, j as AssociationSourceEdge, C as CategoryDimension, P as PlatformCategory, U as UserStateKind, k as UserEntityState, l as CommentAnchor, m as PlatformComment, n as AssociationsEntry, o as CategoriesEntry, p as CommentsEntry, q as AssociationsConfig } from '../results-Du0dzBb4.cjs';
2
2
  import 'react';
3
3
  import '@ai-matrx/data/db';
4
4
 
@@ -110,11 +110,7 @@ interface RpcResultHelpers {
110
110
  mapPgError: PgErrorMapper;
111
111
  mapPgErrorPair: PgErrorPairMapper;
112
112
  }
113
- /**
114
- * Bind the loud funnel to the host's errorSink. Every failure in this
115
- * package's services passes through the returned `mapPgError` exactly once.
116
- */
117
- declare function createRpcResultHelpers(errorSink: ErrorSink): RpcResultHelpers;
113
+ declare function createRpcResultHelpers(errorSink: ErrorSink, sessionAttached?: () => boolean): RpcResultHelpers;
118
114
 
119
115
  interface CoreDeps {
120
116
  dataSource: AssociationsDataSource;
@@ -1,4 +1,4 @@
1
- import { E as EntityOverlayMap, a as EntityTypeToken, b as EntityOverlayEntry, c as ErrorSink, A as AssociationsRpcError, d as AssociationsDataSource, e as AssociationsIdentity, f as AssociationTargetType, g as AssociationsRpcResult, h as AssociationEdge, i as AssociationTargetEdge, j as AssociationSourceEdge, C as CategoryDimension, P as PlatformCategory, U as UserStateKind, k as UserEntityState, l as CommentAnchor, m as PlatformComment, n as AssociationsEntry, o as CategoriesEntry, p as CommentsEntry, q as AssociationsConfig } from '../results-DS6_WIIP.js';
1
+ import { E as EntityOverlayMap, a as EntityTypeToken, b as EntityOverlayEntry, c as ErrorSink, A as AssociationsRpcError, d as AssociationsDataSource, e as AssociationsIdentity, f as AssociationTargetType, g as AssociationsRpcResult, h as AssociationEdge, i as AssociationTargetEdge, j as AssociationSourceEdge, C as CategoryDimension, P as PlatformCategory, U as UserStateKind, k as UserEntityState, l as CommentAnchor, m as PlatformComment, n as AssociationsEntry, o as CategoriesEntry, p as CommentsEntry, q as AssociationsConfig } from '../results-Du0dzBb4.js';
2
2
  import 'react';
3
3
  import '@ai-matrx/data/db';
4
4
 
@@ -110,11 +110,7 @@ interface RpcResultHelpers {
110
110
  mapPgError: PgErrorMapper;
111
111
  mapPgErrorPair: PgErrorPairMapper;
112
112
  }
113
- /**
114
- * Bind the loud funnel to the host's errorSink. Every failure in this
115
- * package's services passes through the returned `mapPgError` exactly once.
116
- */
117
- declare function createRpcResultHelpers(errorSink: ErrorSink): RpcResultHelpers;
113
+ declare function createRpcResultHelpers(errorSink: ErrorSink, sessionAttached?: () => boolean): RpcResultHelpers;
118
114
 
119
115
  interface CoreDeps {
120
116
  dataSource: AssociationsDataSource;
@@ -5,7 +5,7 @@ import {
5
5
  isRecordStoreNounToken,
6
6
  recordStoreNoun,
7
7
  registeredEdgeLabel
8
- } from "../chunk-server-TWGNVHGE.js";
8
+ } from "../chunk-server-TFJNKVMM.js";
9
9
 
10
10
  // src/ports.ts
11
11
  function asAssociationsDataSource(source) {
@@ -148,7 +148,9 @@ function readPgFields(e) {
148
148
  }
149
149
  return { pgCode: null, pgMessage: null, pgHint: void 0 };
150
150
  }
151
- function createRpcResultHelpers(errorSink) {
151
+ var SIGNED_OUT_LEAD = "You're signed out";
152
+ var SIGNED_OUT_MESSAGE = `${SIGNED_OUT_LEAD}. Sign in again \u2014 your text is kept here.`;
153
+ function createRpcResultHelpers(errorSink, sessionAttached) {
152
154
  function mapPgError(e) {
153
155
  const { pgCode, pgMessage, pgHint } = readPgFields(e);
154
156
  if (pgCode === "PGRST202") {
@@ -181,10 +183,13 @@ function createRpcResultHelpers(errorSink) {
181
183
  }
182
184
  if (pgCode === "PGRST116")
183
185
  return { code: "not_found", message: "Not found" };
184
- if (pgCode === "42501")
186
+ if (pgCode === "PGRST301" || pgCode === "PGRST303" || pgCode === "28000")
187
+ return { code: "unauthorized", message: SIGNED_OUT_MESSAGE };
188
+ if (pgCode === "42501") {
189
+ const anonymous = /permission denied for function/i.test(pgMessage ?? "") && !(sessionAttached?.() ?? false);
190
+ if (anonymous) return { code: "unauthorized", message: SIGNED_OUT_MESSAGE };
185
191
  return { code: "forbidden_org", message: "Permission denied" };
186
- if (pgCode === "PGRST301" || pgCode === "PGRST303")
187
- return { code: "unauthorized", message: "Your session expired" };
192
+ }
188
193
  if (pgCode === "57014") {
189
194
  const out2 = {
190
195
  code: "internal",
@@ -1728,7 +1733,10 @@ function createAssociationsStore(config) {
1728
1733
  identity: config.identity,
1729
1734
  errorSink,
1730
1735
  guards: createAssociationGuards(errorSink),
1731
- rpc: createRpcResultHelpers(errorSink),
1736
+ rpc: createRpcResultHelpers(
1737
+ errorSink,
1738
+ config.identity.sessionAttached ? () => config.identity.sessionAttached() : void 0
1739
+ ),
1732
1740
  registry
1733
1741
  };
1734
1742
  const associations = createAssociationsService(deps);