@medicine-wheel/community-identity 0.14.0 → 0.14.2
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/audit.d.ts +59 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +95 -0
- package/dist/audit.js.map +1 -0
- package/dist/circles.d.ts +72 -0
- package/dist/circles.d.ts.map +1 -1
- package/dist/circles.js +64 -1
- package/dist/circles.js.map +1 -1
- package/dist/config.d.ts +47 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +123 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/people.d.ts +14 -0
- package/dist/people.d.ts.map +1 -1
- package/dist/people.js +20 -0
- package/dist/people.js.map +1 -1
- package/package.json +2 -2
package/dist/audit.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The audit log: who did what to whom, kept by the consumer.
|
|
3
|
+
*
|
|
4
|
+
* STPB keeps `audit_logs` (actor, action, entity, metadata, ip) and reads it in
|
|
5
|
+
* the admin's Audit tab. Here the same record, append-only jsonl, with the
|
|
6
|
+
* action names spelled once so every writer and the admin agree.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AUDIT_ACTIONS: readonly ["session.signed_in", "session.signed_out", "person.registered", "person.created", "person.updated", "person.role_changed", "person.deactivated", "person.reactivated", "person.api_access_enabled", "person.api_access_disabled", "token.issued", "token.revoked", "circle.created", "circle.updated", "circle.deactivated", "circle.reactivated", "circle.deleted", "circle.member_added", "circle.member_removed", "circle.joined", "invitation.created", "invitation.accepted", "invitation.revoked", "ceremony.opened", "ceremony.closed", "turn.spoken", "turn.witnessed", "diary.written", "config.updated"];
|
|
9
|
+
export type AuditAction = (typeof AUDIT_ACTIONS)[number];
|
|
10
|
+
export type AuditEntityType = 'person' | 'token' | 'circle' | 'invitation' | 'ceremony' | 'beat' | 'diary' | 'config';
|
|
11
|
+
export interface AuditRecord {
|
|
12
|
+
id: string;
|
|
13
|
+
at: string;
|
|
14
|
+
actor_id: string;
|
|
15
|
+
actor_name?: string;
|
|
16
|
+
action: AuditAction;
|
|
17
|
+
entity_type?: AuditEntityType;
|
|
18
|
+
entity_id?: string;
|
|
19
|
+
/** Free facts about the change: old and new values, names, counts. Never secrets. */
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
/** Where the request came from, when the consumer knows. */
|
|
22
|
+
origin?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AuditQuery {
|
|
25
|
+
actor_id?: string;
|
|
26
|
+
action?: AuditAction | AuditAction[];
|
|
27
|
+
entity_type?: AuditEntityType;
|
|
28
|
+
entity_id?: string;
|
|
29
|
+
/** ISO timestamps, inclusive. */
|
|
30
|
+
since?: string;
|
|
31
|
+
until?: string;
|
|
32
|
+
limit?: number;
|
|
33
|
+
offset?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface AuditPage {
|
|
36
|
+
records: AuditRecord[];
|
|
37
|
+
total: number;
|
|
38
|
+
truncated: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface AuditStore {
|
|
41
|
+
log(record: Omit<AuditRecord, 'id' | 'at'> & {
|
|
42
|
+
at?: string;
|
|
43
|
+
}): Promise<AuditRecord>;
|
|
44
|
+
/** Newest first. */
|
|
45
|
+
query(q?: AuditQuery): Promise<AuditPage>;
|
|
46
|
+
/** Counts per action since a moment; the admin's "last 7 days" panel. */
|
|
47
|
+
countSince(since: string): Promise<Record<string, number>>;
|
|
48
|
+
}
|
|
49
|
+
export declare class JsonlAuditStore implements AuditStore {
|
|
50
|
+
private readonly file;
|
|
51
|
+
constructor(file: string);
|
|
52
|
+
private readAll;
|
|
53
|
+
log(input: Omit<AuditRecord, 'id' | 'at'> & {
|
|
54
|
+
at?: string;
|
|
55
|
+
}): Promise<AuditRecord>;
|
|
56
|
+
query(q?: AuditQuery): Promise<AuditPage>;
|
|
57
|
+
countSince(since: string): Promise<Record<string, number>>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,aAAa,8lBA8BhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IACrC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACpF,oBAAoB;IACpB,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,yEAAyE;IACzE,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC5D;AAMD,qBAAa,eAAgB,YAAW,UAAU;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IAEzC,OAAO,CAAC,OAAO;IAQT,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAOlF,KAAK,CAAC,CAAC,GAAE,UAAe,GAAG,OAAO,CAAC,SAAS,CAAC;IAkB7C,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAQjE"}
|
package/dist/audit.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The audit log: who did what to whom, kept by the consumer.
|
|
4
|
+
*
|
|
5
|
+
* STPB keeps `audit_logs` (actor, action, entity, metadata, ip) and reads it in
|
|
6
|
+
* the admin's Audit tab. Here the same record, append-only jsonl, with the
|
|
7
|
+
* action names spelled once so every writer and the admin agree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.JsonlAuditStore = exports.AUDIT_ACTIONS = void 0;
|
|
11
|
+
const node_crypto_1 = require("node:crypto");
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
|
+
exports.AUDIT_ACTIONS = [
|
|
15
|
+
'session.signed_in',
|
|
16
|
+
'session.signed_out',
|
|
17
|
+
'person.registered',
|
|
18
|
+
'person.created',
|
|
19
|
+
'person.updated',
|
|
20
|
+
'person.role_changed',
|
|
21
|
+
'person.deactivated',
|
|
22
|
+
'person.reactivated',
|
|
23
|
+
'person.api_access_enabled',
|
|
24
|
+
'person.api_access_disabled',
|
|
25
|
+
'token.issued',
|
|
26
|
+
'token.revoked',
|
|
27
|
+
'circle.created',
|
|
28
|
+
'circle.updated',
|
|
29
|
+
'circle.deactivated',
|
|
30
|
+
'circle.reactivated',
|
|
31
|
+
'circle.deleted',
|
|
32
|
+
'circle.member_added',
|
|
33
|
+
'circle.member_removed',
|
|
34
|
+
'circle.joined',
|
|
35
|
+
'invitation.created',
|
|
36
|
+
'invitation.accepted',
|
|
37
|
+
'invitation.revoked',
|
|
38
|
+
'ceremony.opened',
|
|
39
|
+
'ceremony.closed',
|
|
40
|
+
'turn.spoken',
|
|
41
|
+
'turn.witnessed',
|
|
42
|
+
'diary.written',
|
|
43
|
+
'config.updated',
|
|
44
|
+
];
|
|
45
|
+
function auditId() {
|
|
46
|
+
return `audit:${Date.now()}:${(0, node_crypto_1.randomBytes)(3).toString('hex')}`;
|
|
47
|
+
}
|
|
48
|
+
class JsonlAuditStore {
|
|
49
|
+
file;
|
|
50
|
+
constructor(file) {
|
|
51
|
+
this.file = file;
|
|
52
|
+
}
|
|
53
|
+
readAll() {
|
|
54
|
+
if (!(0, node_fs_1.existsSync)(this.file))
|
|
55
|
+
return [];
|
|
56
|
+
return (0, node_fs_1.readFileSync)(this.file, 'utf8')
|
|
57
|
+
.split('\n')
|
|
58
|
+
.filter((line) => line.trim())
|
|
59
|
+
.map((line) => JSON.parse(line));
|
|
60
|
+
}
|
|
61
|
+
async log(input) {
|
|
62
|
+
const record = { id: auditId(), at: input.at ?? new Date().toISOString(), ...input };
|
|
63
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(this.file), { recursive: true });
|
|
64
|
+
(0, node_fs_1.appendFileSync)(this.file, JSON.stringify(record) + '\n');
|
|
65
|
+
return record;
|
|
66
|
+
}
|
|
67
|
+
async query(q = {}) {
|
|
68
|
+
const actions = q.action === undefined ? null : Array.isArray(q.action) ? q.action : [q.action];
|
|
69
|
+
const since = q.since ? Date.parse(q.since) : null;
|
|
70
|
+
const until = q.until ? Date.parse(q.until) : null;
|
|
71
|
+
const matched = this.readAll()
|
|
72
|
+
.filter((r) => (q.actor_id ? r.actor_id === q.actor_id : true))
|
|
73
|
+
.filter((r) => (actions ? actions.includes(r.action) : true))
|
|
74
|
+
.filter((r) => (q.entity_type ? r.entity_type === q.entity_type : true))
|
|
75
|
+
.filter((r) => (q.entity_id ? r.entity_id === q.entity_id : true))
|
|
76
|
+
.filter((r) => (since !== null ? Date.parse(r.at) >= since : true))
|
|
77
|
+
.filter((r) => (until !== null ? Date.parse(r.at) <= until : true))
|
|
78
|
+
.sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
|
|
79
|
+
const offset = q.offset && q.offset > 0 ? q.offset : 0;
|
|
80
|
+
const limit = q.limit && q.limit > 0 ? q.limit : 50;
|
|
81
|
+
const records = matched.slice(offset, offset + limit);
|
|
82
|
+
return { records, total: matched.length, truncated: offset + records.length < matched.length };
|
|
83
|
+
}
|
|
84
|
+
async countSince(since) {
|
|
85
|
+
const t = Date.parse(since);
|
|
86
|
+
const counts = {};
|
|
87
|
+
for (const r of this.readAll()) {
|
|
88
|
+
if (Date.parse(r.at) >= t)
|
|
89
|
+
counts[r.action] = (counts[r.action] ?? 0) + 1;
|
|
90
|
+
}
|
|
91
|
+
return counts;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.JsonlAuditStore = JsonlAuditStore;
|
|
95
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,6CAA0C;AAC1C,qCAA8E;AAC9E,yCAAoC;AAEvB,QAAA,aAAa,GAAG;IAC3B,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;IACnB,gBAAgB;IAChB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B;IAC3B,4BAA4B;IAC5B,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,oBAAoB;IACpB,oBAAoB;IACpB,gBAAgB;IAChB,qBAAqB;IACrB,uBAAuB;IACvB,eAAe;IACf,oBAAoB;IACpB,qBAAqB;IACrB,oBAAoB;IACpB,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,gBAAgB;CACR,CAAC;AA8CX,SAAS,OAAO;IACd,OAAO,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAA,yBAAW,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;AACjE,CAAC;AAED,MAAa,eAAe;IACG;IAA7B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAErC,OAAO;QACb,IAAI,CAAC,IAAA,oBAAU,EAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QACtC,OAAO,IAAA,sBAAY,EAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;aACnC,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAA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AAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAa;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC;gBAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5CD,0CA4CC"}
|
package/dist/circles.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ export interface CircleContainer {
|
|
|
22
22
|
hide_engagement_metrics: boolean;
|
|
23
23
|
}
|
|
24
24
|
export declare const DEFAULT_CONTAINER: CircleContainer;
|
|
25
|
+
/** STPB's circle kinds: an ongoing circle, a seasonal one, one held once. */
|
|
26
|
+
export type CircleType = 'ongoing' | 'seasonal' | 'one_time';
|
|
27
|
+
export declare const CIRCLE_TYPES: readonly CircleType[];
|
|
25
28
|
export interface Circle {
|
|
26
29
|
/** The node id on the wheel. */
|
|
27
30
|
id: string;
|
|
@@ -30,6 +33,11 @@ export interface Circle {
|
|
|
30
33
|
facilitator_id: string;
|
|
31
34
|
direction?: DirectionName;
|
|
32
35
|
capacity?: number;
|
|
36
|
+
circle_type: CircleType;
|
|
37
|
+
/** A public circle is visible to everyone on the wheel; a private one to its members and admins. */
|
|
38
|
+
is_public: boolean;
|
|
39
|
+
/** An inactive circle keeps its members and history; no ceremony is opened in it. */
|
|
40
|
+
active: boolean;
|
|
33
41
|
container: CircleContainer;
|
|
34
42
|
created_at: string;
|
|
35
43
|
updated_at: string;
|
|
@@ -41,6 +49,8 @@ export declare const NewCircleSchema: z.ZodObject<{
|
|
|
41
49
|
facilitator_id: z.ZodString;
|
|
42
50
|
direction: z.ZodOptional<z.ZodEnum<["east", "south", "west", "north"]>>;
|
|
43
51
|
capacity: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
circle_type: z.ZodOptional<z.ZodEnum<["ongoing", "seasonal", "one_time"]>>;
|
|
53
|
+
is_public: z.ZodOptional<z.ZodBoolean>;
|
|
44
54
|
container: z.ZodOptional<z.ZodObject<{
|
|
45
55
|
private_by_default: z.ZodOptional<z.ZodBoolean>;
|
|
46
56
|
explicit_sharing_consent: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -61,6 +71,8 @@ export declare const NewCircleSchema: z.ZodObject<{
|
|
|
61
71
|
id?: string | undefined;
|
|
62
72
|
direction?: "east" | "south" | "west" | "north" | undefined;
|
|
63
73
|
capacity?: number | undefined;
|
|
74
|
+
circle_type?: "ongoing" | "seasonal" | "one_time" | undefined;
|
|
75
|
+
is_public?: boolean | undefined;
|
|
64
76
|
container?: {
|
|
65
77
|
private_by_default?: boolean | undefined;
|
|
66
78
|
explicit_sharing_consent?: boolean | undefined;
|
|
@@ -73,6 +85,8 @@ export declare const NewCircleSchema: z.ZodObject<{
|
|
|
73
85
|
id?: string | undefined;
|
|
74
86
|
direction?: "east" | "south" | "west" | "north" | undefined;
|
|
75
87
|
capacity?: number | undefined;
|
|
88
|
+
circle_type?: "ongoing" | "seasonal" | "one_time" | undefined;
|
|
89
|
+
is_public?: boolean | undefined;
|
|
76
90
|
container?: {
|
|
77
91
|
private_by_default?: boolean | undefined;
|
|
78
92
|
explicit_sharing_consent?: boolean | undefined;
|
|
@@ -97,4 +111,62 @@ export declare function membershipFromEdge(edge: RelationalEdge | Omit<Relationa
|
|
|
97
111
|
export declare function membersOf(circle_id: string, edges: readonly (RelationalEdge | Omit<RelationalEdge, 'id'>)[]): Membership[];
|
|
98
112
|
/** Circles one person belongs to, from the edges that leave them. */
|
|
99
113
|
export declare function circlesOf(person_id: string, edges: readonly (RelationalEdge | Omit<RelationalEdge, 'id'>)[]): Membership[];
|
|
114
|
+
export declare const CirclePatchSchema: z.ZodObject<{
|
|
115
|
+
name: z.ZodOptional<z.ZodString>;
|
|
116
|
+
intention: z.ZodOptional<z.ZodString>;
|
|
117
|
+
facilitator_id: z.ZodOptional<z.ZodString>;
|
|
118
|
+
direction: z.ZodOptional<z.ZodNullable<z.ZodEnum<["east", "south", "west", "north"]>>>;
|
|
119
|
+
capacity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
120
|
+
circle_type: z.ZodOptional<z.ZodEnum<["ongoing", "seasonal", "one_time"]>>;
|
|
121
|
+
is_public: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
+
active: z.ZodOptional<z.ZodBoolean>;
|
|
123
|
+
container: z.ZodOptional<z.ZodObject<{
|
|
124
|
+
private_by_default: z.ZodOptional<z.ZodBoolean>;
|
|
125
|
+
explicit_sharing_consent: z.ZodOptional<z.ZodBoolean>;
|
|
126
|
+
hide_engagement_metrics: z.ZodOptional<z.ZodBoolean>;
|
|
127
|
+
}, "strip", z.ZodTypeAny, {
|
|
128
|
+
private_by_default?: boolean | undefined;
|
|
129
|
+
explicit_sharing_consent?: boolean | undefined;
|
|
130
|
+
hide_engagement_metrics?: boolean | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
private_by_default?: boolean | undefined;
|
|
133
|
+
explicit_sharing_consent?: boolean | undefined;
|
|
134
|
+
hide_engagement_metrics?: boolean | undefined;
|
|
135
|
+
}>>;
|
|
136
|
+
}, "strict", z.ZodTypeAny, {
|
|
137
|
+
name?: string | undefined;
|
|
138
|
+
intention?: string | undefined;
|
|
139
|
+
facilitator_id?: string | undefined;
|
|
140
|
+
direction?: "east" | "south" | "west" | "north" | null | undefined;
|
|
141
|
+
capacity?: number | null | undefined;
|
|
142
|
+
circle_type?: "ongoing" | "seasonal" | "one_time" | undefined;
|
|
143
|
+
is_public?: boolean | undefined;
|
|
144
|
+
container?: {
|
|
145
|
+
private_by_default?: boolean | undefined;
|
|
146
|
+
explicit_sharing_consent?: boolean | undefined;
|
|
147
|
+
hide_engagement_metrics?: boolean | undefined;
|
|
148
|
+
} | undefined;
|
|
149
|
+
active?: boolean | undefined;
|
|
150
|
+
}, {
|
|
151
|
+
name?: string | undefined;
|
|
152
|
+
intention?: string | undefined;
|
|
153
|
+
facilitator_id?: string | undefined;
|
|
154
|
+
direction?: "east" | "south" | "west" | "north" | null | undefined;
|
|
155
|
+
capacity?: number | null | undefined;
|
|
156
|
+
circle_type?: "ongoing" | "seasonal" | "one_time" | undefined;
|
|
157
|
+
is_public?: boolean | undefined;
|
|
158
|
+
container?: {
|
|
159
|
+
private_by_default?: boolean | undefined;
|
|
160
|
+
explicit_sharing_consent?: boolean | undefined;
|
|
161
|
+
hide_engagement_metrics?: boolean | undefined;
|
|
162
|
+
} | undefined;
|
|
163
|
+
active?: boolean | undefined;
|
|
164
|
+
}>;
|
|
165
|
+
export type CirclePatch = z.infer<typeof CirclePatchSchema>;
|
|
166
|
+
/** The node patch (name, direction, metadata) that applies a circle change to the existing node. */
|
|
167
|
+
export declare function circleNodePatch(node: RelationalNode, patch: CirclePatch): {
|
|
168
|
+
name?: string;
|
|
169
|
+
direction?: DirectionName | null;
|
|
170
|
+
metadata: Record<string, unknown>;
|
|
171
|
+
};
|
|
100
172
|
//# sourceMappingURL=circles.d.ts.map
|
package/dist/circles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circles.d.ts","sourceRoot":"","sources":["../src/circles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,WAAW,EAAG,QAAiB,CAAC;AAC7C,eAAO,MAAM,SAAS,EAAG,WAAoB,CAAC;AAE9C,sGAAsG;AACtG,MAAM,WAAW,eAAe;IAC9B,uFAAuF;IACvF,kBAAkB,EAAE,OAAO,CAAC;IAC5B,uEAAuE;IACvE,wBAAwB,EAAE,OAAO,CAAC;IAClC,+CAA+C;IAC/C,uBAAuB,EAAE,OAAO,CAAC;CAClC;AAED,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"circles.d.ts","sourceRoot":"","sources":["../src/circles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,CAAC,EAAE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,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAwBhK"}
|
package/dist/circles.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* in `circle_id` (ontology-core 0.14.0).
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.NewCircleSchema = exports.DEFAULT_CONTAINER = exports.MEMBER_OF = exports.CIRCLE_KIND = void 0;
|
|
13
|
+
exports.CirclePatchSchema = exports.NewCircleSchema = exports.CIRCLE_TYPES = exports.DEFAULT_CONTAINER = exports.MEMBER_OF = exports.CIRCLE_KIND = void 0;
|
|
14
14
|
exports.circleNodeId = circleNodeId;
|
|
15
15
|
exports.circleNode = circleNode;
|
|
16
16
|
exports.circleFromNode = circleFromNode;
|
|
@@ -18,6 +18,7 @@ exports.membershipEdge = membershipEdge;
|
|
|
18
18
|
exports.membershipFromEdge = membershipFromEdge;
|
|
19
19
|
exports.membersOf = membersOf;
|
|
20
20
|
exports.circlesOf = circlesOf;
|
|
21
|
+
exports.circleNodePatch = circleNodePatch;
|
|
21
22
|
const zod_1 = require("zod");
|
|
22
23
|
exports.CIRCLE_KIND = 'circle';
|
|
23
24
|
exports.MEMBER_OF = 'member_of';
|
|
@@ -26,6 +27,7 @@ exports.DEFAULT_CONTAINER = {
|
|
|
26
27
|
explicit_sharing_consent: true,
|
|
27
28
|
hide_engagement_metrics: true,
|
|
28
29
|
};
|
|
30
|
+
exports.CIRCLE_TYPES = ['ongoing', 'seasonal', 'one_time'];
|
|
29
31
|
exports.NewCircleSchema = zod_1.z.object({
|
|
30
32
|
id: zod_1.z.string().trim().min(1).optional(),
|
|
31
33
|
name: zod_1.z.string().trim().min(1),
|
|
@@ -33,6 +35,8 @@ exports.NewCircleSchema = zod_1.z.object({
|
|
|
33
35
|
facilitator_id: zod_1.z.string().trim().min(1),
|
|
34
36
|
direction: zod_1.z.enum(['east', 'south', 'west', 'north']).optional(),
|
|
35
37
|
capacity: zod_1.z.number().int().positive().optional(),
|
|
38
|
+
circle_type: zod_1.z.enum(['ongoing', 'seasonal', 'one_time']).optional(),
|
|
39
|
+
is_public: zod_1.z.boolean().optional(),
|
|
36
40
|
container: zod_1.z
|
|
37
41
|
.object({
|
|
38
42
|
private_by_default: zod_1.z.boolean().optional(),
|
|
@@ -55,6 +59,9 @@ function circleNode(input, now = new Date().toISOString()) {
|
|
|
55
59
|
intention: input.intention,
|
|
56
60
|
facilitator_id: input.facilitator_id,
|
|
57
61
|
...(input.capacity !== undefined ? { capacity: input.capacity } : {}),
|
|
62
|
+
circle_type: input.circle_type ?? 'ongoing',
|
|
63
|
+
is_public: input.is_public ?? false,
|
|
64
|
+
active: true,
|
|
58
65
|
container: { ...exports.DEFAULT_CONTAINER, ...(input.container ?? {}) },
|
|
59
66
|
},
|
|
60
67
|
created_at: now,
|
|
@@ -75,6 +82,9 @@ function circleFromNode(node) {
|
|
|
75
82
|
facilitator_id: meta.facilitator_id,
|
|
76
83
|
...(node.direction ? { direction: node.direction } : {}),
|
|
77
84
|
...(typeof meta.capacity === 'number' ? { capacity: meta.capacity } : {}),
|
|
85
|
+
circle_type: exports.CIRCLE_TYPES.includes(String(meta.circle_type)) ? meta.circle_type : 'ongoing',
|
|
86
|
+
is_public: meta.is_public === true,
|
|
87
|
+
active: meta.active !== false,
|
|
78
88
|
container: { ...exports.DEFAULT_CONTAINER, ...container },
|
|
79
89
|
created_at: node.created_at,
|
|
80
90
|
updated_at: node.updated_at,
|
|
@@ -116,4 +126,57 @@ function circlesOf(person_id, edges) {
|
|
|
116
126
|
.map(membershipFromEdge)
|
|
117
127
|
.filter((m) => m !== null);
|
|
118
128
|
}
|
|
129
|
+
exports.CirclePatchSchema = zod_1.z
|
|
130
|
+
.object({
|
|
131
|
+
name: zod_1.z.string().trim().min(1).optional(),
|
|
132
|
+
intention: zod_1.z.string().trim().min(1).optional(),
|
|
133
|
+
facilitator_id: zod_1.z.string().trim().min(1).optional(),
|
|
134
|
+
direction: zod_1.z.enum(['east', 'south', 'west', 'north']).nullable().optional(),
|
|
135
|
+
capacity: zod_1.z.number().int().positive().nullable().optional(),
|
|
136
|
+
circle_type: zod_1.z.enum(['ongoing', 'seasonal', 'one_time']).optional(),
|
|
137
|
+
is_public: zod_1.z.boolean().optional(),
|
|
138
|
+
active: zod_1.z.boolean().optional(),
|
|
139
|
+
container: zod_1.z
|
|
140
|
+
.object({
|
|
141
|
+
private_by_default: zod_1.z.boolean().optional(),
|
|
142
|
+
explicit_sharing_consent: zod_1.z.boolean().optional(),
|
|
143
|
+
hide_engagement_metrics: zod_1.z.boolean().optional(),
|
|
144
|
+
})
|
|
145
|
+
.optional(),
|
|
146
|
+
})
|
|
147
|
+
.strict();
|
|
148
|
+
/** The node patch (name, direction, metadata) that applies a circle change to the existing node. */
|
|
149
|
+
function circleNodePatch(node, patch) {
|
|
150
|
+
const meta = { ...(node.metadata ?? {}) };
|
|
151
|
+
if (patch.intention !== undefined)
|
|
152
|
+
meta.intention = patch.intention;
|
|
153
|
+
if (patch.facilitator_id !== undefined)
|
|
154
|
+
meta.facilitator_id = patch.facilitator_id;
|
|
155
|
+
if (patch.capacity !== undefined) {
|
|
156
|
+
if (patch.capacity === null)
|
|
157
|
+
delete meta.capacity;
|
|
158
|
+
else
|
|
159
|
+
meta.capacity = patch.capacity;
|
|
160
|
+
}
|
|
161
|
+
if (patch.circle_type !== undefined)
|
|
162
|
+
meta.circle_type = patch.circle_type;
|
|
163
|
+
if (patch.is_public !== undefined)
|
|
164
|
+
meta.is_public = patch.is_public;
|
|
165
|
+
if (patch.active !== undefined) {
|
|
166
|
+
meta.active = patch.active;
|
|
167
|
+
if (!patch.active)
|
|
168
|
+
meta.deactivated_at = new Date().toISOString();
|
|
169
|
+
else
|
|
170
|
+
delete meta.deactivated_at;
|
|
171
|
+
}
|
|
172
|
+
if (patch.container) {
|
|
173
|
+
const current = (meta.container && typeof meta.container === 'object' ? meta.container : {});
|
|
174
|
+
meta.container = { ...exports.DEFAULT_CONTAINER, ...current, ...patch.container };
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
...(patch.name !== undefined ? { name: patch.name } : {}),
|
|
178
|
+
...(patch.direction !== undefined ? { direction: patch.direction } : {}),
|
|
179
|
+
metadata: meta,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
119
182
|
//# sourceMappingURL=circles.js.map
|
package/dist/circles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circles.js","sourceRoot":"","sources":["../src/circles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;
|
|
1
|
+
{"version":3,"file":"circles.js","sourceRoot":"","sources":["../src/circles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAkEH,oCAEC;AAED,gCAmBC;AAED,wCAmBC;AAYD,wCAUC;AAED,gDAQC;AAGD,8BAKC;AAGD,8BAKC;AAyBD,0CAwBC;AA5MD,6BAAwB;AAEX,QAAA,WAAW,GAAG,QAAiB,CAAC;AAChC,QAAA,SAAS,GAAG,WAAoB,CAAC;AAYjC,QAAA,iBAAiB,GAAoB;IAChD,kBAAkB,EAAE,IAAI;IACxB,wBAAwB,EAAE,IAAI;IAC9B,uBAAuB,EAAE,IAAI;CAC9B,CAAC;AAIW,QAAA,YAAY,GAA0B,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AAoBnF,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACvC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,SAAS,EAAE,OAAC,CAAC,MAAM,E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S,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,QAAQ,EAAE,IAAI;KACf,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Community configuration: what an admin sets for the whole platform.
|
|
3
|
+
*
|
|
4
|
+
* STPB keeps `platform_config` (key, value, updated_by) behind its Config tab:
|
|
5
|
+
* open registration, ceremony registration, limits. Here the fields a wheel
|
|
6
|
+
* community needs, one JSON file kept by the consumer, plus the one thing STPB
|
|
7
|
+
* cannot do: grant a role a permission it does not carry by default (so a
|
|
8
|
+
* community may decide that its participants witness).
|
|
9
|
+
*/
|
|
10
|
+
import { type Permission, type Role } from './roles.js';
|
|
11
|
+
export type RegistrationMode = 'invite_only' | 'open' | 'closed';
|
|
12
|
+
export interface CommunityConfig {
|
|
13
|
+
/** `invite_only`: a code from a circle is needed (default). `open`: anyone may register, unseated. `closed`: nobody. */
|
|
14
|
+
registration: RegistrationMode;
|
|
15
|
+
/** The role a newcomer receives. */
|
|
16
|
+
default_role: Role;
|
|
17
|
+
/** Whether a newcomer may issue their own tokens from the start. Default off: an admin enables API access per person. */
|
|
18
|
+
default_api_access: boolean;
|
|
19
|
+
/** Permissions granted beyond the role's default map, per role. */
|
|
20
|
+
role_grants: Partial<Record<Role, Permission[]>>;
|
|
21
|
+
/** Shown to everyone signed in, when set. */
|
|
22
|
+
site_notice?: string;
|
|
23
|
+
updated_at?: string;
|
|
24
|
+
updated_by?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const DEFAULT_CONFIG: CommunityConfig;
|
|
27
|
+
export declare function isRegistrationMode(v: unknown): v is RegistrationMode;
|
|
28
|
+
/** Validate a partial config from the outside; returns the fields that are valid and the reasons for the rest. */
|
|
29
|
+
export declare function validateConfigPatch(input: unknown): {
|
|
30
|
+
patch: Partial<CommunityConfig>;
|
|
31
|
+
errors: string[];
|
|
32
|
+
};
|
|
33
|
+
/** The role's permissions with the community's grants applied. */
|
|
34
|
+
export declare function permissionsFor(role: Role, config?: Pick<CommunityConfig, 'role_grants'>): readonly (Permission | '*')[];
|
|
35
|
+
export declare function mayDo(role: Role, permission: Permission, config?: Pick<CommunityConfig, 'role_grants'>): boolean;
|
|
36
|
+
export interface ConfigStore {
|
|
37
|
+
get(): Promise<CommunityConfig>;
|
|
38
|
+
set(patch: Partial<CommunityConfig>, updated_by: string): Promise<CommunityConfig>;
|
|
39
|
+
}
|
|
40
|
+
/** One JSON file, whole config, rewritten on change. */
|
|
41
|
+
export declare class JsonConfigStore implements ConfigStore {
|
|
42
|
+
private readonly file;
|
|
43
|
+
constructor(file: string);
|
|
44
|
+
get(): Promise<CommunityConfig>;
|
|
45
|
+
set(patch: Partial<CommunityConfig>, updated_by: string): Promise<CommunityConfig>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAwD,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAE9G,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC9B,wHAAwH;IACxH,YAAY,EAAE,gBAAgB,CAAC;IAC/B,oCAAoC;IACpC,YAAY,EAAE,IAAI,CAAC;IACnB,yHAAyH;IACzH,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mEAAmE;IACnE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IACjD,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,eAK5B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,CAEpE;AAED,kHAAkH;AAClH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCzG;AAED,kEAAkE;AAClE,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,IAAI,CAAC,eAAe,EAAE,aAAa,CAAkB,GAAG,SAAS,CAAC,UAAU,GAAG,GAAG,CAAC,EAAE,CAKvI;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAE,IAAI,CAAC,eAAe,EAAE,aAAa,CAAkB,GAAG,OAAO,CAEhI;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IAChC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACpF;AAED,wDAAwD;AACxD,qBAAa,eAAgB,YAAW,WAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IAEnC,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;IAW/B,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAQzF"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Community configuration: what an admin sets for the whole platform.
|
|
4
|
+
*
|
|
5
|
+
* STPB keeps `platform_config` (key, value, updated_by) behind its Config tab:
|
|
6
|
+
* open registration, ceremony registration, limits. Here the fields a wheel
|
|
7
|
+
* community needs, one JSON file kept by the consumer, plus the one thing STPB
|
|
8
|
+
* cannot do: grant a role a permission it does not carry by default (so a
|
|
9
|
+
* community may decide that its participants witness).
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JsonConfigStore = exports.DEFAULT_CONFIG = void 0;
|
|
13
|
+
exports.isRegistrationMode = isRegistrationMode;
|
|
14
|
+
exports.validateConfigPatch = validateConfigPatch;
|
|
15
|
+
exports.permissionsFor = permissionsFor;
|
|
16
|
+
exports.mayDo = mayDo;
|
|
17
|
+
const node_fs_1 = require("node:fs");
|
|
18
|
+
const node_path_1 = require("node:path");
|
|
19
|
+
const roles_js_1 = require("./roles.js");
|
|
20
|
+
exports.DEFAULT_CONFIG = {
|
|
21
|
+
registration: 'invite_only',
|
|
22
|
+
default_role: 'participant',
|
|
23
|
+
default_api_access: false,
|
|
24
|
+
role_grants: {},
|
|
25
|
+
};
|
|
26
|
+
function isRegistrationMode(v) {
|
|
27
|
+
return v === 'invite_only' || v === 'open' || v === 'closed';
|
|
28
|
+
}
|
|
29
|
+
/** Validate a partial config from the outside; returns the fields that are valid and the reasons for the rest. */
|
|
30
|
+
function validateConfigPatch(input) {
|
|
31
|
+
const errors = [];
|
|
32
|
+
const patch = {};
|
|
33
|
+
if (!input || typeof input !== 'object')
|
|
34
|
+
return { patch, errors: ['config must be an object'] };
|
|
35
|
+
const o = input;
|
|
36
|
+
if (o.registration !== undefined) {
|
|
37
|
+
if (isRegistrationMode(o.registration))
|
|
38
|
+
patch.registration = o.registration;
|
|
39
|
+
else
|
|
40
|
+
errors.push('registration must be invite_only, open or closed');
|
|
41
|
+
}
|
|
42
|
+
if (o.default_role !== undefined) {
|
|
43
|
+
if ((0, roles_js_1.isRole)(o.default_role))
|
|
44
|
+
patch.default_role = o.default_role;
|
|
45
|
+
else
|
|
46
|
+
errors.push('default_role is not a role');
|
|
47
|
+
}
|
|
48
|
+
if (o.default_api_access !== undefined) {
|
|
49
|
+
if (typeof o.default_api_access === 'boolean')
|
|
50
|
+
patch.default_api_access = o.default_api_access;
|
|
51
|
+
else
|
|
52
|
+
errors.push('default_api_access must be true or false');
|
|
53
|
+
}
|
|
54
|
+
if (o.role_grants !== undefined) {
|
|
55
|
+
if (!o.role_grants || typeof o.role_grants !== 'object')
|
|
56
|
+
errors.push('role_grants must be an object');
|
|
57
|
+
else {
|
|
58
|
+
const grants = {};
|
|
59
|
+
for (const [role, perms] of Object.entries(o.role_grants)) {
|
|
60
|
+
if (!(0, roles_js_1.isRole)(role)) {
|
|
61
|
+
errors.push(`role_grants: ${role} is not a role`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!Array.isArray(perms) || !perms.every((p) => roles_js_1.PERMISSIONS.includes(String(p)))) {
|
|
65
|
+
errors.push(`role_grants.${role}: unknown permission`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
grants[role] = perms;
|
|
69
|
+
}
|
|
70
|
+
patch.role_grants = grants;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (o.site_notice !== undefined) {
|
|
74
|
+
if (o.site_notice === null || o.site_notice === '')
|
|
75
|
+
patch.site_notice = undefined;
|
|
76
|
+
else if (typeof o.site_notice === 'string')
|
|
77
|
+
patch.site_notice = o.site_notice.slice(0, 500);
|
|
78
|
+
else
|
|
79
|
+
errors.push('site_notice must be text');
|
|
80
|
+
}
|
|
81
|
+
return { patch, errors };
|
|
82
|
+
}
|
|
83
|
+
/** The role's permissions with the community's grants applied. */
|
|
84
|
+
function permissionsFor(role, config = exports.DEFAULT_CONFIG) {
|
|
85
|
+
const base = roles_js_1.ROLE_PERMISSIONS[role];
|
|
86
|
+
if (base.includes('*'))
|
|
87
|
+
return base;
|
|
88
|
+
const extra = config.role_grants?.[role] ?? [];
|
|
89
|
+
return [...new Set([...base, ...extra])];
|
|
90
|
+
}
|
|
91
|
+
function mayDo(role, permission, config = exports.DEFAULT_CONFIG) {
|
|
92
|
+
return (0, roles_js_1.hasPermission)(role, permission) || (config.role_grants?.[role] ?? []).includes(permission);
|
|
93
|
+
}
|
|
94
|
+
/** One JSON file, whole config, rewritten on change. */
|
|
95
|
+
class JsonConfigStore {
|
|
96
|
+
file;
|
|
97
|
+
constructor(file) {
|
|
98
|
+
this.file = file;
|
|
99
|
+
}
|
|
100
|
+
async get() {
|
|
101
|
+
if (!(0, node_fs_1.existsSync)(this.file))
|
|
102
|
+
return { ...exports.DEFAULT_CONFIG };
|
|
103
|
+
try {
|
|
104
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(this.file, 'utf8'));
|
|
105
|
+
const { patch } = validateConfigPatch(parsed);
|
|
106
|
+
return { ...exports.DEFAULT_CONFIG, ...patch, ...(parsed.updated_at ? { updated_at: parsed.updated_at } : {}), ...(parsed.updated_by ? { updated_by: parsed.updated_by } : {}) };
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return { ...exports.DEFAULT_CONFIG };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async set(patch, updated_by) {
|
|
113
|
+
const current = await this.get();
|
|
114
|
+
const next = { ...current, ...patch, updated_at: new Date().toISOString(), updated_by };
|
|
115
|
+
if (patch.site_notice === undefined && 'site_notice' in patch)
|
|
116
|
+
delete next.site_notice;
|
|
117
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(this.file), { recursive: true });
|
|
118
|
+
(0, node_fs_1.writeFileSync)(this.file, JSON.stringify(next, null, 2) + '\n');
|
|
119
|
+
return next;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.JsonConfigStore = JsonConfigStore;
|
|
123
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA8BH,gDAEC;AAGD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"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -33,4 +33,6 @@ __exportStar(require("./people.js"), exports);
|
|
|
33
33
|
__exportStar(require("./circles.js"), exports);
|
|
34
34
|
__exportStar(require("./credentials.js"), exports);
|
|
35
35
|
__exportStar(require("./invitations.js"), exports);
|
|
36
|
+
__exportStar(require("./audit.js"), exports);
|
|
37
|
+
__exportStar(require("./config.js"), exports);
|
|
36
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,mDAAiC;AACjC,mDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,mDAAiC;AACjC,mDAAiC;AACjC,6CAA2B;AAC3B,8CAA4B"}
|
package/dist/people.d.ts
CHANGED
|
@@ -12,11 +12,16 @@ import type { DirectionName, RelationalNode } from '@medicine-wheel/ontology-cor
|
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { type Role } from './roles.js';
|
|
14
14
|
export declare const PERSON_KIND: "person";
|
|
15
|
+
export type PersonStatus = 'active' | 'deactivated';
|
|
15
16
|
export interface Person {
|
|
16
17
|
/** The node id on the wheel. */
|
|
17
18
|
id: string;
|
|
18
19
|
name: string;
|
|
19
20
|
role: Role;
|
|
21
|
+
/** A deactivated person keeps their node and history but cannot sign in. Default `active`. */
|
|
22
|
+
status: PersonStatus;
|
|
23
|
+
/** May this person issue their own tokens? An admin turns it on (STPB's `api_access_enabled`). Default off. */
|
|
24
|
+
api_access: boolean;
|
|
20
25
|
email?: string;
|
|
21
26
|
direction?: DirectionName;
|
|
22
27
|
created_at: string;
|
|
@@ -28,18 +33,21 @@ export declare const NewPersonSchema: z.ZodObject<{
|
|
|
28
33
|
role: z.ZodEffects<z.ZodString, "participant" | "emerging_guide" | "ceremony_facilitator" | "firekeeper" | "story_keeper" | "admin" | "companion_ai" | "integration_ai", string>;
|
|
29
34
|
email: z.ZodOptional<z.ZodString>;
|
|
30
35
|
direction: z.ZodOptional<z.ZodEnum<["east", "south", "west", "north"]>>;
|
|
36
|
+
api_access: z.ZodOptional<z.ZodBoolean>;
|
|
31
37
|
}, "strip", z.ZodTypeAny, {
|
|
32
38
|
name: string;
|
|
33
39
|
role: "participant" | "emerging_guide" | "ceremony_facilitator" | "firekeeper" | "story_keeper" | "admin" | "companion_ai" | "integration_ai";
|
|
34
40
|
id?: string | undefined;
|
|
35
41
|
direction?: "east" | "south" | "west" | "north" | undefined;
|
|
36
42
|
email?: string | undefined;
|
|
43
|
+
api_access?: boolean | undefined;
|
|
37
44
|
}, {
|
|
38
45
|
name: string;
|
|
39
46
|
role: string;
|
|
40
47
|
id?: string | undefined;
|
|
41
48
|
direction?: "east" | "south" | "west" | "north" | undefined;
|
|
42
49
|
email?: string | undefined;
|
|
50
|
+
api_access?: boolean | undefined;
|
|
43
51
|
}>;
|
|
44
52
|
export type NewPerson = z.infer<typeof NewPersonSchema>;
|
|
45
53
|
export declare function personNodeId(): string;
|
|
@@ -49,4 +57,10 @@ export declare function personNode(input: NewPerson, now?: string): RelationalNo
|
|
|
49
57
|
export declare function personFromNode(node: RelationalNode | null | undefined): Person | null;
|
|
50
58
|
/** The metadata patch that grants (or changes) a person's role. */
|
|
51
59
|
export declare function roleGrant(role: Role, current?: Record<string, unknown>): Record<string, unknown>;
|
|
60
|
+
/** The metadata patch that deactivates a person: they stay on the wheel, they cannot sign in. */
|
|
61
|
+
export declare function deactivatePatch(current?: Record<string, unknown>): Record<string, unknown>;
|
|
62
|
+
/** The metadata patch that lets a deactivated person back in. */
|
|
63
|
+
export declare function reactivatePatch(current?: Record<string, unknown>): Record<string, unknown>;
|
|
64
|
+
/** The metadata patch that grants or withdraws API access (the right to issue one's own tokens). */
|
|
65
|
+
export declare function apiAccessPatch(enabled: boolean, current?: Record<string, unknown>): Record<string, unknown>;
|
|
52
66
|
//# sourceMappingURL=people.d.ts.map
|
package/dist/people.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../src/people.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,WAAW,EAAG,QAAiB,CAAC;AAE7C,MAAM,WAAW,MAAM;IACrB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,aAAa,CA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,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEpG;AAED,iGAAiG;AACjG,wBAAgB,eAAe,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9F;AAED,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG9F;AAED,oGAAoG;AACpG,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE/G"}
|
package/dist/people.js
CHANGED
|
@@ -15,6 +15,9 @@ exports.personNodeId = personNodeId;
|
|
|
15
15
|
exports.personNode = personNode;
|
|
16
16
|
exports.personFromNode = personFromNode;
|
|
17
17
|
exports.roleGrant = roleGrant;
|
|
18
|
+
exports.deactivatePatch = deactivatePatch;
|
|
19
|
+
exports.reactivatePatch = reactivatePatch;
|
|
20
|
+
exports.apiAccessPatch = apiAccessPatch;
|
|
18
21
|
const zod_1 = require("zod");
|
|
19
22
|
const roles_js_1 = require("./roles.js");
|
|
20
23
|
exports.PERSON_KIND = 'person';
|
|
@@ -24,6 +27,7 @@ exports.NewPersonSchema = zod_1.z.object({
|
|
|
24
27
|
role: zod_1.z.string().refine(roles_js_1.isRole, 'unknown role'),
|
|
25
28
|
email: zod_1.z.string().trim().email().optional(),
|
|
26
29
|
direction: zod_1.z.enum(['east', 'south', 'west', 'north']).optional(),
|
|
30
|
+
api_access: zod_1.z.boolean().optional(),
|
|
27
31
|
});
|
|
28
32
|
function personNodeId() {
|
|
29
33
|
return `node:human:${Date.now()}:${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -38,6 +42,7 @@ function personNode(input, now = new Date().toISOString()) {
|
|
|
38
42
|
metadata: {
|
|
39
43
|
kind: exports.PERSON_KIND,
|
|
40
44
|
role: input.role,
|
|
45
|
+
api_access: input.api_access === true,
|
|
41
46
|
...(input.email ? { email: input.email } : {}),
|
|
42
47
|
},
|
|
43
48
|
created_at: now,
|
|
@@ -55,6 +60,8 @@ function personFromNode(node) {
|
|
|
55
60
|
id: node.id,
|
|
56
61
|
name: node.name,
|
|
57
62
|
role: meta.role,
|
|
63
|
+
status: meta.status === 'deactivated' ? 'deactivated' : 'active',
|
|
64
|
+
api_access: meta.api_access === true,
|
|
58
65
|
...(typeof meta.email === 'string' ? { email: meta.email } : {}),
|
|
59
66
|
...(node.direction ? { direction: node.direction } : {}),
|
|
60
67
|
created_at: node.created_at,
|
|
@@ -65,4 +72,17 @@ function personFromNode(node) {
|
|
|
65
72
|
function roleGrant(role, current = {}) {
|
|
66
73
|
return { ...current, kind: exports.PERSON_KIND, role };
|
|
67
74
|
}
|
|
75
|
+
/** The metadata patch that deactivates a person: they stay on the wheel, they cannot sign in. */
|
|
76
|
+
function deactivatePatch(current = {}) {
|
|
77
|
+
return { ...current, status: 'deactivated', deactivated_at: new Date().toISOString() };
|
|
78
|
+
}
|
|
79
|
+
/** The metadata patch that lets a deactivated person back in. */
|
|
80
|
+
function reactivatePatch(current = {}) {
|
|
81
|
+
const { deactivated_at: _gone, ...rest } = current;
|
|
82
|
+
return { ...rest, status: 'active' };
|
|
83
|
+
}
|
|
84
|
+
/** The metadata patch that grants or withdraws API access (the right to issue one's own tokens). */
|
|
85
|
+
function apiAccessPatch(enabled, current = {}) {
|
|
86
|
+
return { ...current, api_access: enabled };
|
|
87
|
+
}
|
|
68
88
|
//# sourceMappingURL=people.js.map
|
package/dist/people.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"people.js","sourceRoot":"","sources":["../src/people.ts"],"names":[],"mappings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CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,SAAgB,SAAS,CAAC,IAAU,EAAE,UAAmC,EAAE;IACzE,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,mBAAW,EAAE,IAAI,EAAE,CAAC;AACjD,CAAC;AAED,iGAAiG;AACjG,SAAgB,eAAe,CAAC,UAAmC,EAAE;IACnE,OAAO,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;AACzF,CAAC;AAED,iEAAiE;AACjE,SAAgB,eAAe,CAAC,UAAmC,EAAE;IACnE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACnD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED,oGAAoG;AACpG,SAAgB,cAAc,CAAC,OAAgB,EAAE,UAAmC,EAAE;IACpF,OAAO,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medicine-wheel/community-identity",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "Who is in the circle: people as wheel nodes, roles with a permission map, circles and memberships as relations, invitations and self-issued credentials kept by the consumer — so a Medicine Wheel can tell two people apart.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"directory": "src/community-identity"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@medicine-wheel/ontology-core": "^0.14.
|
|
44
|
+
"@medicine-wheel/ontology-core": "^0.14.2",
|
|
45
45
|
"zod": "^3.23.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|