@superpanel-sdk/runtime 0.2.3 → 0.7.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/README.md +30 -10
- package/dist/builder/codegen/emit.d.ts +25 -12
- package/dist/builder/codegen/emit.js +339 -78
- package/dist/builder/codegen/generate.d.ts +21 -2
- package/dist/builder/codegen/generate.js +147 -34
- package/dist/builder/company-import-graph.d.ts +2 -0
- package/dist/builder/company-import-graph.js +40 -8
- package/dist/builder/company-imports.d.ts +29 -0
- package/dist/builder/company-imports.js +122 -0
- package/dist/builder/compile/compile-sequence.d.ts +61 -8
- package/dist/builder/compile/compile-sequence.js +334 -80
- package/dist/builder/compile/function-code.d.ts +19 -3
- package/dist/builder/compile/function-code.js +123 -45
- package/dist/builder/compile/registry.d.ts +7 -3
- package/dist/builder/compile/registry.js +30 -27
- package/dist/builder/errors.d.ts +9 -0
- package/dist/builder/errors.js +17 -0
- package/dist/builder/function-params.d.ts +10 -0
- package/dist/builder/function-params.js +203 -0
- package/dist/builder/load.d.ts +70 -10
- package/dist/builder/load.js +258 -67
- package/dist/builder/paths.d.ts +9 -1
- package/dist/builder/paths.js +32 -2
- package/dist/builder/schedules.d.ts +25 -0
- package/dist/builder/schedules.js +101 -0
- package/dist/builder/slot-schema-validation.d.ts +4 -0
- package/dist/builder/slot-schema-validation.js +10 -0
- package/dist/builder/typecheck.d.ts +8 -0
- package/dist/builder/typecheck.js +102 -0
- package/dist/builder/types.d.ts +127 -19
- package/dist/builder/types.js +21 -1
- package/dist/cli/auth/auth.d.ts +37 -0
- package/dist/cli/auth/auth.js +211 -0
- package/dist/cli/auth/backend-url.d.ts +5 -0
- package/dist/cli/auth/backend-url.js +25 -0
- package/dist/cli/auth/clipboard.d.ts +9 -0
- package/dist/cli/auth/clipboard.js +38 -0
- package/dist/cli/auth/http.d.ts +20 -0
- package/dist/cli/auth/http.js +27 -0
- package/dist/cli/auth/index.d.ts +10 -0
- package/dist/cli/auth/index.js +27 -0
- package/dist/cli/auth/progress.d.ts +12 -0
- package/dist/cli/auth/progress.js +15 -0
- package/dist/cli/auth/serve-login.d.ts +8 -0
- package/dist/cli/auth/serve-login.js +24 -0
- package/dist/cli/calls/index.d.ts +177 -0
- package/dist/cli/calls/index.js +96 -0
- package/dist/cli/compile/index.js +3 -0
- package/dist/cli/config.d.ts +10 -0
- package/dist/cli/config.js +52 -0
- package/dist/cli/debug/index.d.ts +31 -0
- package/dist/cli/debug/index.js +119 -0
- package/dist/cli/exec/index.d.ts +39 -0
- package/dist/cli/exec/index.js +138 -0
- package/dist/cli/exec/session.d.ts +48 -0
- package/dist/cli/exec/session.js +82 -0
- package/dist/cli/exec/trace.d.ts +18 -0
- package/dist/cli/exec/trace.js +52 -0
- package/dist/cli/index.js +112 -9
- package/dist/cli/logs/index.d.ts +47 -0
- package/dist/cli/logs/index.js +113 -0
- package/dist/cli/mobile/index.d.ts +12 -0
- package/dist/cli/mobile/index.js +405 -0
- package/dist/cli/serve/index.d.ts +109 -3
- package/dist/cli/serve/index.js +506 -118
- package/dist/cli/turns/index.d.ts +105 -0
- package/dist/cli/turns/index.js +128 -0
- package/dist/cli/turns/run.d.ts +13 -0
- package/dist/cli/turns/run.js +57 -0
- package/dist/cli/turns/shadow.d.ts +112 -0
- package/dist/cli/turns/shadow.js +54 -0
- package/dist/cli/type-gen/index.js +9 -9
- package/dist/compiler.d.ts +7 -0
- package/dist/compiler.js +7 -0
- package/dist/compute-host/compute-host.d.ts +14 -23
- package/dist/compute-host/compute-host.js +18 -30
- package/dist/compute-host/index.d.ts +2 -4
- package/dist/compute-host/index.js +1 -2
- package/dist/compute-host/source-compute-host.d.ts +10 -10
- package/dist/compute-host/source-compute-host.js +33 -40
- package/dist/core/case-orchestrator/contact-hours.d.ts +70 -0
- package/dist/core/case-orchestrator/contact-hours.js +127 -0
- package/dist/core/case-orchestrator/index.d.ts +3 -0
- package/dist/core/case-orchestrator/index.js +3 -0
- package/dist/core/case-orchestrator/render.d.ts +75 -0
- package/dist/core/case-orchestrator/render.js +244 -0
- package/dist/core/case-orchestrator/time.d.ts +11 -0
- package/dist/core/case-orchestrator/time.js +29 -0
- package/dist/core/case-orchestrator/types.d.ts +708 -0
- package/dist/core/case-orchestrator/types.js +42 -0
- package/dist/core/context/call.d.ts +291 -0
- package/dist/core/context/call.js +94 -0
- package/dist/core/context/channels.d.ts +60 -0
- package/dist/core/context/channels.js +35 -0
- package/dist/core/context/contact.d.ts +96 -6
- package/dist/core/context/contact.js +48 -2
- package/dist/core/context/email-message.d.ts +198 -0
- package/dist/core/context/email-message.js +86 -0
- package/dist/core/context/email.d.ts +109 -0
- package/dist/core/context/email.js +90 -0
- package/dist/core/context/exchanges.d.ts +167 -0
- package/dist/core/context/exchanges.js +81 -0
- package/dist/core/context/instances.d.ts +307 -0
- package/dist/core/context/instances.js +137 -0
- package/dist/core/context/kv.d.ts +113 -0
- package/dist/core/context/kv.js +60 -0
- package/dist/core/context/platform-registry.d.ts +544 -4
- package/dist/core/context/platform-registry.js +14 -2
- package/dist/core/context/platform.d.ts +2 -1
- package/dist/core/context/sms.d.ts +177 -0
- package/dist/core/context/sms.js +77 -0
- package/dist/core/context/types.d.ts +79 -48
- package/dist/core/context/types.js +1 -7
- package/dist/core/conversation/index.d.ts +85 -0
- package/dist/core/conversation/index.js +133 -0
- package/dist/core/functions/errors.d.ts +74 -0
- package/dist/core/functions/errors.js +26 -0
- package/dist/core/functions/events.d.ts +192 -0
- package/dist/core/functions/events.js +23 -0
- package/dist/core/functions/schedules.d.ts +50 -0
- package/dist/core/functions/schedules.js +20 -0
- package/dist/core/functions/types.d.ts +29 -73
- package/dist/core/functions/types.js +1 -4
- package/dist/core/office-hours/index.d.ts +39 -0
- package/dist/core/office-hours/index.js +187 -0
- package/dist/core/page/define.d.ts +904 -0
- package/dist/core/page/define.js +518 -0
- package/dist/core/page/envelope.d.ts +55 -0
- package/dist/core/page/envelope.js +4 -0
- package/dist/core/page/fns.d.ts +448 -0
- package/dist/core/page/fns.js +539 -0
- package/dist/core/page/memory-reader.d.ts +27 -0
- package/dist/core/page/memory-reader.js +299 -0
- package/dist/core/page/ops.d.ts +58 -0
- package/dist/core/page/ops.js +220 -0
- package/dist/core/page/page-host.d.ts +20 -0
- package/dist/core/page/page-host.js +57 -0
- package/dist/core/page/records-query.d.ts +234 -0
- package/dist/core/page/records-query.js +780 -0
- package/dist/core/page/render.d.ts +295 -0
- package/dist/core/page/render.js +1060 -0
- package/dist/core/page/sandbox.d.ts +85 -0
- package/dist/core/page/sandbox.js +357 -0
- package/dist/core/page/time-format.d.ts +46 -0
- package/dist/core/page/time-format.js +125 -0
- package/dist/core/page/timeline.d.ts +40 -0
- package/dist/core/page/timeline.js +2 -0
- package/dist/core/page/typed.d.ts +648 -0
- package/dist/core/page/typed.js +2 -0
- package/dist/core/page/workspace.d.ts +57 -0
- package/dist/core/page/workspace.js +266 -0
- package/dist/core/party/index.d.ts +3 -0
- package/dist/core/party/index.js +3 -0
- package/dist/core/party/schema.d.ts +208 -0
- package/dist/core/party/schema.js +113 -0
- package/dist/core/party/types.d.ts +35 -0
- package/dist/core/party/types.js +15 -0
- package/dist/core/sequence/define.d.ts +56 -0
- package/dist/core/sequence/define.js +10 -0
- package/dist/core/sequence/index.d.ts +63 -0
- package/dist/core/sequence/index.js +231 -0
- package/dist/core/slot/binding.d.ts +40 -0
- package/dist/core/slot/binding.js +2 -0
- package/dist/core/slot/company-metadata.d.ts +102 -0
- package/dist/core/slot/company-metadata.js +536 -0
- package/dist/core/slot/compile-schema.d.ts +19 -13
- package/dist/core/slot/compile-schema.js +51 -248
- package/dist/core/slot/contact-timezone.d.ts +110 -0
- package/dist/core/slot/contact-timezone.js +186 -0
- package/dist/core/slot/field.d.ts +2 -25
- package/dist/core/slot/field.js +0 -71
- package/dist/core/slot/id-ref.d.ts +17 -2
- package/dist/core/slot/id-ref.js +16 -8
- package/dist/core/slot/index.d.ts +12 -13
- package/dist/core/slot/index.js +11 -12
- package/dist/core/slot/naming.d.ts +15 -0
- package/dist/core/slot/naming.js +96 -0
- package/dist/core/slot/platform-fields.d.ts +119 -0
- package/dist/core/slot/platform-fields.js +121 -0
- package/dist/core/slot/ref.d.ts +16 -0
- package/dist/core/slot/ref.js +14 -0
- package/dist/core/slot/row.d.ts +2 -9
- package/dist/core/slot/row.js +13 -23
- package/dist/core/slot/schema-compat.d.ts +17 -0
- package/dist/core/slot/schema-compat.js +103 -0
- package/dist/core/slot/schema.d.ts +353 -76
- package/dist/core/slot/schema.js +163 -10
- package/dist/core/slot/types.d.ts +30 -103
- package/dist/core/slot/value.d.ts +28 -3
- package/dist/core/slot/value.js +93 -57
- package/dist/dev-overlay/protocol.d.ts +74 -8
- package/dist/fn-context/build-context.d.ts +3 -1
- package/dist/fn-context/build-context.js +26 -10
- package/dist/fn-context/fake/empty-api.js +9 -28
- package/dist/fn-context/fake/index.d.ts +13 -4
- package/dist/fn-context/fake/index.js +29 -2
- package/dist/fn-context/fn-params.d.ts +3 -0
- package/dist/fn-context/fn-params.js +10 -0
- package/dist/fn-context/index.d.ts +5 -5
- package/dist/fn-context/index.js +4 -4
- package/dist/fn-context/log.js +2 -2
- package/dist/fn-context/make-ctx.d.ts +11 -0
- package/dist/fn-context/make-ctx.js +20 -9
- package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +32 -0
- package/dist/fn-context/rpc/case-orchestrator-tools.js +12 -0
- package/dist/fn-context/rpc/errors.d.ts +13 -0
- package/dist/fn-context/rpc/errors.js +22 -0
- package/dist/fn-context/rpc/index.d.ts +4 -2
- package/dist/fn-context/rpc/index.js +4 -2
- package/dist/fn-context/rpc/integration/index.d.ts +15 -5
- package/dist/fn-context/rpc/integration/index.js +1 -1
- package/dist/fn-context/rpc/integration/list-surfaces.d.ts +21 -0
- package/dist/fn-context/rpc/integration/{list-bindings.js → list-surfaces.js} +4 -4
- package/dist/fn-context/rpc/log.d.ts +11 -1
- package/dist/fn-context/rpc/platform.d.ts +13 -3
- package/dist/fn-context/rpc/platform.js +1 -1
- package/dist/fn-context/rpc/records.d.ts +85 -0
- package/dist/fn-context/rpc/records.js +24 -0
- package/dist/fn-context/rpc/trpc-client.d.ts +44 -2
- package/dist/fn-context/rpc/trpc-client.js +222 -12
- package/dist/fn-context/rpc/trpc-init.d.ts +21 -3
- package/dist/fn-context/rpc/trpc-init.js +10 -4
- package/dist/fn-context/rpc/trpc-router-factory.d.ts +111 -7
- package/dist/fn-context/rpc/trpc-router-factory.js +2 -0
- package/dist/fn-context/run-scope.d.ts +4 -0
- package/dist/fn-context/run-scope.js +9 -0
- package/dist/fn-context/types.d.ts +52 -5
- package/dist/index.d.ts +36 -46
- package/dist/index.js +30 -33
- package/dist/logger.d.ts +11 -0
- package/dist/logger.js +49 -0
- package/dist/platform.d.ts +75 -0
- package/dist/platform.js +57 -0
- package/dist/testing-compile-child.d.ts +2 -0
- package/dist/testing-compile-child.js +20 -0
- package/dist/testing.d.ts +368 -0
- package/dist/testing.js +439 -0
- package/dist/voice-service/actions.d.ts +50 -6
- package/dist/voice-service/index.d.ts +2 -0
- package/dist/voice-service/index.js +2 -0
- package/dist/voice-service/protocol.d.ts +604 -0
- package/dist/voice-service/protocol.js +67 -0
- package/dist/voice-service/types.d.ts +55 -8
- package/dist/worker.d.ts +11 -0
- package/dist/worker.js +11 -0
- package/package.json +38 -15
- package/dist/builder/compile/compile-agenda.d.ts +0 -15
- package/dist/builder/compile/compile-agenda.js +0 -64
- package/dist/builder/merge.d.ts +0 -4
- package/dist/builder/merge.js +0 -19
- package/dist/compute-host/read-only-cache.d.ts +0 -20
- package/dist/compute-host/read-only-cache.js +0 -61
- package/dist/core/context/db.d.ts +0 -69
- package/dist/core/context/db.js +0 -44
- package/dist/core/context/docusign.d.ts +0 -134
- package/dist/core/context/docusign.js +0 -108
- package/dist/core/context/filevine.d.ts +0 -323
- package/dist/core/context/filevine.js +0 -254
- package/dist/core/context/http.d.ts +0 -9
- package/dist/core/context/http.js +0 -4
- package/dist/core/context/hubspot.d.ts +0 -250
- package/dist/core/context/hubspot.js +0 -191
- package/dist/core/context/twilio.d.ts +0 -50
- package/dist/core/context/twilio.js +0 -42
- package/dist/core/functions/define/case-context.d.ts +0 -14
- package/dist/core/functions/define/case-context.js +0 -15
- package/dist/core/functions/define/compute.d.ts +0 -7
- package/dist/core/functions/define/compute.js +0 -17
- package/dist/core/functions/define/custom.d.ts +0 -4
- package/dist/core/functions/define/custom.js +0 -8
- package/dist/core/functions/define/system.d.ts +0 -7
- package/dist/core/functions/define/system.js +0 -12
- package/dist/core/functions/func-ref.d.ts +0 -16
- package/dist/core/functions/func-ref.js +0 -20
- package/dist/core/slot/deps.d.ts +0 -15
- package/dist/core/slot/deps.js +0 -88
- package/dist/core/slot/derived.d.ts +0 -32
- package/dist/core/slot/derived.js +0 -115
- package/dist/core/slot/platform-session-fields.d.ts +0 -38
- package/dist/core/slot/platform-session-fields.js +0 -48
- package/dist/core/slot/sf-schema.d.ts +0 -23
- package/dist/core/slot/sf-schema.js +0 -125
- package/dist/core/slot/sf-validate.d.ts +0 -14
- package/dist/core/slot/sf-validate.js +0 -132
- package/dist/core/slot/snapshot.d.ts +0 -18
- package/dist/core/slot/snapshot.js +0 -138
- package/dist/core/slot/write.d.ts +0 -48
- package/dist/core/slot/write.js +0 -426
- package/dist/core/stage/builders.d.ts +0 -54
- package/dist/core/stage/builders.js +0 -31
- package/dist/core/stage/condition.d.ts +0 -17
- package/dist/core/stage/condition.js +0 -198
- package/dist/core/stage/drive.d.ts +0 -43
- package/dist/core/stage/drive.js +0 -78
- package/dist/core/stage/finish-when.d.ts +0 -20
- package/dist/core/stage/finish-when.js +0 -82
- package/dist/core/stage/flatten.d.ts +0 -27
- package/dist/core/stage/flatten.js +0 -466
- package/dist/core/stage/index.d.ts +0 -15
- package/dist/core/stage/index.js +0 -13
- package/dist/core/stage/interrupts.d.ts +0 -28
- package/dist/core/stage/interrupts.js +0 -120
- package/dist/core/stage/ivr-fields.d.ts +0 -9
- package/dist/core/stage/ivr-fields.js +0 -75
- package/dist/core/stage/simulate.d.ts +0 -24
- package/dist/core/stage/simulate.js +0 -33
- package/dist/core/stage/transfer-fields.d.ts +0 -19
- package/dist/core/stage/transfer-fields.js +0 -129
- package/dist/core/stage/transfer-spec.d.ts +0 -48
- package/dist/core/stage/transfer-spec.js +0 -113
- package/dist/core/stage/types.d.ts +0 -208
- package/dist/core/stage/types.js +0 -2
- package/dist/core/stage/validate.d.ts +0 -11
- package/dist/core/stage/validate.js +0 -330
- package/dist/core/stage/walk.d.ts +0 -39
- package/dist/core/stage/walk.js +0 -119
- package/dist/fn-context/rpc/integration/list-bindings.d.ts +0 -21
- package/dist/fn-context/system-args.d.ts +0 -6
- package/dist/fn-context/system-args.js +0 -14
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a `db` read means, apart from where its rows are stored (15 §10.4, 18-record-search-index): the
|
|
3
|
+
* rows a page script and `ctx.api.db` see (`RowOut`, one `SlotOut` per field), what a `where`,
|
|
4
|
+
* `orderBy`, `after` / `skip` / `take` and `select` do to them, what a read may not say, and which of its
|
|
5
|
+
* conditions an index answers. The platform's reader (services `slot/page/records.ts`) loads its
|
|
6
|
+
* candidate rows from the database and applies these; the runtime's page unit tests
|
|
7
|
+
* (`testing.ts`) load them from the test's data and apply the same functions.
|
|
8
|
+
*/
|
|
9
|
+
import { type TableRelation } from '../slot/compile-schema.js';
|
|
10
|
+
import { type DataType } from '../slot/schema.js';
|
|
11
|
+
import type { CompiledSlotSchema, FieldValue, RuntimeFieldDef, RuntimeTableDef } from '../slot/types.js';
|
|
12
|
+
export declare const RECORDS_LIMITS: {
|
|
13
|
+
/** Rows one call may reach through its anchor or the index, before any other filter. */
|
|
14
|
+
readonly rowsPerCall: 500;
|
|
15
|
+
/** `findMany` without `take`. */
|
|
16
|
+
readonly defaultTake: 100;
|
|
17
|
+
/** `skip`: further on, page with `after`. */
|
|
18
|
+
readonly maxSkip: 1000;
|
|
19
|
+
/** Values of one `in` / `notIn`. */
|
|
20
|
+
readonly listValues: 500;
|
|
21
|
+
/** `count` counts up to this many; more answer this. */
|
|
22
|
+
readonly countCap: 10000;
|
|
23
|
+
/** Rows read by one reader (a page run; one `ctx.api.db` call). */
|
|
24
|
+
readonly rowsPerRun: 5000;
|
|
25
|
+
/**
|
|
26
|
+
* Stored row data (its JSON, UTF-8 bytes) one batch of calls may read (one `ctx.api.db` call, one
|
|
27
|
+
* sandbox slice), and one reader: what keeps a read from filling this process's memory, checked
|
|
28
|
+
* before the rows are loaded (34 §8).
|
|
29
|
+
*/
|
|
30
|
+
readonly bytesPerCall: number;
|
|
31
|
+
readonly bytesPerRun: number;
|
|
32
|
+
/** One statement of a read, in milliseconds: past it the read fails as `query_timeout` (34 §8). */
|
|
33
|
+
readonly statementMs: 3000;
|
|
34
|
+
readonly includeDepth: 3;
|
|
35
|
+
};
|
|
36
|
+
export type SlotState = FieldValue['state'];
|
|
37
|
+
/** One field as a page script sees it (15 §10.4). */
|
|
38
|
+
export type SlotOut = {
|
|
39
|
+
value: unknown;
|
|
40
|
+
state: SlotState;
|
|
41
|
+
reason: string | null;
|
|
42
|
+
updatedAt: string | null;
|
|
43
|
+
ref: {
|
|
44
|
+
table: string;
|
|
45
|
+
id: string;
|
|
46
|
+
field: string;
|
|
47
|
+
};
|
|
48
|
+
/** The target row, when the lookup was `include`d. */
|
|
49
|
+
row?: RowOut | null;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A row: its id and times (ISO 8601; a stored row's, not the session's), one slot per field, and the
|
|
53
|
+
* rows of each way back `include`d (`relatedName`).
|
|
54
|
+
*/
|
|
55
|
+
export type RowOut = {
|
|
56
|
+
id: string;
|
|
57
|
+
createdAt?: string;
|
|
58
|
+
updatedAt?: string;
|
|
59
|
+
[field: string]: SlotOut | RowOut[] | string | undefined;
|
|
60
|
+
};
|
|
61
|
+
export type RecordsMethod = 'findUnique' | 'findFirst' | 'findMany' | 'count';
|
|
62
|
+
export type RecordsCall = {
|
|
63
|
+
table: string;
|
|
64
|
+
method: RecordsMethod;
|
|
65
|
+
args: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
/** Why a read was refused: a read this API does not take, or one past a limit (18-record-search-index §4.10). */
|
|
68
|
+
export type RecordsQueryErrorCode = 'invalid_read' | 'limit_exceeded';
|
|
69
|
+
export declare class RecordsQueryError extends Error {
|
|
70
|
+
readonly code: RecordsQueryErrorCode;
|
|
71
|
+
constructor(message: string, code?: RecordsQueryErrorCode);
|
|
72
|
+
}
|
|
73
|
+
export declare function limitExceeded(message: string): RecordsQueryError;
|
|
74
|
+
export type WhereInput = Record<string, unknown>;
|
|
75
|
+
export type FindArgs = {
|
|
76
|
+
where?: unknown;
|
|
77
|
+
include?: unknown;
|
|
78
|
+
select?: unknown;
|
|
79
|
+
orderBy?: unknown;
|
|
80
|
+
take?: unknown;
|
|
81
|
+
skip?: unknown;
|
|
82
|
+
/** A row as read: the rows strictly after it in this read's order ({@link afterOf}). */
|
|
83
|
+
after?: unknown;
|
|
84
|
+
/** Replaced by `after`: refused, saying so. */
|
|
85
|
+
cursor?: unknown;
|
|
86
|
+
};
|
|
87
|
+
export declare const COMBINATORS: Set<string>;
|
|
88
|
+
/** Prisma's list filters, on a way back (`relatedName`). */
|
|
89
|
+
export declare const WAY_BACK_FILTERS: Set<string>;
|
|
90
|
+
/** What an `include` of a way back may say of its rows. */
|
|
91
|
+
export declare const RELATION_INCLUDE_KEYS: Set<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Refuses `contains` / `endsWith` as an operator anywhere in a where (under AND / OR / NOT, a `not`, a
|
|
94
|
+
* relation's filter), saying what to write instead; before anything is read, whatever path the read
|
|
95
|
+
* takes. A field may be named `contains`: the where's own keys are fields, only a condition's are
|
|
96
|
+
* operators.
|
|
97
|
+
*/
|
|
98
|
+
export declare function refuseSearch(tableName: string, where: unknown, path?: string): void;
|
|
99
|
+
/** An anchor: `ids` the field is equal to / in. */
|
|
100
|
+
export type Anchor = {
|
|
101
|
+
field: string;
|
|
102
|
+
ids: string[];
|
|
103
|
+
};
|
|
104
|
+
/** The fields of a read's conditions and order that are index entries (not row times): their dictionary ids are needed. */
|
|
105
|
+
export declare function indexedFieldsOf(conditions: readonly IndexCondition[], order: IndexOrder | null | undefined): string[];
|
|
106
|
+
/**
|
|
107
|
+
* The conditions of a where that pin it to some rows (top level and top-level AND): `id` or a ref
|
|
108
|
+
* field equal to / in some ids (15 §10.6.1).
|
|
109
|
+
*/
|
|
110
|
+
export declare function findAnchors(table: RuntimeTableDef, where: WhereInput): Anchor[];
|
|
111
|
+
export declare function relationFilters(table: RuntimeTableDef, where: WhereInput): Array<{
|
|
112
|
+
field: string;
|
|
113
|
+
target: string;
|
|
114
|
+
sub: unknown[];
|
|
115
|
+
}>;
|
|
116
|
+
/** What a `where` is judged against beyond the row: `is` targets and the rows of each way back, by parent. */
|
|
117
|
+
export type MatchContext = {
|
|
118
|
+
schema: CompiledSlotSchema;
|
|
119
|
+
targets: ReadonlyMap<string, RowOut>;
|
|
120
|
+
/** `relatedKey(table, relatedName)` → parent id → its rows. */
|
|
121
|
+
related: ReadonlyMap<string, ReadonlyMap<string, RowOut[]>>;
|
|
122
|
+
relationOf: (tableName: string, name: string) => TableRelation | undefined;
|
|
123
|
+
};
|
|
124
|
+
/** The ways back a `where` filters by (top level and inside AND / OR / NOT), with their sub-wheres. */
|
|
125
|
+
export declare function wayBackFilters(tableName: string, where: WhereInput, relationOf: MatchContext['relationOf']): Array<{
|
|
126
|
+
relation: TableRelation;
|
|
127
|
+
sub: unknown[];
|
|
128
|
+
}>;
|
|
129
|
+
export declare function relatedKey(tableName: string, name: string): string;
|
|
130
|
+
export declare function matches(context: MatchContext, tableName: string, row: RowOut, where: unknown): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* One key of `orderBy`: the field (a field, `id` or a row time), its direction, how its values compare,
|
|
133
|
+
* and a field's definition (none for `id` or a row time).
|
|
134
|
+
*/
|
|
135
|
+
export type OrderKey = {
|
|
136
|
+
field: string;
|
|
137
|
+
sign: 1 | -1;
|
|
138
|
+
order: (a: unknown, b: unknown) => number;
|
|
139
|
+
def?: RuntimeFieldDef;
|
|
140
|
+
};
|
|
141
|
+
export declare function orderKeys(table: RuntimeTableDef, orderBy: unknown): OrderKey[];
|
|
142
|
+
/**
|
|
143
|
+
* A row's place in a read's order: its value of each order key (null or undefined: none), then its
|
|
144
|
+
* creation (ms) and id, which break ties.
|
|
145
|
+
*/
|
|
146
|
+
export type Place = {
|
|
147
|
+
values: unknown[];
|
|
148
|
+
created: number;
|
|
149
|
+
id: string;
|
|
150
|
+
};
|
|
151
|
+
/** Rows in the read's order; without keys, as they come (creation order). */
|
|
152
|
+
export declare function orderRows(keys: readonly OrderKey[], rows: RowOut[]): RowOut[];
|
|
153
|
+
/**
|
|
154
|
+
* `orderBy` as the database can order: null without one, the field when it is one indexed field or a
|
|
155
|
+
* row time; undefined when it cannot (several keys, `id`, a field not indexed).
|
|
156
|
+
*/
|
|
157
|
+
export declare function indexOrder(table: RuntimeTableDef, orderBy: unknown): IndexOrder | null | undefined;
|
|
158
|
+
/** Rows in the read's order, paged: from strictly after `place`, then `skip`, then `take`. */
|
|
159
|
+
export declare function pageRows(keys: readonly OrderKey[], rows: RowOut[], place: Place | undefined, args: FindArgs): RowOut[];
|
|
160
|
+
/**
|
|
161
|
+
* `after`: the place a page starts after, read off a row as the reader returned it (normally the last
|
|
162
|
+
* of the page before). Taken by value, never looked up: its id only breaks ties, so a row since deleted,
|
|
163
|
+
* changed or of another tenant is only a place and discloses nothing. It needs the row's `id` and
|
|
164
|
+
* `createdAt`, and its value of each order key: `updatedAt`, or the field's slot (`{ value }`, a null
|
|
165
|
+
* value for none). A field's value must be of its type ({@link fitsField}): one the index cannot hold
|
|
166
|
+
* would otherwise place as "no value" in SQL and compare as text in memory.
|
|
167
|
+
*/
|
|
168
|
+
export declare function afterOf(tableName: string, keys: readonly OrderKey[], args: FindArgs): Place | undefined;
|
|
169
|
+
export declare function skipOf(value: unknown): number;
|
|
170
|
+
/** Every `in` / `notIn` of a where (and its AND / OR / NOT, way-back and `is` filters) within `listValues`. */
|
|
171
|
+
export declare function checkListSizes(tableName: string, where: unknown): void;
|
|
172
|
+
export declare function optionalCount(value: unknown, name: string): number | undefined;
|
|
173
|
+
export declare function selectFields(tableName: string, table: RuntimeTableDef, row: RowOut, select: unknown): RowOut;
|
|
174
|
+
export declare function toSlot(table: string, id: string, field: string, value: FieldValue): SlotOut;
|
|
175
|
+
export declare function isUuid(value: unknown): value is string;
|
|
176
|
+
export declare function asArray(value: unknown): unknown[];
|
|
177
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
178
|
+
/** A projected field as its schema declares it. */
|
|
179
|
+
export type IndexedField = {
|
|
180
|
+
dataType: DataType;
|
|
181
|
+
unique: boolean;
|
|
182
|
+
};
|
|
183
|
+
/** The fields of one table's definition that go to the index. */
|
|
184
|
+
export declare function tableIndexedFields(fields: Record<string, unknown>): Map<string, IndexedField>;
|
|
185
|
+
/** An index entry's typed value columns. */
|
|
186
|
+
export type IndexValue = {
|
|
187
|
+
valueText: string | null;
|
|
188
|
+
valueNum: number | null;
|
|
189
|
+
valueTime: Date | null;
|
|
190
|
+
};
|
|
191
|
+
/** A stored value's index columns; null when it has none to index (empty, or not of its type). */
|
|
192
|
+
export declare function indexValueOf(dataType: DataType, value: unknown): IndexValue | null;
|
|
193
|
+
/**
|
|
194
|
+
* One condition the database can answer: a field (through the index) or a row time (`row`, a column of
|
|
195
|
+
* `Record`), its type, and the operators on it.
|
|
196
|
+
*/
|
|
197
|
+
export type IndexCondition = {
|
|
198
|
+
field: string;
|
|
199
|
+
dataType: DataType;
|
|
200
|
+
ops: Record<string, unknown>;
|
|
201
|
+
insensitive: boolean;
|
|
202
|
+
row?: true;
|
|
203
|
+
/** No operators: every row with a value, in its order (a walk along the order, 34 §7). */
|
|
204
|
+
walk?: true;
|
|
205
|
+
};
|
|
206
|
+
/** The order a read asks for, as the index can order: one field (or a row time) and its direction. */
|
|
207
|
+
export type IndexOrder = {
|
|
208
|
+
field: string;
|
|
209
|
+
dataType: DataType;
|
|
210
|
+
desc: boolean;
|
|
211
|
+
row?: true;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* The conditions of a where the database can answer (top level and top-level AND): on indexed fields
|
|
215
|
+
* and row times. And whether they are the whole where (nothing else to check in memory). A condition
|
|
216
|
+
* on a field that is not indexed, an empty value, `not`, `notIn`, `state`, `OR` and `NOT` are left to
|
|
217
|
+
* the in-memory filter.
|
|
218
|
+
*/
|
|
219
|
+
export declare function indexConditions(table: RuntimeTableDef, where: WhereInput): {
|
|
220
|
+
conditions: IndexCondition[];
|
|
221
|
+
whole: boolean;
|
|
222
|
+
};
|
|
223
|
+
/** The conditions that can start a query; when none can, why. */
|
|
224
|
+
export declare function startableConditions(conditions: readonly IndexCondition[]): {
|
|
225
|
+
candidates: IndexCondition[];
|
|
226
|
+
why: string | null;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Why a `where` with no anchor (`id` or a ref field equal to / in some ids) cannot be read: no condition
|
|
230
|
+
* on an indexed field or a row time starts it. Null when one does. The platform's reader and the page
|
|
231
|
+
* unit tests refuse the same reads, with this message.
|
|
232
|
+
*/
|
|
233
|
+
export declare function unstartableWhy(tableName: string, table: RuntimeTableDef, where: WhereInput): string | null;
|
|
234
|
+
//# sourceMappingURL=records-query.d.ts.map
|