@selvajs/platform 1.0.0-beta.4 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -111,7 +111,7 @@ Throw `ProviderError` for user-facing failures (`new ProviderError('...', 404)`)
111
111
 
112
112
  ## Data privacy
113
113
 
114
- Identity and credentials belong to whichever `IAuthProvider` is configured — for Supabase that's a separate service; for the local provider, Selva itself is the auth provider and holds email addresses and password hashes on disk. This package's own stores hold user IDs, authorization metadata, display names, invite email addresses, and audit payloads. **The operator is the data controller.** See [data privacy](../../docs/self-hosting/concepts/data-privacy.md) for the full inventory and what erasure reaches, plus [providers](../../docs/self-hosting/providers/overview.md) and [security & limits](../../docs/self-hosting/concepts/security-and-limits.md).
114
+ Identity and credentials belong to whichever `IAuthProvider` is configured — for Supabase that's a separate service; for the local provider, Selva itself is the auth provider and holds email addresses and password hashes on disk. This package's own stores hold user IDs, authorization metadata, display names, invite email addresses, and audit payloads. **The operator is the data controller.** See [data privacy](../../docs/self-hosting/concepts/data-privacy.md) for the full inventory and what erasure reaches, plus [providers](../../docs/self-hosting/providers/overview.md) and [security & limits](../../docs/self-hosting/deployment/security-and-limits.md).
115
115
 
116
116
  ---
117
117
 
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export { NoopBindingResolver } from './bindings/interface.js';
28
28
  export type { RequestContext } from './context.js';
29
29
  export { SYSTEM_CONTEXT, hasPermission, requireActingOrg, isShareContext, assertNotShareContext } from './context.js';
30
30
  export type { ListOptions, DefinitionListOptions, Page } from './pagination.js';
31
- export { DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT, clampPageLimit, decodeOffsetCursor, encodeOffsetCursor } from './pagination.js';
31
+ export { DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT, clampPageLimit, decodeOffsetCursor, encodeOffsetCursor, listAll, walkPages } from './pagination.js';
32
32
  export type { TenancyMode, SelvaFlags, SelvaBranding, SelvaConfig, SelvaConfigFactory } from './config.js';
33
33
  export { isFlagEnabled, defineConfig } from './config.js';
34
34
  export { ProviderError } from './errors.js';
package/dist/index.js CHANGED
@@ -22,6 +22,6 @@ export { NoopErrorReporter } from './errors/interface.js';
22
22
  export { NoopLogger } from './logging/interface.js';
23
23
  export { NoopBindingResolver } from './bindings/interface.js';
24
24
  export { SYSTEM_CONTEXT, hasPermission, requireActingOrg, isShareContext, assertNotShareContext } from './context.js';
25
- export { DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT, clampPageLimit, decodeOffsetCursor, encodeOffsetCursor } from './pagination.js';
25
+ export { DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT, clampPageLimit, decodeOffsetCursor, encodeOffsetCursor, listAll, walkPages } from './pagination.js';
26
26
  export { isFlagEnabled, defineConfig } from './config.js';
27
27
  export { ProviderError } from './errors.js';
@@ -49,5 +49,17 @@ export declare const MAX_PAGE_LIMIT = 200;
49
49
  /** For adapters paging by offset. Junk and negatives read as the first page. */
50
50
  export declare function decodeOffsetCursor(cursor: string | undefined): number;
51
51
  export declare function encodeOffsetCursor(offset: number): string;
52
+ type PageFetcher<T> = (page: {
53
+ limit: number;
54
+ cursor?: string;
55
+ }) => Promise<Page<T>>;
56
+ /**
57
+ * Every page of a list, in order. One call stops at `MAX_PAGE_LIMIT` without saying so, which is
58
+ * fatal for a read that must see every row. Break out of the loop to stop reading.
59
+ */
60
+ export declare function walkPages<T>(fetchPage: PageFetcher<T>): AsyncGenerator<Page<T>>;
61
+ /** Every row of a list, across all its pages. */
62
+ export declare function listAll<T>(fetchPage: PageFetcher<T>): Promise<T[]>;
52
63
  /** The effective page size for a requested limit. */
53
64
  export declare function clampPageLimit(limit: number | undefined): number;
65
+ export {};
@@ -8,6 +8,25 @@ export function decodeOffsetCursor(cursor) {
8
8
  export function encodeOffsetCursor(offset) {
9
9
  return String(offset);
10
10
  }
11
+ /**
12
+ * Every page of a list, in order. One call stops at `MAX_PAGE_LIMIT` without saying so, which is
13
+ * fatal for a read that must see every row. Break out of the loop to stop reading.
14
+ */
15
+ export async function* walkPages(fetchPage) {
16
+ let cursor;
17
+ do {
18
+ const page = await fetchPage({ limit: MAX_PAGE_LIMIT, cursor });
19
+ yield page;
20
+ cursor = page.nextCursor;
21
+ } while (cursor);
22
+ }
23
+ /** Every row of a list, across all its pages. */
24
+ export async function listAll(fetchPage) {
25
+ const items = [];
26
+ for await (const page of walkPages(fetchPage))
27
+ items.push(...page.items);
28
+ return items;
29
+ }
11
30
  /** The effective page size for a requested limit. */
12
31
  export function clampPageLimit(limit) {
13
32
  const requested = limit ?? DEFAULT_PAGE_LIMIT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selvajs/platform",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "Interfaces, access rules and conformance suites for Selva platform providers",
5
5
  "license": "MIT",
6
6
  "author": "VektorNode",