@segmentstream/ontology 0.139.3 → 0.141.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.141.0
4
+
5
+ `chat_history` reads a Slack channel's history, every thread of it, as the archive now keeps a
6
+ Slack channel's threads under the channel; it refused Slack channels before. A Slack private
7
+ destination is still refused: read a direct message by the chat the inbox registered for it.
8
+
9
+ ## 0.140.0
10
+
11
+ Stored ontology properties accept `excludeFromReplication: true`. Deploy this option to omit
12
+ the property's value from new replication snapshots and the replication record size check.
13
+ The property remains available through the ontology. Removing the option restores warehouse
14
+ coverage after a scoped copy of the current records. Previously exported data is retained.
15
+
3
16
  ## 0.139.3
4
17
 
5
18
  An approved reply in a Slack direct message is archived in the person's direct message, beside
package/dist/analyze.js CHANGED
@@ -2300,6 +2300,9 @@ function resolveProperties(candidate, scope) {
2300
2300
  continue;
2301
2301
  }
2302
2302
  checkProperty(path, schema, definition, report);
2303
+ if (definition.excludeFromReplication && candidate.definition.source !== undefined) {
2304
+ report("invalid-property", path, "excludeFromReplication applies only to stored ontology properties.");
2305
+ }
2303
2306
  if (definition.type === "list" &&
2304
2307
  !(scope.builtIns.has(candidate.definition) && candidate.name === User.name)) {
2305
2308
  report("invalid-property", path, "p.list is kept by the platform and only the built-in user has one, roles; " +
@@ -119,6 +119,7 @@ export declare const PropertyManifest: Schema.Struct<{
119
119
  readonly optional: Schema.Boolean;
120
120
  readonly unique: Schema.Boolean;
121
121
  readonly managed: Schema.Boolean;
122
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
122
123
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
123
124
  readonly display: Schema.optionalKey<Schema.String>;
124
125
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -307,6 +308,7 @@ export declare const EntityManifest: Schema.Struct<{
307
308
  readonly optional: Schema.Boolean;
308
309
  readonly unique: Schema.Boolean;
309
310
  readonly managed: Schema.Boolean;
311
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
310
312
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
311
313
  readonly display: Schema.optionalKey<Schema.String>;
312
314
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -951,6 +953,7 @@ export declare const PropertyManifestWire: Schema.encodeKeys<Schema.Struct<{
951
953
  readonly optional: Schema.Boolean;
952
954
  readonly unique: Schema.Boolean;
953
955
  readonly managed: Schema.Boolean;
956
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
954
957
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
955
958
  readonly display: Schema.optionalKey<Schema.String>;
956
959
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -970,6 +973,7 @@ export declare const PropertyManifestWire: Schema.encodeKeys<Schema.Struct<{
970
973
  readonly renamedFrom: "renamed_from";
971
974
  readonly maxLength: "max_length";
972
975
  readonly maxBytes: "max_bytes";
976
+ readonly excludeFromReplication: "exclude_from_replication";
973
977
  }>;
974
978
  /** A relationship in the snake_case wire spelling, for records that store definitions. */
975
979
  export declare const RelationshipManifestWire: Schema.encodeKeys<Schema.Struct<{
@@ -1022,6 +1026,7 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1022
1026
  readonly optional: Schema.Boolean;
1023
1027
  readonly unique: Schema.Boolean;
1024
1028
  readonly managed: Schema.Boolean;
1029
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
1025
1030
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
1026
1031
  readonly display: Schema.optionalKey<Schema.String>;
1027
1032
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -1041,6 +1046,7 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1041
1046
  readonly renamedFrom: "renamed_from";
1042
1047
  readonly maxLength: "max_length";
1043
1048
  readonly maxBytes: "max_bytes";
1049
+ readonly excludeFromReplication: "exclude_from_replication";
1044
1050
  }>>;
1045
1051
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
1046
1052
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -1520,6 +1526,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1520
1526
  readonly column?: string | undefined;
1521
1527
  readonly renamedFrom?: string | undefined;
1522
1528
  readonly scope?: readonly string[] | undefined;
1529
+ readonly excludeFromReplication?: boolean | undefined;
1523
1530
  readonly display?: string | undefined;
1524
1531
  readonly maxLength?: number | undefined;
1525
1532
  readonly accept?: readonly string[] | undefined;
@@ -1874,6 +1881,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1874
1881
  readonly column?: string | undefined;
1875
1882
  readonly renamedFrom?: string | undefined;
1876
1883
  readonly scope?: readonly string[] | undefined;
1884
+ readonly excludeFromReplication?: boolean | undefined;
1877
1885
  readonly display?: string | undefined;
1878
1886
  readonly maxLength?: number | undefined;
1879
1887
  readonly accept?: readonly string[] | undefined;
@@ -2238,6 +2246,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2238
2246
  readonly renamed_from?: string | undefined;
2239
2247
  readonly max_length?: number | undefined;
2240
2248
  readonly max_bytes?: number | undefined;
2249
+ readonly exclude_from_replication?: boolean | undefined;
2241
2250
  }[];
2242
2251
  readonly relationships: readonly {
2243
2252
  readonly name: string;
@@ -2582,6 +2591,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2582
2591
  readonly column?: string | undefined;
2583
2592
  readonly renamedFrom?: string | undefined;
2584
2593
  readonly scope?: readonly string[] | undefined;
2594
+ readonly excludeFromReplication?: boolean | undefined;
2585
2595
  readonly display?: string | undefined;
2586
2596
  readonly maxLength?: number | undefined;
2587
2597
  readonly accept?: readonly string[] | undefined;
@@ -2929,6 +2939,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2929
2939
  readonly optional: Schema.Boolean;
2930
2940
  readonly unique: Schema.Boolean;
2931
2941
  readonly managed: Schema.Boolean;
2942
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
2932
2943
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
2933
2944
  readonly display: Schema.optionalKey<Schema.String>;
2934
2945
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -2948,6 +2959,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2948
2959
  readonly renamedFrom: "renamed_from";
2949
2960
  readonly maxLength: "max_length";
2950
2961
  readonly maxBytes: "max_bytes";
2962
+ readonly excludeFromReplication: "exclude_from_replication";
2951
2963
  }>>;
2952
2964
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
2953
2965
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -3442,6 +3454,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3442
3454
  readonly optional: Schema.Boolean;
3443
3455
  readonly unique: Schema.Boolean;
3444
3456
  readonly managed: Schema.Boolean;
3457
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
3445
3458
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
3446
3459
  readonly display: Schema.optionalKey<Schema.String>;
3447
3460
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -3897,6 +3910,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3897
3910
  readonly column?: string | undefined;
3898
3911
  readonly renamedFrom?: string | undefined;
3899
3912
  readonly scope?: readonly string[] | undefined;
3913
+ readonly excludeFromReplication?: boolean | undefined;
3900
3914
  readonly display?: string | undefined;
3901
3915
  readonly maxLength?: number | undefined;
3902
3916
  readonly accept?: readonly string[] | undefined;
@@ -4251,6 +4265,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
4251
4265
  readonly column?: string | undefined;
4252
4266
  readonly renamedFrom?: string | undefined;
4253
4267
  readonly scope?: readonly string[] | undefined;
4268
+ readonly excludeFromReplication?: boolean | undefined;
4254
4269
  readonly display?: string | undefined;
4255
4270
  readonly maxLength?: number | undefined;
4256
4271
  readonly accept?: readonly string[] | undefined;
@@ -4611,6 +4626,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4611
4626
  readonly column?: string | undefined;
4612
4627
  readonly renamedFrom?: string | undefined;
4613
4628
  readonly scope?: readonly string[] | undefined;
4629
+ readonly excludeFromReplication?: boolean | undefined;
4614
4630
  readonly display?: string | undefined;
4615
4631
  readonly maxLength?: number | undefined;
4616
4632
  readonly accept?: readonly string[] | undefined;
@@ -4965,6 +4981,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4965
4981
  readonly column?: string | undefined;
4966
4982
  readonly renamedFrom?: string | undefined;
4967
4983
  readonly scope?: readonly string[] | undefined;
4984
+ readonly excludeFromReplication?: boolean | undefined;
4968
4985
  readonly display?: string | undefined;
4969
4986
  readonly maxLength?: number | undefined;
4970
4987
  readonly accept?: readonly string[] | undefined;
package/dist/manifest.js CHANGED
@@ -124,6 +124,7 @@ export const PropertyManifest = Schema.Struct({
124
124
  optional: Schema.Boolean,
125
125
  unique: Schema.Boolean,
126
126
  managed: Schema.Boolean,
127
+ excludeFromReplication: Schema.optionalKey(Schema.Boolean),
127
128
  default: Schema.optionalKey(Schema.Json),
128
129
  display: Schema.optionalKey(Schema.String),
129
130
  renamedFrom: Schema.optionalKey(Schema.String),
@@ -643,6 +644,7 @@ export const PropertyManifestWire = PropertyManifest.pipe(Schema.encodeKeys({
643
644
  renamedFrom: "renamed_from",
644
645
  maxLength: "max_length",
645
646
  maxBytes: "max_bytes",
647
+ excludeFromReplication: "exclude_from_replication",
646
648
  }));
647
649
  const OnDeleteWire = Schema.Literals(["set_null", "cascade", "restrict"]).pipe(Schema.decodeTo(Schema.Literals(ON_DELETE), SchemaTransformation.transform({
648
650
  decode: (value) => (value === "set_null" ? "setNull" : value),
@@ -883,6 +885,7 @@ function propertyManifest({ name, definition }) {
883
885
  optional: definition.optional,
884
886
  unique: definition.unique,
885
887
  managed: definition.managed,
888
+ ...(definition.excludeFromReplication ? { excludeFromReplication: true } : {}),
886
889
  ...("default" in definition ? { default: definition.default } : {}),
887
890
  ...(definition.display !== undefined ? { display: definition.display } : {}),
888
891
  ...(definition.renamedFrom !== undefined ? { renamedFrom: definition.renamedFrom } : {}),
@@ -60,6 +60,7 @@ export declare const RetainedEntity: Schema.Struct<{
60
60
  readonly optional: Schema.Boolean;
61
61
  readonly unique: Schema.Boolean;
62
62
  readonly managed: Schema.Boolean;
63
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
63
64
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
64
65
  readonly display: Schema.optionalKey<Schema.String>;
65
66
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -78,6 +79,7 @@ export declare const RetainedEntity: Schema.Struct<{
78
79
  readonly renamedFrom: "renamed_from";
79
80
  readonly maxLength: "max_length";
80
81
  readonly maxBytes: "max_bytes";
82
+ readonly excludeFromReplication: "exclude_from_replication";
81
83
  }>>;
82
84
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
83
85
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -114,6 +116,7 @@ export declare const RetainedEntity: Schema.Struct<{
114
116
  readonly optional: Schema.Boolean;
115
117
  readonly unique: Schema.Boolean;
116
118
  readonly managed: Schema.Boolean;
119
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
117
120
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
118
121
  readonly display: Schema.optionalKey<Schema.String>;
119
122
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -132,6 +135,7 @@ export declare const RetainedEntity: Schema.Struct<{
132
135
  readonly renamedFrom: "renamed_from";
133
136
  readonly maxLength: "max_length";
134
137
  readonly maxBytes: "max_bytes";
138
+ readonly excludeFromReplication: "exclude_from_replication";
135
139
  }>>;
136
140
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
137
141
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -173,6 +177,7 @@ export declare const RetainedStorage: Schema.Struct<{
173
177
  readonly optional: Schema.Boolean;
174
178
  readonly unique: Schema.Boolean;
175
179
  readonly managed: Schema.Boolean;
180
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
176
181
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
177
182
  readonly display: Schema.optionalKey<Schema.String>;
178
183
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -191,6 +196,7 @@ export declare const RetainedStorage: Schema.Struct<{
191
196
  readonly renamedFrom: "renamed_from";
192
197
  readonly maxLength: "max_length";
193
198
  readonly maxBytes: "max_bytes";
199
+ readonly excludeFromReplication: "exclude_from_replication";
194
200
  }>>;
195
201
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
196
202
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -227,6 +233,7 @@ export declare const RetainedStorage: Schema.Struct<{
227
233
  readonly optional: Schema.Boolean;
228
234
  readonly unique: Schema.Boolean;
229
235
  readonly managed: Schema.Boolean;
236
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
230
237
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
231
238
  readonly display: Schema.optionalKey<Schema.String>;
232
239
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -245,6 +252,7 @@ export declare const RetainedStorage: Schema.Struct<{
245
252
  readonly renamedFrom: "renamed_from";
246
253
  readonly maxLength: "max_length";
247
254
  readonly maxBytes: "max_bytes";
255
+ readonly excludeFromReplication: "exclude_from_replication";
248
256
  }>>;
249
257
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
250
258
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -315,6 +323,7 @@ export declare const MigrationPlan: Schema.Struct<{
315
323
  readonly column?: string | undefined;
316
324
  readonly renamedFrom?: string | undefined;
317
325
  readonly scope?: readonly string[] | undefined;
326
+ readonly excludeFromReplication?: boolean | undefined;
318
327
  readonly display?: string | undefined;
319
328
  readonly maxLength?: number | undefined;
320
329
  readonly accept?: readonly string[] | undefined;
@@ -669,6 +678,7 @@ export declare const MigrationPlan: Schema.Struct<{
669
678
  readonly column?: string | undefined;
670
679
  readonly renamedFrom?: string | undefined;
671
680
  readonly scope?: readonly string[] | undefined;
681
+ readonly excludeFromReplication?: boolean | undefined;
672
682
  readonly display?: string | undefined;
673
683
  readonly maxLength?: number | undefined;
674
684
  readonly accept?: readonly string[] | undefined;
@@ -1033,6 +1043,7 @@ export declare const MigrationPlan: Schema.Struct<{
1033
1043
  readonly renamed_from?: string | undefined;
1034
1044
  readonly max_length?: number | undefined;
1035
1045
  readonly max_bytes?: number | undefined;
1046
+ readonly exclude_from_replication?: boolean | undefined;
1036
1047
  }[];
1037
1048
  readonly relationships: readonly {
1038
1049
  readonly name: string;
@@ -1377,6 +1388,7 @@ export declare const MigrationPlan: Schema.Struct<{
1377
1388
  readonly column?: string | undefined;
1378
1389
  readonly renamedFrom?: string | undefined;
1379
1390
  readonly scope?: readonly string[] | undefined;
1391
+ readonly excludeFromReplication?: boolean | undefined;
1380
1392
  readonly display?: string | undefined;
1381
1393
  readonly maxLength?: number | undefined;
1382
1394
  readonly accept?: readonly string[] | undefined;
@@ -1720,6 +1732,7 @@ export declare const MigrationPlan: Schema.Struct<{
1720
1732
  readonly optional: Schema.Boolean;
1721
1733
  readonly unique: Schema.Boolean;
1722
1734
  readonly managed: Schema.Boolean;
1735
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
1723
1736
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
1724
1737
  readonly display: Schema.optionalKey<Schema.String>;
1725
1738
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -1738,6 +1751,7 @@ export declare const MigrationPlan: Schema.Struct<{
1738
1751
  readonly renamedFrom: "renamed_from";
1739
1752
  readonly maxLength: "max_length";
1740
1753
  readonly maxBytes: "max_bytes";
1754
+ readonly excludeFromReplication: "exclude_from_replication";
1741
1755
  }>>;
1742
1756
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
1743
1757
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -2110,6 +2124,7 @@ export declare const MigrationPlan: Schema.Struct<{
2110
2124
  readonly optional: Schema.Boolean;
2111
2125
  readonly unique: Schema.Boolean;
2112
2126
  readonly managed: Schema.Boolean;
2127
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
2113
2128
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
2114
2129
  readonly display: Schema.optionalKey<Schema.String>;
2115
2130
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -2444,6 +2459,7 @@ export declare const MigrationPlan: Schema.Struct<{
2444
2459
  readonly column?: string | undefined;
2445
2460
  readonly renamedFrom?: string | undefined;
2446
2461
  readonly scope?: readonly string[] | undefined;
2462
+ readonly excludeFromReplication?: boolean | undefined;
2447
2463
  readonly display?: string | undefined;
2448
2464
  readonly maxLength?: number | undefined;
2449
2465
  readonly accept?: readonly string[] | undefined;
@@ -2798,6 +2814,7 @@ export declare const MigrationPlan: Schema.Struct<{
2798
2814
  readonly column?: string | undefined;
2799
2815
  readonly renamedFrom?: string | undefined;
2800
2816
  readonly scope?: readonly string[] | undefined;
2817
+ readonly excludeFromReplication?: boolean | undefined;
2801
2818
  readonly display?: string | undefined;
2802
2819
  readonly maxLength?: number | undefined;
2803
2820
  readonly accept?: readonly string[] | undefined;
@@ -3163,6 +3180,7 @@ export declare const MigrationPlan: Schema.Struct<{
3163
3180
  readonly optional: Schema.Boolean;
3164
3181
  readonly unique: Schema.Boolean;
3165
3182
  readonly managed: Schema.Boolean;
3183
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
3166
3184
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
3167
3185
  readonly display: Schema.optionalKey<Schema.String>;
3168
3186
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -3181,6 +3199,7 @@ export declare const MigrationPlan: Schema.Struct<{
3181
3199
  readonly renamedFrom: "renamed_from";
3182
3200
  readonly maxLength: "max_length";
3183
3201
  readonly maxBytes: "max_bytes";
3202
+ readonly excludeFromReplication: "exclude_from_replication";
3184
3203
  }>>;
3185
3204
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
3186
3205
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -3217,6 +3236,7 @@ export declare const MigrationPlan: Schema.Struct<{
3217
3236
  readonly optional: Schema.Boolean;
3218
3237
  readonly unique: Schema.Boolean;
3219
3238
  readonly managed: Schema.Boolean;
3239
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
3220
3240
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
3221
3241
  readonly display: Schema.optionalKey<Schema.String>;
3222
3242
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -3235,6 +3255,7 @@ export declare const MigrationPlan: Schema.Struct<{
3235
3255
  readonly renamedFrom: "renamed_from";
3236
3256
  readonly maxLength: "max_length";
3237
3257
  readonly maxBytes: "max_bytes";
3258
+ readonly excludeFromReplication: "exclude_from_replication";
3238
3259
  }>>;
3239
3260
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
3240
3261
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -3275,6 +3296,7 @@ export declare const MigrationPlan: Schema.Struct<{
3275
3296
  readonly optional: Schema.Boolean;
3276
3297
  readonly unique: Schema.Boolean;
3277
3298
  readonly managed: Schema.Boolean;
3299
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
3278
3300
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
3279
3301
  readonly display: Schema.optionalKey<Schema.String>;
3280
3302
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -3293,6 +3315,7 @@ export declare const MigrationPlan: Schema.Struct<{
3293
3315
  readonly renamedFrom: "renamed_from";
3294
3316
  readonly maxLength: "max_length";
3295
3317
  readonly maxBytes: "max_bytes";
3318
+ readonly excludeFromReplication: "exclude_from_replication";
3296
3319
  }>>;
3297
3320
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
3298
3321
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -3329,6 +3352,7 @@ export declare const MigrationPlan: Schema.Struct<{
3329
3352
  readonly optional: Schema.Boolean;
3330
3353
  readonly unique: Schema.Boolean;
3331
3354
  readonly managed: Schema.Boolean;
3355
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
3332
3356
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
3333
3357
  readonly display: Schema.optionalKey<Schema.String>;
3334
3358
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -3347,6 +3371,7 @@ export declare const MigrationPlan: Schema.Struct<{
3347
3371
  readonly renamedFrom: "renamed_from";
3348
3372
  readonly maxLength: "max_length";
3349
3373
  readonly maxBytes: "max_bytes";
3374
+ readonly excludeFromReplication: "exclude_from_replication";
3350
3375
  }>>;
3351
3376
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
3352
3377
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -31,6 +31,7 @@ export interface PropertyDefinition {
31
31
  readonly optional: boolean;
32
32
  readonly unique: boolean;
33
33
  readonly managed: boolean;
34
+ readonly excludeFromReplication?: boolean;
34
35
  /** Present only when the property declares a default. */
35
36
  readonly default?: unknown;
36
37
  readonly label?: string;
@@ -72,6 +73,8 @@ export interface PropertyOptions<T> {
72
73
  readonly renamedFrom?: string;
73
74
  /** Excluded from the generated `update` action: it changes only through authored actions. */
74
75
  readonly managed?: boolean;
76
+ /** Keep this stored property in the ontology and omit its value from warehouse replication. */
77
+ readonly excludeFromReplication?: boolean;
75
78
  /** A display hint independent of the storage type, for example `multiline` for text. */
76
79
  readonly display?: string;
77
80
  }
package/dist/property.js CHANGED
@@ -45,6 +45,7 @@ const COMMON_OPTIONS = [
45
45
  "description",
46
46
  "renamedFrom",
47
47
  "managed",
48
+ "excludeFromReplication",
48
49
  "display",
49
50
  ];
50
51
  /** The options a constructor takes beyond {@link COMMON_OPTIONS}, by property type. */
@@ -84,6 +85,7 @@ function construct({ type, base, options, checks = [], format, selectOptions, it
84
85
  optional: options.optional === true,
85
86
  unique: options.unique === true,
86
87
  managed: options.managed === true,
88
+ ...(options.excludeFromReplication === true ? { excludeFromReplication: true } : {}),
87
89
  ...(options.default !== undefined ? { default: options.default } : {}),
88
90
  ...(options.label !== undefined ? { label: options.label } : {}),
89
91
  ...(options.description !== undefined ? { description: options.description } : {}),
@@ -24,6 +24,7 @@ export const prepareReplicationEvolution = (sql) => Effect.gen(function* () {
24
24
  export function replicationRecoveryScopes(current, target, retained) {
25
25
  const scopes = [];
26
26
  const resets = [];
27
+ const previousIds = target.identities ? replicationIdentities(current) : undefined;
27
28
  for (const next of target.selection) {
28
29
  const previous = current.selection.find((item) => item.entityId === next.entityId);
29
30
  const before = current.manifest.entities.find((entity) => entity.id === next.entityId);
@@ -36,9 +37,18 @@ export function replicationRecoveryScopes(current, target, retained) {
36
37
  continue;
37
38
  }
38
39
  const previousFields = new Set(queryFields(before).map((field) => field.name));
40
+ const priorIds = previousIds?.[entity.id];
41
+ const nextIds = target.identities?.[entity.id];
42
+ const continuingEntity = priorIds && nextIds && priorIds.id === nextIds.id;
43
+ const nextIdentities = new Set(Object.values(nextIds ?? {}));
39
44
  const needsRecords = next.fields.some((field) => {
40
45
  const old = renamedReplicationField(current.manifest, target.manifest, entity.id, field) ?? field;
41
46
  return ((!previous.fields.includes(old) && previousFields.has(old)) ||
47
+ // A deploy can re-include a field before the exclusion reaches the warehouse.
48
+ // Its new capture identity needs a scan even when the serving epoch still has the old one.
49
+ (continuingEntity &&
50
+ previous.fields.includes(old) &&
51
+ !nextIdentities.has(priorIds[old])) ||
42
52
  kept?.fields.properties.some((property) => property.name === field) ||
43
53
  kept?.fields.relationships.some((relationship) => `${relationship.name}_id` === field));
44
54
  });
@@ -21,13 +21,21 @@ export function replicationIdentities(target) {
21
21
  export function migratedReplicationIdentities(current, target) {
22
22
  const previous = replicationIdentities(current);
23
23
  const initial = replicationIdentities({ ...target, identities: undefined });
24
- return Object.fromEntries(Object.entries(initial).map(([entityId, fields]) => [
25
- entityId,
26
- Object.fromEntries(Object.entries(fields).map(([field, identity]) => {
24
+ return Object.fromEntries(Object.entries(initial).map(([entityId, fields]) => {
25
+ const previouslyExcluded = new Set(current.manifest.entities
26
+ .find((item) => item.id === entityId)
27
+ ?.properties.filter((property) => property.excludeFromReplication)
28
+ .map((property) => property.name));
29
+ const selected = target.selection.find((item) => item.entityId === entityId);
30
+ const migrated = Object.entries(fields).map(([field, identity]) => {
27
31
  const old = renamedReplicationField(current.manifest, target.manifest, entityId, field) ?? field;
28
- return [field, previous[entityId]?.[old] ?? identity];
29
- })),
30
- ]));
32
+ // Earlier copies missed writes made while this property was excluded. A new coverage
33
+ // identity keeps the old value out of queries until the current value is published.
34
+ const restored = previouslyExcluded.has(old) && selected?.fields.includes(field);
35
+ return [field, restored ? identity : (previous[entityId]?.[old] ?? identity)];
36
+ });
37
+ return [entityId, Object.fromEntries(migrated)];
38
+ }));
31
39
  }
32
40
  export function permittedReplicationField(actual, policy, entity, field) {
33
41
  const selected = policy.selection.find((item) => item.entityId === entity);
@@ -1,4 +1,4 @@
1
- import type { OntologyManifest } from "../manifest.js";
1
+ import type { EntityManifest, OntologyManifest } from "../manifest.js";
2
2
  /** The current projection of a continuous replication stream. `id` is always included. */
3
3
  export interface ReplicationSelection {
4
4
  readonly entityId: string;
@@ -10,10 +10,9 @@ export interface ReplicationSelection {
10
10
  * captured before the field existed lack its key, while every record they describe holds this value.
11
11
  */
12
12
  export type ReplicationFills = Readonly<Record<string, Readonly<Record<string, unknown>>>>;
13
- /**
14
- * Every stored business entity replicates with all of its fields and its relationships between
15
- * stored business entities. Built-in and warehouse-backed entities are never exported.
16
- */
13
+ /** System fields and relationship keys always replicate. Only declared properties can opt out. */
14
+ export declare function replicatedFields(entity: EntityManifest): import("../query.js").QueryField[];
15
+ /** Every stored business entity and its relationships to other stored entities replicate. */
17
16
  export declare function resolveReplicationSelection(manifest: OntologyManifest): ReadonlyArray<ReplicationSelection>;
18
17
  export interface ReplicationEvent {
19
18
  readonly event_id: string;
@@ -1,14 +1,16 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { queryFields } from "../query.js";
3
- /**
4
- * Every stored business entity replicates with all of its fields and its relationships between
5
- * stored business entities. Built-in and warehouse-backed entities are never exported.
6
- */
3
+ /** System fields and relationship keys always replicate. Only declared properties can opt out. */
4
+ export function replicatedFields(entity) {
5
+ const excluded = new Set(entity.properties.filter((p) => p.excludeFromReplication).map((p) => p.name));
6
+ return queryFields(entity).filter((field) => !excluded.has(field.name));
7
+ }
8
+ /** Every stored business entity and its relationships to other stored entities replicate. */
7
9
  export function resolveReplicationSelection(manifest) {
8
10
  const entities = manifest.entities.filter((entity) => !entity.builtIn && !entity.source);
9
11
  const selection = entities.map((entity) => ({
10
12
  entityId: entity.id,
11
- fields: queryFields(entity).map((field) => field.name),
13
+ fields: replicatedFields(entity).map((field) => field.name),
12
14
  relationships: entity.relationships
13
15
  .filter((relationship) => relationship.cardinality === "many" &&
14
16
  entities.some((target) => target.name === relationship.to))
@@ -39,7 +41,7 @@ export function validateReplicationSelection(manifest, selection) {
39
41
  throw new Error(`Only stored business entities can be replicated: ${item.entityId}.`);
40
42
  }
41
43
  addView(entity.name);
42
- const fields = new Set(queryFields(entity).map((f) => f.name));
44
+ const fields = new Set(replicatedFields(entity).map((f) => f.name));
43
45
  if (item.fields.some((field) => !fields.has(field))) {
44
46
  throw new Error(`Unknown replication field on ${entity.name}.`);
45
47
  }
@@ -1,7 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
- import { queryFields } from "../query.js";
3
2
  import { columnName, historyTableName, quoteIdentifier as qi, quoteLiteral as ql, relationshipColumnName, SYSTEM_COLUMNS, tableName, joinTableName, } from "../migrate/storage.js";
4
- import { REPLICATION_RECORD_BYTES } from "./model.js";
3
+ import { replicatedFields, REPLICATION_RECORD_BYTES } from "./model.js";
5
4
  import { SHADOW_REPLICATION_DDL, SHADOW_CONTROL_JOBS_DDL, SHADOW_SOURCE_REPLACEMENTS_DDL, } from "./shadow-schema.js";
6
5
  export const REPLICATION_SCHEMA_VERSION = 6;
7
6
  /** Targets of sources not migrated since fills were introduced have no `fills` column. */
@@ -121,7 +120,7 @@ export const REPLICATION_DDL = [
121
120
  END $$`,
122
121
  ];
123
122
  export function snapshotExpression(entity, alias) {
124
- const values = queryFields(entity).flatMap((field) => {
123
+ const values = replicatedFields(entity).flatMap((field) => {
125
124
  const system = SYSTEM_COLUMNS[field.name];
126
125
  const column = system ??
127
126
  (entity.properties.some((p) => p.name === field.name)
@@ -7,7 +7,7 @@ import { lockReplicationLifecycle, shareReplicationLifecycle } from "./transacti
7
7
  import { canonicalJson } from "../manifest.js";
8
8
  import { readCatalog } from "../migrate/apply.js";
9
9
  import { historyTableName, quoteIdentifier as qi } from "../migrate/storage.js";
10
- import { REPLICATION_BATCH_BYTES, REPLICATION_BATCH_SIZE, publishMessage, replicationEventId, resolveReplicationSelection, } from "./model.js";
10
+ import { REPLICATION_BATCH_BYTES, REPLICATION_BATCH_SIZE, publishMessage, replicationEventId, resolveReplicationSelection, validateReplicationSelection, } from "./model.js";
11
11
  import { createReplicationBaseline, advanceReplicationBaseline, ReplicationBaselineFailed, } from "./baseline.js";
12
12
  import { migratedReplicationFills } from "./migrate.js";
13
13
  import { refreshReplicationProjection } from "./evolution.js";
@@ -38,11 +38,16 @@ export const startReplication = (sql, input) => Effect.gen(function* () {
38
38
  input.selection === undefined) {
39
39
  return previous;
40
40
  }
41
- const selection = input.selection ??
42
- (yield* Effect.try({
43
- try: () => resolveReplicationSelection(manifest),
44
- catch: (cause) => new ReplicationBaselineFailed({ message: "Invalid replication projection.", cause }),
45
- }));
41
+ const selection = yield* Effect.try({
42
+ try: () => {
43
+ if (input.selection === undefined) {
44
+ return resolveReplicationSelection(manifest);
45
+ }
46
+ validateReplicationSelection(manifest, input.selection);
47
+ return input.selection;
48
+ },
49
+ catch: (cause) => new ReplicationBaselineFailed({ message: "Invalid replication projection.", cause }),
50
+ });
46
51
  if (previous &&
47
52
  (paused ||
48
53
  restricted ||
@@ -6,8 +6,11 @@ import { CurrentPrincipal } from "../authentication.js";
6
6
  import { currentCaller } from "../caller-context.js";
7
7
  import { chatAttribution } from "./attribution.js";
8
8
  import { chatResolver, groupChatKey, isChatMember } from "./resolve.js";
9
- /** The kinds of channel whose archived chats are keyed by the chat a destination names. */
10
- const HISTORY_KINDS = new Set(["telegram"]);
9
+ /**
10
+ * The kinds of channel whose archived group chats are keyed by the chat a destination names: a
11
+ * Telegram chat, and a Slack channel, whose threads the archive keeps under it.
12
+ */
13
+ const HISTORY_KINDS = new Set(["telegram", "slack"]);
11
14
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
12
15
  /**
13
16
  * A private chat the inbox registered, by its record id, when the caller may read it: a member with
@@ -107,13 +110,20 @@ export function chatReads(backend, options) {
107
110
  if (principal.kind !== "member") {
108
111
  return yield* new PermissionDenied({ message: "Only members may read chatHistory." });
109
112
  }
110
- // History reads the chats of Telegram channels only. Other channels archive a chat under
111
- // their session's address with private coordinates, not under the chat a destination
112
- // names, so their history would be incomplete until the archive keys them the same way.
113
+ // History reads Telegram's chats and Slack's channels, which the archive keeps under the
114
+ // chat a destination names. Other channels' chats are read by the record the inbox
115
+ // registered for them, above.
113
116
  const target = yield* chatResolver(backend, principal, history, {
114
117
  memberGroups: true,
115
118
  kindOf,
116
119
  }).resolve(input.chat);
120
+ // A Slack private destination names its person, while the archive keeps their direct
121
+ // message under its own channel id.
122
+ if (target.kind !== "group" && kindOf(target.provider) !== "telegram") {
123
+ return yield* new ActionRejected({
124
+ message: "Read a direct message by the chat the inbox registered for it.",
125
+ });
126
+ }
117
127
  // A group's members read its history, as they read its attachments; agent_chat:read reads
118
128
  // every group. A private chat is read only by its participant.
119
129
  const member = target.kind === "group" &&
@@ -324,6 +324,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
324
324
  readonly optional: Schema.Boolean;
325
325
  readonly unique: Schema.Boolean;
326
326
  readonly managed: Schema.Boolean;
327
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
327
328
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
328
329
  readonly display: Schema.optionalKey<Schema.String>;
329
330
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -342,6 +343,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
342
343
  readonly renamedFrom: "renamed_from";
343
344
  readonly maxLength: "max_length";
344
345
  readonly maxBytes: "max_bytes";
346
+ readonly excludeFromReplication: "exclude_from_replication";
345
347
  }>>;
346
348
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
347
349
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
@@ -687,6 +689,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
687
689
  readonly optional: Schema.Boolean;
688
690
  readonly unique: Schema.Boolean;
689
691
  readonly managed: Schema.Boolean;
692
+ readonly excludeFromReplication: Schema.optionalKey<Schema.Boolean>;
690
693
  readonly default: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
691
694
  readonly display: Schema.optionalKey<Schema.String>;
692
695
  readonly renamedFrom: Schema.optionalKey<Schema.String>;
@@ -705,6 +708,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
705
708
  readonly renamedFrom: "renamed_from";
706
709
  readonly maxLength: "max_length";
707
710
  readonly maxBytes: "max_bytes";
711
+ readonly excludeFromReplication: "exclude_from_replication";
708
712
  }>>;
709
713
  readonly relationships: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
710
714
  readonly on: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.139.3",
3
+ "version": "0.141.0",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",