@camstack/types 1.2.379 → 1.2.381
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/addon.d.ts +3 -0
- package/dist/addon.js +67 -2
- package/dist/addon.mjs +5 -3
- package/dist/capabilities/caller-stamp.d.ts +12 -0
- package/dist/capabilities/index.d.ts +7 -2
- package/dist/capabilities/record-entries.cap.d.ts +84 -0
- package/dist/capabilities/records.cap.d.ts +399 -0
- package/dist/capabilities/storage-admin.cap.d.ts +268 -0
- package/dist/client.js +57 -32
- package/dist/client.mjs +57 -32
- package/dist/device/device-context.d.ts +2 -0
- package/dist/ffmpeg/fmp4-fragment-child.d.ts +2 -2
- package/dist/ffmpeg/process.d.ts +21 -0
- package/dist/generated/addon-api.d.ts +191 -0
- package/dist/generated/cap-input-defaults.d.ts +1 -1
- package/dist/generated/capability-router-map.d.ts +8 -2
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +2 -2
- package/dist/generated/system-proxy.d.ts +2 -0
- package/dist/helpers/addon-slice-handle.d.ts +4 -0
- package/dist/helpers/trpc-leaf.d.ts +17 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +724 -32
- package/dist/index.mjs +646 -33
- package/dist/interfaces/addon-peer-bytes.d.ts +19 -2
- package/dist/interfaces/addon.d.ts +13 -0
- package/dist/interfaces/config-ui.d.ts +4 -0
- package/dist/interfaces/event-bus.d.ts +32 -3
- package/dist/interfaces/storage.d.ts +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.js +4 -0
- package/dist/node.mjs +4 -1
- package/dist/records/constants.d.ts +23 -0
- package/dist/records/entry-kind.d.ts +31 -0
- package/dist/records/errors.d.ts +81 -0
- package/dist/records/in-memory-records.d.ts +21 -0
- package/dist/records/index.d.ts +9 -0
- package/dist/records/record-kind.d.ts +144 -0
- package/dist/records/records-access.d.ts +153 -0
- package/dist/records/secret-paths.d.ts +52 -0
- package/dist/records/settings-array-adopts-from.d.ts +12 -0
- package/dist/records/settings-brokers-adopts-from.d.ts +10 -0
- package/dist/{sleep-DQYi915G.js → sleep-D8yJVc4r.js} +1971 -290
- package/dist/{sleep-D-Q2_Mcd.mjs → sleep-bZIhUvjd.mjs} +1413 -128
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ctx.records` - an addon's handle on its OWN record kinds (D881).
|
|
3
|
+
*
|
|
4
|
+
* The owner is closed over at construction (the addon id) and the transport
|
|
5
|
+
* decides how it is proven: a hub in-process caller states it, a forked or
|
|
6
|
+
* agent addon sends the bare input and the parent stamps who is calling - the
|
|
7
|
+
* `ctx.secrets` model. Nothing a caller passes can change it.
|
|
8
|
+
*
|
|
9
|
+
* ## Secrets are a feature of the kind
|
|
10
|
+
*
|
|
11
|
+
* A field of the kind's Zod schema marked `.meta({ secret: true })` is stored
|
|
12
|
+
* as a keychain MARKER bound to the row's own ref and never as a value:
|
|
13
|
+
*
|
|
14
|
+
* - **write**: a non-empty string goes to the keychain FIRST, then the row is
|
|
15
|
+
* written holding the marker. The redaction token (or an empty/absent
|
|
16
|
+
* value on a `patch`) keeps what is stored; `put` is a full replace, so a
|
|
17
|
+
* secret field it omits is removed - and so is its keychain value. A locked
|
|
18
|
+
* keychain refuses the whole write (`records/secret-unavailable`):
|
|
19
|
+
* plaintext is never stored, never logged, never in an error message.
|
|
20
|
+
* - **read**: every read shows the redaction token for a set secret. The
|
|
21
|
+
* owner that needs the value asks for it (`getResolved`, `query` with
|
|
22
|
+
* `resolveSecrets`); the keychain answering `unavailable` or `missing`
|
|
23
|
+
* THROWS - a locked keychain is never read as an empty password.
|
|
24
|
+
* - **delete**: the keychain values of the removed rows go with them.
|
|
25
|
+
*/
|
|
26
|
+
import type { z } from 'zod';
|
|
27
|
+
import type { DeclareKindResult, IRecordsProvider, RecordQueryInput, RecordWhere } from '../capabilities/records.cap.js';
|
|
28
|
+
import type { SecretsAccess } from '../keychain/secrets-access.js';
|
|
29
|
+
import { type DefinedRecordKind } from './record-kind.js';
|
|
30
|
+
import { collectSecretLeaves } from './secret-paths.js';
|
|
31
|
+
/** The wire: the `records` provider's methods. The owner is never an argument. */
|
|
32
|
+
export type RecordsTransport = IRecordsProvider;
|
|
33
|
+
/** A row as the owner sees it. Secret fields hold the redaction token unless resolved. */
|
|
34
|
+
export interface RecordRow<T> {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly deviceId: number | null;
|
|
37
|
+
readonly at: number | null;
|
|
38
|
+
readonly expiresAt: number | null;
|
|
39
|
+
readonly rev: number;
|
|
40
|
+
readonly updatedAt: number;
|
|
41
|
+
readonly data: T;
|
|
42
|
+
}
|
|
43
|
+
export interface RecordPut<T> {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly deviceId?: number;
|
|
46
|
+
readonly at?: number;
|
|
47
|
+
readonly expiresAt?: number;
|
|
48
|
+
readonly data: T;
|
|
49
|
+
}
|
|
50
|
+
export interface RecordsLogger {
|
|
51
|
+
warn(message: string, extras?: {
|
|
52
|
+
readonly meta?: Record<string, unknown>;
|
|
53
|
+
}): void;
|
|
54
|
+
}
|
|
55
|
+
export interface RecordsAccessOptions {
|
|
56
|
+
readonly owner: string;
|
|
57
|
+
readonly transport: RecordsTransport;
|
|
58
|
+
/** The owner's keychain handle; `null` where there is none (a kind with secrets then refuses). */
|
|
59
|
+
readonly secrets: SecretsAccess | null;
|
|
60
|
+
readonly logger?: RecordsLogger;
|
|
61
|
+
/** Builds the transport for another owner - in-process system builtins only. */
|
|
62
|
+
readonly transportForOwner?: (owner: string) => RecordsTransport;
|
|
63
|
+
}
|
|
64
|
+
export interface RecordQueryOptions {
|
|
65
|
+
/** Resolve the secret fields of the page in ONE keychain call. A failure throws. */
|
|
66
|
+
readonly resolveSecrets?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface RecordKindHandle<T> {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
get(id: string): Promise<RecordRow<T> | null>;
|
|
71
|
+
getMany(ids: readonly string[]): Promise<readonly RecordRow<T>[]>;
|
|
72
|
+
/** `get` with the secret fields resolved from the keychain. */
|
|
73
|
+
getResolved(id: string): Promise<RecordRow<T> | null>;
|
|
74
|
+
put(input: RecordPut<T>, opts?: {
|
|
75
|
+
readonly ifRev?: number;
|
|
76
|
+
}): Promise<{
|
|
77
|
+
readonly rev: number;
|
|
78
|
+
}>;
|
|
79
|
+
putMany(inputs: readonly RecordPut<T>[]): Promise<{
|
|
80
|
+
readonly count: number;
|
|
81
|
+
}>;
|
|
82
|
+
/** RFC 7396 merge in one statement. `null` removes a field. */
|
|
83
|
+
patch(id: string, partial: Readonly<Record<string, unknown>>, opts?: {
|
|
84
|
+
readonly ifRev?: number;
|
|
85
|
+
readonly at?: number | null;
|
|
86
|
+
readonly expiresAt?: number | null;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
readonly rev: number;
|
|
89
|
+
}>;
|
|
90
|
+
delete(id: string): Promise<boolean>;
|
|
91
|
+
deleteMany(ids: readonly string[]): Promise<number>;
|
|
92
|
+
query(q: Omit<RecordQueryInput, 'kind' | 'limit'> & {
|
|
93
|
+
readonly limit?: number;
|
|
94
|
+
}, opts?: RecordQueryOptions): Promise<{
|
|
95
|
+
readonly records: readonly RecordRow<T>[];
|
|
96
|
+
readonly nextCursor: string | null;
|
|
97
|
+
}>;
|
|
98
|
+
count(q: {
|
|
99
|
+
readonly deviceId?: number;
|
|
100
|
+
readonly atFrom?: number;
|
|
101
|
+
readonly atTo?: number;
|
|
102
|
+
readonly where?: RecordWhere;
|
|
103
|
+
}): Promise<number>;
|
|
104
|
+
histogram(q: {
|
|
105
|
+
readonly deviceId?: number;
|
|
106
|
+
readonly from: number;
|
|
107
|
+
readonly to: number;
|
|
108
|
+
readonly bucketMs: number;
|
|
109
|
+
}): Promise<readonly {
|
|
110
|
+
readonly bucketStart: number;
|
|
111
|
+
readonly count: number;
|
|
112
|
+
}[]>;
|
|
113
|
+
aggregate(q: {
|
|
114
|
+
readonly op: 'sum' | 'min' | 'max' | 'count';
|
|
115
|
+
readonly field?: string;
|
|
116
|
+
readonly groupBy?: string;
|
|
117
|
+
readonly where?: RecordWhere;
|
|
118
|
+
}): Promise<readonly {
|
|
119
|
+
readonly group: string | number | null;
|
|
120
|
+
readonly value: number | null;
|
|
121
|
+
}[]>;
|
|
122
|
+
deleteWhere(q: {
|
|
123
|
+
readonly deviceId?: number;
|
|
124
|
+
readonly atBefore?: number;
|
|
125
|
+
readonly where?: RecordWhere;
|
|
126
|
+
}): Promise<number>;
|
|
127
|
+
allocateId(): Promise<number>;
|
|
128
|
+
}
|
|
129
|
+
export interface RecordsAccess {
|
|
130
|
+
readonly owner: string;
|
|
131
|
+
/**
|
|
132
|
+
* Reconcile this addon's kinds (the engine creates the indexes; additive
|
|
133
|
+
* only). THROWS {@link AdoptionPendingError} while a kind is empty and the
|
|
134
|
+
* legacy table it adopts from still holds rows - the boot guard (D853: no
|
|
135
|
+
* migration code in the product).
|
|
136
|
+
*/
|
|
137
|
+
declare(kinds: Readonly<Record<string, DefinedRecordKind>>): Promise<Readonly<Record<string, DeclareKindResult>>>;
|
|
138
|
+
kind<S extends z.ZodType>(definition: DefinedRecordKind<S>): RecordKindHandle<z.infer<S>>;
|
|
139
|
+
/**
|
|
140
|
+
* In-process SYSTEM builtins only (the entries service): act as the door of
|
|
141
|
+
* another owner. `null` everywhere else - a forked addon has no way to state
|
|
142
|
+
* an identity the transport would accept.
|
|
143
|
+
*/
|
|
144
|
+
readonly forOwner: ((owner: string) => RecordsAccess) | null;
|
|
145
|
+
/** The D865 hook body: delete the device's rows from every kind declared `deviceRemoval: 'delete'`. */
|
|
146
|
+
deleteDevice(deviceId: number, opts?: {
|
|
147
|
+
readonly kinds?: readonly string[];
|
|
148
|
+
}): Promise<Readonly<Record<string, number>>>;
|
|
149
|
+
}
|
|
150
|
+
/** Build the owner's records handle. */
|
|
151
|
+
export declare function createRecordsAccess(options: RecordsAccessOptions): RecordsAccess;
|
|
152
|
+
/** Re-exported so adoption tooling builds the same concrete paths the facade does. */
|
|
153
|
+
export { collectSecretLeaves };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
3
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
4
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
5
|
+
*
|
|
6
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
7
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
9
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
10
|
+
*
|
|
11
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
12
|
+
*/
|
|
13
|
+
import { arrayItemFieldPath } from '../keychain/secret-ref.js';
|
|
14
|
+
/** One segment of a declared path. */
|
|
15
|
+
export interface SecretPathSegment {
|
|
16
|
+
readonly key: string;
|
|
17
|
+
/** `true` when the key holds an array and the path continues into each element. */
|
|
18
|
+
readonly each: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
21
|
+
export declare function parseSecretPath(path: string): readonly SecretPathSegment[];
|
|
22
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
23
|
+
export declare function secretArrayPrefixes(path: string): readonly string[];
|
|
24
|
+
/** One secret leaf found in a record body. */
|
|
25
|
+
export interface SecretLeaf {
|
|
26
|
+
/** The declared path it matched (`headers[].value`). */
|
|
27
|
+
readonly declared: string;
|
|
28
|
+
/** Its concrete path, naming array elements by id (`headers[X-Api].value`). */
|
|
29
|
+
readonly concrete: string;
|
|
30
|
+
readonly value: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
34
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
35
|
+
* result is a new body, `data` is untouched.
|
|
36
|
+
*/
|
|
37
|
+
export declare const REMOVE_LEAF: unique symbol;
|
|
38
|
+
export type LeafReplacement = unknown | typeof REMOVE_LEAF;
|
|
39
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
40
|
+
export declare function mapSecretLeaves(data: unknown, paths: readonly string[], arrayKeys: Readonly<Record<string, string>>, visit: (leaf: SecretLeaf) => LeafReplacement): unknown;
|
|
41
|
+
/** Every present secret leaf, read-only. */
|
|
42
|
+
export declare function collectSecretLeaves(data: unknown, paths: readonly string[], arrayKeys: Readonly<Record<string, string>>): readonly SecretLeaf[];
|
|
43
|
+
/**
|
|
44
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
45
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
46
|
+
* already holds during an adoption.
|
|
47
|
+
*/
|
|
48
|
+
export declare function recordSecretCollection(kind: string): string;
|
|
49
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
50
|
+
export declare function recordSecretRef(owner: string, kind: string, rowId: string, concretePath: string): string;
|
|
51
|
+
/** A concrete path built from a flat array item, re-exported for adoption tooling. */
|
|
52
|
+
export declare const recordArrayItemPath: typeof arrayItemFieldPath;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy source for entry adoption (B3): a list stored under addon-settings
|
|
3
|
+
* `<addonId>.<key>` until records-adopt copies rows into the entry kind.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SETTINGS_ARRAY_ADOPTS_PREFIX = "@settings-array/";
|
|
6
|
+
/** The `adoptsFrom` value for an addon-settings array field. */
|
|
7
|
+
export declare function settingsArrayAdoptsFrom(addonId: string, settingsKey: string): string;
|
|
8
|
+
/** When non-null, `from` names an addon-settings array blob, not a SQL table. */
|
|
9
|
+
export declare function parseSettingsArrayAdoptsFrom(from: string): {
|
|
10
|
+
readonly addonId: string;
|
|
11
|
+
readonly settingsKey: string;
|
|
12
|
+
} | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy source for broker entry adoption (B2): brokers live in addon-settings
|
|
3
|
+
* as one row `<addonId>.brokers` whose value is an array until records-adopt
|
|
4
|
+
* copies them into the entry kind.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
|
|
7
|
+
/** The `adoptsFrom` value for an addon's broker entry kind. */
|
|
8
|
+
export declare function settingsBrokersAdoptsFrom(addonId: string): string;
|
|
9
|
+
/** When non-null, `from` names an addon-settings brokers blob, not a SQL table. */
|
|
10
|
+
export declare function parseSettingsBrokersAdoptsFrom(from: string): string | null;
|