@camstack/types 1.2.601 → 1.2.602
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/CHANGELOG.md +6 -0
- package/dist/addon/base-addon.d.ts +39 -0
- package/dist/addon/instance-switches-unread-error.d.ts +12 -0
- package/dist/addon/instance-switches.d.ts +75 -0
- package/dist/addon/notification-targets.d.ts +0 -2
- package/dist/addon/record-integration-instances.d.ts +29 -13
- package/dist/addon.d.ts +2 -0
- package/dist/addon.js +3 -1
- package/dist/addon.mjs +2 -2
- package/dist/capabilities/integrations.cap.d.ts +43 -6
- package/dist/client.js +2 -0
- package/dist/client.mjs +2 -0
- package/dist/generated/addon-api.d.ts +14 -0
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/system-proxy.d.ts +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +92 -186
- package/dist/index.mjs +69 -181
- package/dist/interfaces/addon.d.ts +12 -0
- package/dist/interfaces/integration-registry.d.ts +12 -0
- package/dist/migrations/api/migration-api-ports.d.ts +3 -0
- package/dist/migrations/body-switch-to-registry.d.ts +102 -0
- package/dist/{runtime-capabilities-azf1ve5b.js → runtime-capabilities-D9KsXMv7.js} +726 -24
- package/dist/{runtime-capabilities-B36VcCR6.mjs → runtime-capabilities-ql3VRzQu.mjs} +605 -23
- package/package.json +1 -1
|
@@ -916,6 +916,18 @@ export interface ICamstackAddon {
|
|
|
916
916
|
* is no separate hub to wait for).
|
|
917
917
|
*/
|
|
918
918
|
onHubReachable?(): Promise<void> | void;
|
|
919
|
+
/**
|
|
920
|
+
* What the runner calls on the hub-reachable event (`BaseAddon`): the instance switches are read
|
|
921
|
+
* from the registry again and announced, then {@link onHubReachable} runs. An addon that does
|
|
922
|
+
* not extend `BaseAddon` has none and its `onHubReachable` is called directly.
|
|
923
|
+
*/
|
|
924
|
+
hubReachable?(): Promise<void>;
|
|
925
|
+
/**
|
|
926
|
+
* Read the instance switches from the registry and announce them (`BaseAddon`). Throws when the
|
|
927
|
+
* registry does not answer while the addon serves instance kinds. Called on EVERY hub connect
|
|
928
|
+
* and when the hub-main registry becomes available.
|
|
929
|
+
*/
|
|
930
|
+
rehydrateSwitches?(): Promise<void>;
|
|
919
931
|
shutdown(): Promise<void>;
|
|
920
932
|
/**
|
|
921
933
|
* D986: the schema one capability this addon provides declares for a settings scope
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `info` key of a registry row that stands for a SERVICES instance (D1066): every instance of every
|
|
3
|
+
* role has a row, the one stored switch, but only a row of an instance that brings devices is an
|
|
4
|
+
* entry of the Integrations list.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SERVICE_INSTANCE_INFO_KEY = "serviceInstance";
|
|
1
7
|
/** Persisted integration (provider instance) */
|
|
2
8
|
export interface Integration {
|
|
3
9
|
readonly id: string;
|
|
@@ -16,6 +22,12 @@ export interface Integration {
|
|
|
16
22
|
}
|
|
17
23
|
/** Input for creating an integration */
|
|
18
24
|
export interface CreateIntegrationInput {
|
|
25
|
+
/**
|
|
26
|
+
* The row id. Absent: the registry mints `int_NNNN`. A SERVICES instance (a broker account, a
|
|
27
|
+
* relay, a destination) is a row too, under the id its addon minted (D1066); an id already taken
|
|
28
|
+
* is refused, never overwritten.
|
|
29
|
+
*/
|
|
30
|
+
readonly id?: string;
|
|
19
31
|
readonly addonId: string;
|
|
20
32
|
readonly name: string;
|
|
21
33
|
readonly enabled?: boolean;
|
|
@@ -11,6 +11,7 @@ import type { KeychainResolveResult } from '../../capabilities/keychain.cap.js';
|
|
|
11
11
|
import type { DefaultIntegrationApi } from '../default-integration-migrations.js';
|
|
12
12
|
import type { IntegrationRowsApi, RowsRecordsDoor } from '../integration-rows-api-ports.js';
|
|
13
13
|
import type { MigrationApiV1 } from './migration-api.v1.js';
|
|
14
|
+
import type { BodySwitchRecordsDoor } from '../body-switch-to-registry.js';
|
|
14
15
|
import type { SwitchRecordsDoor } from '../registry-switch-to-body.js';
|
|
15
16
|
/** The keychain handle of the migration API: resolve and delete, owner-scoped by the transport. */
|
|
16
17
|
export interface MigrationSecretsDoor {
|
|
@@ -20,6 +21,8 @@ export interface MigrationSecretsDoor {
|
|
|
20
21
|
export declare function secretsOverMigrationApi(api: MigrationApiV1): MigrationSecretsDoor;
|
|
21
22
|
/** The record calls the one-switch migration makes, over the migration API. */
|
|
22
23
|
export declare function switchRecordsOverMigrationApi(api: MigrationApiV1): SwitchRecordsDoor;
|
|
24
|
+
/** The record calls the body-to-registry switch migration makes, over the migration API. */
|
|
25
|
+
export declare function bodySwitchRecordsOverMigrationApi(api: MigrationApiV1): BodySwitchRecordsDoor;
|
|
23
26
|
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
24
27
|
export declare function recordsOverMigrationApi(api: MigrationApiV1): RowsRecordsDoor;
|
|
25
28
|
export declare function integrationRowsApiOver(api: MigrationApiV1): IntegrationRowsApi;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The switch comes back to the registry (D1066), the reverse of {@link registrySwitchToBodyMigration}.
|
|
3
|
+
* An instance's on/off state lived in its record body (`enabled`, D1007 superseded by D1015); the hub
|
|
4
|
+
* registry row, keyed by (addon, integration id) like a device, is now the only stored switch.
|
|
5
|
+
*
|
|
6
|
+
* For every record of the addon's kind:
|
|
7
|
+
* - the state is the body's `enabled` (absent means on). When the registry row of that id disagrees,
|
|
8
|
+
* the BODY wins: it was the only live copy while the body held the switch, and the registry
|
|
9
|
+
* column of a migrated row was never read;
|
|
10
|
+
* - a record with no registry row gets one (a services instance, under its addon-minted id);
|
|
11
|
+
* - the key is then removed from the body, so no second copy remains.
|
|
12
|
+
* A rerun finds no body that states `enabled` and writes nothing. The registry write goes first, so
|
|
13
|
+
* a crash between the two steps repeats the pair (idempotent) and never loses a switched-off state.
|
|
14
|
+
*
|
|
15
|
+
* It runs in the addon process, after {@link registrySwitchToBodyMigration}, BEFORE the addon
|
|
16
|
+
* registers its provider.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import type { DefinedRecordKind } from '../records/record-kind.js';
|
|
20
|
+
import type { AddonProcedureMigration } from './addon-migration.js';
|
|
21
|
+
import type { MigrationProcedureResult } from './migration.js';
|
|
22
|
+
/** One record of the addon with the switch its body stated. */
|
|
23
|
+
export interface BodySwitchRow {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** The body's `enabled`; absent in the body reads as on. */
|
|
27
|
+
readonly enabled: boolean;
|
|
28
|
+
/** True when the body carries the key (so it must be stripped). */
|
|
29
|
+
readonly stated: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface BodySwitchAdoption {
|
|
32
|
+
readonly created: number;
|
|
33
|
+
readonly updated: number;
|
|
34
|
+
/** Rows whose id belongs to another addon: the record keeps its body switch. */
|
|
35
|
+
readonly conflicts: readonly {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly ownerAddonId: string;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
export interface BodySwitchPorts {
|
|
41
|
+
/** Every record of the addon's kind. */
|
|
42
|
+
listRecords(): Promise<readonly BodySwitchRow[]>;
|
|
43
|
+
/** Put the states into the registry rows (creating the absent ones). */
|
|
44
|
+
adoptRows(addonId: string, rows: readonly {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly enabled: boolean;
|
|
48
|
+
readonly stated: boolean;
|
|
49
|
+
}[]): Promise<BodySwitchAdoption>;
|
|
50
|
+
/** Remove the switch key from the record body. */
|
|
51
|
+
stripSwitch(id: string): Promise<void>;
|
|
52
|
+
/** A WARN on the run's log. */
|
|
53
|
+
warn(message: string): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export declare function bodySwitchToRegistryId(addonId: string, date: string, kindName: string): string;
|
|
56
|
+
export declare function moveBodySwitchToRegistry(ports: BodySwitchPorts, spec: {
|
|
57
|
+
readonly addonId: string;
|
|
58
|
+
}): Promise<MigrationProcedureResult>;
|
|
59
|
+
/** A migration entry: an addon states its kind, nothing else. */
|
|
60
|
+
export declare function bodySwitchToRegistryMigration(spec: {
|
|
61
|
+
readonly addonId: string;
|
|
62
|
+
/** `yyyy-mm-dd` of the migration id. */
|
|
63
|
+
readonly date: string;
|
|
64
|
+
/** Position in the addon's catalogue; after the registry-to-body move. */
|
|
65
|
+
readonly seq: number;
|
|
66
|
+
/** The record kind this entry moves: one entry per instance kind of the addon. */
|
|
67
|
+
readonly kindName: string;
|
|
68
|
+
/** The date of the registry-to-body migration it follows, when the addon ran that one. */
|
|
69
|
+
readonly followsDate?: string;
|
|
70
|
+
}): AddonProcedureMigration<BodySwitchPorts>;
|
|
71
|
+
/** The record calls the ports make on the addon's kind. */
|
|
72
|
+
export interface BodySwitchRecordHandle<T> {
|
|
73
|
+
query(q: {
|
|
74
|
+
readonly limit?: number;
|
|
75
|
+
}): Promise<{
|
|
76
|
+
readonly records: readonly {
|
|
77
|
+
readonly id: string;
|
|
78
|
+
readonly rev: number;
|
|
79
|
+
readonly data: T;
|
|
80
|
+
}[];
|
|
81
|
+
}>;
|
|
82
|
+
get(id: string): Promise<{
|
|
83
|
+
readonly rev: number;
|
|
84
|
+
readonly data: T;
|
|
85
|
+
} | null>;
|
|
86
|
+
put(input: {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly data: T;
|
|
89
|
+
}, opts?: {
|
|
90
|
+
readonly ifRev?: number;
|
|
91
|
+
}): Promise<unknown>;
|
|
92
|
+
}
|
|
93
|
+
export interface BodySwitchRecordsDoor {
|
|
94
|
+
kind<S extends z.ZodType>(definition: DefinedRecordKind<S>): BodySwitchRecordHandle<z.infer<S>>;
|
|
95
|
+
}
|
|
96
|
+
export declare function bodySwitchPortsOver(deps: {
|
|
97
|
+
readonly records: BodySwitchRecordsDoor;
|
|
98
|
+
readonly kind: DefinedRecordKind;
|
|
99
|
+
readonly nameField: string;
|
|
100
|
+
readonly adopt: BodySwitchPorts['adoptRows'];
|
|
101
|
+
readonly warn: BodySwitchPorts['warn'];
|
|
102
|
+
}): BodySwitchPorts;
|