@capybara-hq/kernel 0.1.0-rc.136 → 0.1.0-rc.137
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/admin/audit-log.service.d.ts +96 -12
- package/dist/admin/audit-log.service.js +508 -44
- package/dist/admin/audit-targets.d.ts +17 -0
- package/dist/admin/audit-targets.js +84 -0
- package/dist/admin/audit.controller.d.ts +12 -9
- package/dist/admin/audit.controller.js +29 -8
- package/dist/admin/audit.schemas.d.ts +20 -4
- package/dist/admin/audit.schemas.js +42 -17
- package/dist/agents/templates.js +3 -10
- package/dist/app.d.ts +3 -1
- package/dist/app.js +1 -0
- package/dist/automations/automations.service.js +4 -5
- package/dist/catalog/catalog-content.d.ts +1 -1
- package/dist/catalog/catalog-content.js +17 -22
- package/dist/catalog/catalog-items.d.ts +5 -10
- package/dist/catalog/catalog-items.js +27 -51
- package/dist/catalog/catalog-scope.service.d.ts +4 -2
- package/dist/catalog/catalog-scope.service.js +105 -141
- package/dist/catalog/catalog.module.js +2 -0
- package/dist/catalog/catalog.service.d.ts +3 -3
- package/dist/catalog/catalog.service.js +33 -8
- package/dist/catalog/cli.js +17 -0
- package/dist/catalog/component-promotion.js +8 -4
- package/dist/catalog/component-scope.service.d.ts +3 -1
- package/dist/catalog/component-scope.service.js +101 -140
- package/dist/catalog/component-state.d.ts +10 -8
- package/dist/catalog/component-state.js +42 -30
- package/dist/catalog/dependency-edges.d.ts +25 -0
- package/dist/catalog/dependency-edges.js +125 -0
- package/dist/catalog/install-status.d.ts +2 -3
- package/dist/catalog/install-status.js +2 -3
- package/dist/catalog/org-catalog.service.d.ts +3 -1
- package/dist/catalog/org-catalog.service.js +33 -94
- package/dist/catalog/org-intent.d.ts +43 -0
- package/dist/catalog/org-intent.js +184 -0
- package/dist/catalog/owned-items.d.ts +1 -1
- package/dist/catalog/owned-items.js +9 -29
- package/dist/catalog/ownership.d.ts +2 -3
- package/dist/catalog/ownership.js +10 -28
- package/dist/catalog/platform-components.d.ts +3 -1
- package/dist/catalog/platform-components.js +9 -1
- package/dist/catalog/plugin-import.js +12 -16
- package/dist/catalog/plugin-install.d.ts +3 -4
- package/dist/catalog/plugin-install.js +25 -49
- package/dist/catalog/plugin-upgrade.d.ts +2 -2
- package/dist/catalog/plugin-upgrade.js +18 -34
- package/dist/catalog/request-rules.js +20 -8
- package/dist/catalog/scope-orgs.js +2 -7
- package/dist/catalog/scope-state.d.ts +6 -6
- package/dist/catalog/scope-state.js +24 -43
- package/dist/catalog/scope-sync.d.ts +0 -2
- package/dist/catalog/scope-sync.js +11 -39
- package/dist/catalog/scope-writer.d.ts +78 -0
- package/dist/catalog/scope-writer.js +181 -0
- package/dist/catalog/unshare.js +8 -41
- package/dist/channels/connections.service.js +6 -6
- package/dist/channels/supervisor.js +3 -7
- package/dist/client/client-access.service.js +2 -12
- package/dist/config/schema.d.ts +6 -0
- package/dist/config/schema.js +29 -1
- package/dist/ctx/create-ctx.d.ts +2 -2
- package/dist/ctx/create-ctx.js +2 -60
- package/dist/ctx/guard-db.d.ts +6 -0
- package/dist/ctx/guard-db.js +55 -0
- package/dist/db/extension-handoff-schema.d.ts +1 -1
- package/dist/db/extension-handoff-schema.js +48 -10
- package/dist/db/extension-schema-transfer.js +5 -2
- package/dist/db/kernel-schema.d.ts +11 -1
- package/dist/device-access/host-services.d.ts +2 -2
- package/dist/device-access/host-services.js +5 -6
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/erasure/org-rules.js +5 -0
- package/dist/extensions/admin-ops.d.ts +9 -5
- package/dist/extensions/admin-ops.js +52 -8
- package/dist/extensions/admin-view.js +1 -4
- package/dist/extensions/bootstrap.js +4 -1
- package/dist/extensions/cli.js +1 -0
- package/dist/extensions/effective-config.js +1 -4
- package/dist/extensions/enabled.d.ts +23 -29
- package/dist/extensions/enabled.js +141 -62
- package/dist/extensions/host.d.ts +64 -45
- package/dist/extensions/host.js +443 -128
- package/dist/extensions/installs.d.ts +9 -0
- package/dist/extensions/installs.js +23 -0
- package/dist/extensions/isolated/admission.d.ts +10 -0
- package/dist/extensions/isolated/admission.js +206 -0
- package/dist/extensions/isolated/authorization.d.ts +37 -0
- package/dist/extensions/isolated/authorization.js +146 -0
- package/dist/extensions/isolated/broker.d.ts +15 -0
- package/dist/extensions/isolated/broker.js +452 -0
- package/dist/extensions/isolated/child-protocol.d.ts +84 -0
- package/dist/extensions/isolated/child-protocol.js +21 -0
- package/dist/extensions/isolated/child-registration.d.ts +22 -0
- package/dist/extensions/isolated/child-registration.js +152 -0
- package/dist/extensions/isolated/child-session.d.ts +6 -0
- package/dist/extensions/isolated/child-session.js +343 -0
- package/dist/extensions/isolated/child-streams.d.ts +4 -0
- package/dist/extensions/isolated/child-streams.js +142 -0
- package/dist/extensions/isolated/child.d.ts +1 -0
- package/dist/extensions/isolated/child.js +10 -0
- package/dist/extensions/isolated/configured-package.d.ts +15 -0
- package/dist/extensions/isolated/configured-package.js +73 -0
- package/dist/extensions/isolated/lanes.d.ts +100 -0
- package/dist/extensions/isolated/lanes.js +699 -0
- package/dist/extensions/isolated/postgres-gate.d.ts +14 -0
- package/dist/extensions/isolated/postgres-gate.js +255 -0
- package/dist/extensions/isolated/revision.d.ts +32 -0
- package/dist/extensions/isolated/revision.js +358 -0
- package/dist/extensions/isolated/rpc-frame.d.ts +50 -0
- package/dist/extensions/isolated/rpc-frame.js +193 -0
- package/dist/extensions/isolated/rpc.d.ts +66 -0
- package/dist/extensions/isolated/rpc.js +314 -0
- package/dist/extensions/isolated/sandbox.d.ts +35 -0
- package/dist/extensions/isolated/sandbox.js +372 -0
- package/dist/extensions/isolated/tier.d.ts +6 -0
- package/dist/extensions/isolated/tier.js +45 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/lifecycle-topics.d.ts +1 -0
- package/dist/extensions/lifecycle-topics.js +1 -0
- package/dist/extensions/lifecycle.d.ts +3 -1
- package/dist/extensions/lifecycle.js +32 -5
- package/dist/extensions/locks.d.ts +2 -0
- package/dist/extensions/locks.js +7 -0
- package/dist/extensions/org-config.d.ts +17 -27
- package/dist/extensions/org-config.js +114 -129
- package/dist/extensions/plugin-guides.d.ts +5 -10
- package/dist/extensions/plugin-guides.js +18 -37
- package/dist/extensions/plugin-icons.d.ts +3 -21
- package/dist/extensions/plugin-icons.js +9 -44
- package/dist/extensions/plugin-items.d.ts +10 -30
- package/dist/extensions/plugin-items.js +32 -73
- package/dist/extensions/source-intent.d.ts +14 -0
- package/dist/extensions/source-intent.js +77 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/infra/database/database.module.js +6 -1
- package/dist/infra/database/kernel-db.d.ts +3 -1
- package/dist/infra/database/kernel-db.js +4 -0
- package/dist/infra/paging/paged-read.d.ts +56 -0
- package/dist/infra/paging/paged-read.js +78 -0
- package/dist/kernel.d.ts +3 -2
- package/dist/kernel.js +21 -2
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +22 -12
- package/dist/lifecycle/tokens.d.ts +8 -0
- package/dist/lifecycle/tokens.js +2 -0
- package/dist/orgs/directory-sync.js +1 -4
- package/dist/platform/ops/admin.ops.js +14 -3
- package/dist/platform/ops/orgs.ops.js +13 -3
- package/dist/setup/setup-checks.service.js +3 -2
- package/dist/skills/usable.js +41 -30
- package/dist/themes/theme-state.js +3 -3
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +1 -1
- package/package.json +2 -2
- package/src/migrations/0228_extension_org_switches.sql +56 -0
- package/src/migrations/0229_catalog_dependency_edges.sql +17 -0
- package/src/migrations/0230_audit_filter_idx.sql +18 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
2
|
+
import { type Paged } from "../infra/paging/paged-read.js";
|
|
2
3
|
/**
|
|
3
4
|
* One audit event (admin overview spec §5.2, §9): who, what, on what and when, and two flags.
|
|
4
5
|
* Never the event's `detail` (it may carry config field names, ids or values); a deleted actor
|
|
5
6
|
* account reads as its id with a null name and email; `actor` is null for the kernel itself.
|
|
6
7
|
*/
|
|
7
8
|
export interface AuditEvent {
|
|
8
|
-
/** The event id (a bigserial, as a decimal string); also the
|
|
9
|
+
/** The event id (a bigserial, as a decimal string); also the snapshot key (`asOf`). */
|
|
9
10
|
id: string;
|
|
10
11
|
at: string;
|
|
11
12
|
actor: {
|
|
@@ -14,19 +15,23 @@ export interface AuditEvent {
|
|
|
14
15
|
email: string | null;
|
|
15
16
|
avatarUrl: string | null;
|
|
16
17
|
} | null;
|
|
17
|
-
/** Done with a personal
|
|
18
|
+
/** Done with an access token (a personal one, or an org's service token when `actor` is null). */
|
|
18
19
|
viaToken: boolean;
|
|
19
20
|
/** Done through the Platform tool by the actor's own agent (`detail.via === "agent"`). */
|
|
20
21
|
viaAgent: boolean;
|
|
21
22
|
/** The action. */
|
|
22
23
|
action: string;
|
|
23
24
|
target: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* The target's name when the kernel knows the kind of object and finds it in this log's scope
|
|
27
|
+
* (table pagination spec §3.1); null otherwise. A soft-deleted object keeps its name.
|
|
28
|
+
*/
|
|
29
|
+
targetLabel: string | null;
|
|
30
|
+
/** The target is an object of a known kind that no longer exists (or is soft-deleted). */
|
|
31
|
+
targetDeleted: boolean;
|
|
24
32
|
}
|
|
25
|
-
/** A page of {@link AuditEvent}s
|
|
26
|
-
export
|
|
27
|
-
events: AuditEvent[];
|
|
28
|
-
next: string | null;
|
|
29
|
-
}
|
|
33
|
+
/** A page of {@link AuditEvent}s (spec §2.3). */
|
|
34
|
+
export type AuditPage = Paged<AuditEvent>;
|
|
30
35
|
/** Whose events: the platform's (`org_id IS NULL`, decision D3) or one org's. */
|
|
31
36
|
export type AuditScope = {
|
|
32
37
|
platform: true;
|
|
@@ -34,19 +39,98 @@ export type AuditScope = {
|
|
|
34
39
|
orgId: string;
|
|
35
40
|
};
|
|
36
41
|
export interface AuditListQuery {
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
page: number;
|
|
43
|
+
size: number;
|
|
44
|
+
/** The snapshot: the newest event id the first page saw. */
|
|
45
|
+
asOf?: string | undefined;
|
|
46
|
+
/** Events at or after this time (ISO). */
|
|
47
|
+
from?: string | undefined;
|
|
48
|
+
/** Events before this time (ISO). */
|
|
49
|
+
to?: string | undefined;
|
|
50
|
+
/** An account id, `system` or `token:<token id>`. */
|
|
51
|
+
actor?: string | undefined;
|
|
39
52
|
/** Only actions starting with this prefix. */
|
|
40
53
|
action?: string | undefined;
|
|
54
|
+
/** The target id, or a part of the target's name. */
|
|
55
|
+
q?: string | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** An account that acted in a log (the actor filter's options). */
|
|
58
|
+
export interface AuditActorAccount {
|
|
59
|
+
id: string;
|
|
60
|
+
/** Null when the account no longer exists. */
|
|
61
|
+
name: string | null;
|
|
62
|
+
email: string | null;
|
|
63
|
+
avatarUrl: string | null;
|
|
64
|
+
}
|
|
65
|
+
/** An access token that acted in a log, by name (`actor=token:<id>`). */
|
|
66
|
+
export interface AuditActorToken {
|
|
67
|
+
id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
/** The owner of a personal token; null for an org's service token. */
|
|
70
|
+
accountId: string | null;
|
|
71
|
+
}
|
|
72
|
+
/** Who acted in a log: at most {@link ACTORS_CAP} accounts and tokens each. */
|
|
73
|
+
export interface AuditActors {
|
|
74
|
+
accounts: AuditActorAccount[];
|
|
75
|
+
tokens: AuditActorToken[];
|
|
76
|
+
/** More accounts or tokens acted than listed. */
|
|
77
|
+
truncated: boolean;
|
|
41
78
|
}
|
|
79
|
+
/** The most accounts (and tokens) the actor options list. */
|
|
80
|
+
export declare const ACTORS_CAP = 200;
|
|
42
81
|
/**
|
|
43
82
|
* Reads the audit log of one scope: the platform's (the admin console's Audit log) or one org's (the
|
|
44
|
-
* org settings' Audit log, and the super admin's view of an org), newest first by id,
|
|
45
|
-
* (
|
|
83
|
+
* org settings' Audit log, and the super admin's view of an org), newest first by id, by page
|
|
84
|
+
* number on a snapshot of ids (table pagination spec §2.3), with the filters of §3 and the
|
|
85
|
+
* targets' names (§3.1). Read-only and not audited (D5). Every query names the scope's `org_id`:
|
|
86
|
+
* an org's log never reads, counts or names another org's rows. The queries of one read run one
|
|
87
|
+
* after another (a read holds one pool connection at a time).
|
|
46
88
|
*/
|
|
47
89
|
export declare class AuditLogService {
|
|
48
90
|
private readonly kdb;
|
|
49
91
|
constructor(kdb: KernelDb);
|
|
50
|
-
/**
|
|
92
|
+
/** The scope's events (`audit_events_platform_idx` / `audit_events_org_id_idx`). */
|
|
93
|
+
private events;
|
|
94
|
+
/**
|
|
95
|
+
* One page. Without `asOf` the snapshot is the newest event id of the scope (whatever the
|
|
96
|
+
* filters; "0" for an empty log), so a later read with it sees the same rows and counts the
|
|
97
|
+
* newer ones.
|
|
98
|
+
*
|
|
99
|
+
* Known caveat (accepted): ids are taken when an event's transaction inserts it, not when it
|
|
100
|
+
* commits, so an event whose transaction commits after the snapshot was taken may carry an id
|
|
101
|
+
* at or below `asOf` and appear inside an older snapshot, shifting later rows of that snapshot
|
|
102
|
+
* by one page position.
|
|
103
|
+
*/
|
|
51
104
|
list(scope: AuditScope, q: AuditListQuery): Promise<AuditPage>;
|
|
105
|
+
/** The newest event id of the scope, "0" when it has none. */
|
|
106
|
+
private newestId;
|
|
107
|
+
/**
|
|
108
|
+
* The filters of `q` as one condition (the scope and the snapshot are added by the caller). `q`
|
|
109
|
+
* matches the target exactly, or by name through one semi-join per kind the scope can name
|
|
110
|
+
* (`audit_events_target_idx` serves the exact match and the `IN (…)` probes).
|
|
111
|
+
*/
|
|
112
|
+
private matcher;
|
|
113
|
+
/** The event's key names an object of `kind` in the scope whose name is LIKE `like`. */
|
|
114
|
+
private nameMatch;
|
|
115
|
+
/** The catalog items an org may see: the platform's, its own, and shared ones (the share gate). */
|
|
116
|
+
private catalogShareGate;
|
|
117
|
+
/**
|
|
118
|
+
* The label of each event's target: one query per kind the page holds, one after another (spec
|
|
119
|
+
* §3.1). A known kind whose object is gone is deleted with a null label; an unknown kind has
|
|
120
|
+
* neither.
|
|
121
|
+
*/
|
|
122
|
+
private labels;
|
|
123
|
+
/**
|
|
124
|
+
* Objects of one kind by id, within the scope: an org's objects only (its own org, the catalog
|
|
125
|
+
* items it may see); the platform's log names accounts, catalog items and marketplaces.
|
|
126
|
+
*/
|
|
127
|
+
private readKind;
|
|
128
|
+
/**
|
|
129
|
+
* The accounts and access tokens that acted in the scope's log (the actor filter's options), by
|
|
130
|
+
* name; at most {@link ACTORS_CAP} of each. Distinct actors are read by a skip scan over
|
|
131
|
+
* `audit_events_actor_idx` / `audit_events_token_idx` (one index probe per actor, not one row
|
|
132
|
+
* per event). Token names come from the scope's own tokens: an org's service tokens, the
|
|
133
|
+
* platform's personal tokens.
|
|
134
|
+
*/
|
|
135
|
+
actors(scope: AuditScope): Promise<AuditActors>;
|
|
52
136
|
}
|