@happyvertical/smrt-types 0.42.4 → 0.42.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/AGENTS.md +1 -0
- package/README.md +9 -0
- package/dist/index.d.ts +191 -0
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -11,6 +11,7 @@ Shared TypeScript type definitions. Prevents circular dependencies between packa
|
|
|
11
11
|
| `user.ts` | `UserStatus`, `TenantStatus`, `MembershipStatus`, `SessionStatus`, `OverrideEffect` — status enums |
|
|
12
12
|
| `identity.ts` | `User`, `Tenant`, `Role`, `Membership`, `SmrtEntityFields` — cross-package identity data contracts (runtime classes live in smrt-users, which `implements` these) |
|
|
13
13
|
| `knowledge.ts` | Additive schema-version-1 domain knowledge contracts shared by core generation and development tooling |
|
|
14
|
+
| `data-query.ts` | Serializable bounded query request/result envelope, allowlisted schema, filters, paging, totals, freshness, and facets |
|
|
14
15
|
|
|
15
16
|
## Rules
|
|
16
17
|
|
package/README.md
CHANGED
|
@@ -39,6 +39,15 @@ import { UserStatus, TenantStatus, MembershipStatus } from '@happyvertical/smrt-
|
|
|
39
39
|
| `ModuleUIBaseProps` | Base props interface for module UI components |
|
|
40
40
|
| `ModuleUIRegistryInterface` | Registry interface for module UI registration |
|
|
41
41
|
|
|
42
|
+
### Bounded Data Queries (types)
|
|
43
|
+
|
|
44
|
+
| Export | Description |
|
|
45
|
+
|--------|------------|
|
|
46
|
+
| `DataQueryRequest` / `DataQueryResult` | Serializable, transport-neutral bounded query and normalized result envelopes |
|
|
47
|
+
| `DataQuerySchema` / `DataQueryFieldDescriptor` | Trusted adapter allowlist for projection, filter, sort, and facet capabilities |
|
|
48
|
+
| `DataQueryFilter` / `DataQuerySort` / `DataQueryPage` | Typed predicates, deterministic sort terms, and cursor/offset paging |
|
|
49
|
+
| `DataQueryTotal` / `DataQueryFreshness` | Explicit total exactness/as-of semantics and response freshness |
|
|
50
|
+
|
|
42
51
|
### User/Tenant Status (enums — runtime values)
|
|
43
52
|
|
|
44
53
|
| Export | Description |
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,197 @@ export declare interface AiUsageSummaryOptions extends Omit<AiUsageListOptions,
|
|
|
137
137
|
groupBy?: AiUsageGroupBy;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/** One typed predicate. `in` and `notIn` require a non-empty value array. */
|
|
141
|
+
export declare interface DataQueryCondition {
|
|
142
|
+
kind: 'condition';
|
|
143
|
+
field: DataQueryFieldId;
|
|
144
|
+
operator: DataQueryFilterOperator;
|
|
145
|
+
value: DataQueryScalar | DataQueryScalar[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export declare interface DataQueryConsistency {
|
|
149
|
+
/** Prefer the adapter's most recently available data. */
|
|
150
|
+
mode: DataQueryConsistencyMode;
|
|
151
|
+
/** Optional RFC 3339 instant requested by a time-travel capable adapter. */
|
|
152
|
+
asOf?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Read consistency requested by a caller; adapters decide whether they support it. */
|
|
156
|
+
export declare type DataQueryConsistencyMode = 'eventual' | 'snapshot';
|
|
157
|
+
|
|
158
|
+
/** Cursor values are opaque to callers and bound to a normalized query. */
|
|
159
|
+
export declare interface DataQueryCursorPage {
|
|
160
|
+
kind: 'cursor';
|
|
161
|
+
after?: string;
|
|
162
|
+
limit: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** A bounded request for one declared facet. */
|
|
166
|
+
export declare interface DataQueryFacetRequest {
|
|
167
|
+
field: DataQueryFieldId;
|
|
168
|
+
limit: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export declare interface DataQueryFacetResult {
|
|
172
|
+
field: DataQueryFieldId;
|
|
173
|
+
values: DataQueryFacetValue[];
|
|
174
|
+
truncated: boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** A bounded facet value/count pair. */
|
|
178
|
+
export declare interface DataQueryFacetValue {
|
|
179
|
+
value: DataQueryScalar;
|
|
180
|
+
count: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** An explicitly declared query field and its capability allowlist. */
|
|
184
|
+
export declare interface DataQueryFieldDescriptor {
|
|
185
|
+
id: DataQueryFieldId;
|
|
186
|
+
type: 'string' | 'number' | 'boolean' | 'datetime' | 'json';
|
|
187
|
+
projectable?: boolean;
|
|
188
|
+
sortable?: boolean;
|
|
189
|
+
facetable?: boolean;
|
|
190
|
+
filterOperators?: DataQueryFilterOperator[];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** A stable, adapter-defined field identifier. It is never a property path. */
|
|
194
|
+
export declare type DataQueryFieldId = string;
|
|
195
|
+
|
|
196
|
+
/** Bounded, recursive filter expression with explicit boolean semantics. */
|
|
197
|
+
export declare type DataQueryFilter = DataQueryCondition | {
|
|
198
|
+
kind: 'all' | 'any';
|
|
199
|
+
filters: DataQueryFilter[];
|
|
200
|
+
} | {
|
|
201
|
+
kind: 'not';
|
|
202
|
+
filter: DataQueryFilter;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/** Operators map to an adapter's allowlisted, typed predicate implementation. */
|
|
206
|
+
export declare type DataQueryFilterOperator = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'notIn' | 'like';
|
|
207
|
+
|
|
208
|
+
/** Freshness metadata is declarative; it does not grant access to a snapshot. */
|
|
209
|
+
export declare interface DataQueryFreshness {
|
|
210
|
+
state: 'fresh' | 'stale' | 'unknown';
|
|
211
|
+
asOf?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Offset pagination is explicit so callers cannot smuggle arbitrary bounds. */
|
|
215
|
+
export declare interface DataQueryOffsetPage {
|
|
216
|
+
kind: 'offset';
|
|
217
|
+
offset: number;
|
|
218
|
+
limit: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export declare type DataQueryPage = DataQueryOffsetPage | DataQueryCursorPage;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Canonical data-query request.
|
|
225
|
+
*
|
|
226
|
+
* A request id correlates transport logs and results only; it is intentionally
|
|
227
|
+
* excluded from the semantic query fingerprint. The query does not contain
|
|
228
|
+
* authority, raw database expressions, property paths, functions, or a
|
|
229
|
+
* transport-specific filter object.
|
|
230
|
+
*/
|
|
231
|
+
export declare interface DataQueryRequest {
|
|
232
|
+
version: 1;
|
|
233
|
+
requestId: string;
|
|
234
|
+
mode: 'rows' | 'count' | 'facets';
|
|
235
|
+
projection?: DataQueryFieldId[];
|
|
236
|
+
filter?: DataQueryFilter;
|
|
237
|
+
sort?: DataQuerySort[];
|
|
238
|
+
page?: DataQueryPage;
|
|
239
|
+
consistency?: DataQueryConsistency;
|
|
240
|
+
facets?: DataQueryFacetRequest[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Normalized adapter result. `queryFingerprint` identifies the semantic query
|
|
245
|
+
* (not the request id or page cursor), while pagination state stays explicit.
|
|
246
|
+
*/
|
|
247
|
+
export declare interface DataQueryResult {
|
|
248
|
+
version: 1;
|
|
249
|
+
requestId: string;
|
|
250
|
+
queryFingerprint: string;
|
|
251
|
+
identityField: DataQueryFieldId;
|
|
252
|
+
rows: DataQueryRow[];
|
|
253
|
+
page?: {
|
|
254
|
+
kind: 'offset';
|
|
255
|
+
limit: number;
|
|
256
|
+
offset: number;
|
|
257
|
+
hasMore: boolean;
|
|
258
|
+
} | {
|
|
259
|
+
kind: 'cursor';
|
|
260
|
+
limit: number;
|
|
261
|
+
nextCursor?: string;
|
|
262
|
+
hasMore: boolean;
|
|
263
|
+
};
|
|
264
|
+
total: DataQueryTotal;
|
|
265
|
+
facets?: DataQueryFacetResult[];
|
|
266
|
+
freshness: DataQueryFreshness;
|
|
267
|
+
warnings: string[];
|
|
268
|
+
truncated: boolean;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Rows use JSON-safe values; adapters must project only declared fields. */
|
|
272
|
+
export declare type DataQueryRow = Record<string, unknown>;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Transport-neutral, bounded data-query contract (#2444).
|
|
276
|
+
*
|
|
277
|
+
* This module intentionally has no runtime code. The core package owns
|
|
278
|
+
* normalization, policy enforcement, canonical fingerprints, and result
|
|
279
|
+
* validation; browser, REST, MCP, WebMCP, ContentList, and report adapters
|
|
280
|
+
* share these serializable shapes without importing a server runtime.
|
|
281
|
+
*
|
|
282
|
+
* Authority is deliberately absent. A query can name only adapter-declared
|
|
283
|
+
* field ids and operators; tenant, principal, SQL, relationship paths, and
|
|
284
|
+
* execution details belong to the authenticated adapter, never this envelope.
|
|
285
|
+
*/
|
|
286
|
+
/** JSON scalar values accepted in predicates, facets, and normalized rows. */
|
|
287
|
+
export declare type DataQueryScalar = string | number | boolean | null;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Per-adapter execution policy. It is trusted adapter configuration, never
|
|
291
|
+
* client input, and therefore carries the field allowlists the normalizer
|
|
292
|
+
* applies to requests and returned rows.
|
|
293
|
+
*/
|
|
294
|
+
export declare interface DataQuerySchema {
|
|
295
|
+
version: 1;
|
|
296
|
+
identityField: DataQueryFieldId;
|
|
297
|
+
fields: DataQueryFieldDescriptor[];
|
|
298
|
+
defaultPageLimit?: number;
|
|
299
|
+
maxPageLimit?: number;
|
|
300
|
+
maxResultBytes?: number;
|
|
301
|
+
defaultSort?: DataQuerySort[];
|
|
302
|
+
supports?: {
|
|
303
|
+
cursorPagination?: boolean;
|
|
304
|
+
consistency?: boolean;
|
|
305
|
+
facets?: boolean;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** Deterministic sort precedence; earlier terms take precedence. */
|
|
310
|
+
export declare interface DataQuerySort {
|
|
311
|
+
field: DataQueryFieldId;
|
|
312
|
+
direction: DataQuerySortDirection;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export declare type DataQuerySortDirection = 'asc' | 'desc';
|
|
316
|
+
|
|
317
|
+
/** How a returned total was obtained, including the absence of a total. */
|
|
318
|
+
export declare type DataQueryTotal = {
|
|
319
|
+
kind: 'exact';
|
|
320
|
+
value: number;
|
|
321
|
+
asOf?: string;
|
|
322
|
+
} | {
|
|
323
|
+
kind: 'estimated';
|
|
324
|
+
value: number;
|
|
325
|
+
asOf?: string;
|
|
326
|
+
} | {
|
|
327
|
+
kind: 'unavailable';
|
|
328
|
+
reason?: string;
|
|
329
|
+
};
|
|
330
|
+
|
|
140
331
|
/** Per-object configuration controlling domain-knowledge generation and exposure. */
|
|
141
332
|
export declare interface DomainKnowledgeConfig {
|
|
142
333
|
enabled?: boolean;
|