@mistriwork/engine 1.0.0-rc.77 → 1.0.0-rc.79
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/adapters/adapter.d.ts +6 -0
- package/dist/adapters/postgres.js +13 -7
- package/dist/adapters/scoped/scopedReads.js +5 -1
- package/dist/adapters/scoped/scopedTransaction.js +3 -1
- package/dist/adapters/sqlite.js +7 -5
- package/dist/server/columnGrants.d.ts +3 -0
- package/dist/server/columnGrants.js +29 -4
- package/dist/server/http/probes.d.ts +10 -1
- package/dist/server/http/probes.js +6 -2
- package/dist/server/http/recordWrites.js +7 -1
- package/dist/server/http/serverCore.d.ts +2 -1
- package/dist/server/migrate/cli.js +7 -0
- package/dist/server/resourceReadOperations.js +5 -1
- package/dist/shared/aggregate.js +7 -1
- package/dist/shared/computedParse.d.ts +2 -0
- package/dist/shared/computedParse.js +1 -1
- package/dist/shared/computedWhere.d.ts +47 -0
- package/dist/shared/computedWhere.js +159 -0
- package/dist/shared/filter.d.ts +5 -0
- package/dist/shared/filter.js +4 -0
- package/dist/shared/query.js +20 -22
- package/dist/shared/queryDates.d.ts +16 -0
- package/dist/shared/queryDates.js +29 -0
- package/dist/shared/queryOperands.d.ts +24 -0
- package/dist/shared/queryOperands.js +36 -0
- package/dist/shared/refusal.d.ts +8 -0
- package/dist/shared/refusal.js +15 -0
- package/dist/shared/resourceHttp.d.ts +1 -1
- package/dist/shared/rowCondition.d.ts +5 -0
- package/dist/shared/rowCondition.js +80 -0
- package/dist/shared/schema.d.ts +10 -0
- package/dist/shared/schema.js +8 -0
- package/dist/shared/scopeCatalog.d.ts +1 -1
- package/dist/shared/scopeCatalog.js +13 -1
- package/dist/shared/servedApp.d.ts +19 -0
- package/dist/shared/structuredFilter.d.ts +3 -0
- package/dist/shared/viewLabels.d.ts +6 -1
- package/dist/shared/viewLabels.js +1 -1
- package/package.json +2 -1
- package/schema/model.d.ts +12 -3
|
@@ -605,6 +605,8 @@ export interface ServedResource {
|
|
|
605
605
|
favorite?: true;
|
|
606
606
|
/** Its one row is a settings record, opened from the reader's settings under these words. */
|
|
607
607
|
settings?: string;
|
|
608
|
+
/** The condition (query language) that freezes a record: one it matches takes no write, and the page draws it read-only. */
|
|
609
|
+
frozen?: string;
|
|
608
610
|
/** What one record is called and several: New, a split's detail heading. */
|
|
609
611
|
noun?: AppNoun;
|
|
610
612
|
/** Its rows are files, as appFileRules resolved them: a list over it draws as attachments. */
|
|
@@ -711,9 +713,26 @@ export interface ServedApp<View extends object = ServedDashboardView | ServedFor
|
|
|
711
713
|
ai?: {
|
|
712
714
|
label: string;
|
|
713
715
|
};
|
|
716
|
+
/** The App-wide choices this reader can make (an App's `choose`), by name: each a table id of this reader's catalog,
|
|
717
|
+
the column its chooser shows, and whether the shell asks before the first page. A choice over a table this
|
|
718
|
+
reader cannot read is not here. */
|
|
719
|
+
choose?: Record<string, ServedChoice>;
|
|
720
|
+
/** The picks this person holds on the server, by choice name, each the row's key as text and proven under this reader
|
|
721
|
+
(a pick they can no longer read is left out). Present, even empty, only where the database keeps the preferences
|
|
722
|
+
store: it is how the shell knows a pick is written there too, and not only in the browser. */
|
|
723
|
+
picks?: Record<string, string>;
|
|
714
724
|
/** This reader may approve something an AI can propose: For review, `/{app}/review`, and the proposals list. */
|
|
715
725
|
review?: true;
|
|
716
726
|
}
|
|
727
|
+
/** One App-wide choice as the shell draws it (ServedApp.choose). */
|
|
728
|
+
export interface ServedChoice {
|
|
729
|
+
/** The table id the choice is a row of. */
|
|
730
|
+
table: string;
|
|
731
|
+
/** The column its chooser shows for a row; absent, the record's own label. */
|
|
732
|
+
label?: string;
|
|
733
|
+
/** The shell asks before the first page. */
|
|
734
|
+
required?: true;
|
|
735
|
+
}
|
|
717
736
|
/** A menu node as the view order reads it: a view's reference, a group of nodes, or a link elsewhere. */
|
|
718
737
|
export type ServedNavNode = {
|
|
719
738
|
view: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FilterComputed } from './computedWhere.js';
|
|
1
2
|
import type { Op } from './filter.js';
|
|
2
3
|
export type StructuredScalar = string | number | boolean | null;
|
|
3
4
|
/** A validated condition, shared by execution and transport. Parsing may build
|
|
@@ -18,5 +19,7 @@ type StructuredCondition<Field extends 'column' | 'path'> = Record<Field, string
|
|
|
18
19
|
} : never));
|
|
19
20
|
export interface StructuredFilter<Field extends 'column' | 'path' = 'column'> {
|
|
20
21
|
groups: Array<Array<StructuredCondition<Field>>>;
|
|
22
|
+
/** The computed columns a column filter's conditions name, each checked where it is written (computedWhere.ts). */
|
|
23
|
+
computed?: Field extends 'column' ? FilterComputed : never;
|
|
21
24
|
}
|
|
22
25
|
export {};
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* from view.ts, which plans the joins these qualify against.
|
|
6
6
|
*/
|
|
7
7
|
import type { AnyRows, Condition, SqlStyle } from './filter.js';
|
|
8
|
-
import { type DatabaseSchema } from './schema.js';
|
|
8
|
+
import { type ColumnMeta, type DatabaseSchema } from './schema.js';
|
|
9
9
|
import type { JoinPlan } from './view.js';
|
|
10
10
|
import { type ResolvedPath, type ViewDef } from './viewPaths.js';
|
|
11
|
+
import { type ValueKind } from './computed.js';
|
|
11
12
|
import type { ScopedRelations } from './rowScope.js';
|
|
12
13
|
/**
|
|
13
14
|
* A view's paths, resolved and written against one join plan.
|
|
@@ -30,6 +31,10 @@ export declare function viewPaths(schema: DatabaseSchema, view: ViewDef, plan: J
|
|
|
30
31
|
exists: (rows: AnyRows) => string;
|
|
31
32
|
typeOf: (path: string) => string | undefined;
|
|
32
33
|
};
|
|
34
|
+
export declare function columnRead(column: ColumnMeta | undefined): {
|
|
35
|
+
kind: ValueKind;
|
|
36
|
+
native?: boolean;
|
|
37
|
+
} | undefined;
|
|
33
38
|
/**
|
|
34
39
|
* The view with the record-label templates its `$label` paths need, read from
|
|
35
40
|
* a catalog that serves them (an App's, `TableMeta.labelTemplate`) — and with
|
|
@@ -404,7 +404,7 @@ function dayText(value, style, literal) {
|
|
|
404
404
|
return `CASE WHEN ${iso} THEN ${style.concat([month, day, literal(', '), `SUBSTR(${value}, 1, 4)`])} ELSE COALESCE(${value}, '') END`;
|
|
405
405
|
}
|
|
406
406
|
/* What a stored column is to an expression that reads it: a yes-or-no column native or a 0/1 integer. */
|
|
407
|
-
function columnRead(column) {
|
|
407
|
+
export function columnRead(column) {
|
|
408
408
|
if (!column)
|
|
409
409
|
return undefined;
|
|
410
410
|
if (isFlagColumn(column))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/engine",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.79",
|
|
4
4
|
"description": "The engine both products stand on: the adapters (SQLite, Postgres), the catalog, the query language, keyset pages, the HTTP kit and the shared rules. No React.",
|
|
5
5
|
"homepage": "https://mistriwork.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -237,6 +237,7 @@
|
|
|
237
237
|
"./shared/resourceHttp.js": "./dist/shared/resourceHttp.js",
|
|
238
238
|
"./shared/richText.js": "./dist/shared/richText.js",
|
|
239
239
|
"./shared/rollups.js": "./dist/shared/rollups.js",
|
|
240
|
+
"./shared/rowCondition.js": "./dist/shared/rowCondition.js",
|
|
240
241
|
"./shared/rowScope.js": "./dist/shared/rowScope.js",
|
|
241
242
|
"./shared/runtimeTables.js": "./dist/shared/runtimeTables.js",
|
|
242
243
|
"./shared/schema.js": "./dist/shared/schema.js",
|
package/schema/model.d.ts
CHANGED
|
@@ -61,6 +61,11 @@ export type StaticAppTarget = AppTarget<string | number>;
|
|
|
61
61
|
* `{ record }` and `{ tenant }` are read when the form is prepared, so they
|
|
62
62
|
* fill a field of the input itself; `{ record }` on a command that targets one
|
|
63
63
|
* record.
|
|
64
|
+
*
|
|
65
|
+
* `{ answer: 'treatment.usual_fee' }` starts from another input's pick: the column of the row a choice from a table
|
|
66
|
+
* has picked (`field.choice({ from, labelColumn })`), or the key of the `values` a static option carries. It is
|
|
67
|
+
* filled when the person picks, in an input they have not edited, and stays theirs to change. The choice is another
|
|
68
|
+
* input of the same list: of the input itself, or of the same group or line. No input filled this way is another's source.
|
|
64
69
|
*/
|
|
65
70
|
export type CommandFieldDefault =
|
|
66
71
|
| string
|
|
@@ -68,7 +73,8 @@ export type CommandFieldDefault =
|
|
|
68
73
|
| boolean
|
|
69
74
|
| { readonly auto: 'today' | 'now' | 'me' }
|
|
70
75
|
| { readonly record: string }
|
|
71
|
-
| { readonly tenant: string }
|
|
76
|
+
| { readonly tenant: string }
|
|
77
|
+
| { readonly answer: string };
|
|
72
78
|
|
|
73
79
|
/** One option of a `choice` input. */
|
|
74
80
|
export interface AppCommandChoice {
|
|
@@ -83,8 +89,11 @@ export interface AppCommandChoice {
|
|
|
83
89
|
`tenant.<column>` alone (`"tenant.country = 'IN'"`), shared through `auth.tenancy.shared`. Judged as the form
|
|
84
90
|
is prepared or a public form is served; a submitted withheld value is refused as no choice. */
|
|
85
91
|
when?: string;
|
|
86
|
-
/**
|
|
87
|
-
|
|
92
|
+
/** What picking this option fills into other inputs of the form: the keys inputs name in `default: { answer: '<this input>.<key>' }`. Scalars only. */
|
|
93
|
+
values?: Readonly<Record<string, string | number | boolean | null>>;
|
|
94
|
+
/** Set by the server on a table's row it served (`source.served`): the columns its `where` compares and the ones
|
|
95
|
+
other inputs start from (`default: { answer }`), so the page offers the rows the answers given match, and fills
|
|
96
|
+
from the pick, without a read of its own. Never written in an App. */
|
|
88
97
|
row?: Readonly<Record<string, string | number | boolean | null>>;
|
|
89
98
|
}
|
|
90
99
|
|