@atscript/ui 0.1.151 → 0.1.153
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/dist/index.cjs +337 -252
- package/dist/index.d.cts +67 -12
- package/dist/index.d.mts +67 -12
- package/dist/index.mjs +336 -254
- package/package.json +10 -10
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializedAnnotatedType, TValidatorOptions, TValidatorPlugin } from "@atscript/typescript/utils";
|
|
2
|
-
import { Client, FilterExpr, TCrudOp, TCrudPermissions, TCrudPermissions as TCrudPermissions$1, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionLevel, TDbActionProcessor } from "@atscript/db-client";
|
|
2
|
+
import { Client, ClientOptions, FilterExpr, TCrudOp, TCrudPermissions, TCrudPermissions as TCrudPermissions$1, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionLevel, TDbActionProcessor } from "@atscript/db-client";
|
|
3
3
|
|
|
4
4
|
//#region src/shared/annotation-keys.d.ts
|
|
5
5
|
declare const UI_TYPE: "ui.type";
|
|
@@ -1439,22 +1439,37 @@ declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
|
1439
1439
|
declare function optionValue(option: NonNullable<ColumnDef["options"]>[number]): string | number | boolean;
|
|
1440
1440
|
//#endregion
|
|
1441
1441
|
//#region src/client-factory.d.ts
|
|
1442
|
+
/**
|
|
1443
|
+
* Client options the library itself may ask a {@link ClientFactory} for —
|
|
1444
|
+
* spread them into the `Client` options your factory builds:
|
|
1445
|
+
*
|
|
1446
|
+
* ```ts
|
|
1447
|
+
* setDefaultClientFactory((url, opts) => new Client(url, { ...opts, fetch: myFetch }))
|
|
1448
|
+
* ```
|
|
1449
|
+
*
|
|
1450
|
+
* - `metaKey` — the store key for `/meta` revalidation, set when a table is
|
|
1451
|
+
* given `metaKey` (e.g. the route template of a parametric mount). Since 0.1.153.
|
|
1452
|
+
* - `metaStore` — `false` during server rendering, so `/meta` bodies are never
|
|
1453
|
+
* kept in a process-wide store shared by every viewer. Since 0.1.153.
|
|
1454
|
+
*/
|
|
1455
|
+
type ClientFactoryOptions = Pick<ClientOptions, "metaKey" | "metaStore">;
|
|
1442
1456
|
/**
|
|
1443
1457
|
* Factory that creates a `Client` for a given URL.
|
|
1444
1458
|
*
|
|
1445
1459
|
* Single contract shared by every atscript-ui primitive that needs to talk
|
|
1446
1460
|
* to an atscript-db-compatible endpoint: table composables, FK value-help,
|
|
1447
1461
|
* and any future consumer. Produces a `Client` configured with whatever
|
|
1448
|
-
* transport / auth wiring the host application wants.
|
|
1462
|
+
* transport / auth wiring the host application wants. Forward the optional
|
|
1463
|
+
* second argument ({@link ClientFactoryOptions}) into the `Client` options.
|
|
1449
1464
|
*/
|
|
1450
|
-
type ClientFactory = (url: string) => Client;
|
|
1465
|
+
type ClientFactory = (url: string, options?: ClientFactoryOptions) => Client;
|
|
1451
1466
|
/**
|
|
1452
1467
|
* Override the app-wide default factory. Call once at startup (e.g. in
|
|
1453
1468
|
* `entry-client.ts`) to wire shared fetch, credentials, error handling, etc.
|
|
1454
1469
|
* Every table, value-help picker, and other client consumer will pick it up.
|
|
1455
1470
|
*/
|
|
1456
1471
|
declare function setDefaultClientFactory(factory: ClientFactory): void;
|
|
1457
|
-
/** Current app-wide default factory. Falls back to `new Client(url)`. */
|
|
1472
|
+
/** Current app-wide default factory. Falls back to `new Client(url, options)`. */
|
|
1458
1473
|
declare function getDefaultClientFactory(): ClientFactory;
|
|
1459
1474
|
/** Reset the default factory to the built-in one (primarily for tests). */
|
|
1460
1475
|
declare function resetDefaultClientFactory(): void;
|
|
@@ -1467,10 +1482,14 @@ declare function resetDefaultClientFactory(): void;
|
|
|
1467
1482
|
* `resolveValueHelp` and `useTable` route through it so a given URL triggers
|
|
1468
1483
|
* at most one network round-trip and one `deserializeAnnotatedType`.
|
|
1469
1484
|
*
|
|
1485
|
+
* Byte-identical `/meta` bodies (same `ETag`, e.g. one parametric controller
|
|
1486
|
+
* under different route params) also share the deserialized type and the
|
|
1487
|
+
* `TableDef` across URLs.
|
|
1488
|
+
*
|
|
1470
1489
|
* `/meta` is projected per viewer, so the cache belongs to one identity
|
|
1471
1490
|
* (`setMetaCacheIdentity`) and exists only in the browser: during server
|
|
1472
1491
|
* rendering one process serves many viewers, so every call builds a fresh,
|
|
1473
|
-
* uncached entry.
|
|
1492
|
+
* uncached entry whose client keeps no `/meta` store.
|
|
1474
1493
|
*/
|
|
1475
1494
|
interface MetaCacheEntry {
|
|
1476
1495
|
client: Client;
|
|
@@ -1479,16 +1498,38 @@ interface MetaCacheEntry {
|
|
|
1479
1498
|
resolved?: Promise<ResolvedValueHelp>;
|
|
1480
1499
|
tableDef?: Promise<TableDef>;
|
|
1481
1500
|
}
|
|
1501
|
+
/** Options for {@link getMetaEntry}. */
|
|
1502
|
+
interface MetaEntryOptions {
|
|
1503
|
+
/**
|
|
1504
|
+
* Key under which the `/meta` revalidation store keeps this URL's `ETag`s
|
|
1505
|
+
* (default: the `/meta` URL). Give every URL of one parametric mount the
|
|
1506
|
+
* route template (e.g. `"/api/db/ticket-issue/:key"`): a new route param
|
|
1507
|
+
* then revalidates against the body already loaded for another one and
|
|
1508
|
+
* costs a `304` instead of the full `/meta`. Forwarded to the
|
|
1509
|
+
* {@link ClientFactory} as `metaKey`; honoured only by the first call per
|
|
1510
|
+
* URL, like the factory. Since 0.1.153.
|
|
1511
|
+
*/
|
|
1512
|
+
metaKey?: string;
|
|
1513
|
+
}
|
|
1482
1514
|
/**
|
|
1483
|
-
* Get or create the cache entry for `url`. First caller's `factory`
|
|
1484
|
-
* `Client`; subsequent callers reuse it. On
|
|
1485
|
-
* evicted so the next call retries. Without a
|
|
1486
|
-
* cached
|
|
1515
|
+
* Get or create the cache entry for `url`. First caller's `factory` (and
|
|
1516
|
+
* `options.metaKey`) seeds the `Client`; subsequent callers reuse it. On
|
|
1517
|
+
* `meta` rejection, the entry is evicted so the next call retries. Without a
|
|
1518
|
+
* browser `window` nothing is cached and the client is asked for
|
|
1519
|
+
* `metaStore: false`.
|
|
1487
1520
|
*/
|
|
1488
|
-
declare function getMetaEntry(url: string, factory?: ClientFactory): MetaCacheEntry;
|
|
1521
|
+
declare function getMetaEntry(url: string, factory?: ClientFactory, options?: MetaEntryOptions): MetaCacheEntry;
|
|
1522
|
+
/**
|
|
1523
|
+
* The `TableDef` for a cache entry, built once per entry — and once per
|
|
1524
|
+
* `/meta` `ETag` across entries. Since 0.1.153.
|
|
1525
|
+
*/
|
|
1526
|
+
declare function getMetaTableDef(entry: MetaCacheEntry): Promise<TableDef>;
|
|
1489
1527
|
/**
|
|
1490
1528
|
* Drop every cached `/meta` — including the copy each cached `Client`
|
|
1491
|
-
* memoizes
|
|
1529
|
+
* memoizes and the `@atscript/db-client` meta stores used to revalidate it
|
|
1530
|
+
* (the shared default one and any custom one a factory supplied) — the
|
|
1531
|
+
* value-help searches shared under them, and everything registered through
|
|
1532
|
+
* {@link onMetaCacheReset} (e.g. the table-presets cache). Entries already
|
|
1492
1533
|
* handed out keep working; the next `getMetaEntry` refetches.
|
|
1493
1534
|
*/
|
|
1494
1535
|
declare function resetMetaCache(): void;
|
|
@@ -1498,8 +1539,22 @@ declare function resetMetaCache(): void;
|
|
|
1498
1539
|
* every reload of the current user. A key that differs from the previous
|
|
1499
1540
|
* one resets the cache (`resetMetaCache`); the same key keeps it. `null` /
|
|
1500
1541
|
* `undefined` = anonymous.
|
|
1542
|
+
*
|
|
1543
|
+
* Binding an identity also turns on caches that are only safe when the app
|
|
1544
|
+
* reports sign-in changes, such as the table-presets cache.
|
|
1501
1545
|
*/
|
|
1502
1546
|
declare function setMetaCacheIdentity(key: string | null | undefined): void;
|
|
1547
|
+
/**
|
|
1548
|
+
* The identity last passed to {@link setMetaCacheIdentity}: `undefined` when
|
|
1549
|
+
* the app never bound one, `null` for anonymous. Since 0.1.153.
|
|
1550
|
+
*/
|
|
1551
|
+
declare function getMetaCacheIdentity(): string | null | undefined;
|
|
1552
|
+
/**
|
|
1553
|
+
* Run `listener` on every {@link resetMetaCache} (and so on every identity
|
|
1554
|
+
* change). For caches that belong to the signed-in viewer. Returns an
|
|
1555
|
+
* unsubscribe function. Since 0.1.153.
|
|
1556
|
+
*/
|
|
1557
|
+
declare function onMetaCacheReset(listener: () => void): () => void;
|
|
1503
1558
|
//#endregion
|
|
1504
1559
|
//#region src/shared/str.d.ts
|
|
1505
1560
|
/** Escape special regex characters in user input for safe embedding in a `$regex` filter. */
|
|
@@ -1573,4 +1628,4 @@ interface TModelRoute {
|
|
|
1573
1628
|
*/
|
|
1574
1629
|
declare function buildModelRoutes(models: readonly TAtscriptAnnotatedType[]): TModelRoute[];
|
|
1575
1630
|
//#endregion
|
|
1576
|
-
export { type ClientFactory, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
|
|
1631
|
+
export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializedAnnotatedType, TValidatorOptions, TValidatorPlugin } from "@atscript/typescript/utils";
|
|
2
|
-
import { Client, FilterExpr, TCrudOp, TCrudPermissions, TCrudPermissions as TCrudPermissions$1, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionLevel, TDbActionProcessor } from "@atscript/db-client";
|
|
2
|
+
import { Client, ClientOptions, FilterExpr, TCrudOp, TCrudPermissions, TCrudPermissions as TCrudPermissions$1, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionLevel, TDbActionProcessor } from "@atscript/db-client";
|
|
3
3
|
|
|
4
4
|
//#region src/shared/annotation-keys.d.ts
|
|
5
5
|
declare const UI_TYPE: "ui.type";
|
|
@@ -1439,22 +1439,37 @@ declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
|
1439
1439
|
declare function optionValue(option: NonNullable<ColumnDef["options"]>[number]): string | number | boolean;
|
|
1440
1440
|
//#endregion
|
|
1441
1441
|
//#region src/client-factory.d.ts
|
|
1442
|
+
/**
|
|
1443
|
+
* Client options the library itself may ask a {@link ClientFactory} for —
|
|
1444
|
+
* spread them into the `Client` options your factory builds:
|
|
1445
|
+
*
|
|
1446
|
+
* ```ts
|
|
1447
|
+
* setDefaultClientFactory((url, opts) => new Client(url, { ...opts, fetch: myFetch }))
|
|
1448
|
+
* ```
|
|
1449
|
+
*
|
|
1450
|
+
* - `metaKey` — the store key for `/meta` revalidation, set when a table is
|
|
1451
|
+
* given `metaKey` (e.g. the route template of a parametric mount). Since 0.1.153.
|
|
1452
|
+
* - `metaStore` — `false` during server rendering, so `/meta` bodies are never
|
|
1453
|
+
* kept in a process-wide store shared by every viewer. Since 0.1.153.
|
|
1454
|
+
*/
|
|
1455
|
+
type ClientFactoryOptions = Pick<ClientOptions, "metaKey" | "metaStore">;
|
|
1442
1456
|
/**
|
|
1443
1457
|
* Factory that creates a `Client` for a given URL.
|
|
1444
1458
|
*
|
|
1445
1459
|
* Single contract shared by every atscript-ui primitive that needs to talk
|
|
1446
1460
|
* to an atscript-db-compatible endpoint: table composables, FK value-help,
|
|
1447
1461
|
* and any future consumer. Produces a `Client` configured with whatever
|
|
1448
|
-
* transport / auth wiring the host application wants.
|
|
1462
|
+
* transport / auth wiring the host application wants. Forward the optional
|
|
1463
|
+
* second argument ({@link ClientFactoryOptions}) into the `Client` options.
|
|
1449
1464
|
*/
|
|
1450
|
-
type ClientFactory = (url: string) => Client;
|
|
1465
|
+
type ClientFactory = (url: string, options?: ClientFactoryOptions) => Client;
|
|
1451
1466
|
/**
|
|
1452
1467
|
* Override the app-wide default factory. Call once at startup (e.g. in
|
|
1453
1468
|
* `entry-client.ts`) to wire shared fetch, credentials, error handling, etc.
|
|
1454
1469
|
* Every table, value-help picker, and other client consumer will pick it up.
|
|
1455
1470
|
*/
|
|
1456
1471
|
declare function setDefaultClientFactory(factory: ClientFactory): void;
|
|
1457
|
-
/** Current app-wide default factory. Falls back to `new Client(url)`. */
|
|
1472
|
+
/** Current app-wide default factory. Falls back to `new Client(url, options)`. */
|
|
1458
1473
|
declare function getDefaultClientFactory(): ClientFactory;
|
|
1459
1474
|
/** Reset the default factory to the built-in one (primarily for tests). */
|
|
1460
1475
|
declare function resetDefaultClientFactory(): void;
|
|
@@ -1467,10 +1482,14 @@ declare function resetDefaultClientFactory(): void;
|
|
|
1467
1482
|
* `resolveValueHelp` and `useTable` route through it so a given URL triggers
|
|
1468
1483
|
* at most one network round-trip and one `deserializeAnnotatedType`.
|
|
1469
1484
|
*
|
|
1485
|
+
* Byte-identical `/meta` bodies (same `ETag`, e.g. one parametric controller
|
|
1486
|
+
* under different route params) also share the deserialized type and the
|
|
1487
|
+
* `TableDef` across URLs.
|
|
1488
|
+
*
|
|
1470
1489
|
* `/meta` is projected per viewer, so the cache belongs to one identity
|
|
1471
1490
|
* (`setMetaCacheIdentity`) and exists only in the browser: during server
|
|
1472
1491
|
* rendering one process serves many viewers, so every call builds a fresh,
|
|
1473
|
-
* uncached entry.
|
|
1492
|
+
* uncached entry whose client keeps no `/meta` store.
|
|
1474
1493
|
*/
|
|
1475
1494
|
interface MetaCacheEntry {
|
|
1476
1495
|
client: Client;
|
|
@@ -1479,16 +1498,38 @@ interface MetaCacheEntry {
|
|
|
1479
1498
|
resolved?: Promise<ResolvedValueHelp>;
|
|
1480
1499
|
tableDef?: Promise<TableDef>;
|
|
1481
1500
|
}
|
|
1501
|
+
/** Options for {@link getMetaEntry}. */
|
|
1502
|
+
interface MetaEntryOptions {
|
|
1503
|
+
/**
|
|
1504
|
+
* Key under which the `/meta` revalidation store keeps this URL's `ETag`s
|
|
1505
|
+
* (default: the `/meta` URL). Give every URL of one parametric mount the
|
|
1506
|
+
* route template (e.g. `"/api/db/ticket-issue/:key"`): a new route param
|
|
1507
|
+
* then revalidates against the body already loaded for another one and
|
|
1508
|
+
* costs a `304` instead of the full `/meta`. Forwarded to the
|
|
1509
|
+
* {@link ClientFactory} as `metaKey`; honoured only by the first call per
|
|
1510
|
+
* URL, like the factory. Since 0.1.153.
|
|
1511
|
+
*/
|
|
1512
|
+
metaKey?: string;
|
|
1513
|
+
}
|
|
1482
1514
|
/**
|
|
1483
|
-
* Get or create the cache entry for `url`. First caller's `factory`
|
|
1484
|
-
* `Client`; subsequent callers reuse it. On
|
|
1485
|
-
* evicted so the next call retries. Without a
|
|
1486
|
-
* cached
|
|
1515
|
+
* Get or create the cache entry for `url`. First caller's `factory` (and
|
|
1516
|
+
* `options.metaKey`) seeds the `Client`; subsequent callers reuse it. On
|
|
1517
|
+
* `meta` rejection, the entry is evicted so the next call retries. Without a
|
|
1518
|
+
* browser `window` nothing is cached and the client is asked for
|
|
1519
|
+
* `metaStore: false`.
|
|
1487
1520
|
*/
|
|
1488
|
-
declare function getMetaEntry(url: string, factory?: ClientFactory): MetaCacheEntry;
|
|
1521
|
+
declare function getMetaEntry(url: string, factory?: ClientFactory, options?: MetaEntryOptions): MetaCacheEntry;
|
|
1522
|
+
/**
|
|
1523
|
+
* The `TableDef` for a cache entry, built once per entry — and once per
|
|
1524
|
+
* `/meta` `ETag` across entries. Since 0.1.153.
|
|
1525
|
+
*/
|
|
1526
|
+
declare function getMetaTableDef(entry: MetaCacheEntry): Promise<TableDef>;
|
|
1489
1527
|
/**
|
|
1490
1528
|
* Drop every cached `/meta` — including the copy each cached `Client`
|
|
1491
|
-
* memoizes
|
|
1529
|
+
* memoizes and the `@atscript/db-client` meta stores used to revalidate it
|
|
1530
|
+
* (the shared default one and any custom one a factory supplied) — the
|
|
1531
|
+
* value-help searches shared under them, and everything registered through
|
|
1532
|
+
* {@link onMetaCacheReset} (e.g. the table-presets cache). Entries already
|
|
1492
1533
|
* handed out keep working; the next `getMetaEntry` refetches.
|
|
1493
1534
|
*/
|
|
1494
1535
|
declare function resetMetaCache(): void;
|
|
@@ -1498,8 +1539,22 @@ declare function resetMetaCache(): void;
|
|
|
1498
1539
|
* every reload of the current user. A key that differs from the previous
|
|
1499
1540
|
* one resets the cache (`resetMetaCache`); the same key keeps it. `null` /
|
|
1500
1541
|
* `undefined` = anonymous.
|
|
1542
|
+
*
|
|
1543
|
+
* Binding an identity also turns on caches that are only safe when the app
|
|
1544
|
+
* reports sign-in changes, such as the table-presets cache.
|
|
1501
1545
|
*/
|
|
1502
1546
|
declare function setMetaCacheIdentity(key: string | null | undefined): void;
|
|
1547
|
+
/**
|
|
1548
|
+
* The identity last passed to {@link setMetaCacheIdentity}: `undefined` when
|
|
1549
|
+
* the app never bound one, `null` for anonymous. Since 0.1.153.
|
|
1550
|
+
*/
|
|
1551
|
+
declare function getMetaCacheIdentity(): string | null | undefined;
|
|
1552
|
+
/**
|
|
1553
|
+
* Run `listener` on every {@link resetMetaCache} (and so on every identity
|
|
1554
|
+
* change). For caches that belong to the signed-in viewer. Returns an
|
|
1555
|
+
* unsubscribe function. Since 0.1.153.
|
|
1556
|
+
*/
|
|
1557
|
+
declare function onMetaCacheReset(listener: () => void): () => void;
|
|
1503
1558
|
//#endregion
|
|
1504
1559
|
//#region src/shared/str.d.ts
|
|
1505
1560
|
/** Escape special regex characters in user input for safe embedding in a `$regex` filter. */
|
|
@@ -1573,4 +1628,4 @@ interface TModelRoute {
|
|
|
1573
1628
|
*/
|
|
1574
1629
|
declare function buildModelRoutes(models: readonly TAtscriptAnnotatedType[]): TModelRoute[];
|
|
1575
1630
|
//#endregion
|
|
1576
|
-
export { type ClientFactory, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
|
|
1631
|
+
export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
|