@segmentstream/ontology 0.95.0 → 0.96.0
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 +28 -4
- package/dist/analyze.d.ts +15 -3
- package/dist/analyze.js +208 -3
- package/dist/authoring.js +3 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/manifest.d.ts +102 -18
- package/dist/manifest.js +41 -2
- package/dist/migrate/apply.js +5 -1
- package/dist/migrate/model.d.ts +60 -12
- package/dist/migrate/storage.js +2 -0
- package/dist/ontology.d.ts +2 -2
- package/dist/runtime/member-tables.d.ts +7 -2
- package/dist/runtime/member-tables.js +18 -3
- package/dist/runtime/new-user-hook.d.ts +11 -1
- package/dist/runtime/new-user-hook.js +69 -29
- package/dist/runtime/pipeline.d.ts +2 -0
- package/dist/runtime/pipeline.js +11 -3
- package/dist/runtime/principals.d.ts +13 -0
- package/dist/runtime/principals.js +98 -28
- package/dist/runtime/resolve-agent-identity.js +43 -12
- package/dist/runtime/service-binding.js +10 -4
- package/dist/service/chat/envelope.d.ts +2 -2
- package/dist/service/schemas.d.ts +12 -0
- package/dist/sign-in.d.ts +32 -1
- package/dist/sign-in.js +12 -1
- package/dist/user-identity.d.ts +1 -1
- package/package.json +1 -1
package/dist/manifest.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Effect, Schema } from "effect";
|
|
|
3
3
|
import type { ResolvedConnection, ResolvedEntity } from "./analyze.js";
|
|
4
4
|
import type { ResolvedFeedback } from "./feedback-config.js";
|
|
5
5
|
import type { Role } from "./role.js";
|
|
6
|
-
import { type
|
|
6
|
+
import { type ResolvedSignInOptions, type SignInPolicy } from "./sign-in.js";
|
|
7
7
|
/**
|
|
8
8
|
* The manifest format this SDK writes. Readers accept any version and ignore unknown fields. Version
|
|
9
9
|
* 2 replaced the actions' `allow` with `permission`, and added the roles' `permissions` and the
|
|
@@ -56,6 +56,9 @@ import { type SignInOptions, type SignInPolicy } from "./sign-in.js";
|
|
|
56
56
|
* Within version 15, `chat` may carry `slack` and `whatsapp` beside `telegram`: the connections
|
|
57
57
|
* exact chat posts to Slack chats and to members' WhatsApp chats go through. Older readers ignore
|
|
58
58
|
* them, and their services post to Telegram alone.
|
|
59
|
+
* Within version 15, `signIn` may carry `signUp`, the wire names of the roles each channel open to
|
|
60
|
+
* sign-up grants, and `onSignUp`, written only when declared. Older readers ignore them and keep
|
|
61
|
+
* every channel closed to sign-up.
|
|
59
62
|
*/
|
|
60
63
|
export declare const MANIFEST_VERSION = 15;
|
|
61
64
|
/** The phrase used for a direction the author did not phrase. */
|
|
@@ -548,6 +551,10 @@ export declare const BrowserSignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
|
548
551
|
}>, {
|
|
549
552
|
readonly autoRedirect: "auto_redirect";
|
|
550
553
|
}>;
|
|
554
|
+
/** Sign-up: the wire names of the roles each open channel grants. Unknown channels stay closed. */
|
|
555
|
+
export declare const SignUpManifest: Schema.Struct<{
|
|
556
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
557
|
+
}>;
|
|
551
558
|
export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
552
559
|
readonly browser: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
|
|
553
560
|
readonly methods: Schema.$Array<Schema.String>;
|
|
@@ -563,9 +570,15 @@ export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
|
563
570
|
readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
564
571
|
readonly onNewUser: Schema.optionalKey<Schema.String>;
|
|
565
572
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
573
|
+
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
574
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
575
|
+
}>>;
|
|
576
|
+
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
566
577
|
}>, {
|
|
567
578
|
readonly onNewUser: "on_new_user";
|
|
568
579
|
readonly codeLink: "code_link";
|
|
580
|
+
readonly signUp: "sign_up";
|
|
581
|
+
readonly onSignUp: "on_sign_up";
|
|
569
582
|
}>;
|
|
570
583
|
export type SignInManifest = typeof SignInManifest.Type;
|
|
571
584
|
/** One of the workspace's emails, as `defineOntology({ emails })` declares it; see `EmailTemplate`. */
|
|
@@ -837,9 +850,15 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
|
|
|
837
850
|
readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
838
851
|
readonly onNewUser: Schema.optionalKey<Schema.String>;
|
|
839
852
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
853
|
+
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
854
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
855
|
+
}>>;
|
|
856
|
+
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
840
857
|
}>, {
|
|
841
858
|
readonly onNewUser: "on_new_user";
|
|
842
859
|
readonly codeLink: "code_link";
|
|
860
|
+
readonly signUp: "sign_up";
|
|
861
|
+
readonly onSignUp: "on_sign_up";
|
|
843
862
|
}>>;
|
|
844
863
|
/** The workspace's own emails by wire name. Written only when there are some; absent reads as none. */
|
|
845
864
|
readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
|
|
@@ -1067,10 +1086,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1067
1086
|
readonly telegram?: {
|
|
1068
1087
|
readonly connection: string;
|
|
1069
1088
|
} | undefined;
|
|
1070
|
-
readonly
|
|
1089
|
+
readonly whatsapp?: {
|
|
1071
1090
|
readonly connection: string;
|
|
1072
1091
|
} | undefined;
|
|
1073
|
-
readonly
|
|
1092
|
+
readonly slack?: {
|
|
1074
1093
|
readonly connection: string;
|
|
1075
1094
|
} | undefined;
|
|
1076
1095
|
readonly attribution?: {
|
|
@@ -1158,6 +1177,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1158
1177
|
} | undefined;
|
|
1159
1178
|
readonly onNewUser?: string | undefined;
|
|
1160
1179
|
readonly codeLink?: boolean | undefined;
|
|
1180
|
+
readonly signUp?: {
|
|
1181
|
+
readonly channels: {
|
|
1182
|
+
readonly [x: string]: unknown;
|
|
1183
|
+
};
|
|
1184
|
+
} | undefined;
|
|
1185
|
+
readonly onSignUp?: string | undefined;
|
|
1161
1186
|
} | undefined;
|
|
1162
1187
|
readonly emails?: {
|
|
1163
1188
|
readonly [x: string]: {
|
|
@@ -1294,10 +1319,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1294
1319
|
readonly telegram?: {
|
|
1295
1320
|
readonly connection: string;
|
|
1296
1321
|
} | undefined;
|
|
1297
|
-
readonly
|
|
1322
|
+
readonly whatsapp?: {
|
|
1298
1323
|
readonly connection: string;
|
|
1299
1324
|
} | undefined;
|
|
1300
|
-
readonly
|
|
1325
|
+
readonly slack?: {
|
|
1301
1326
|
readonly connection: string;
|
|
1302
1327
|
} | undefined;
|
|
1303
1328
|
readonly attribution?: {
|
|
@@ -1385,6 +1410,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1385
1410
|
} | undefined;
|
|
1386
1411
|
readonly onNewUser?: string | undefined;
|
|
1387
1412
|
readonly codeLink?: boolean | undefined;
|
|
1413
|
+
readonly signUp?: {
|
|
1414
|
+
readonly channels: {
|
|
1415
|
+
readonly [x: string]: unknown;
|
|
1416
|
+
};
|
|
1417
|
+
} | undefined;
|
|
1418
|
+
readonly onSignUp?: string | undefined;
|
|
1388
1419
|
} | undefined;
|
|
1389
1420
|
readonly emails?: {
|
|
1390
1421
|
readonly [x: string]: {
|
|
@@ -1521,10 +1552,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1521
1552
|
readonly telegram?: {
|
|
1522
1553
|
readonly connection: string;
|
|
1523
1554
|
} | undefined;
|
|
1524
|
-
readonly
|
|
1555
|
+
readonly whatsapp?: {
|
|
1525
1556
|
readonly connection: string;
|
|
1526
1557
|
} | undefined;
|
|
1527
|
-
readonly
|
|
1558
|
+
readonly slack?: {
|
|
1528
1559
|
readonly connection: string;
|
|
1529
1560
|
} | undefined;
|
|
1530
1561
|
readonly attribution?: {
|
|
@@ -1628,6 +1659,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1628
1659
|
} | undefined;
|
|
1629
1660
|
readonly on_new_user?: string | undefined;
|
|
1630
1661
|
readonly code_link?: boolean | undefined;
|
|
1662
|
+
readonly sign_up?: {
|
|
1663
|
+
readonly channels: {
|
|
1664
|
+
readonly [x: string]: unknown;
|
|
1665
|
+
};
|
|
1666
|
+
} | undefined;
|
|
1667
|
+
readonly on_sign_up?: string | undefined;
|
|
1631
1668
|
} | undefined;
|
|
1632
1669
|
} | {
|
|
1633
1670
|
readonly version: number;
|
|
@@ -1748,10 +1785,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1748
1785
|
readonly telegram?: {
|
|
1749
1786
|
readonly connection: string;
|
|
1750
1787
|
} | undefined;
|
|
1751
|
-
readonly
|
|
1788
|
+
readonly whatsapp?: {
|
|
1752
1789
|
readonly connection: string;
|
|
1753
1790
|
} | undefined;
|
|
1754
|
-
readonly
|
|
1791
|
+
readonly slack?: {
|
|
1755
1792
|
readonly connection: string;
|
|
1756
1793
|
} | undefined;
|
|
1757
1794
|
readonly attribution?: {
|
|
@@ -1839,6 +1876,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1839
1876
|
} | undefined;
|
|
1840
1877
|
readonly on_new_user?: string | undefined;
|
|
1841
1878
|
readonly code_link?: boolean | undefined;
|
|
1879
|
+
readonly sign_up?: {
|
|
1880
|
+
readonly channels: {
|
|
1881
|
+
readonly [x: string]: unknown;
|
|
1882
|
+
};
|
|
1883
|
+
} | undefined;
|
|
1884
|
+
readonly on_sign_up?: string | undefined;
|
|
1842
1885
|
} | undefined;
|
|
1843
1886
|
readonly emails?: {
|
|
1844
1887
|
readonly [x: string]: {
|
|
@@ -2052,9 +2095,15 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2052
2095
|
readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
2053
2096
|
readonly onNewUser: Schema.optionalKey<Schema.String>;
|
|
2054
2097
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
2098
|
+
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
2099
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
2100
|
+
}>>;
|
|
2101
|
+
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
2055
2102
|
}>, {
|
|
2056
2103
|
readonly onNewUser: "on_new_user";
|
|
2057
2104
|
readonly codeLink: "code_link";
|
|
2105
|
+
readonly signUp: "sign_up";
|
|
2106
|
+
readonly onSignUp: "on_sign_up";
|
|
2058
2107
|
}>>;
|
|
2059
2108
|
/** The workspace's own emails by wire name. Written only when there are some; absent reads as none. */
|
|
2060
2109
|
readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
|
|
@@ -2346,9 +2395,15 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2346
2395
|
readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
2347
2396
|
readonly onNewUser: Schema.optionalKey<Schema.String>;
|
|
2348
2397
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
2398
|
+
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
2399
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
2400
|
+
}>>;
|
|
2401
|
+
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
2349
2402
|
}>, {
|
|
2350
2403
|
readonly onNewUser: "on_new_user";
|
|
2351
2404
|
readonly codeLink: "code_link";
|
|
2405
|
+
readonly signUp: "sign_up";
|
|
2406
|
+
readonly onSignUp: "on_sign_up";
|
|
2352
2407
|
}>>;
|
|
2353
2408
|
/** The workspace's own emails by wire name. Written only when there are some; absent reads as none. */
|
|
2354
2409
|
readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
|
|
@@ -2568,10 +2623,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2568
2623
|
readonly telegram?: {
|
|
2569
2624
|
readonly connection: string;
|
|
2570
2625
|
} | undefined;
|
|
2571
|
-
readonly
|
|
2626
|
+
readonly whatsapp?: {
|
|
2572
2627
|
readonly connection: string;
|
|
2573
2628
|
} | undefined;
|
|
2574
|
-
readonly
|
|
2629
|
+
readonly slack?: {
|
|
2575
2630
|
readonly connection: string;
|
|
2576
2631
|
} | undefined;
|
|
2577
2632
|
readonly attribution?: {
|
|
@@ -2659,6 +2714,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2659
2714
|
} | undefined;
|
|
2660
2715
|
readonly onNewUser?: string | undefined;
|
|
2661
2716
|
readonly codeLink?: boolean | undefined;
|
|
2717
|
+
readonly signUp?: {
|
|
2718
|
+
readonly channels: {
|
|
2719
|
+
readonly [x: string]: unknown;
|
|
2720
|
+
};
|
|
2721
|
+
} | undefined;
|
|
2722
|
+
readonly onSignUp?: string | undefined;
|
|
2662
2723
|
} | undefined;
|
|
2663
2724
|
readonly emails?: {
|
|
2664
2725
|
readonly [x: string]: {
|
|
@@ -2795,10 +2856,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2795
2856
|
readonly telegram?: {
|
|
2796
2857
|
readonly connection: string;
|
|
2797
2858
|
} | undefined;
|
|
2798
|
-
readonly
|
|
2859
|
+
readonly whatsapp?: {
|
|
2799
2860
|
readonly connection: string;
|
|
2800
2861
|
} | undefined;
|
|
2801
|
-
readonly
|
|
2862
|
+
readonly slack?: {
|
|
2802
2863
|
readonly connection: string;
|
|
2803
2864
|
} | undefined;
|
|
2804
2865
|
readonly attribution?: {
|
|
@@ -2886,6 +2947,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2886
2947
|
} | undefined;
|
|
2887
2948
|
readonly onNewUser?: string | undefined;
|
|
2888
2949
|
readonly codeLink?: boolean | undefined;
|
|
2950
|
+
readonly signUp?: {
|
|
2951
|
+
readonly channels: {
|
|
2952
|
+
readonly [x: string]: unknown;
|
|
2953
|
+
};
|
|
2954
|
+
} | undefined;
|
|
2955
|
+
readonly onSignUp?: string | undefined;
|
|
2889
2956
|
} | undefined;
|
|
2890
2957
|
readonly emails?: {
|
|
2891
2958
|
readonly [x: string]: {
|
|
@@ -3028,10 +3095,10 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3028
3095
|
readonly telegram?: {
|
|
3029
3096
|
readonly connection: string;
|
|
3030
3097
|
} | undefined;
|
|
3031
|
-
readonly
|
|
3098
|
+
readonly whatsapp?: {
|
|
3032
3099
|
readonly connection: string;
|
|
3033
3100
|
} | undefined;
|
|
3034
|
-
readonly
|
|
3101
|
+
readonly slack?: {
|
|
3035
3102
|
readonly connection: string;
|
|
3036
3103
|
} | undefined;
|
|
3037
3104
|
readonly attribution?: {
|
|
@@ -3119,6 +3186,12 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3119
3186
|
} | undefined;
|
|
3120
3187
|
readonly onNewUser?: string | undefined;
|
|
3121
3188
|
readonly codeLink?: boolean | undefined;
|
|
3189
|
+
readonly signUp?: {
|
|
3190
|
+
readonly channels: {
|
|
3191
|
+
readonly [x: string]: unknown;
|
|
3192
|
+
};
|
|
3193
|
+
} | undefined;
|
|
3194
|
+
readonly onSignUp?: string | undefined;
|
|
3122
3195
|
} | undefined;
|
|
3123
3196
|
readonly emails?: {
|
|
3124
3197
|
readonly [x: string]: {
|
|
@@ -3255,10 +3328,10 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3255
3328
|
readonly telegram?: {
|
|
3256
3329
|
readonly connection: string;
|
|
3257
3330
|
} | undefined;
|
|
3258
|
-
readonly
|
|
3331
|
+
readonly whatsapp?: {
|
|
3259
3332
|
readonly connection: string;
|
|
3260
3333
|
} | undefined;
|
|
3261
|
-
readonly
|
|
3334
|
+
readonly slack?: {
|
|
3262
3335
|
readonly connection: string;
|
|
3263
3336
|
} | undefined;
|
|
3264
3337
|
readonly attribution?: {
|
|
@@ -3346,6 +3419,12 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3346
3419
|
} | undefined;
|
|
3347
3420
|
readonly onNewUser?: string | undefined;
|
|
3348
3421
|
readonly codeLink?: boolean | undefined;
|
|
3422
|
+
readonly signUp?: {
|
|
3423
|
+
readonly channels: {
|
|
3424
|
+
readonly [x: string]: unknown;
|
|
3425
|
+
};
|
|
3426
|
+
} | undefined;
|
|
3427
|
+
readonly onSignUp?: string | undefined;
|
|
3349
3428
|
} | undefined;
|
|
3350
3429
|
readonly emails?: {
|
|
3351
3430
|
readonly [x: string]: {
|
|
@@ -3371,6 +3450,11 @@ export declare function encodeManifest(manifest: OntologyManifest): Readonly<Rec
|
|
|
3371
3450
|
* not know, reads as `invited`: the closed choice, so that a misread never lets strangers in.
|
|
3372
3451
|
*/
|
|
3373
3452
|
export declare function signInPolicyOf(manifest: Pick<OntologyManifest, "signIn">): SignInPolicy;
|
|
3453
|
+
/**
|
|
3454
|
+
* The wire names of the roles a stranger who signs up on this channel is given, or `undefined` when
|
|
3455
|
+
* the channel is closed to sign-up: not a channel this reader knows, or no well-formed entry.
|
|
3456
|
+
*/
|
|
3457
|
+
export declare function signUpRolesOf(manifest: Pick<OntologyManifest, "signIn">, channel: string): ReadonlyArray<string> | undefined;
|
|
3374
3458
|
/** Unsupported providers and missing or unknown channel policies require invitation. */
|
|
3375
3459
|
export declare function channelPolicyOf(manifest: Pick<OntologyManifest, "signIn">, provider: string): SignInPolicy;
|
|
3376
3460
|
/** JSON with object keys sorted at every level and no whitespace: the input of the manifest hash. */
|
|
@@ -3403,7 +3487,7 @@ export declare function buildManifest(input: {
|
|
|
3403
3487
|
};
|
|
3404
3488
|
readonly entities: ReadonlyArray<ResolvedEntity>;
|
|
3405
3489
|
readonly roles: ReadonlyArray<Role>;
|
|
3406
|
-
readonly signIn:
|
|
3490
|
+
readonly signIn: ResolvedSignInOptions;
|
|
3407
3491
|
/** The workspace's own emails by wire name. */
|
|
3408
3492
|
readonly emails?: Readonly<Record<string, EmailTemplateManifest>>;
|
|
3409
3493
|
readonly connections?: ReadonlyArray<ResolvedConnection>;
|
package/dist/manifest.js
CHANGED
|
@@ -4,7 +4,7 @@ import { acceptingEarlierManifestNames, withEarlierManifestNames } from "./legac
|
|
|
4
4
|
import { humanize, MEMBER_ROLE, FEEDBACK_REPORTER_ROLE } from "./names.js";
|
|
5
5
|
import { PROPERTY_TYPES } from "./property.js";
|
|
6
6
|
import { ON_DELETE } from "./relationship.js";
|
|
7
|
-
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, } from "./sign-in.js";
|
|
7
|
+
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, isSignUpChannel, } from "./sign-in.js";
|
|
8
8
|
/**
|
|
9
9
|
* The manifest format this SDK writes. Readers accept any version and ignore unknown fields. Version
|
|
10
10
|
* 2 replaced the actions' `allow` with `permission`, and added the roles' `permissions` and the
|
|
@@ -57,6 +57,9 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, } from "./si
|
|
|
57
57
|
* Within version 15, `chat` may carry `slack` and `whatsapp` beside `telegram`: the connections
|
|
58
58
|
* exact chat posts to Slack chats and to members' WhatsApp chats go through. Older readers ignore
|
|
59
59
|
* them, and their services post to Telegram alone.
|
|
60
|
+
* Within version 15, `signIn` may carry `signUp`, the wire names of the roles each channel open to
|
|
61
|
+
* sign-up grants, and `onSignUp`, written only when declared. Older readers ignore them and keep
|
|
62
|
+
* every channel closed to sign-up.
|
|
60
63
|
*/
|
|
61
64
|
export const MANIFEST_VERSION = 15;
|
|
62
65
|
/** The first version whose documents use snake_case names on the wire. */
|
|
@@ -366,13 +369,24 @@ export const BrowserSignInManifest = Schema.Struct({
|
|
|
366
369
|
autoRedirect: Schema.Boolean,
|
|
367
370
|
local: Schema.optionalKey(Schema.Struct({ port: Schema.Int })),
|
|
368
371
|
}).pipe(Schema.encodeKeys({ autoRedirect: "auto_redirect" }));
|
|
372
|
+
/** Sign-up: the wire names of the roles each open channel grants. Unknown channels stay closed. */
|
|
373
|
+
export const SignUpManifest = Schema.Struct({
|
|
374
|
+
channels: Schema.Record(Schema.String, Schema.Unknown),
|
|
375
|
+
});
|
|
369
376
|
export const SignInManifest = Schema.Struct({
|
|
370
377
|
browser: Schema.optionalKey(BrowserSignInManifest),
|
|
371
378
|
policy: Schema.String,
|
|
372
379
|
channels: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)),
|
|
373
380
|
onNewUser: Schema.optionalKey(Schema.String),
|
|
374
381
|
codeLink: Schema.optionalKey(Schema.Boolean),
|
|
375
|
-
|
|
382
|
+
signUp: Schema.optionalKey(SignUpManifest),
|
|
383
|
+
onSignUp: Schema.optionalKey(Schema.String),
|
|
384
|
+
}).pipe(Schema.encodeKeys({
|
|
385
|
+
onNewUser: "on_new_user",
|
|
386
|
+
codeLink: "code_link",
|
|
387
|
+
signUp: "sign_up",
|
|
388
|
+
onSignUp: "on_sign_up",
|
|
389
|
+
}));
|
|
376
390
|
/** One of the workspace's emails, as `defineOntology({ emails })` declares it; see `EmailTemplate`. */
|
|
377
391
|
export const EmailTemplateManifest = Schema.Struct({
|
|
378
392
|
subject: Schema.String,
|
|
@@ -503,6 +517,20 @@ export function signInPolicyOf(manifest) {
|
|
|
503
517
|
const policy = manifest.signIn?.policy;
|
|
504
518
|
return isSignInPolicy(policy) ? policy : DEFAULT_SIGN_IN_POLICY;
|
|
505
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* The wire names of the roles a stranger who signs up on this channel is given, or `undefined` when
|
|
522
|
+
* the channel is closed to sign-up: not a channel this reader knows, or no well-formed entry.
|
|
523
|
+
*/
|
|
524
|
+
export function signUpRolesOf(manifest, channel) {
|
|
525
|
+
if (!isSignUpChannel(channel)) {
|
|
526
|
+
return undefined;
|
|
527
|
+
}
|
|
528
|
+
const roles = manifest.signIn?.signUp?.channels[channel];
|
|
529
|
+
return Array.isArray(roles) && roles.every((role) => typeof role === "string")
|
|
530
|
+
? roles
|
|
531
|
+
: undefined;
|
|
532
|
+
}
|
|
533
|
+
// @legacy ontology.legacy-channel-admission
|
|
506
534
|
/** Unsupported providers and missing or unknown channel policies require invitation. */
|
|
507
535
|
export function channelPolicyOf(manifest, provider) {
|
|
508
536
|
if (!CHANNEL_PROVIDERS.some((supported) => supported === provider)) {
|
|
@@ -741,6 +769,17 @@ export function buildManifest(input) {
|
|
|
741
769
|
...(Object.keys(input.signIn.channels ?? {}).length > 0
|
|
742
770
|
? { channels: input.signIn.channels }
|
|
743
771
|
: {}),
|
|
772
|
+
...(input.signIn.signUp === undefined
|
|
773
|
+
? {}
|
|
774
|
+
: {
|
|
775
|
+
signUp: {
|
|
776
|
+
channels: Object.fromEntries(Object.entries(input.signIn.signUp.channels).map(([channel, roles]) => [
|
|
777
|
+
channel,
|
|
778
|
+
[...(roles ?? [])],
|
|
779
|
+
])),
|
|
780
|
+
},
|
|
781
|
+
}),
|
|
782
|
+
...(input.signIn.onSignUp === undefined ? {} : { onSignUp: input.signIn.onSignUp }),
|
|
744
783
|
},
|
|
745
784
|
...(Object.keys(emails).length > 0 ? { emails } : {}),
|
|
746
785
|
...(input.chat === undefined ? {} : { chat: input.chat }),
|
package/dist/migrate/apply.js
CHANGED
|
@@ -19,7 +19,7 @@ import { principalsOntology, reconcileWorkflowUsers } from "../runtime/principal
|
|
|
19
19
|
import { FEDERATION_TABLES } from "../runtime/federation-tables.js";
|
|
20
20
|
import { syncUserIdentities, USER_IDENTITY_ENTITY_ID } from "../runtime/user-identities.js";
|
|
21
21
|
import { resolveReplicationSelection, } from "../replication/model.js";
|
|
22
|
-
import { ACTION_ATTRIBUTION_TABLE, AGENT_TABLES, API_KEYS_TABLE, CATALOG_TABLE, OAUTH_TABLES, USER_ROLES_TABLE, quoteIdentifier, quoteLiteral, historyTableName, } from "./storage.js";
|
|
22
|
+
import { ACTION_ATTRIBUTION_TABLE, AGENT_TABLES, API_KEYS_TABLE, CATALOG_TABLE, CHANNEL_USERS_TABLE, OAUTH_TABLES, USER_ROLES_TABLE, quoteIdentifier, quoteLiteral, historyTableName, } from "./storage.js";
|
|
23
23
|
const CATALOG = quoteIdentifier(CATALOG_TABLE);
|
|
24
24
|
const IDENTITY_SYNC = "Copy members' sign-in identities the legacy identity stores hold.";
|
|
25
25
|
/**
|
|
@@ -489,6 +489,10 @@ export const readRuntimeTables = (input) => input.sql
|
|
|
489
489
|
`AND ("tablename" <> '_oauth_grants' OR EXISTS (` +
|
|
490
490
|
`SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() ` +
|
|
491
491
|
`AND table_name = '_oauth_grants' AND column_name = 'identity_id')) ` +
|
|
492
|
+
// Without `signed_up` the agent tables' idempotent DDL runs again and adds it.
|
|
493
|
+
`AND ("tablename" <> ${quoteLiteral(CHANNEL_USERS_TABLE)} OR EXISTS (` +
|
|
494
|
+
`SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() ` +
|
|
495
|
+
`AND table_name = ${quoteLiteral(CHANNEL_USERS_TABLE)} AND column_name = 'signed_up')) ` +
|
|
492
496
|
`AND ("tablename" <> ${quoteLiteral(API_KEYS_TABLE)} OR EXISTS (` +
|
|
493
497
|
`SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() ` +
|
|
494
498
|
`AND table_name = ${quoteLiteral(API_KEYS_TABLE)} AND column_name = 'delegation')) ` +
|
package/dist/migrate/model.d.ts
CHANGED
|
@@ -400,10 +400,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
400
400
|
readonly telegram?: {
|
|
401
401
|
readonly connection: string;
|
|
402
402
|
} | undefined;
|
|
403
|
-
readonly
|
|
403
|
+
readonly whatsapp?: {
|
|
404
404
|
readonly connection: string;
|
|
405
405
|
} | undefined;
|
|
406
|
-
readonly
|
|
406
|
+
readonly slack?: {
|
|
407
407
|
readonly connection: string;
|
|
408
408
|
} | undefined;
|
|
409
409
|
readonly attribution?: {
|
|
@@ -491,6 +491,12 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
491
491
|
} | undefined;
|
|
492
492
|
readonly onNewUser?: string | undefined;
|
|
493
493
|
readonly codeLink?: boolean | undefined;
|
|
494
|
+
readonly signUp?: {
|
|
495
|
+
readonly channels: {
|
|
496
|
+
readonly [x: string]: unknown;
|
|
497
|
+
};
|
|
498
|
+
} | undefined;
|
|
499
|
+
readonly onSignUp?: string | undefined;
|
|
494
500
|
} | undefined;
|
|
495
501
|
readonly emails?: {
|
|
496
502
|
readonly [x: string]: {
|
|
@@ -627,10 +633,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
627
633
|
readonly telegram?: {
|
|
628
634
|
readonly connection: string;
|
|
629
635
|
} | undefined;
|
|
630
|
-
readonly
|
|
636
|
+
readonly whatsapp?: {
|
|
631
637
|
readonly connection: string;
|
|
632
638
|
} | undefined;
|
|
633
|
-
readonly
|
|
639
|
+
readonly slack?: {
|
|
634
640
|
readonly connection: string;
|
|
635
641
|
} | undefined;
|
|
636
642
|
readonly attribution?: {
|
|
@@ -718,6 +724,12 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
718
724
|
} | undefined;
|
|
719
725
|
readonly onNewUser?: string | undefined;
|
|
720
726
|
readonly codeLink?: boolean | undefined;
|
|
727
|
+
readonly signUp?: {
|
|
728
|
+
readonly channels: {
|
|
729
|
+
readonly [x: string]: unknown;
|
|
730
|
+
};
|
|
731
|
+
} | undefined;
|
|
732
|
+
readonly onSignUp?: string | undefined;
|
|
721
733
|
} | undefined;
|
|
722
734
|
readonly emails?: {
|
|
723
735
|
readonly [x: string]: {
|
|
@@ -854,10 +866,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
854
866
|
readonly telegram?: {
|
|
855
867
|
readonly connection: string;
|
|
856
868
|
} | undefined;
|
|
857
|
-
readonly
|
|
869
|
+
readonly whatsapp?: {
|
|
858
870
|
readonly connection: string;
|
|
859
871
|
} | undefined;
|
|
860
|
-
readonly
|
|
872
|
+
readonly slack?: {
|
|
861
873
|
readonly connection: string;
|
|
862
874
|
} | undefined;
|
|
863
875
|
readonly attribution?: {
|
|
@@ -961,6 +973,12 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
961
973
|
} | undefined;
|
|
962
974
|
readonly on_new_user?: string | undefined;
|
|
963
975
|
readonly code_link?: boolean | undefined;
|
|
976
|
+
readonly sign_up?: {
|
|
977
|
+
readonly channels: {
|
|
978
|
+
readonly [x: string]: unknown;
|
|
979
|
+
};
|
|
980
|
+
} | undefined;
|
|
981
|
+
readonly on_sign_up?: string | undefined;
|
|
964
982
|
} | undefined;
|
|
965
983
|
} | {
|
|
966
984
|
readonly version: number;
|
|
@@ -1081,10 +1099,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1081
1099
|
readonly telegram?: {
|
|
1082
1100
|
readonly connection: string;
|
|
1083
1101
|
} | undefined;
|
|
1084
|
-
readonly
|
|
1102
|
+
readonly whatsapp?: {
|
|
1085
1103
|
readonly connection: string;
|
|
1086
1104
|
} | undefined;
|
|
1087
|
-
readonly
|
|
1105
|
+
readonly slack?: {
|
|
1088
1106
|
readonly connection: string;
|
|
1089
1107
|
} | undefined;
|
|
1090
1108
|
readonly attribution?: {
|
|
@@ -1172,6 +1190,12 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1172
1190
|
} | undefined;
|
|
1173
1191
|
readonly on_new_user?: string | undefined;
|
|
1174
1192
|
readonly code_link?: boolean | undefined;
|
|
1193
|
+
readonly sign_up?: {
|
|
1194
|
+
readonly channels: {
|
|
1195
|
+
readonly [x: string]: unknown;
|
|
1196
|
+
};
|
|
1197
|
+
} | undefined;
|
|
1198
|
+
readonly on_sign_up?: string | undefined;
|
|
1175
1199
|
} | undefined;
|
|
1176
1200
|
readonly emails?: {
|
|
1177
1201
|
readonly [x: string]: {
|
|
@@ -1341,9 +1365,15 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1341
1365
|
readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
1342
1366
|
readonly onNewUser: Schema.optionalKey<Schema.String>;
|
|
1343
1367
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
1368
|
+
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
1369
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
1370
|
+
}>>;
|
|
1371
|
+
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
1344
1372
|
}>, {
|
|
1345
1373
|
readonly onNewUser: "on_new_user";
|
|
1346
1374
|
readonly codeLink: "code_link";
|
|
1375
|
+
readonly signUp: "sign_up";
|
|
1376
|
+
readonly onSignUp: "on_sign_up";
|
|
1347
1377
|
}>>;
|
|
1348
1378
|
readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
|
|
1349
1379
|
readonly subject: Schema.String;
|
|
@@ -1563,9 +1593,15 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1563
1593
|
readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
1564
1594
|
readonly onNewUser: Schema.optionalKey<Schema.String>;
|
|
1565
1595
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
1596
|
+
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
1597
|
+
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
1598
|
+
}>>;
|
|
1599
|
+
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
1566
1600
|
}>, {
|
|
1567
1601
|
readonly onNewUser: "on_new_user";
|
|
1568
1602
|
readonly codeLink: "code_link";
|
|
1603
|
+
readonly signUp: "sign_up";
|
|
1604
|
+
readonly onSignUp: "on_sign_up";
|
|
1569
1605
|
}>>;
|
|
1570
1606
|
readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
|
|
1571
1607
|
readonly subject: Schema.String;
|
|
@@ -1765,10 +1801,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1765
1801
|
readonly telegram?: {
|
|
1766
1802
|
readonly connection: string;
|
|
1767
1803
|
} | undefined;
|
|
1768
|
-
readonly
|
|
1804
|
+
readonly whatsapp?: {
|
|
1769
1805
|
readonly connection: string;
|
|
1770
1806
|
} | undefined;
|
|
1771
|
-
readonly
|
|
1807
|
+
readonly slack?: {
|
|
1772
1808
|
readonly connection: string;
|
|
1773
1809
|
} | undefined;
|
|
1774
1810
|
readonly attribution?: {
|
|
@@ -1856,6 +1892,12 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1856
1892
|
} | undefined;
|
|
1857
1893
|
readonly onNewUser?: string | undefined;
|
|
1858
1894
|
readonly codeLink?: boolean | undefined;
|
|
1895
|
+
readonly signUp?: {
|
|
1896
|
+
readonly channels: {
|
|
1897
|
+
readonly [x: string]: unknown;
|
|
1898
|
+
};
|
|
1899
|
+
} | undefined;
|
|
1900
|
+
readonly onSignUp?: string | undefined;
|
|
1859
1901
|
} | undefined;
|
|
1860
1902
|
readonly emails?: {
|
|
1861
1903
|
readonly [x: string]: {
|
|
@@ -1992,10 +2034,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1992
2034
|
readonly telegram?: {
|
|
1993
2035
|
readonly connection: string;
|
|
1994
2036
|
} | undefined;
|
|
1995
|
-
readonly
|
|
2037
|
+
readonly whatsapp?: {
|
|
1996
2038
|
readonly connection: string;
|
|
1997
2039
|
} | undefined;
|
|
1998
|
-
readonly
|
|
2040
|
+
readonly slack?: {
|
|
1999
2041
|
readonly connection: string;
|
|
2000
2042
|
} | undefined;
|
|
2001
2043
|
readonly attribution?: {
|
|
@@ -2083,6 +2125,12 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2083
2125
|
} | undefined;
|
|
2084
2126
|
readonly onNewUser?: string | undefined;
|
|
2085
2127
|
readonly codeLink?: boolean | undefined;
|
|
2128
|
+
readonly signUp?: {
|
|
2129
|
+
readonly channels: {
|
|
2130
|
+
readonly [x: string]: unknown;
|
|
2131
|
+
};
|
|
2132
|
+
} | undefined;
|
|
2133
|
+
readonly onSignUp?: string | undefined;
|
|
2086
2134
|
} | undefined;
|
|
2087
2135
|
readonly emails?: {
|
|
2088
2136
|
readonly [x: string]: {
|
package/dist/migrate/storage.js
CHANGED
|
@@ -663,6 +663,8 @@ export const AGENT_TABLES_DDL = [
|
|
|
663
663
|
"blocked_at" timestamptz,
|
|
664
664
|
"on_new_user_completed_at" timestamptz
|
|
665
665
|
)`,
|
|
666
|
+
// A user `signUp` created holds exactly the roles sign-up granted, never `member`.
|
|
667
|
+
`ALTER TABLE "${CHANNEL_USERS_TABLE}" ADD COLUMN IF NOT EXISTS "signed_up" boolean NOT NULL DEFAULT false`,
|
|
666
668
|
`INSERT INTO "${CHANNEL_USERS_TABLE}" ("user_id", "created_via")
|
|
667
669
|
SELECT DISTINCT ON ("user_id") "user_id", "provider" FROM "${AGENT_IDENTITIES_TABLE}"
|
|
668
670
|
WHERE "origin" = 'provisioned' ORDER BY "user_id", "created_at", "id"
|
package/dist/ontology.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { AnyEntity } from "./entity.js";
|
|
|
4
4
|
import { type OntologyManifest, type WorkflowManifest } from "./manifest.js";
|
|
5
5
|
import type { ModelMetrics } from "./metric.js";
|
|
6
6
|
import type { Role } from "./role.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { ResolvedSignInOptions } from "./sign-in.js";
|
|
8
8
|
/** A checked ontology: the resolved definitions and the manifest built from them. */
|
|
9
9
|
export interface Ontology<Entities extends ReadonlyArray<AnyEntity> = ReadonlyArray<AnyEntity>, Metrics extends ModelMetrics = ModelMetrics> {
|
|
10
10
|
/** The definition as given to `defineOntology`. */
|
|
@@ -14,7 +14,7 @@ export interface Ontology<Entities extends ReadonlyArray<AnyEntity> = ReadonlyAr
|
|
|
14
14
|
/** The workspace-owned `member` role first, declared roles, then the implicit reporter when enabled. */
|
|
15
15
|
readonly roles: ReadonlyArray<Role>;
|
|
16
16
|
/** Who may become a member by signing in, with the default policy when the definition sets none. */
|
|
17
|
-
readonly signIn:
|
|
17
|
+
readonly signIn: ResolvedSignInOptions;
|
|
18
18
|
/** The connections the actions call, as `defineOntology({ connections })` lists them. */
|
|
19
19
|
readonly connections: ReadonlyArray<ResolvedConnection>;
|
|
20
20
|
/** The workflows, with wire names and their triggers' input in wire form, as the manifest lists them. */
|
|
@@ -2,7 +2,12 @@ import { Effect } from "effect";
|
|
|
2
2
|
import type { SqlClient } from "effect/unstable/sql";
|
|
3
3
|
/** Legacy workspace databases remain readable before their next additive migration. */
|
|
4
4
|
export declare function channelUsersAvailable(sql: SqlClient.SqlClient): Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Records how a user came to be: `invite`, `email` or a channel's sign-up. The first record stays.
|
|
7
|
+
* `signedUp` marks a user `signUp` created, who never holds `member`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function recordUserCreation(sql: SqlClient.SqlClient, userId: string, via: string, signedUp?: boolean): Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
7
10
|
/** Session revocation integration point for every channel-app issuer (including Mini Apps). */
|
|
8
11
|
export declare function revokeMemberSessions(sql: SqlClient.SqlClient, userId: string): Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
12
|
+
/** Whether a user sign-up created still waits for `onSignUp`: not completed and not blocked. */
|
|
13
|
+
export declare function signUpPending(sql: SqlClient.SqlClient, userId: string): Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|