@camstack/system 1.2.443 → 1.2.445
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/assets/record-entries/icon.svg +8 -0
- package/dist/addon-runner.js +81 -42
- package/dist/addon-runner.mjs +82 -43
- package/dist/{agent-https-DlpTMDqA.js → agent-https-CiOW0-sj.js} +810 -12
- package/dist/{agent-https-U0d4uvn2.mjs → agent-https-D4Q8iFNd.mjs} +697 -13
- package/dist/auth/admin-token-manager.d.ts +9 -3
- package/dist/auth/api-key-manager.d.ts +9 -3
- package/dist/auth/auth-audit-log.d.ts +9 -3
- package/dist/auth/device-credential-manager.d.ts +5 -1
- package/dist/auth/external-identity-manager.d.ts +8 -21
- package/dist/auth/login-session-manager.d.ts +11 -3
- package/dist/auth/scoped-token-manager.d.ts +8 -52
- package/dist/auth/totp-manager.d.ts +11 -3
- package/dist/auth/user-manager.d.ts +10 -17
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alert-store.d.ts +32 -0
- package/dist/builtins/alerts/alerts.addon.d.ts +19 -4
- package/dist/builtins/alerts/alerts.addon.js +331 -159
- package/dist/builtins/alerts/alerts.addon.mjs +330 -159
- package/dist/builtins/alerts/record-kinds.d.ts +15 -0
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +1 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +134 -193
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +134 -193
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/record-kinds.d.ts +58 -0
- package/dist/builtins/backup-orchestrator/schedule-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/seed-marker-store.d.ts +4 -2
- package/dist/builtins/calendars/calendar-prefs-store.d.ts +13 -5
- package/dist/builtins/calendars/calendars.addon.d.ts +2 -2
- package/dist/builtins/calendars/calendars.addon.js +67 -64
- package/dist/builtins/calendars/calendars.addon.mjs +59 -64
- package/dist/builtins/calendars/record-kinds.d.ts +18 -0
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/cluster-agent/record-kinds.d.ts +36 -0
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/block-settings-store.d.ts +8 -4
- package/dist/builtins/core-blocks/core-block-store.d.ts +8 -16
- package/dist/builtins/core-blocks/core-blocks.addon.js +85 -112
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +86 -113
- package/dist/builtins/core-blocks/index.mjs +1 -1
- package/dist/builtins/core-blocks/record-kinds.d.ts +26 -0
- package/dist/builtins/device-manager/device-manager.addon.js +111 -187
- package/dist/builtins/device-manager/device-manager.addon.mjs +110 -187
- package/dist/builtins/device-manager/device-tombstone-store.d.ts +9 -48
- package/dist/builtins/device-manager/record-kinds.d.ts +14 -0
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +152 -22
- package/dist/builtins/keychain/index.mjs +152 -22
- package/dist/builtins/keychain/keychain-service.d.ts +3 -2
- package/dist/builtins/keychain/keychain-store.d.ts +13 -2
- package/dist/builtins/keychain/record-kinds.d.ts +16 -0
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/auth-schema.d.ts +3 -1
- package/dist/builtins/local-auth/local-auth.addon.js +2903 -2123
- package/dist/builtins/local-auth/local-auth.addon.mjs +2904 -2124
- package/dist/builtins/local-auth/oauth-session-manager.d.ts +8 -48
- package/dist/builtins/local-auth/record-kinds.d.ts +141 -0
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/record-entries/entries-service.d.ts +42 -0
- package/dist/builtins/record-entries/index.d.ts +1 -0
- package/dist/builtins/record-entries/index.js +142 -0
- package/dist/builtins/record-entries/index.mjs +136 -0
- package/dist/builtins/record-entries/record-entries.addon.d.ts +13 -0
- package/dist/builtins/records/legacy-table-row-count.d.ts +5 -0
- package/dist/builtins/records/phase6-declare-gate.d.ts +28 -0
- package/dist/builtins/records-isolated.d.ts +10 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/file-host-client.d.ts +2 -0
- package/dist/builtins/sqlite-storage/file-host-handlers.d.ts +4 -0
- package/dist/builtins/sqlite-storage/file-host-protocol.d.ts +7 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +30 -0
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +10 -16
- package/dist/builtins/sqlite-storage/owned-sqlite-file.d.ts +7 -0
- package/dist/builtins/sqlite-storage/placement-router.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +6 -0
- package/dist/builtins/sqlite-storage/records/records-catalog.d.ts +29 -0
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +51 -0
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +94 -0
- package/dist/builtins/sqlite-storage/records/records-explain.d.ts +18 -0
- package/dist/builtins/sqlite-storage/records/records-plan.d.ts +90 -0
- package/dist/builtins/sqlite-storage/records/records-probe.d.ts +33 -0
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +63 -0
- package/dist/builtins/sqlite-storage/records/records-rows.d.ts +46 -0
- package/dist/builtins/sqlite-storage/records/records-sql.d.ts +41 -0
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +17 -10
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +8 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +446 -5
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +446 -5
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +15 -1
- package/dist/builtins/storage-orchestrator/drain-state-store.d.ts +5 -2
- package/dist/builtins/storage-orchestrator/location-store.d.ts +7 -2
- package/dist/builtins/storage-orchestrator/record-kinds.d.ts +38 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +196 -5
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +195 -6
- package/dist/builtins/system-config/record-kinds.d.ts +32 -0
- package/dist/builtins/system-config/system-config.addon.js +53 -618
- package/dist/builtins/system-config/system-config.addon.mjs +29 -577
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-C8tUG2uL.mjs → composition-sources-BMt5cFYb.mjs} +1 -1
- package/dist/{composition-sources-BUXX1e8j.js → composition-sources-D3fi9Xns.js} +1 -1
- package/dist/{constants-CGwVaAV3.mjs → constants-BMHCxRzb.mjs} +1 -1
- package/dist/{constants-DWmm7_of.js → constants-Br879Axi.js} +1 -1
- package/dist/{device-ca-DGayRmC0.js → device-ca-CnJ_va7i.js} +1 -1
- package/dist/{device-ca-DBfiJ_SB.mjs → device-ca-T8osSMos.mjs} +1 -1
- package/dist/{dist-Bxt_S-9a.mjs → dist-BNunRyXT.mjs} +1133 -93
- package/dist/{dist-D9qT3jHr.js → dist-DgOG8flk.js} +1354 -92
- package/dist/file-host-worker.js +11 -1
- package/dist/file-host-worker.mjs +11 -1
- package/dist/{hub-mdns-ciao-B-wk9nzx.js → hub-mdns-ciao-BIkTHq-n.js} +2 -2
- package/dist/{hub-mdns-ciao-DpPcQDg-.mjs → hub-mdns-ciao-D16oRQ9K.mjs} +2 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3111 -2806
- package/dist/index.mjs +3083 -2795
- package/dist/kernel/index.d.ts +2 -0
- package/dist/kernel/moleculer/event-bus.d.ts +3 -1
- package/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +5 -1
- package/dist/kernel/moleculer/records-api-transport.d.ts +9 -0
- package/dist/kernel/moleculer/remote-logger.d.ts +2 -2
- package/dist/kernel/settings-view-types.d.ts +0 -7
- package/dist/kernel/transport/cap-route-resolver.d.ts +9 -38
- package/dist/phase6-declare-gate-Ci1-8uUn.js +98 -0
- package/dist/phase6-declare-gate-tkKOEitw.mjs +93 -0
- package/dist/read-all-rows-CVoO1ONM.js +29 -0
- package/dist/read-all-rows-TaPqdWNF.mjs +25 -0
- package/dist/records/read-all-rows.d.ts +6 -0
- package/dist/{restore-archive-9CGgeBzD.mjs → restore-archive-DR9MtO7J.mjs} +339 -9
- package/dist/{restore-archive-BMNXwWWD.js → restore-archive-DjJnCgap.js} +353 -5
- package/dist/tls/agent-https-names.d.ts +9 -13
- package/dist/{wal-maintenance-cRHR4rUY.js → wal-maintenance-CODGqhKY.js} +0 -0
- package/dist/{wal-maintenance-sIB32ONp.mjs → wal-maintenance-CfvgtQ7C.mjs} +0 -0
- package/package.json +22 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { SettingsStoreClient, TokenScope } from "@camstack/types";
|
|
1
|
+
import type { RecordKindHandle, SettingsStoreClient, TokenScope } from "@camstack/types";
|
|
2
|
+
import type { OauthSessionBody } from "./record-kinds.js";
|
|
2
3
|
export interface OauthSession {
|
|
3
4
|
readonly id: string;
|
|
4
5
|
readonly userId: string;
|
|
@@ -15,61 +16,20 @@ interface CreateInput {
|
|
|
15
16
|
readonly integrationId: string;
|
|
16
17
|
readonly scopes: TokenScope[];
|
|
17
18
|
}
|
|
19
|
+
export interface OauthSessionRecordsDeps {
|
|
20
|
+
readonly oauthSessionsKind: RecordKindHandle<OauthSessionBody>;
|
|
21
|
+
readonly legacyStore?: SettingsStoreClient;
|
|
22
|
+
}
|
|
18
23
|
export declare class OauthSessionManager {
|
|
24
|
+
private readonly kind;
|
|
19
25
|
private readonly store;
|
|
20
|
-
constructor(
|
|
21
|
-
/**
|
|
22
|
-
* Create a new OAuth session record. Generates a UUID as the session id,
|
|
23
|
-
* sets `createdAt` and `lastUsedAt` to now, `revokedAt` to null.
|
|
24
|
-
*/
|
|
26
|
+
constructor(deps: SettingsStoreClient | OauthSessionRecordsDeps);
|
|
25
27
|
create(input: CreateInput): Promise<OauthSession>;
|
|
26
|
-
/**
|
|
27
|
-
* Return all sessions — both active and revoked. Callers decide
|
|
28
|
-
* whether to filter by `revokedAt`.
|
|
29
|
-
*/
|
|
30
28
|
list(): Promise<OauthSession[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Look up a session by its id. Returns null when not found.
|
|
33
|
-
*/
|
|
34
29
|
getById(id: string): Promise<OauthSession | null>;
|
|
35
|
-
/**
|
|
36
|
-
* Mark a session as revoked by setting `revokedAt = now`.
|
|
37
|
-
*
|
|
38
|
-
* - Returns `true` on success (including idempotent re-revoke — the
|
|
39
|
-
* existing `revokedAt` timestamp is preserved; it is NOT updated).
|
|
40
|
-
* - Returns `false` when the session id is not found.
|
|
41
|
-
*/
|
|
42
30
|
markRevoked(id: string): Promise<boolean>;
|
|
43
|
-
/**
|
|
44
|
-
* Delete one session row. Used by hub bulk revoke when the link is already
|
|
45
|
-
* revoked ("Remove revoked"): absence fails closed the same way as a
|
|
46
|
-
* revoked row, so dropping it only clears the list.
|
|
47
|
-
*/
|
|
48
31
|
remove(id: string): Promise<boolean>;
|
|
49
|
-
/**
|
|
50
|
-
* Delete sessions revoked longer ago than `horizonMs`.
|
|
51
|
-
*
|
|
52
|
-
* Safe because an ABSENT session already fails closed exactly like a revoked
|
|
53
|
-
* one: every consumer in `oauth-grants.ts` reads
|
|
54
|
-
* `if (!session || session.revokedAt != null) return null`. Deleting the row
|
|
55
|
-
* therefore cannot re-enable a link that was cut — it removes a record whose
|
|
56
|
-
* only remaining job was to say "no", which the absence says too.
|
|
57
|
-
*
|
|
58
|
-
* A retention window rather than an immediate delete: a revoked account link
|
|
59
|
-
* is the kind of thing an operator looks up AFTER the fact ("when did I
|
|
60
|
-
* unlink that?"), and the row is tiny. Active sessions are never touched —
|
|
61
|
-
* the filter matches only rows with a `revokedAt` timestamp in range, and
|
|
62
|
-
* `revokedAt` is NULL on every live session, which SQL's `BETWEEN` never
|
|
63
|
-
* matches.
|
|
64
|
-
*
|
|
65
|
-
* Returns how many rows went.
|
|
66
|
-
*/
|
|
67
32
|
reapRevoked(horizonMs: number): Promise<number>;
|
|
68
|
-
/**
|
|
69
|
-
* Update `lastUsedAt` to now. No-op (does not throw) when the session
|
|
70
|
-
* id is not found — the caller (token-use hot path) should not fail
|
|
71
|
-
* for a missing session that may have been concurrently revoked.
|
|
72
|
-
*/
|
|
73
33
|
touch(id: string): Promise<void>;
|
|
74
34
|
}
|
|
75
35
|
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record kinds owned by `local-auth` (records plan phase 6 / §2.8).
|
|
3
|
+
*
|
|
4
|
+
* Operator-only legacy drop: auth tables are NEVER removed by the orphan job —
|
|
5
|
+
* use `storageAdmin.dropCollection` with `expectRows` after verify (see
|
|
6
|
+
* `docs/design/records-phase-6-auth-migration.md`).
|
|
7
|
+
*
|
|
8
|
+
* Before hub restart: mint and test an admin token (`csa_`); snapshot every kind.
|
|
9
|
+
*/
|
|
10
|
+
import { ApiKeyRecordSchema, type DefinedRecordKind, type RecordKindHandle, type RecordsAccess, ScopedTokenSchema, TokenScopeSchema, UserRecordSchema } from "@camstack/types";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
export type UserBody = Omit<z.infer<typeof UserRecordSchema>, "id">;
|
|
13
|
+
export declare const UserBodySchema: z.ZodType<UserBody>;
|
|
14
|
+
export type ApiKeyBody = Omit<z.infer<typeof ApiKeyRecordSchema>, "id">;
|
|
15
|
+
export declare const ApiKeyBodySchema: z.ZodType<ApiKeyBody>;
|
|
16
|
+
export type ScopedTokenBody = Omit<z.infer<typeof ScopedTokenSchema>, "id">;
|
|
17
|
+
export declare const ScopedTokenBodySchema: z.ZodType<ScopedTokenBody>;
|
|
18
|
+
export type AdminTokenBody = {
|
|
19
|
+
readonly createdBy: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly tokenHash: string;
|
|
22
|
+
readonly tokenPrefix: string;
|
|
23
|
+
readonly createdAt: number;
|
|
24
|
+
readonly expiresAt: number;
|
|
25
|
+
readonly lastUsedAt?: number | null;
|
|
26
|
+
readonly revokedAt?: number | null;
|
|
27
|
+
};
|
|
28
|
+
export declare const AdminTokenBodySchema: z.ZodType<AdminTokenBody>;
|
|
29
|
+
export type LoginSessionBody = {
|
|
30
|
+
readonly userId: string;
|
|
31
|
+
readonly method: string;
|
|
32
|
+
readonly refreshable: boolean;
|
|
33
|
+
readonly createdAt: number;
|
|
34
|
+
readonly lastUsedAt: number;
|
|
35
|
+
readonly expiresAt: number;
|
|
36
|
+
readonly revokedAt?: number | null;
|
|
37
|
+
readonly revokedReason?: string | null;
|
|
38
|
+
readonly refreshHash?: string | null;
|
|
39
|
+
readonly previousRefreshHash?: string | null;
|
|
40
|
+
readonly rotatedAt?: number | null;
|
|
41
|
+
readonly client?: string | null;
|
|
42
|
+
readonly ip?: string | null;
|
|
43
|
+
readonly credentialId?: string | null;
|
|
44
|
+
};
|
|
45
|
+
export declare const LoginSessionBodySchema: z.ZodType<LoginSessionBody>;
|
|
46
|
+
export type LoginSessionCutoffBody = {
|
|
47
|
+
readonly notBefore: number;
|
|
48
|
+
};
|
|
49
|
+
export declare const LoginSessionCutoffBodySchema: z.ZodType<LoginSessionCutoffBody>;
|
|
50
|
+
export type OauthSessionBody = {
|
|
51
|
+
readonly userId: string;
|
|
52
|
+
readonly username: string;
|
|
53
|
+
readonly integrationId: string;
|
|
54
|
+
readonly scopes: z.infer<typeof TokenScopeSchema>[];
|
|
55
|
+
readonly createdAt: number;
|
|
56
|
+
readonly lastUsedAt: number;
|
|
57
|
+
readonly revokedAt?: number | null;
|
|
58
|
+
};
|
|
59
|
+
export declare const OauthSessionBodySchema: z.ZodType<OauthSessionBody>;
|
|
60
|
+
/** TOTP seed is a keychain-backed secret (D878); the row holds only a marker. */
|
|
61
|
+
export type UserTotpBody = {
|
|
62
|
+
readonly confirmedAt?: number | null;
|
|
63
|
+
readonly createdAt: number;
|
|
64
|
+
readonly secret: string;
|
|
65
|
+
};
|
|
66
|
+
export declare const UserTotpBodySchema: z.ZodType<UserTotpBody>;
|
|
67
|
+
export type ExternalIdentityBody = {
|
|
68
|
+
readonly provider: string;
|
|
69
|
+
readonly subject: string;
|
|
70
|
+
readonly issuer: string;
|
|
71
|
+
readonly userId: string;
|
|
72
|
+
readonly label?: string | null;
|
|
73
|
+
readonly linkedAt: number;
|
|
74
|
+
};
|
|
75
|
+
export declare const ExternalIdentityBodySchema: z.ZodType<ExternalIdentityBody>;
|
|
76
|
+
export type DeviceCredentialBody = {
|
|
77
|
+
readonly userId: string;
|
|
78
|
+
readonly deviceName: string;
|
|
79
|
+
readonly platform: string;
|
|
80
|
+
readonly enrolledVia: string;
|
|
81
|
+
readonly fingerprint: string;
|
|
82
|
+
readonly serial: string;
|
|
83
|
+
readonly previousFingerprint?: string | null;
|
|
84
|
+
readonly renewedAt?: number | null;
|
|
85
|
+
readonly publicKey: string;
|
|
86
|
+
readonly issuedAt: number;
|
|
87
|
+
readonly expiresAt: number;
|
|
88
|
+
readonly lastUsedAt?: number | null;
|
|
89
|
+
readonly lastUsedFrom?: string | null;
|
|
90
|
+
readonly revokedAt?: number | null;
|
|
91
|
+
readonly revokedBy?: string | null;
|
|
92
|
+
};
|
|
93
|
+
export declare const DeviceCredentialBodySchema: z.ZodType<DeviceCredentialBody>;
|
|
94
|
+
export type AuthAuditBody = {
|
|
95
|
+
readonly action: string;
|
|
96
|
+
readonly userId?: string | null;
|
|
97
|
+
readonly ip?: string | null;
|
|
98
|
+
readonly detail?: string | null;
|
|
99
|
+
};
|
|
100
|
+
export declare const AuthAuditBodySchema: z.ZodType<AuthAuditBody>;
|
|
101
|
+
export type LocalAuthRecordKindsMap = {
|
|
102
|
+
readonly users: DefinedRecordKind<z.ZodType<UserBody>>;
|
|
103
|
+
readonly "api-keys": DefinedRecordKind<z.ZodType<ApiKeyBody>>;
|
|
104
|
+
readonly "scoped-tokens": DefinedRecordKind<z.ZodType<ScopedTokenBody>>;
|
|
105
|
+
readonly "admin-tokens": DefinedRecordKind<z.ZodType<AdminTokenBody>>;
|
|
106
|
+
readonly "login-sessions": DefinedRecordKind<z.ZodType<LoginSessionBody>>;
|
|
107
|
+
readonly "login-session-cutoffs": DefinedRecordKind<z.ZodType<LoginSessionCutoffBody>>;
|
|
108
|
+
readonly "oauth-sessions": DefinedRecordKind<z.ZodType<OauthSessionBody>>;
|
|
109
|
+
readonly "user-totp": DefinedRecordKind<z.ZodType<UserTotpBody>>;
|
|
110
|
+
readonly "user-external-identities": DefinedRecordKind<z.ZodType<ExternalIdentityBody>>;
|
|
111
|
+
readonly "device-credentials": DefinedRecordKind<z.ZodType<DeviceCredentialBody>>;
|
|
112
|
+
readonly "auth-audit": DefinedRecordKind<z.ZodType<AuthAuditBody>>;
|
|
113
|
+
};
|
|
114
|
+
export declare const localAuthRecordKinds: LocalAuthRecordKindsMap;
|
|
115
|
+
export declare const localAuthUsersRecordKind: DefinedRecordKind<z.ZodType<UserBody>>;
|
|
116
|
+
export declare const localAuthApiKeysRecordKind: DefinedRecordKind<z.ZodType<ApiKeyBody>>;
|
|
117
|
+
export declare const localAuthScopedTokensRecordKind: DefinedRecordKind<z.ZodType<ScopedTokenBody>>;
|
|
118
|
+
export declare const localAuthAdminTokensRecordKind: DefinedRecordKind<z.ZodType<AdminTokenBody>>;
|
|
119
|
+
export declare const localAuthLoginSessionsRecordKind: DefinedRecordKind<z.ZodType<LoginSessionBody>>;
|
|
120
|
+
export declare const localAuthLoginSessionCutoffsRecordKind: DefinedRecordKind<z.ZodType<LoginSessionCutoffBody>>;
|
|
121
|
+
export declare const localAuthOauthSessionsRecordKind: DefinedRecordKind<z.ZodType<OauthSessionBody>>;
|
|
122
|
+
export declare const localAuthUserTotpRecordKind: DefinedRecordKind<z.ZodType<UserTotpBody>>;
|
|
123
|
+
export declare const localAuthUserExternalIdentitiesRecordKind: DefinedRecordKind<z.ZodType<ExternalIdentityBody>>;
|
|
124
|
+
export declare const localAuthDeviceCredentialsRecordKind: DefinedRecordKind<z.ZodType<DeviceCredentialBody>>;
|
|
125
|
+
export declare const localAuthAuthAuditRecordKind: DefinedRecordKind<z.ZodType<AuthAuditBody>>;
|
|
126
|
+
/** Legacy collections that must not be `declareCollection` once these kinds are live. */
|
|
127
|
+
export declare const LOCAL_AUTH_RECORDS_LEGACY_COLLECTIONS: readonly string[];
|
|
128
|
+
export interface LocalAuthRecordStores {
|
|
129
|
+
readonly users: RecordKindHandle<UserBody>;
|
|
130
|
+
readonly apiKeys: RecordKindHandle<ApiKeyBody>;
|
|
131
|
+
readonly scopedTokens: RecordKindHandle<ScopedTokenBody>;
|
|
132
|
+
readonly adminTokens: RecordKindHandle<AdminTokenBody>;
|
|
133
|
+
readonly loginSessions: RecordKindHandle<LoginSessionBody>;
|
|
134
|
+
readonly loginSessionCutoffs: RecordKindHandle<LoginSessionCutoffBody>;
|
|
135
|
+
readonly oauthSessions: RecordKindHandle<OauthSessionBody>;
|
|
136
|
+
readonly userTotp: RecordKindHandle<UserTotpBody>;
|
|
137
|
+
readonly userExternalIdentities: RecordKindHandle<ExternalIdentityBody>;
|
|
138
|
+
readonly deviceCredentials: RecordKindHandle<DeviceCredentialBody>;
|
|
139
|
+
readonly authAudit: RecordKindHandle<AuthAuditBody>;
|
|
140
|
+
}
|
|
141
|
+
export declare function localAuthRecordStoresOf(records: Pick<RecordsAccess, "kind">): LocalAuthRecordStores;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
4
|
-
const require_hub_mdns_ciao = require("../../hub-mdns-ciao-
|
|
3
|
+
const require_dist = require("../../dist-DgOG8flk.js");
|
|
4
|
+
const require_hub_mdns_ciao = require("../../hub-mdns-ciao-BIkTHq-n.js");
|
|
5
5
|
let zod = require("zod");
|
|
6
6
|
let node_net = require("node:net");
|
|
7
7
|
let node_os = require("node:os");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P as readLanHttpState, a as storeUploadedCertificate, d as servedHttpsLeafFingerprint, g as readTlsMode, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as applyLanHttp, k as DEFAULT_LAN_HTTP_PORT, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, r as regenerateCertificate, t as createCiaoPublisher, v as writeExtraSans, w as ensureTlsCert } from "../../hub-mdns-ciao-
|
|
1
|
+
import { Fn as pickAppLinkHub, Jn as resolveHubAddressRoles, L as HUB_MDNS_SERVICE_TYPE, R as HUB_MDNS_TXT_KEYS, Rr as BaseAddon, Wn as resolveAppConnections, Zn as resolveNotificationTapAddress, _r as validateCustomAddress, l as CAMSTACK_APP_LINK_ORIGIN, la as EventCategory, ln as isDefaultAppConnectionEndpoint, on as isAppLinkBase, q as NetworkTunnelStartedDataSchema, wt as checkRoleAddress, yn as localNetworkCapability } from "../../dist-BNunRyXT.mjs";
|
|
2
|
+
import { P as readLanHttpState, a as storeUploadedCertificate, d as servedHttpsLeafFingerprint, g as readTlsMode, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as applyLanHttp, k as DEFAULT_LAN_HTTP_PORT, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, r as regenerateCertificate, t as createCiaoPublisher, v as writeExtraSans, w as ensureTlsCert } from "../../hub-mdns-ciao-D16oRQ9K.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { isIP } from "node:net";
|
|
5
5
|
import * as os$1 from "node:os";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-DgOG8flk.js");
|
|
7
7
|
//#region src/builtins/loki-logging/loki-payload.ts
|
|
8
8
|
/**
|
|
9
9
|
* Loki rejects a label name that is not a valid Prometheus label
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Rr as BaseAddon, xn as logDestinationCapability } from "../../dist-BNunRyXT.mjs";
|
|
2
2
|
//#region src/builtins/loki-logging/loki-payload.ts
|
|
3
3
|
/**
|
|
4
4
|
* Loki rejects a label name that is not a valid Prometheus label
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-DgOG8flk.js");
|
|
7
7
|
let node_fs_promises = require("node:fs/promises");
|
|
8
8
|
let node_util = require("node:util");
|
|
9
9
|
let node_os = require("node:os");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ci as createEvent, Dn as metricsProviderCapability, Gn as resolveBucketMs, Hn as reducePoints, Lr as errMsg, Rr as BaseAddon, la as EventCategory, tn as foldSnapshotByFunction } from "../../dist-BNunRyXT.mjs";
|
|
2
2
|
import { access, readFile, readdir } from "node:fs/promises";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
4
|
import * as os$1 from "node:os";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-DgOG8flk.js");
|
|
7
7
|
let node_util = require("node:util");
|
|
8
8
|
let node_os = require("node:os");
|
|
9
9
|
node_os = require_chunk.__toESM(node_os);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as __toESM, r as __exportAll } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Kt as enumerateInferenceDevices, Ln as platformProbeCapability, Lr as errMsg, Rr as BaseAddon, ki as emitReadiness, la as EventCategory, tr as scoreRuntimes } from "../../dist-BNunRyXT.mjs";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
4
|
import * as os$1 from "node:os";
|
|
5
5
|
import * as fs from "node:fs";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type EntryKindInfo, type EntryView, type RecordsAccess, type StorageKind } from "@camstack/types";
|
|
2
|
+
/** Entries one list answers: an entries list is a settings page, not a table. */
|
|
3
|
+
export declare const ENTRIES_LIST_MAX = 2e3;
|
|
4
|
+
export interface EntriesServiceDeps {
|
|
5
|
+
/** Every record kind of the engine; `counts: false` is a catalog read with no row counting. */
|
|
6
|
+
listKinds(counts: boolean): Promise<readonly StorageKind[]>;
|
|
7
|
+
/** The records door of `owner` (hub in-process builtins only). */
|
|
8
|
+
recordsFor(owner: string): RecordsAccess;
|
|
9
|
+
newId?: () => string;
|
|
10
|
+
}
|
|
11
|
+
export declare class EntriesService {
|
|
12
|
+
private readonly deps;
|
|
13
|
+
constructor(deps: EntriesServiceDeps);
|
|
14
|
+
private entryKind;
|
|
15
|
+
private definitionOf;
|
|
16
|
+
listEntryKinds(): Promise<{
|
|
17
|
+
kinds: EntryKindInfo[];
|
|
18
|
+
}>;
|
|
19
|
+
listEntries(input: {
|
|
20
|
+
owner: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
entries: EntryView[];
|
|
24
|
+
}>;
|
|
25
|
+
putEntry(input: {
|
|
26
|
+
owner: string;
|
|
27
|
+
kind: string;
|
|
28
|
+
id?: string | undefined;
|
|
29
|
+
data: Record<string, unknown>;
|
|
30
|
+
ifRev?: number | undefined;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
id: string;
|
|
33
|
+
rev: number;
|
|
34
|
+
}>;
|
|
35
|
+
deleteEntry(input: {
|
|
36
|
+
owner: string;
|
|
37
|
+
kind: string;
|
|
38
|
+
id: string;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
deleted: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RecordEntriesAddon, default } from "./record-entries.addon.js";
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
require("../../chunk-Cek0wNdY.js");
|
|
6
|
+
const require_dist = require("../../dist-DgOG8flk.js");
|
|
7
|
+
let zod = require("zod");
|
|
8
|
+
let node_crypto = require("node:crypto");
|
|
9
|
+
//#region src/builtins/record-entries/entries-service.ts
|
|
10
|
+
/**
|
|
11
|
+
* The entries service (D881): one list/add/edit/delete surface for every entry
|
|
12
|
+
* kind an addon declares (`defineEntryKind`). It holds no data and no schema of
|
|
13
|
+
* its own - the engine's catalog is the source (`storageAdmin.listKinds`), and
|
|
14
|
+
* each call acts for the entry's OWNER through `ctx.records.forOwner`, so the
|
|
15
|
+
* owner's keychain refs and the owner-only rule of records both hold.
|
|
16
|
+
*
|
|
17
|
+
* The body is validated against the kind's JSON Schema descriptor
|
|
18
|
+
* (`z.fromJSONSchema`), so a form can only save what the owner's own schema
|
|
19
|
+
* describes. A password field is whatever the schema marks `secret: true`.
|
|
20
|
+
*/
|
|
21
|
+
/** Entries one list answers: an entries list is a settings page, not a table. */
|
|
22
|
+
var ENTRIES_LIST_MAX = 2e3;
|
|
23
|
+
function isRecord(value) {
|
|
24
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
var EntriesService = class {
|
|
27
|
+
deps;
|
|
28
|
+
constructor(deps) {
|
|
29
|
+
this.deps = deps;
|
|
30
|
+
}
|
|
31
|
+
async entryKind(owner, kind) {
|
|
32
|
+
const found = (await this.deps.listKinds(false)).find((k) => k.owner === owner && k.kind === kind && k.declaration.entry !== void 0);
|
|
33
|
+
if (found === void 0) throw new require_dist.UnknownRecordKindError(`"${owner}" declared no entry kind "${kind}"`);
|
|
34
|
+
return found;
|
|
35
|
+
}
|
|
36
|
+
definitionOf(info) {
|
|
37
|
+
const entry = info.declaration.entry;
|
|
38
|
+
if (entry === void 0) throw new require_dist.UnknownRecordKindError(`"${info.kind}" is not an entry kind`);
|
|
39
|
+
const body = zod.z.fromJSONSchema(entry.fields);
|
|
40
|
+
const schema = zod.z.custom((value) => isRecord(value) && body.safeParse(value).success, { message: "the entry does not match the kind's schema" });
|
|
41
|
+
return {
|
|
42
|
+
name: info.kind,
|
|
43
|
+
schema,
|
|
44
|
+
declaration: info.declaration
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async listEntryKinds() {
|
|
48
|
+
return { kinds: (await this.deps.listKinds(true)).filter((k) => k.declaration.entry !== void 0 && k.state === "declared").map((k) => {
|
|
49
|
+
const entry = k.declaration.entry;
|
|
50
|
+
return {
|
|
51
|
+
owner: k.owner,
|
|
52
|
+
kind: k.kind,
|
|
53
|
+
title: entry?.title ?? k.kind,
|
|
54
|
+
nameField: entry?.nameField ?? "name",
|
|
55
|
+
fields: entry?.fields ?? {},
|
|
56
|
+
secretPaths: k.declaration.secretPaths,
|
|
57
|
+
rows: k.rows ?? 0
|
|
58
|
+
};
|
|
59
|
+
}) };
|
|
60
|
+
}
|
|
61
|
+
async listEntries(input) {
|
|
62
|
+
const info = await this.entryKind(input.owner, input.kind);
|
|
63
|
+
const nameField = info.declaration.entry?.nameField ?? "name";
|
|
64
|
+
const handle = this.deps.recordsFor(input.owner).kind(this.definitionOf(info));
|
|
65
|
+
const entries = [];
|
|
66
|
+
let cursor;
|
|
67
|
+
do {
|
|
68
|
+
const page = await handle.query({
|
|
69
|
+
limit: 500,
|
|
70
|
+
...cursor === void 0 ? {} : { cursor },
|
|
71
|
+
order: "id"
|
|
72
|
+
});
|
|
73
|
+
for (const row of page.records) {
|
|
74
|
+
const name = row.data[nameField];
|
|
75
|
+
entries.push({
|
|
76
|
+
id: row.id,
|
|
77
|
+
name: typeof name === "string" ? name : row.id,
|
|
78
|
+
rev: row.rev,
|
|
79
|
+
updatedAt: row.updatedAt,
|
|
80
|
+
data: row.data
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
cursor = page.nextCursor ?? void 0;
|
|
84
|
+
if (entries.length > 2e3) throw new require_dist.InvalidRecordError(`${input.kind}: more than ${ENTRIES_LIST_MAX} entries`);
|
|
85
|
+
} while (cursor !== void 0);
|
|
86
|
+
return { entries };
|
|
87
|
+
}
|
|
88
|
+
async putEntry(input) {
|
|
89
|
+
const info = await this.entryKind(input.owner, input.kind);
|
|
90
|
+
const handle = this.deps.recordsFor(input.owner).kind(this.definitionOf(info));
|
|
91
|
+
const id = input.id ?? (this.deps.newId ?? node_crypto.randomUUID)();
|
|
92
|
+
const ifRev = input.id === void 0 ? 0 : input.ifRev;
|
|
93
|
+
const { rev } = await handle.put({
|
|
94
|
+
id,
|
|
95
|
+
data: input.data
|
|
96
|
+
}, ifRev === void 0 ? {} : { ifRev });
|
|
97
|
+
return {
|
|
98
|
+
id,
|
|
99
|
+
rev
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async deleteEntry(input) {
|
|
103
|
+
const info = await this.entryKind(input.owner, input.kind);
|
|
104
|
+
return { deleted: await this.deps.recordsFor(input.owner).kind(this.definitionOf(info)).delete(input.id) };
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/builtins/record-entries/record-entries.addon.ts
|
|
109
|
+
/**
|
|
110
|
+
* `record-entries` - the generic entries surface (D881). Hub-only and
|
|
111
|
+
* in-process: it acts for each entry's owner on the keychain and on the
|
|
112
|
+
* records door, which only a hub in-process system builtin may do
|
|
113
|
+
* (`ctx.records.forOwner`, `ctx.secrets.forOwner`).
|
|
114
|
+
*/
|
|
115
|
+
var RecordEntriesAddon = class extends require_dist.BaseAddon {
|
|
116
|
+
id = "record-entries";
|
|
117
|
+
constructor() {
|
|
118
|
+
super({});
|
|
119
|
+
}
|
|
120
|
+
async onInitialize() {
|
|
121
|
+
const ctx = this.ctx;
|
|
122
|
+
const records = ctx.records;
|
|
123
|
+
const forOwner = records?.forOwner ?? null;
|
|
124
|
+
if (records === void 0 || forOwner === null) throw new Error("record-entries: this process cannot act for another owner (hub in-process only)");
|
|
125
|
+
const service = new EntriesService({
|
|
126
|
+
listKinds: async (counts) => (await ctx.api.storageAdmin.listKinds.query({ counts })).kinds,
|
|
127
|
+
recordsFor: (owner) => forOwner(owner)
|
|
128
|
+
});
|
|
129
|
+
return [{
|
|
130
|
+
capability: require_dist.recordEntriesCapability,
|
|
131
|
+
provider: {
|
|
132
|
+
listEntryKinds: () => service.listEntryKinds(),
|
|
133
|
+
listEntries: (input) => service.listEntries(input),
|
|
134
|
+
putEntry: (input) => service.putEntry(input),
|
|
135
|
+
deleteEntry: (input) => service.deleteEntry(input)
|
|
136
|
+
}
|
|
137
|
+
}];
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
exports.RecordEntriesAddon = RecordEntriesAddon;
|
|
142
|
+
exports.default = RecordEntriesAddon;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Bn as recordEntriesCapability, Rr as BaseAddon, fi as UnknownRecordKindError, qr as InvalidRecordError } from "../../dist-BNunRyXT.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
//#region src/builtins/record-entries/entries-service.ts
|
|
5
|
+
/**
|
|
6
|
+
* The entries service (D881): one list/add/edit/delete surface for every entry
|
|
7
|
+
* kind an addon declares (`defineEntryKind`). It holds no data and no schema of
|
|
8
|
+
* its own - the engine's catalog is the source (`storageAdmin.listKinds`), and
|
|
9
|
+
* each call acts for the entry's OWNER through `ctx.records.forOwner`, so the
|
|
10
|
+
* owner's keychain refs and the owner-only rule of records both hold.
|
|
11
|
+
*
|
|
12
|
+
* The body is validated against the kind's JSON Schema descriptor
|
|
13
|
+
* (`z.fromJSONSchema`), so a form can only save what the owner's own schema
|
|
14
|
+
* describes. A password field is whatever the schema marks `secret: true`.
|
|
15
|
+
*/
|
|
16
|
+
/** Entries one list answers: an entries list is a settings page, not a table. */
|
|
17
|
+
var ENTRIES_LIST_MAX = 2e3;
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
var EntriesService = class {
|
|
22
|
+
deps;
|
|
23
|
+
constructor(deps) {
|
|
24
|
+
this.deps = deps;
|
|
25
|
+
}
|
|
26
|
+
async entryKind(owner, kind) {
|
|
27
|
+
const found = (await this.deps.listKinds(false)).find((k) => k.owner === owner && k.kind === kind && k.declaration.entry !== void 0);
|
|
28
|
+
if (found === void 0) throw new UnknownRecordKindError(`"${owner}" declared no entry kind "${kind}"`);
|
|
29
|
+
return found;
|
|
30
|
+
}
|
|
31
|
+
definitionOf(info) {
|
|
32
|
+
const entry = info.declaration.entry;
|
|
33
|
+
if (entry === void 0) throw new UnknownRecordKindError(`"${info.kind}" is not an entry kind`);
|
|
34
|
+
const body = z.fromJSONSchema(entry.fields);
|
|
35
|
+
const schema = z.custom((value) => isRecord(value) && body.safeParse(value).success, { message: "the entry does not match the kind's schema" });
|
|
36
|
+
return {
|
|
37
|
+
name: info.kind,
|
|
38
|
+
schema,
|
|
39
|
+
declaration: info.declaration
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async listEntryKinds() {
|
|
43
|
+
return { kinds: (await this.deps.listKinds(true)).filter((k) => k.declaration.entry !== void 0 && k.state === "declared").map((k) => {
|
|
44
|
+
const entry = k.declaration.entry;
|
|
45
|
+
return {
|
|
46
|
+
owner: k.owner,
|
|
47
|
+
kind: k.kind,
|
|
48
|
+
title: entry?.title ?? k.kind,
|
|
49
|
+
nameField: entry?.nameField ?? "name",
|
|
50
|
+
fields: entry?.fields ?? {},
|
|
51
|
+
secretPaths: k.declaration.secretPaths,
|
|
52
|
+
rows: k.rows ?? 0
|
|
53
|
+
};
|
|
54
|
+
}) };
|
|
55
|
+
}
|
|
56
|
+
async listEntries(input) {
|
|
57
|
+
const info = await this.entryKind(input.owner, input.kind);
|
|
58
|
+
const nameField = info.declaration.entry?.nameField ?? "name";
|
|
59
|
+
const handle = this.deps.recordsFor(input.owner).kind(this.definitionOf(info));
|
|
60
|
+
const entries = [];
|
|
61
|
+
let cursor;
|
|
62
|
+
do {
|
|
63
|
+
const page = await handle.query({
|
|
64
|
+
limit: 500,
|
|
65
|
+
...cursor === void 0 ? {} : { cursor },
|
|
66
|
+
order: "id"
|
|
67
|
+
});
|
|
68
|
+
for (const row of page.records) {
|
|
69
|
+
const name = row.data[nameField];
|
|
70
|
+
entries.push({
|
|
71
|
+
id: row.id,
|
|
72
|
+
name: typeof name === "string" ? name : row.id,
|
|
73
|
+
rev: row.rev,
|
|
74
|
+
updatedAt: row.updatedAt,
|
|
75
|
+
data: row.data
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
cursor = page.nextCursor ?? void 0;
|
|
79
|
+
if (entries.length > 2e3) throw new InvalidRecordError(`${input.kind}: more than ${ENTRIES_LIST_MAX} entries`);
|
|
80
|
+
} while (cursor !== void 0);
|
|
81
|
+
return { entries };
|
|
82
|
+
}
|
|
83
|
+
async putEntry(input) {
|
|
84
|
+
const info = await this.entryKind(input.owner, input.kind);
|
|
85
|
+
const handle = this.deps.recordsFor(input.owner).kind(this.definitionOf(info));
|
|
86
|
+
const id = input.id ?? (this.deps.newId ?? randomUUID)();
|
|
87
|
+
const ifRev = input.id === void 0 ? 0 : input.ifRev;
|
|
88
|
+
const { rev } = await handle.put({
|
|
89
|
+
id,
|
|
90
|
+
data: input.data
|
|
91
|
+
}, ifRev === void 0 ? {} : { ifRev });
|
|
92
|
+
return {
|
|
93
|
+
id,
|
|
94
|
+
rev
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async deleteEntry(input) {
|
|
98
|
+
const info = await this.entryKind(input.owner, input.kind);
|
|
99
|
+
return { deleted: await this.deps.recordsFor(input.owner).kind(this.definitionOf(info)).delete(input.id) };
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/builtins/record-entries/record-entries.addon.ts
|
|
104
|
+
/**
|
|
105
|
+
* `record-entries` - the generic entries surface (D881). Hub-only and
|
|
106
|
+
* in-process: it acts for each entry's owner on the keychain and on the
|
|
107
|
+
* records door, which only a hub in-process system builtin may do
|
|
108
|
+
* (`ctx.records.forOwner`, `ctx.secrets.forOwner`).
|
|
109
|
+
*/
|
|
110
|
+
var RecordEntriesAddon = class extends BaseAddon {
|
|
111
|
+
id = "record-entries";
|
|
112
|
+
constructor() {
|
|
113
|
+
super({});
|
|
114
|
+
}
|
|
115
|
+
async onInitialize() {
|
|
116
|
+
const ctx = this.ctx;
|
|
117
|
+
const records = ctx.records;
|
|
118
|
+
const forOwner = records?.forOwner ?? null;
|
|
119
|
+
if (records === void 0 || forOwner === null) throw new Error("record-entries: this process cannot act for another owner (hub in-process only)");
|
|
120
|
+
const service = new EntriesService({
|
|
121
|
+
listKinds: async (counts) => (await ctx.api.storageAdmin.listKinds.query({ counts })).kinds,
|
|
122
|
+
recordsFor: (owner) => forOwner(owner)
|
|
123
|
+
});
|
|
124
|
+
return [{
|
|
125
|
+
capability: recordEntriesCapability,
|
|
126
|
+
provider: {
|
|
127
|
+
listEntryKinds: () => service.listEntryKinds(),
|
|
128
|
+
listEntries: (input) => service.listEntries(input),
|
|
129
|
+
putEntry: (input) => service.putEntry(input),
|
|
130
|
+
deleteEntry: (input) => service.deleteEntry(input)
|
|
131
|
+
}
|
|
132
|
+
}];
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
//#endregion
|
|
136
|
+
export { RecordEntriesAddon, RecordEntriesAddon as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `record-entries` - the generic entries surface (D881). Hub-only and
|
|
3
|
+
* in-process: it acts for each entry's owner on the keychain and on the
|
|
4
|
+
* records door, which only a hub in-process system builtin may do
|
|
5
|
+
* (`ctx.records.forOwner`, `ctx.secrets.forOwner`).
|
|
6
|
+
*/
|
|
7
|
+
import { BaseAddon, type ProviderRegistration } from "@camstack/types";
|
|
8
|
+
export declare class RecordEntriesAddon extends BaseAddon {
|
|
9
|
+
readonly id = "record-entries";
|
|
10
|
+
constructor();
|
|
11
|
+
protected onInitialize(): Promise<ProviderRegistration[]>;
|
|
12
|
+
}
|
|
13
|
+
export default RecordEntriesAddon;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 6 auth/alert builtins: do not call `ctx.records.declare` while legacy
|
|
3
|
+
* tables still hold rows unless every kind is already adopted, or the operator
|
|
4
|
+
* set {@link CAMSTACK_RECORDS_DECLARE_PHASE6} for the declare pass before
|
|
5
|
+
* `records-adopt.ts --apply`.
|
|
6
|
+
*/
|
|
7
|
+
import { type AddonContext, type DefinedRecordKind, type RecordsAccess, type StorageKind } from "@camstack/types";
|
|
8
|
+
/** Operator override: declare kinds even when adoption is still pending (legacy path until adopt completes). */
|
|
9
|
+
export declare const CAMSTACK_RECORDS_DECLARE_PHASE6 = "CAMSTACK_RECORDS_DECLARE_PHASE6";
|
|
10
|
+
export declare function isPhase6RecordsDeclareForced(): boolean;
|
|
11
|
+
export interface Phase6DeclareGateDeps {
|
|
12
|
+
readonly owner: string;
|
|
13
|
+
readonly records: RecordsAccess;
|
|
14
|
+
readonly kinds: Readonly<Record<string, DefinedRecordKind>>;
|
|
15
|
+
readonly legacyCollections: readonly string[];
|
|
16
|
+
readonly legacyRowCount: (collection: string) => Promise<number>;
|
|
17
|
+
readonly listKindsForOwner: (owner: string) => Promise<readonly StorageKind[]>;
|
|
18
|
+
readonly isAdoptedLegacyTable: (collection: string) => Promise<boolean>;
|
|
19
|
+
readonly log: {
|
|
20
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @returns `true` when stores should bind record kinds; `false` for legacy collections only.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolvePhase6UseRecordsPath(deps: Phase6DeclareGateDeps): Promise<boolean>;
|
|
27
|
+
/** Shared wiring for hub builtins (local-auth, keychain, alert-center). */
|
|
28
|
+
export declare function resolvePhase6UseRecordsPathForHub(ctx: Pick<AddonContext, "api" | "logger" | "records">, owner: string, kinds: Readonly<Record<string, DefinedRecordKind>>, legacyCollections: readonly string[]): Promise<boolean>;
|