shutro 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +99 -2
- package/dist/audit/index.d.ts +59 -0
- package/dist/audit/index.js +96 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +11 -0
- package/dist/cli/cli.d.ts +10 -0
- package/dist/cli/cli.js +164 -0
- package/dist/cli/config.d.ts +18 -0
- package/dist/cli/config.js +49 -0
- package/dist/cli/errors.d.ts +16 -0
- package/dist/cli/errors.js +23 -0
- package/dist/cli/generate/generate.d.ts +33 -0
- package/dist/cli/generate/generate.js +84 -0
- package/dist/cli/generate/render.d.ts +23 -0
- package/dist/cli/generate/render.js +249 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.js +12 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +65 -0
- package/dist/cli/inspect.d.ts +10 -0
- package/dist/cli/inspect.js +82 -0
- package/dist/cli/packages.d.ts +6 -0
- package/dist/cli/packages.js +6 -0
- package/dist/cli/project.d.ts +18 -0
- package/dist/cli/project.js +39 -0
- package/dist/cli/resolve.d.ts +2 -0
- package/dist/cli/resolve.js +28 -0
- package/dist/core/compute/graph.d.ts +52 -0
- package/dist/core/compute/graph.js +162 -0
- package/dist/core/data/data.d.ts +59 -0
- package/dist/core/data/data.js +119 -0
- package/dist/core/data/load.d.ts +37 -0
- package/dist/core/data/load.js +236 -0
- package/dist/core/env/env.d.ts +468 -0
- package/dist/core/env/env.js +916 -0
- package/dist/core/env/identity.d.ts +43 -0
- package/dist/core/env/identity.js +65 -0
- package/dist/core/env/inspector.d.ts +55 -0
- package/dist/core/env/inspector.js +85 -0
- package/dist/core/env/time.d.ts +12 -0
- package/dist/core/env/time.js +38 -0
- package/dist/core/errors.d.ts +256 -0
- package/dist/core/errors.js +360 -0
- package/dist/core/events/events.d.ts +44 -0
- package/dist/core/events/events.js +58 -0
- package/dist/core/events/workers.d.ts +56 -0
- package/dist/core/events/workers.js +155 -0
- package/dist/core/index.d.ts +51 -0
- package/dist/core/index.js +42 -0
- package/dist/core/model/company.d.ts +6 -0
- package/dist/core/model/company.js +31 -0
- package/dist/core/model/faces.d.ts +42 -0
- package/dist/core/model/faces.js +1 -0
- package/dist/core/model/field.d.ts +479 -0
- package/dist/core/model/field.js +461 -0
- package/dist/core/model/generated.d.ts +77 -0
- package/dist/core/model/generated.js +1 -0
- package/dist/core/model/id.d.ts +33 -0
- package/dist/core/model/id.js +4 -0
- package/dist/core/model/model.d.ts +387 -0
- package/dist/core/model/model.js +566 -0
- package/dist/core/model/partition.d.ts +31 -0
- package/dist/core/model/partition.js +71 -0
- package/dist/core/model/related.d.ts +17 -0
- package/dist/core/model/related.js +60 -0
- package/dist/core/model/typed.d.ts +107 -0
- package/dist/core/model/typed.js +46 -0
- package/dist/core/money/currency.d.ts +39 -0
- package/dist/core/money/currency.js +37 -0
- package/dist/core/money/decimal.d.ts +26 -0
- package/dist/core/money/decimal.js +51 -0
- package/dist/core/money/fx.d.ts +68 -0
- package/dist/core/money/fx.js +124 -0
- package/dist/core/money/money.d.ts +84 -0
- package/dist/core/money/money.js +173 -0
- package/dist/core/money/quantity.d.ts +67 -0
- package/dist/core/money/quantity.js +108 -0
- package/dist/core/money/rounding.d.ts +11 -0
- package/dist/core/money/rounding.js +12 -0
- package/dist/core/recordset/aggregate.d.ts +22 -0
- package/dist/core/recordset/aggregate.js +258 -0
- package/dist/core/recordset/audit.d.ts +33 -0
- package/dist/core/recordset/audit.js +262 -0
- package/dist/core/recordset/compute.d.ts +36 -0
- package/dist/core/recordset/compute.js +414 -0
- package/dist/core/recordset/constraints.d.ts +9 -0
- package/dist/core/recordset/constraints.js +61 -0
- package/dist/core/recordset/domain.d.ts +31 -0
- package/dist/core/recordset/domain.js +300 -0
- package/dist/core/recordset/onchange.d.ts +43 -0
- package/dist/core/recordset/onchange.js +240 -0
- package/dist/core/recordset/recordset.d.ts +110 -0
- package/dist/core/recordset/recordset.js +789 -0
- package/dist/core/recordset/relations.d.ts +15 -0
- package/dist/core/recordset/relations.js +13 -0
- package/dist/core/recordset/rls.d.ts +15 -0
- package/dist/core/recordset/rls.js +108 -0
- package/dist/core/recordset/security.d.ts +56 -0
- package/dist/core/recordset/security.js +269 -0
- package/dist/core/recordset/sequences.d.ts +31 -0
- package/dist/core/recordset/sequences.js +154 -0
- package/dist/core/recordset/source.d.ts +9 -0
- package/dist/core/recordset/source.js +19 -0
- package/dist/core/recordset/sqlErrors.d.ts +6 -0
- package/dist/core/recordset/sqlErrors.js +39 -0
- package/dist/core/recordset/transitions.d.ts +10 -0
- package/dist/core/recordset/transitions.js +80 -0
- package/dist/core/recordset/types.d.ts +415 -0
- package/dist/core/recordset/types.js +8 -0
- package/dist/core/recordset/values.d.ts +33 -0
- package/dist/core/recordset/values.js +177 -0
- package/dist/core/recordset/writes.d.ts +42 -0
- package/dist/core/recordset/writes.js +786 -0
- package/dist/core/registry/ddl.d.ts +31 -0
- package/dist/core/registry/ddl.js +174 -0
- package/dist/core/registry/extension.d.ts +94 -0
- package/dist/core/registry/extension.js +90 -0
- package/dist/core/registry/module.d.ts +89 -0
- package/dist/core/registry/module.js +98 -0
- package/dist/core/registry/registry.d.ts +130 -0
- package/dist/core/registry/registry.js +591 -0
- package/dist/core/security/runtime.d.ts +102 -0
- package/dist/core/security/runtime.js +232 -0
- package/dist/driver-pg/driver.d.ts +88 -0
- package/dist/driver-pg/driver.js +177 -0
- package/dist/driver-pg/errors.d.ts +72 -0
- package/dist/driver-pg/errors.js +182 -0
- package/dist/driver-pg/index.d.ts +7 -0
- package/dist/driver-pg/index.js +7 -0
- package/dist/i18n/index.d.ts +25 -0
- package/dist/i18n/index.js +51 -0
- package/dist/migrate/apply.d.ts +78 -0
- package/dist/migrate/apply.js +167 -0
- package/dist/migrate/catalog.d.ts +10 -0
- package/dist/migrate/catalog.js +122 -0
- package/dist/migrate/diff.d.ts +98 -0
- package/dist/migrate/diff.js +160 -0
- package/dist/migrate/errors.d.ts +21 -0
- package/dist/migrate/errors.js +31 -0
- package/dist/migrate/index.d.ts +18 -0
- package/dist/migrate/index.js +18 -0
- package/dist/migrate/render.d.ts +5 -0
- package/dist/migrate/render.js +101 -0
- package/dist/migrate/schema.d.ts +61 -0
- package/dist/migrate/schema.js +233 -0
- package/dist/security/index.d.ts +147 -0
- package/dist/security/index.js +278 -0
- package/dist/sequence/index.d.ts +63 -0
- package/dist/sequence/index.js +106 -0
- package/dist/sql/ast.d.ts +49 -0
- package/dist/sql/ast.js +47 -0
- package/dist/sql/builder/builder.d.ts +215 -0
- package/dist/sql/builder/builder.js +308 -0
- package/dist/sql/builder/expression.d.ts +80 -0
- package/dist/sql/builder/expression.js +126 -0
- package/dist/sql/compile.d.ts +18 -0
- package/dist/sql/compile.js +41 -0
- package/dist/sql/errors.d.ts +13 -0
- package/dist/sql/errors.js +16 -0
- package/dist/sql/index.d.ts +19 -0
- package/dist/sql/index.js +19 -0
- package/dist/sql/tag.d.ts +47 -0
- package/dist/sql/tag.js +123 -0
- package/package.json +82 -4
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recordset runtime (RFC 0004): identity map per transaction, prefetch groups, batched loads, typed access, and
|
|
3
|
+
* the entry points of writes (see writes.ts) and computes (see compute.ts).
|
|
4
|
+
*/
|
|
5
|
+
import type { AuditEntry } from '../../audit/index.js';
|
|
6
|
+
import { type Translations } from '../../i18n/index.js';
|
|
7
|
+
import { type Env, type ScopeInternals } from '../env/env.js';
|
|
8
|
+
import type { AnyModel } from '../model/model.js';
|
|
9
|
+
import { type Currency } from '../money/currency.js';
|
|
10
|
+
import { type Uom } from '../money/quantity.js';
|
|
11
|
+
import type { RegisteredModel } from '../registry/registry.js';
|
|
12
|
+
import { type AggregateQueryRaw } from './aggregate.js';
|
|
13
|
+
import { type OnchangeInputRaw, type OnchangeResultRaw } from './onchange.js';
|
|
14
|
+
/** Field values of one record. Scalars as values, many2one as id | null, x2many as id arrays. */
|
|
15
|
+
type Values = Map<string, unknown>;
|
|
16
|
+
/** The per-transaction identity map and value-object caches (RFC 0004 §7.4). */
|
|
17
|
+
export interface RecordCache {
|
|
18
|
+
readonly records: Map<string, Map<number, Values>>;
|
|
19
|
+
readonly currencies: Map<number, Currency>;
|
|
20
|
+
readonly uoms: Map<number, Uom>;
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
export declare function createRecordCache(): RecordCache;
|
|
24
|
+
/** Stored, non-binary, not x2many (RFC 0004 §6.1). */
|
|
25
|
+
export declare function defaultKeys(model: AnyModel): string[];
|
|
26
|
+
/** Ids shared by the records loaded together (RFC 0004 §7.3). */
|
|
27
|
+
interface Group {
|
|
28
|
+
readonly ids: readonly number[];
|
|
29
|
+
}
|
|
30
|
+
interface Pending {
|
|
31
|
+
readonly parentModel: AnyModel;
|
|
32
|
+
readonly key: string;
|
|
33
|
+
/** The parent record(s) this set belongs to. */
|
|
34
|
+
readonly own: readonly number[];
|
|
35
|
+
/** Every parent of the prefetch group: loading fetches the relation for all of them. */
|
|
36
|
+
readonly parents: readonly number[];
|
|
37
|
+
}
|
|
38
|
+
/** @internal Runtime recordset. Typed through `RecordSet` / `Rec` / `PendingSet` (types.ts). */
|
|
39
|
+
export declare class RecordSetImpl {
|
|
40
|
+
#private;
|
|
41
|
+
readonly env: Env;
|
|
42
|
+
readonly registered: RegisteredModel;
|
|
43
|
+
readonly modelName: string;
|
|
44
|
+
constructor(env: Env, registered: RegisteredModel, ids: readonly number[] | undefined, group: Group | undefined, pending: Pending | undefined);
|
|
45
|
+
get model(): AnyModel;
|
|
46
|
+
get ids(): readonly number[];
|
|
47
|
+
get length(): number;
|
|
48
|
+
isEmpty(): boolean;
|
|
49
|
+
[Symbol.iterator](): Iterator<RecordSetImpl>;
|
|
50
|
+
first(): RecordSetImpl;
|
|
51
|
+
ensureOne(): RecordSetImpl;
|
|
52
|
+
/** The record's id (singletons only). */
|
|
53
|
+
get id(): number;
|
|
54
|
+
map<T>(fn: (record: never, index: number) => T): T[];
|
|
55
|
+
filter(fn: (record: never, index: number) => boolean): RecordSetImpl;
|
|
56
|
+
mapped(key: string): unknown[];
|
|
57
|
+
sum(key: string, currency?: Currency | {
|
|
58
|
+
readonly id: number;
|
|
59
|
+
} | number): unknown;
|
|
60
|
+
load(spec?: unknown): Promise<RecordSetImpl>;
|
|
61
|
+
/** Updates the records in the cache now; flushed at the next flush point. */
|
|
62
|
+
write(values: Readonly<Record<string, unknown>>, options?: {
|
|
63
|
+
readonly expect?: Readonly<Record<string, unknown>>;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
/** Deletes the records now. */
|
|
66
|
+
unlink(): Promise<void>;
|
|
67
|
+
/** Ids of a pending x2many set, loading them if needed. */
|
|
68
|
+
resolveIds(): Promise<readonly number[]>;
|
|
69
|
+
read(keys: readonly string[]): Record<string, unknown>[];
|
|
70
|
+
toJSON(): readonly number[];
|
|
71
|
+
/** The full translation map of a translatable field of a singleton (`null` when empty). */
|
|
72
|
+
translations(key: string): Translations | null;
|
|
73
|
+
/** The audit rows of these records, newest first (RFC 0013 §7.4). Pending changes are flushed first. */
|
|
74
|
+
trail(options?: {
|
|
75
|
+
readonly field?: string;
|
|
76
|
+
readonly limit?: number;
|
|
77
|
+
readonly action?: AuditEntry['action'];
|
|
78
|
+
/** Rows older than this row id (pagination: the last `id` of the previous page). */
|
|
79
|
+
readonly before?: number;
|
|
80
|
+
}): Promise<AuditEntry[]>;
|
|
81
|
+
/** Numbers unnumbered records of a manual sequence field (RFC 0012 §7.4). */
|
|
82
|
+
assignNumber(key: string, options?: {
|
|
83
|
+
readonly date?: string | undefined;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
/** @internal Runs a transition of state field `key` on these records (RFC 0010 §7.2). */
|
|
86
|
+
transition(key: string, name: string): Promise<void>;
|
|
87
|
+
/** Transition names the current state allows (singleton, state loaded). Defaults to the model's state field. */
|
|
88
|
+
transitions(key?: string): string[];
|
|
89
|
+
/** @internal Assigns a computed field of a singleton from inside its compute (RFC 0008 §7.5). */
|
|
90
|
+
assign(key: string, value: unknown): void;
|
|
91
|
+
/** @internal Reads field `key` of a singleton from the cache. */
|
|
92
|
+
fieldValue(key: string): unknown;
|
|
93
|
+
}
|
|
94
|
+
/** @internal The currency value object of a `res.currency` id, loaded through the cache. */
|
|
95
|
+
export declare function currencyById(internals: ScopeInternals, id: number): Promise<Currency>;
|
|
96
|
+
/** @internal The currency id of a company (`res.company.currency`). */
|
|
97
|
+
export declare function companyCurrencyId(internals: ScopeInternals, company: number): Promise<number>;
|
|
98
|
+
/** @internal Flushes the unit of work (every model, or one): pending computes first, then the dirty records. */
|
|
99
|
+
export declare function flushAll(internals: ScopeInternals, model?: string): Promise<void>;
|
|
100
|
+
/** @internal `env.model(name)`. */
|
|
101
|
+
export declare function modelRef(env: Env, name: string): {
|
|
102
|
+
modelName: string;
|
|
103
|
+
create(rows: readonly Readonly<Record<string, unknown>>[]): Promise<RecordSetImpl>;
|
|
104
|
+
search(query?: unknown): Promise<RecordSetImpl>;
|
|
105
|
+
browse(ids: readonly number[]): RecordSetImpl;
|
|
106
|
+
onchange(input: OnchangeInputRaw): Promise<OnchangeResultRaw>;
|
|
107
|
+
copy(rows: readonly Readonly<Record<string, unknown>>[]): Promise<RecordSetImpl>;
|
|
108
|
+
aggregate(query: AggregateQueryRaw): Promise<Record<string, unknown>[]>;
|
|
109
|
+
};
|
|
110
|
+
export {};
|