@segmentstream/ontology 0.168.1 → 0.169.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 +10 -0
- package/dist/agent-draft.js +2 -0
- package/dist/analyze.js +13 -0
- package/dist/diagnostics.d.ts +3 -3
- package/dist/diagnostics.js +1 -0
- package/dist/entity.d.ts +9 -0
- package/dist/manifest.d.ts +33 -0
- package/dist/manifest.js +16 -1
- package/dist/migrate/model.d.ts +9 -0
- package/dist/replication/schema.js +19 -0
- package/dist/service/schemas.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.169.0
|
|
4
|
+
|
|
5
|
+
An entity can declare `eraseFromWarehouseOnDelete: true`: deleting one of its records then erases
|
|
6
|
+
the record's replicated history from the workspace warehouse, in every copy the platform keeps,
|
|
7
|
+
leaving only the content-free fact of its deletion. Every deletion counts, whether by an action, a
|
|
8
|
+
cascade or a retention purge, and so do the deletions recorded before the setting was turned on.
|
|
9
|
+
Erasure runs daily; the record is gone from everything the workspace can query within about two
|
|
10
|
+
days. It is off by default. The built-in `agent_draft` turns it on, so drafts the chat retention
|
|
11
|
+
deletes no longer remain readable in the warehouse.
|
|
12
|
+
|
|
3
13
|
## 0.168.1
|
|
4
14
|
|
|
5
15
|
The replication schema adds a content-free erasure journal, `_ontology_replication_erasures`.
|
package/dist/agent-draft.js
CHANGED
|
@@ -162,6 +162,8 @@ export const AgentDraft = entity("agent_draft", {
|
|
|
162
162
|
id: "ent_agent_review",
|
|
163
163
|
// @legacy ontology.agent-review-entity-name
|
|
164
164
|
renamedFrom: "agent_review",
|
|
165
|
+
// A draft the chat retention deletes takes its text, notes and reasons out of the warehouse too.
|
|
166
|
+
eraseFromWarehouseOnDelete: true,
|
|
165
167
|
label: "Agent draft",
|
|
166
168
|
plural: "Agent drafts",
|
|
167
169
|
title: "draft",
|
package/dist/analyze.js
CHANGED
|
@@ -2298,6 +2298,7 @@ function resolveEntity(candidate, scope, resolvedProperties) {
|
|
|
2298
2298
|
report("invalid-guide", `${name}.guide`, "must be a relative path to a Markdown file, such as ./lead.md.");
|
|
2299
2299
|
}
|
|
2300
2300
|
checkWrites(name, definition, report);
|
|
2301
|
+
checkErasure(name, definition, report);
|
|
2301
2302
|
const properties = resolvedProperties ?? resolveProperties(candidate, scope);
|
|
2302
2303
|
const relationships = resolveRelationships(candidate, scope);
|
|
2303
2304
|
if (isBlank(definition.title)) {
|
|
@@ -2337,6 +2338,18 @@ function writesOf(candidate) {
|
|
|
2337
2338
|
? "actions"
|
|
2338
2339
|
: "generated";
|
|
2339
2340
|
}
|
|
2341
|
+
function checkErasure(name, definition, report) {
|
|
2342
|
+
const erase = definition.eraseFromWarehouseOnDelete;
|
|
2343
|
+
if (erase === undefined) {
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
if (typeof erase !== "boolean") {
|
|
2347
|
+
report("invalid-erasure", `${name}.eraseFromWarehouseOnDelete`, "eraseFromWarehouseOnDelete is true or false.");
|
|
2348
|
+
}
|
|
2349
|
+
else if (erase && definition.source !== undefined) {
|
|
2350
|
+
report("invalid-erasure", `${name}.eraseFromWarehouseOnDelete`, "a warehouse-backed entity's records are the warehouse's own; remove eraseFromWarehouseOnDelete.");
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2340
2353
|
function checkWrites(name, definition, report) {
|
|
2341
2354
|
const writes = definition.writes;
|
|
2342
2355
|
if (writes === undefined) {
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
export declare const DIAGNOSTIC_CODES: readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-inbox", "invalid-chat", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "feedback-unreportable", "agent-tools-implicit", "named-secret-deprecated", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "trigger_runs_invalid", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"];
|
|
2
|
+
export declare const DIAGNOSTIC_CODES: readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "invalid-erasure", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-inbox", "invalid-chat", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "feedback-unreportable", "agent-tools-implicit", "named-secret-deprecated", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "trigger_runs_invalid", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"];
|
|
3
3
|
export type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number];
|
|
4
4
|
/** A problem `check` found in an ontology definition. */
|
|
5
5
|
export declare const Diagnostic: Schema.Struct<{
|
|
6
6
|
readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
|
|
7
|
-
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-inbox", "invalid-chat", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "feedback-unreportable", "agent-tools-implicit", "named-secret-deprecated", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "trigger_runs_invalid", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
7
|
+
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "invalid-erasure", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-inbox", "invalid-chat", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "feedback-unreportable", "agent-tools-implicit", "named-secret-deprecated", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "trigger_runs_invalid", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
8
8
|
/** Where the problem is, for example `lead.properties.status.options[1]`. */
|
|
9
9
|
readonly path: Schema.String;
|
|
10
10
|
readonly message: Schema.String;
|
|
@@ -14,7 +14,7 @@ declare const InvalidOntology_base: Schema.Class<InvalidOntology, Schema.TaggedS
|
|
|
14
14
|
readonly message: Schema.String;
|
|
15
15
|
readonly diagnostics: Schema.$Array<Schema.Struct<{
|
|
16
16
|
readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
|
|
17
|
-
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-inbox", "invalid-chat", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "feedback-unreportable", "agent-tools-implicit", "named-secret-deprecated", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "trigger_runs_invalid", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
17
|
+
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "invalid-erasure", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-inbox", "invalid-chat", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "feedback-unreportable", "agent-tools-implicit", "named-secret-deprecated", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "trigger_runs_invalid", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
18
18
|
/** Where the problem is, for example `lead.properties.status.options[1]`. */
|
|
19
19
|
readonly path: Schema.String;
|
|
20
20
|
readonly message: Schema.String;
|
package/dist/diagnostics.js
CHANGED
package/dist/entity.d.ts
CHANGED
|
@@ -179,6 +179,15 @@ export interface EntityDefinition<P extends Properties, R extends Relationships,
|
|
|
179
179
|
* Reads stay the same. Stored entities only.
|
|
180
180
|
*/
|
|
181
181
|
readonly writes?: EntityWrites;
|
|
182
|
+
/**
|
|
183
|
+
* Whether deleting a record also erases its replicated history from the workspace warehouse:
|
|
184
|
+
* every earlier value the warehouse holds for it, in each copy the platform keeps. The record's
|
|
185
|
+
* deletion itself stays, with no content. Erasure runs daily; see the replication docs for its
|
|
186
|
+
* timing. Every deletion counts, by an action, a cascade or a retention purge, as do the
|
|
187
|
+
* deletions recorded before it was turned on. Off by default: the warehouse keeps a deleted
|
|
188
|
+
* record's history for queries over the past. Stored entities only.
|
|
189
|
+
*/
|
|
190
|
+
readonly eraseFromWarehouseOnDelete?: boolean;
|
|
182
191
|
}
|
|
183
192
|
/** Who writes an entity's records; see {@link EntityDefinition.writes}. */
|
|
184
193
|
export type EntityWrites = "generated" | "actions";
|
package/dist/manifest.d.ts
CHANGED
|
@@ -110,6 +110,9 @@ import { type ResolvedGuest, type ResolvedSignInOptions, type SignInPolicy } fro
|
|
|
110
110
|
* `private` without members. Older readers ignore it and register no chat without members.
|
|
111
111
|
* Within version 16, a mailbox in `chat` may carry `signature: true`, written only when declared:
|
|
112
112
|
* the ontology's replies to mail end with the mailbox's own signature. Older readers ignore it.
|
|
113
|
+
* Within version 16, an entity may carry `erase_from_warehouse_on_delete: true`, written only when
|
|
114
|
+
* declared: deleting a record erases its replicated history from the warehouse. The SDK's own
|
|
115
|
+
* replication capture acts on it; readers ignore it.
|
|
113
116
|
*/
|
|
114
117
|
export declare const MANIFEST_VERSION = 16;
|
|
115
118
|
/** The phrase used for a direction the author did not phrase. */
|
|
@@ -418,6 +421,11 @@ export declare const EntityManifest: Schema.Struct<{
|
|
|
418
421
|
* writes and its `permissions` hold only `read`. Absent means the generated writes exist.
|
|
419
422
|
*/
|
|
420
423
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
424
|
+
/**
|
|
425
|
+
* `true` when deleting a record erases its replicated history from the warehouse; written only
|
|
426
|
+
* then. The SDK's replication capture acts on it; the platform does not read it.
|
|
427
|
+
*/
|
|
428
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
421
429
|
}>;
|
|
422
430
|
export type EntityManifest = typeof EntityManifest.Type;
|
|
423
431
|
/**
|
|
@@ -1151,9 +1159,15 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
|
|
|
1151
1159
|
* writes and its `permissions` hold only `read`. Absent means the generated writes exist.
|
|
1152
1160
|
*/
|
|
1153
1161
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
1162
|
+
/**
|
|
1163
|
+
* `true` when deleting a record erases its replicated history from the warehouse; written only
|
|
1164
|
+
* then. The SDK's replication capture acts on it; the platform does not read it.
|
|
1165
|
+
*/
|
|
1166
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
1154
1167
|
}>, {
|
|
1155
1168
|
readonly builtIn: "built_in";
|
|
1156
1169
|
readonly renamedFrom: "renamed_from";
|
|
1170
|
+
readonly eraseFromWarehouseOnDelete: "erase_from_warehouse_on_delete";
|
|
1157
1171
|
}>>;
|
|
1158
1172
|
readonly roles: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
1159
1173
|
readonly name: Schema.String;
|
|
@@ -1650,6 +1664,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1650
1664
|
readonly balanceOver?: string | undefined;
|
|
1651
1665
|
}[] | undefined;
|
|
1652
1666
|
readonly guide?: string | undefined;
|
|
1667
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
1653
1668
|
}[];
|
|
1654
1669
|
readonly chat?: {
|
|
1655
1670
|
readonly telegram?: {
|
|
@@ -2027,6 +2042,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2027
2042
|
readonly balanceOver?: string | undefined;
|
|
2028
2043
|
}[] | undefined;
|
|
2029
2044
|
readonly guide?: string | undefined;
|
|
2045
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
2030
2046
|
}[];
|
|
2031
2047
|
readonly chat?: {
|
|
2032
2048
|
readonly telegram?: {
|
|
@@ -2404,6 +2420,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2404
2420
|
}[] | undefined;
|
|
2405
2421
|
readonly guide?: string | undefined;
|
|
2406
2422
|
readonly renamed_from?: string | undefined;
|
|
2423
|
+
readonly erase_from_warehouse_on_delete?: true | undefined;
|
|
2407
2424
|
}[];
|
|
2408
2425
|
readonly chat?: {
|
|
2409
2426
|
readonly telegram?: {
|
|
@@ -2781,6 +2798,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2781
2798
|
readonly balanceOver?: string | undefined;
|
|
2782
2799
|
}[] | undefined;
|
|
2783
2800
|
readonly guide?: string | undefined;
|
|
2801
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
2784
2802
|
}[];
|
|
2785
2803
|
readonly chat?: {
|
|
2786
2804
|
readonly telegram?: {
|
|
@@ -3185,9 +3203,15 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
3185
3203
|
* writes and its `permissions` hold only `read`. Absent means the generated writes exist.
|
|
3186
3204
|
*/
|
|
3187
3205
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
3206
|
+
/**
|
|
3207
|
+
* `true` when deleting a record erases its replicated history from the warehouse; written only
|
|
3208
|
+
* then. The SDK's replication capture acts on it; the platform does not read it.
|
|
3209
|
+
*/
|
|
3210
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
3188
3211
|
}>, {
|
|
3189
3212
|
readonly builtIn: "built_in";
|
|
3190
3213
|
readonly renamedFrom: "renamed_from";
|
|
3214
|
+
readonly eraseFromWarehouseOnDelete: "erase_from_warehouse_on_delete";
|
|
3191
3215
|
}>>;
|
|
3192
3216
|
readonly roles: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
3193
3217
|
readonly name: Schema.String;
|
|
@@ -3718,6 +3742,11 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
3718
3742
|
* writes and its `permissions` hold only `read`. Absent means the generated writes exist.
|
|
3719
3743
|
*/
|
|
3720
3744
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
3745
|
+
/**
|
|
3746
|
+
* `true` when deleting a record erases its replicated history from the warehouse; written only
|
|
3747
|
+
* then. The SDK's replication capture acts on it; the platform does not read it.
|
|
3748
|
+
*/
|
|
3749
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
3721
3750
|
}>>;
|
|
3722
3751
|
readonly roles: Schema.$Array<Schema.Struct<{
|
|
3723
3752
|
readonly name: Schema.String;
|
|
@@ -4188,6 +4217,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
4188
4217
|
readonly balanceOver?: string | undefined;
|
|
4189
4218
|
}[] | undefined;
|
|
4190
4219
|
readonly guide?: string | undefined;
|
|
4220
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
4191
4221
|
}[];
|
|
4192
4222
|
readonly chat?: {
|
|
4193
4223
|
readonly telegram?: {
|
|
@@ -4565,6 +4595,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
4565
4595
|
readonly balanceOver?: string | undefined;
|
|
4566
4596
|
}[] | undefined;
|
|
4567
4597
|
readonly guide?: string | undefined;
|
|
4598
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
4568
4599
|
}[];
|
|
4569
4600
|
readonly chat?: {
|
|
4570
4601
|
readonly telegram?: {
|
|
@@ -4948,6 +4979,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
4948
4979
|
readonly balanceOver?: string | undefined;
|
|
4949
4980
|
}[] | undefined;
|
|
4950
4981
|
readonly guide?: string | undefined;
|
|
4982
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
4951
4983
|
}[];
|
|
4952
4984
|
readonly chat?: {
|
|
4953
4985
|
readonly telegram?: {
|
|
@@ -5325,6 +5357,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
5325
5357
|
readonly balanceOver?: string | undefined;
|
|
5326
5358
|
}[] | undefined;
|
|
5327
5359
|
readonly guide?: string | undefined;
|
|
5360
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
5328
5361
|
}[];
|
|
5329
5362
|
readonly chat?: {
|
|
5330
5363
|
readonly telegram?: {
|
package/dist/manifest.js
CHANGED
|
@@ -111,6 +111,9 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGue
|
|
|
111
111
|
* `private` without members. Older readers ignore it and register no chat without members.
|
|
112
112
|
* Within version 16, a mailbox in `chat` may carry `signature: true`, written only when declared:
|
|
113
113
|
* the ontology's replies to mail end with the mailbox's own signature. Older readers ignore it.
|
|
114
|
+
* Within version 16, an entity may carry `erase_from_warehouse_on_delete: true`, written only when
|
|
115
|
+
* declared: deleting a record erases its replicated history from the warehouse. The SDK's own
|
|
116
|
+
* replication capture acts on it; readers ignore it.
|
|
114
117
|
*/
|
|
115
118
|
export const MANIFEST_VERSION = 16;
|
|
116
119
|
/** The first version whose documents use snake_case names on the wire. */
|
|
@@ -296,6 +299,11 @@ export const EntityManifest = Schema.Struct({
|
|
|
296
299
|
* writes and its `permissions` hold only `read`. Absent means the generated writes exist.
|
|
297
300
|
*/
|
|
298
301
|
writes: Schema.optionalKey(Schema.Literal("actions")),
|
|
302
|
+
/**
|
|
303
|
+
* `true` when deleting a record erases its replicated history from the warehouse; written only
|
|
304
|
+
* then. The SDK's replication capture acts on it; the platform does not read it.
|
|
305
|
+
*/
|
|
306
|
+
eraseFromWarehouseOnDelete: Schema.optionalKey(Schema.Literal(true)),
|
|
299
307
|
});
|
|
300
308
|
/**
|
|
301
309
|
* A scoped permission of a role: `<entity>:<verb>` and the `where` of the records it covers, in the
|
|
@@ -696,7 +704,11 @@ const EntityManifestWire = Schema.Struct({
|
|
|
696
704
|
metrics: Schema.optionalKey(Schema.Array(MetricManifestWire)),
|
|
697
705
|
properties: Schema.Array(PropertyManifestWire),
|
|
698
706
|
relationships: Schema.Array(RelationshipManifestWire),
|
|
699
|
-
}).pipe(Schema.encodeKeys({
|
|
707
|
+
}).pipe(Schema.encodeKeys({
|
|
708
|
+
builtIn: "built_in",
|
|
709
|
+
renamedFrom: "renamed_from",
|
|
710
|
+
eraseFromWarehouseOnDelete: "erase_from_warehouse_on_delete",
|
|
711
|
+
}));
|
|
700
712
|
const RoleManifestWire = RoleManifest.pipe(Schema.encodeKeys({ builtIn: "built_in" }));
|
|
701
713
|
/** The JSON contract written since version 4; decoded SDK models remain camelCase. */
|
|
702
714
|
export const OntologyManifestWire = Schema.Struct({
|
|
@@ -1100,6 +1112,9 @@ function entityManifest(input) {
|
|
|
1100
1112
|
})),
|
|
1101
1113
|
permissions: { ...resolved.permissions },
|
|
1102
1114
|
...(resolved.writes === "actions" ? { writes: "actions" } : {}),
|
|
1115
|
+
...(definition.eraseFromWarehouseOnDelete === true && definition.source === undefined
|
|
1116
|
+
? { eraseFromWarehouseOnDelete: true }
|
|
1117
|
+
: {}),
|
|
1103
1118
|
};
|
|
1104
1119
|
}
|
|
1105
1120
|
/** Builds the manifest of a resolved ontology that passed `check`. */
|
package/dist/migrate/model.d.ts
CHANGED
|
@@ -404,6 +404,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
404
404
|
readonly balanceOver?: string | undefined;
|
|
405
405
|
}[] | undefined;
|
|
406
406
|
readonly guide?: string | undefined;
|
|
407
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
407
408
|
}[];
|
|
408
409
|
readonly chat?: {
|
|
409
410
|
readonly telegram?: {
|
|
@@ -781,6 +782,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
781
782
|
readonly balanceOver?: string | undefined;
|
|
782
783
|
}[] | undefined;
|
|
783
784
|
readonly guide?: string | undefined;
|
|
785
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
784
786
|
}[];
|
|
785
787
|
readonly chat?: {
|
|
786
788
|
readonly telegram?: {
|
|
@@ -1158,6 +1160,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1158
1160
|
}[] | undefined;
|
|
1159
1161
|
readonly guide?: string | undefined;
|
|
1160
1162
|
readonly renamed_from?: string | undefined;
|
|
1163
|
+
readonly erase_from_warehouse_on_delete?: true | undefined;
|
|
1161
1164
|
}[];
|
|
1162
1165
|
readonly chat?: {
|
|
1163
1166
|
readonly telegram?: {
|
|
@@ -1535,6 +1538,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1535
1538
|
readonly balanceOver?: string | undefined;
|
|
1536
1539
|
}[] | undefined;
|
|
1537
1540
|
readonly guide?: string | undefined;
|
|
1541
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
1538
1542
|
}[];
|
|
1539
1543
|
readonly chat?: {
|
|
1540
1544
|
readonly telegram?: {
|
|
@@ -1907,9 +1911,11 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1907
1911
|
readonly unlink: Schema.optionalKey<Schema.String>;
|
|
1908
1912
|
}>>;
|
|
1909
1913
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
1914
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
1910
1915
|
}>, {
|
|
1911
1916
|
readonly builtIn: "built_in";
|
|
1912
1917
|
readonly renamedFrom: "renamed_from";
|
|
1918
|
+
readonly eraseFromWarehouseOnDelete: "erase_from_warehouse_on_delete";
|
|
1913
1919
|
}>>;
|
|
1914
1920
|
readonly roles: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
1915
1921
|
readonly name: Schema.String;
|
|
@@ -2300,6 +2306,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2300
2306
|
readonly unlink: Schema.optionalKey<Schema.String>;
|
|
2301
2307
|
}>>;
|
|
2302
2308
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
2309
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
2303
2310
|
}>>;
|
|
2304
2311
|
readonly roles: Schema.$Array<Schema.Struct<{
|
|
2305
2312
|
readonly name: Schema.String;
|
|
@@ -2676,6 +2683,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2676
2683
|
readonly balanceOver?: string | undefined;
|
|
2677
2684
|
}[] | undefined;
|
|
2678
2685
|
readonly guide?: string | undefined;
|
|
2686
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
2679
2687
|
}[];
|
|
2680
2688
|
readonly chat?: {
|
|
2681
2689
|
readonly telegram?: {
|
|
@@ -3053,6 +3061,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
3053
3061
|
readonly balanceOver?: string | undefined;
|
|
3054
3062
|
}[] | undefined;
|
|
3055
3063
|
readonly guide?: string | undefined;
|
|
3064
|
+
readonly eraseFromWarehouseOnDelete?: true | undefined;
|
|
3056
3065
|
}[];
|
|
3057
3066
|
readonly chat?: {
|
|
3058
3067
|
readonly telegram?: {
|
|
@@ -158,6 +158,15 @@ export function replicationEntityDdl(manifest, previous) {
|
|
|
158
158
|
const declared = entity.relationships
|
|
159
159
|
.filter((r) => r.cardinality === "many")
|
|
160
160
|
.map((r) => r.name);
|
|
161
|
+
// A deletion of an entity that erases its history is journaled whatever replication's state,
|
|
162
|
+
// in the deleting transaction, so no path of deletion escapes it.
|
|
163
|
+
const erases = entity.eraseFromWarehouseOnDelete === true;
|
|
164
|
+
const journal = erases
|
|
165
|
+
? `IF NEW.kind = 'delete' THEN
|
|
166
|
+
INSERT INTO _ontology_replication_erasures (entity_id, record_id)
|
|
167
|
+
VALUES (${ql(entity.id)}, NEW.record_id) ON CONFLICT DO NOTHING;
|
|
168
|
+
END IF;`
|
|
169
|
+
: "";
|
|
161
170
|
return [
|
|
162
171
|
`ALTER TABLE ${history} ADD COLUMN IF NOT EXISTS replication jsonb`,
|
|
163
172
|
`CREATE INDEX IF NOT EXISTS ${qi(`_replication_${key}_idx`)} ON ${history}
|
|
@@ -167,6 +176,7 @@ export function replicationEntityDdl(manifest, previous) {
|
|
|
167
176
|
event_revision bigint; record_key text; record_kind text := 'entity';
|
|
168
177
|
is_deleted boolean := NEW.kind = 'delete';
|
|
169
178
|
BEGIN
|
|
179
|
+
${journal}
|
|
170
180
|
SELECT * INTO state FROM _ontology_replication WHERE id;
|
|
171
181
|
policy := state.selection->${ql(entity.id)};
|
|
172
182
|
IF NOT state.enabled OR policy IS NULL THEN RETURN NEW; END IF;
|
|
@@ -209,6 +219,15 @@ export function replicationEntityDdl(manifest, previous) {
|
|
|
209
219
|
END IF;
|
|
210
220
|
RETURN NEW;
|
|
211
221
|
END $$`,
|
|
222
|
+
// Deletions recorded before the entity erased its history, such as drafts a retention purge
|
|
223
|
+
// already deleted, are erased as well: due at once, requested when they were deleted.
|
|
224
|
+
...(erases
|
|
225
|
+
? [
|
|
226
|
+
`INSERT INTO _ontology_replication_erasures (entity_id, record_id, requested_at, due_at)
|
|
227
|
+
SELECT ${ql(entity.id)}, record_id, min(at), now() FROM ${history}
|
|
228
|
+
WHERE kind = 'delete' GROUP BY record_id ON CONFLICT DO NOTHING`,
|
|
229
|
+
]
|
|
230
|
+
: []),
|
|
212
231
|
`DROP TRIGGER IF EXISTS _ontology_capture ON ${history}`,
|
|
213
232
|
`CREATE TRIGGER _ontology_capture BEFORE INSERT ON ${history} FOR EACH ROW EXECUTE FUNCTION ${fn}()`,
|
|
214
233
|
`DROP TRIGGER IF EXISTS _ontology_writer_guard ON ${table}`,
|
|
@@ -411,9 +411,11 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
411
411
|
readonly unlink: Schema.optionalKey<Schema.String>;
|
|
412
412
|
}>>;
|
|
413
413
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
414
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
414
415
|
}>, {
|
|
415
416
|
readonly builtIn: "built_in";
|
|
416
417
|
readonly renamedFrom: "renamed_from";
|
|
418
|
+
readonly eraseFromWarehouseOnDelete: "erase_from_warehouse_on_delete";
|
|
417
419
|
}>>;
|
|
418
420
|
readonly roles: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
419
421
|
readonly name: Schema.String;
|
|
@@ -800,9 +802,11 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
800
802
|
readonly unlink: Schema.optionalKey<Schema.String>;
|
|
801
803
|
}>>;
|
|
802
804
|
readonly writes: Schema.optionalKey<Schema.Literal<"actions">>;
|
|
805
|
+
readonly eraseFromWarehouseOnDelete: Schema.optionalKey<Schema.Literal<true>>;
|
|
803
806
|
}>, {
|
|
804
807
|
readonly builtIn: "built_in";
|
|
805
808
|
readonly renamedFrom: "renamed_from";
|
|
809
|
+
readonly eraseFromWarehouseOnDelete: "erase_from_warehouse_on_delete";
|
|
806
810
|
}>>>;
|
|
807
811
|
readonly roles: Schema.toEncoded<Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
808
812
|
readonly name: Schema.String;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.169.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",
|