@odla-ai/chapter 0.0.1
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/README.md +72 -0
- package/dist/index.cjs +368 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +198 -0
- package/dist/index.d.ts +198 -0
- package/dist/index.js +345 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/index.d.ts +48 -0
- package/dist/ui/index.js +217 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/worker/index.cjs +122 -0
- package/dist/worker/index.cjs.map +1 -0
- package/dist/worker/index.d.cts +177 -0
- package/dist/worker/index.d.ts +177 -0
- package/dist/worker/index.js +101 -0
- package/dist/worker/index.js.map +1 -0
- package/package.json +115 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { CrmConfig, Crm } from '@odla-ai/crm';
|
|
2
|
+
|
|
3
|
+
/** Which feature profile a site runs. `chapter` is the full public member site
|
|
4
|
+
* (join, Stripe membership, booking, member area, admin, CRM); `hub` is
|
|
5
|
+
* admin-only and CRM-focused (a directory/registry over the same CRM). */
|
|
6
|
+
type ChapterMode = "chapter" | "hub";
|
|
7
|
+
/** The scalar kinds an odla-db attribute can hold. */
|
|
8
|
+
type AttrType = "string" | "number" | "boolean" | "json";
|
|
9
|
+
/** One odla-db attribute: its type and index/uniqueness/optionality flags. */
|
|
10
|
+
interface Attr {
|
|
11
|
+
type: AttrType;
|
|
12
|
+
unique: boolean;
|
|
13
|
+
indexed: boolean;
|
|
14
|
+
optional: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** One odla-db namespace: its attribute map. */
|
|
17
|
+
interface Entity {
|
|
18
|
+
attrs: Record<string, Attr>;
|
|
19
|
+
}
|
|
20
|
+
/** A serialized odla-db schema fragment (namespaces + links). */
|
|
21
|
+
interface DbSchema {
|
|
22
|
+
entities: Record<string, Entity>;
|
|
23
|
+
links: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/** Per-namespace CEL rule strings (deny-all is `"false"` for each action). */
|
|
26
|
+
interface Rule {
|
|
27
|
+
view: string;
|
|
28
|
+
create: string;
|
|
29
|
+
update: string;
|
|
30
|
+
delete: string;
|
|
31
|
+
}
|
|
32
|
+
/** Namespace → rule set. */
|
|
33
|
+
type DbRules = Record<string, Rule>;
|
|
34
|
+
/** Brand tokens that theme the site: palette, fonts, wordmark, nav, logos. */
|
|
35
|
+
interface ChapterBrand {
|
|
36
|
+
/** Palette overrides written into styles.css :root (e.g. `{ moss: "#2F3E34" }`
|
|
37
|
+
* or `--ui-*` token names). */
|
|
38
|
+
palette?: Record<string, string>;
|
|
39
|
+
fonts?: {
|
|
40
|
+
display?: string;
|
|
41
|
+
body?: string;
|
|
42
|
+
numeral?: string;
|
|
43
|
+
};
|
|
44
|
+
wordmark?: string;
|
|
45
|
+
tagline?: string;
|
|
46
|
+
/** Header/footer nav sections for the web-component chrome: label → entries. */
|
|
47
|
+
nav?: Record<string, ReadonlyArray<{
|
|
48
|
+
label: string;
|
|
49
|
+
href: string;
|
|
50
|
+
}>>;
|
|
51
|
+
logos?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Membership pricing for the group row (chapter mode). */
|
|
54
|
+
interface ChapterPrices {
|
|
55
|
+
standardCents: number;
|
|
56
|
+
foundingDiscountCents?: number;
|
|
57
|
+
/** ISO currency, default "usd". */
|
|
58
|
+
currency?: string;
|
|
59
|
+
/** Billing interval, default "year". */
|
|
60
|
+
interval?: "year" | "month";
|
|
61
|
+
}
|
|
62
|
+
/** Membership policy + compliance copy stored on the group row. */
|
|
63
|
+
interface ChapterPolicy {
|
|
64
|
+
disclaimerText?: string;
|
|
65
|
+
refundPolicyText?: string;
|
|
66
|
+
trustCopy?: string;
|
|
67
|
+
commitmentText?: string;
|
|
68
|
+
normsText?: string;
|
|
69
|
+
}
|
|
70
|
+
/** One owner-editable transactional email template. */
|
|
71
|
+
interface EmailTemplate {
|
|
72
|
+
subject: string;
|
|
73
|
+
text: string;
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** Notification/reply/debug addresses + operational email templates. */
|
|
77
|
+
interface ChapterEmails {
|
|
78
|
+
notificationEmail: string;
|
|
79
|
+
replyTo?: string;
|
|
80
|
+
debugEmail?: string;
|
|
81
|
+
/** Operational lifecycle templates: adminNotification / paymentConfirmation /
|
|
82
|
+
* prepEmail / onboardingInvite, each `{ subject, text, enabled? }`. */
|
|
83
|
+
templates?: Record<string, EmailTemplate>;
|
|
84
|
+
}
|
|
85
|
+
/** Booking rules for the intro-call scheduler (stored as schedulingJson). */
|
|
86
|
+
interface ChapterScheduling {
|
|
87
|
+
slotMinutes?: number;
|
|
88
|
+
days?: readonly number[];
|
|
89
|
+
startHour?: number;
|
|
90
|
+
endHour?: number;
|
|
91
|
+
timezone?: string;
|
|
92
|
+
minNoticeHours?: number;
|
|
93
|
+
windowDays?: number;
|
|
94
|
+
summaryTemplate?: string;
|
|
95
|
+
}
|
|
96
|
+
/** The `defineChapter()` config a site fills in. */
|
|
97
|
+
interface ChapterConfig {
|
|
98
|
+
/** Slug: app id, tenant, group id, worker name. `[a-z0-9-]`. */
|
|
99
|
+
id: string;
|
|
100
|
+
name: string;
|
|
101
|
+
url?: string;
|
|
102
|
+
/** Default `"chapter"`. */
|
|
103
|
+
mode?: ChapterMode;
|
|
104
|
+
/** A `defineCrm()` config or a resolved `Crm`. Omit for the per-mode default. */
|
|
105
|
+
crm?: CrmConfig | Crm;
|
|
106
|
+
brand?: ChapterBrand;
|
|
107
|
+
thesis?: unknown;
|
|
108
|
+
/** Required in `chapter` mode. */
|
|
109
|
+
prices?: ChapterPrices;
|
|
110
|
+
policy?: ChapterPolicy;
|
|
111
|
+
/** `notificationEmail` required in `chapter` mode. */
|
|
112
|
+
emails?: ChapterEmails;
|
|
113
|
+
scheduling?: ChapterScheduling;
|
|
114
|
+
/** odla services (db implied). Default `["db","calendar","o11y"]`. */
|
|
115
|
+
services?: readonly string[];
|
|
116
|
+
}
|
|
117
|
+
/** The resolved engine `defineChapter()` returns. */
|
|
118
|
+
interface Chapter {
|
|
119
|
+
config: ChapterConfig;
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
url?: string;
|
|
123
|
+
mode: ChapterMode;
|
|
124
|
+
/** Resolved CRM engine (from `defineCrm`). */
|
|
125
|
+
crm: Crm;
|
|
126
|
+
/** The chapter's own odla-db namespaces (mode-dependent; excludes `crm_*`). */
|
|
127
|
+
schema: DbSchema;
|
|
128
|
+
rules: DbRules;
|
|
129
|
+
services: readonly string[];
|
|
130
|
+
/** The seed `groups` row derived from config (chapter mode), else `null`. */
|
|
131
|
+
groupSeed(): Record<string, unknown> | null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Validate a chapter/hub config and resolve its engine — the CRM, the chapter's
|
|
136
|
+
* odla-db schema/rules, and the seed groups row. Throws at import on a bad
|
|
137
|
+
* config (bad slug, wrong mode, missing chapter-mode prices/emails), never at
|
|
138
|
+
* request time.
|
|
139
|
+
*/
|
|
140
|
+
declare function defineChapter(config: ChapterConfig): Chapter;
|
|
141
|
+
|
|
142
|
+
/** Options for {@link createChapterIntegration}. */
|
|
143
|
+
interface ChapterIntegrationOptions {
|
|
144
|
+
/** CRM route mount point. Default "/api/crm". */
|
|
145
|
+
basePath?: string;
|
|
146
|
+
/** Seed timestamp override for reproducible builds/tests. */
|
|
147
|
+
now?: number;
|
|
148
|
+
}
|
|
149
|
+
interface IntegrationSeed {
|
|
150
|
+
id: string;
|
|
151
|
+
ns: string;
|
|
152
|
+
key: {
|
|
153
|
+
attr: string;
|
|
154
|
+
value: string;
|
|
155
|
+
};
|
|
156
|
+
attrs: Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
/** Structural match for the CLI's `OdlaIntegration`. */
|
|
159
|
+
interface ChapterIntegrationDescriptor {
|
|
160
|
+
id: string;
|
|
161
|
+
title: string;
|
|
162
|
+
npm: string;
|
|
163
|
+
schema: {
|
|
164
|
+
entities: Record<string, unknown>;
|
|
165
|
+
links: Record<string, unknown>;
|
|
166
|
+
};
|
|
167
|
+
rules: Record<string, unknown>;
|
|
168
|
+
seeds: IntegrationSeed[];
|
|
169
|
+
probes: Array<{
|
|
170
|
+
path: string;
|
|
171
|
+
expectedStatus: number;
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Build the one CLI-consumable integration for a chapter/hub: the crm_*
|
|
176
|
+
* namespaces + crm_config seed + route probe, merged with the chapter's own
|
|
177
|
+
* namespaces and a guarded `groups`-row seed. Drop it in odla.config.mjs's
|
|
178
|
+
* `integrations` array.
|
|
179
|
+
*/
|
|
180
|
+
declare function createChapterIntegration(chapter: Chapter, options?: ChapterIntegrationOptions): ChapterIntegrationDescriptor;
|
|
181
|
+
|
|
182
|
+
/** The chapter's own schema + deny-all rules for a mode. `hub` needs only the
|
|
183
|
+
* `admins` allowlist (its records live in `crm_*`); `chapter` adds the
|
|
184
|
+
* operational membership tables. */
|
|
185
|
+
declare function chapterDb(mode: ChapterMode): {
|
|
186
|
+
schema: DbSchema;
|
|
187
|
+
rules: DbRules;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/** The per-mode default CRM config: `chapter` = a person lead pipeline;
|
|
191
|
+
* `hub` = people + businesses with a works_at relation. */
|
|
192
|
+
declare function defaultCrm(mode: ChapterMode): CrmConfig;
|
|
193
|
+
|
|
194
|
+
/** The `groups` row (attrs) for `chapter` mode. Missing config falls back to
|
|
195
|
+
* empty copy / defaults, so a minimal config still provisions cleanly. */
|
|
196
|
+
declare function buildGroupSeed(config: ChapterConfig): Record<string, unknown>;
|
|
197
|
+
|
|
198
|
+
export { type Attr, type AttrType, type Chapter, type ChapterBrand, type ChapterConfig, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterPolicy, type ChapterPrices, type ChapterScheduling, type DbRules, type DbSchema, type EmailTemplate, type Entity, type Rule, buildGroupSeed, chapterDb, createChapterIntegration, defaultCrm, defineChapter };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { CrmConfig, Crm } from '@odla-ai/crm';
|
|
2
|
+
|
|
3
|
+
/** Which feature profile a site runs. `chapter` is the full public member site
|
|
4
|
+
* (join, Stripe membership, booking, member area, admin, CRM); `hub` is
|
|
5
|
+
* admin-only and CRM-focused (a directory/registry over the same CRM). */
|
|
6
|
+
type ChapterMode = "chapter" | "hub";
|
|
7
|
+
/** The scalar kinds an odla-db attribute can hold. */
|
|
8
|
+
type AttrType = "string" | "number" | "boolean" | "json";
|
|
9
|
+
/** One odla-db attribute: its type and index/uniqueness/optionality flags. */
|
|
10
|
+
interface Attr {
|
|
11
|
+
type: AttrType;
|
|
12
|
+
unique: boolean;
|
|
13
|
+
indexed: boolean;
|
|
14
|
+
optional: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** One odla-db namespace: its attribute map. */
|
|
17
|
+
interface Entity {
|
|
18
|
+
attrs: Record<string, Attr>;
|
|
19
|
+
}
|
|
20
|
+
/** A serialized odla-db schema fragment (namespaces + links). */
|
|
21
|
+
interface DbSchema {
|
|
22
|
+
entities: Record<string, Entity>;
|
|
23
|
+
links: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/** Per-namespace CEL rule strings (deny-all is `"false"` for each action). */
|
|
26
|
+
interface Rule {
|
|
27
|
+
view: string;
|
|
28
|
+
create: string;
|
|
29
|
+
update: string;
|
|
30
|
+
delete: string;
|
|
31
|
+
}
|
|
32
|
+
/** Namespace → rule set. */
|
|
33
|
+
type DbRules = Record<string, Rule>;
|
|
34
|
+
/** Brand tokens that theme the site: palette, fonts, wordmark, nav, logos. */
|
|
35
|
+
interface ChapterBrand {
|
|
36
|
+
/** Palette overrides written into styles.css :root (e.g. `{ moss: "#2F3E34" }`
|
|
37
|
+
* or `--ui-*` token names). */
|
|
38
|
+
palette?: Record<string, string>;
|
|
39
|
+
fonts?: {
|
|
40
|
+
display?: string;
|
|
41
|
+
body?: string;
|
|
42
|
+
numeral?: string;
|
|
43
|
+
};
|
|
44
|
+
wordmark?: string;
|
|
45
|
+
tagline?: string;
|
|
46
|
+
/** Header/footer nav sections for the web-component chrome: label → entries. */
|
|
47
|
+
nav?: Record<string, ReadonlyArray<{
|
|
48
|
+
label: string;
|
|
49
|
+
href: string;
|
|
50
|
+
}>>;
|
|
51
|
+
logos?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Membership pricing for the group row (chapter mode). */
|
|
54
|
+
interface ChapterPrices {
|
|
55
|
+
standardCents: number;
|
|
56
|
+
foundingDiscountCents?: number;
|
|
57
|
+
/** ISO currency, default "usd". */
|
|
58
|
+
currency?: string;
|
|
59
|
+
/** Billing interval, default "year". */
|
|
60
|
+
interval?: "year" | "month";
|
|
61
|
+
}
|
|
62
|
+
/** Membership policy + compliance copy stored on the group row. */
|
|
63
|
+
interface ChapterPolicy {
|
|
64
|
+
disclaimerText?: string;
|
|
65
|
+
refundPolicyText?: string;
|
|
66
|
+
trustCopy?: string;
|
|
67
|
+
commitmentText?: string;
|
|
68
|
+
normsText?: string;
|
|
69
|
+
}
|
|
70
|
+
/** One owner-editable transactional email template. */
|
|
71
|
+
interface EmailTemplate {
|
|
72
|
+
subject: string;
|
|
73
|
+
text: string;
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** Notification/reply/debug addresses + operational email templates. */
|
|
77
|
+
interface ChapterEmails {
|
|
78
|
+
notificationEmail: string;
|
|
79
|
+
replyTo?: string;
|
|
80
|
+
debugEmail?: string;
|
|
81
|
+
/** Operational lifecycle templates: adminNotification / paymentConfirmation /
|
|
82
|
+
* prepEmail / onboardingInvite, each `{ subject, text, enabled? }`. */
|
|
83
|
+
templates?: Record<string, EmailTemplate>;
|
|
84
|
+
}
|
|
85
|
+
/** Booking rules for the intro-call scheduler (stored as schedulingJson). */
|
|
86
|
+
interface ChapterScheduling {
|
|
87
|
+
slotMinutes?: number;
|
|
88
|
+
days?: readonly number[];
|
|
89
|
+
startHour?: number;
|
|
90
|
+
endHour?: number;
|
|
91
|
+
timezone?: string;
|
|
92
|
+
minNoticeHours?: number;
|
|
93
|
+
windowDays?: number;
|
|
94
|
+
summaryTemplate?: string;
|
|
95
|
+
}
|
|
96
|
+
/** The `defineChapter()` config a site fills in. */
|
|
97
|
+
interface ChapterConfig {
|
|
98
|
+
/** Slug: app id, tenant, group id, worker name. `[a-z0-9-]`. */
|
|
99
|
+
id: string;
|
|
100
|
+
name: string;
|
|
101
|
+
url?: string;
|
|
102
|
+
/** Default `"chapter"`. */
|
|
103
|
+
mode?: ChapterMode;
|
|
104
|
+
/** A `defineCrm()` config or a resolved `Crm`. Omit for the per-mode default. */
|
|
105
|
+
crm?: CrmConfig | Crm;
|
|
106
|
+
brand?: ChapterBrand;
|
|
107
|
+
thesis?: unknown;
|
|
108
|
+
/** Required in `chapter` mode. */
|
|
109
|
+
prices?: ChapterPrices;
|
|
110
|
+
policy?: ChapterPolicy;
|
|
111
|
+
/** `notificationEmail` required in `chapter` mode. */
|
|
112
|
+
emails?: ChapterEmails;
|
|
113
|
+
scheduling?: ChapterScheduling;
|
|
114
|
+
/** odla services (db implied). Default `["db","calendar","o11y"]`. */
|
|
115
|
+
services?: readonly string[];
|
|
116
|
+
}
|
|
117
|
+
/** The resolved engine `defineChapter()` returns. */
|
|
118
|
+
interface Chapter {
|
|
119
|
+
config: ChapterConfig;
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
url?: string;
|
|
123
|
+
mode: ChapterMode;
|
|
124
|
+
/** Resolved CRM engine (from `defineCrm`). */
|
|
125
|
+
crm: Crm;
|
|
126
|
+
/** The chapter's own odla-db namespaces (mode-dependent; excludes `crm_*`). */
|
|
127
|
+
schema: DbSchema;
|
|
128
|
+
rules: DbRules;
|
|
129
|
+
services: readonly string[];
|
|
130
|
+
/** The seed `groups` row derived from config (chapter mode), else `null`. */
|
|
131
|
+
groupSeed(): Record<string, unknown> | null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Validate a chapter/hub config and resolve its engine — the CRM, the chapter's
|
|
136
|
+
* odla-db schema/rules, and the seed groups row. Throws at import on a bad
|
|
137
|
+
* config (bad slug, wrong mode, missing chapter-mode prices/emails), never at
|
|
138
|
+
* request time.
|
|
139
|
+
*/
|
|
140
|
+
declare function defineChapter(config: ChapterConfig): Chapter;
|
|
141
|
+
|
|
142
|
+
/** Options for {@link createChapterIntegration}. */
|
|
143
|
+
interface ChapterIntegrationOptions {
|
|
144
|
+
/** CRM route mount point. Default "/api/crm". */
|
|
145
|
+
basePath?: string;
|
|
146
|
+
/** Seed timestamp override for reproducible builds/tests. */
|
|
147
|
+
now?: number;
|
|
148
|
+
}
|
|
149
|
+
interface IntegrationSeed {
|
|
150
|
+
id: string;
|
|
151
|
+
ns: string;
|
|
152
|
+
key: {
|
|
153
|
+
attr: string;
|
|
154
|
+
value: string;
|
|
155
|
+
};
|
|
156
|
+
attrs: Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
/** Structural match for the CLI's `OdlaIntegration`. */
|
|
159
|
+
interface ChapterIntegrationDescriptor {
|
|
160
|
+
id: string;
|
|
161
|
+
title: string;
|
|
162
|
+
npm: string;
|
|
163
|
+
schema: {
|
|
164
|
+
entities: Record<string, unknown>;
|
|
165
|
+
links: Record<string, unknown>;
|
|
166
|
+
};
|
|
167
|
+
rules: Record<string, unknown>;
|
|
168
|
+
seeds: IntegrationSeed[];
|
|
169
|
+
probes: Array<{
|
|
170
|
+
path: string;
|
|
171
|
+
expectedStatus: number;
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Build the one CLI-consumable integration for a chapter/hub: the crm_*
|
|
176
|
+
* namespaces + crm_config seed + route probe, merged with the chapter's own
|
|
177
|
+
* namespaces and a guarded `groups`-row seed. Drop it in odla.config.mjs's
|
|
178
|
+
* `integrations` array.
|
|
179
|
+
*/
|
|
180
|
+
declare function createChapterIntegration(chapter: Chapter, options?: ChapterIntegrationOptions): ChapterIntegrationDescriptor;
|
|
181
|
+
|
|
182
|
+
/** The chapter's own schema + deny-all rules for a mode. `hub` needs only the
|
|
183
|
+
* `admins` allowlist (its records live in `crm_*`); `chapter` adds the
|
|
184
|
+
* operational membership tables. */
|
|
185
|
+
declare function chapterDb(mode: ChapterMode): {
|
|
186
|
+
schema: DbSchema;
|
|
187
|
+
rules: DbRules;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/** The per-mode default CRM config: `chapter` = a person lead pipeline;
|
|
191
|
+
* `hub` = people + businesses with a works_at relation. */
|
|
192
|
+
declare function defaultCrm(mode: ChapterMode): CrmConfig;
|
|
193
|
+
|
|
194
|
+
/** The `groups` row (attrs) for `chapter` mode. Missing config falls back to
|
|
195
|
+
* empty copy / defaults, so a minimal config still provisions cleanly. */
|
|
196
|
+
declare function buildGroupSeed(config: ChapterConfig): Record<string, unknown>;
|
|
197
|
+
|
|
198
|
+
export { type Attr, type AttrType, type Chapter, type ChapterBrand, type ChapterConfig, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterPolicy, type ChapterPrices, type ChapterScheduling, type DbRules, type DbSchema, type EmailTemplate, type Entity, type Rule, buildGroupSeed, chapterDb, createChapterIntegration, defaultCrm, defineChapter };
|