@astrale-os/kernel-dsl 1.0.0-beta.27 → 1.0.0-beta.29

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.
Files changed (91) hide show
  1. package/dist/v1/addressing/ordering.d.ts +2 -2
  2. package/dist/v1/addressing/ordering.js +2 -4
  3. package/dist/v1/builder/index.d.ts +2 -0
  4. package/dist/v1/builder/index.js +1 -0
  5. package/dist/v1/builder/schema/projection/identity.d.ts +15 -0
  6. package/dist/v1/builder/schema/projection/property.d.ts +3 -3
  7. package/dist/v1/builder/schema/projection/resolved-class.d.ts +3 -3
  8. package/dist/v1/builder/schema/rule.d.ts +316 -0
  9. package/dist/v1/builder/schema/rule.js +192 -0
  10. package/dist/v1/bundle/index.d.ts +2 -0
  11. package/dist/v1/bundle/index.js +1 -0
  12. package/dist/v1/bundle/rule.d.ts +14 -0
  13. package/dist/v1/bundle/rule.js +41 -0
  14. package/dist/v1/compiled/admission/diagnostic.d.ts +14 -0
  15. package/dist/v1/compiled/admission/diagnostic.js +6 -0
  16. package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -3
  17. package/dist/v1/compiled/admission/semantics/policy/parity.js +8 -13
  18. package/dist/v1/compiled/admission/semantics/policy/pattern.js +3 -5
  19. package/dist/v1/compiled/admission/wire/policy.js +16 -11
  20. package/dist/v1/compiled/index.d.ts +2 -0
  21. package/dist/v1/compiled/index.js +1 -0
  22. package/dist/v1/compiled/rule.d.ts +49 -0
  23. package/dist/v1/compiled/rule.js +169 -0
  24. package/dist/v1/domain/namespace/member-collection.js +4 -1
  25. package/dist/v1/language/callable/admission.js +2 -1
  26. package/dist/v1/language/class/resolved.d.ts +9 -4
  27. package/dist/v1/language/policy/analysis/branches.js +6 -7
  28. package/dist/v1/language/policy/analysis/budgets.js +8 -6
  29. package/dist/v1/language/policy/analysis/checks.js +5 -4
  30. package/dist/v1/language/policy/analysis/composition.js +2 -2
  31. package/dist/v1/language/policy/analysis/typing.js +3 -2
  32. package/dist/v1/language/policy/model/policy.d.ts +22 -0
  33. package/dist/v1/language/policy/model/policy.js +28 -4
  34. package/dist/v1/language/policy/normalization/normalize.js +33 -56
  35. package/dist/v1/language/value/evaluate/assertions.d.ts +2 -2
  36. package/dist/v1/language/value/evaluate/assertions.js +4 -34
  37. package/dist/v1/language/value/evaluate/evaluator.js +10 -15
  38. package/dist/v1/language/value/evaluate/validity.optimization.js +9 -14
  39. package/dist/v1/language/value/files.js +2 -1
  40. package/dist/v1/language/value/model/blob.d.ts +6 -0
  41. package/dist/v1/language/value/model/blob.js +8 -0
  42. package/dist/v1/language/value/ordering.js +1 -3
  43. package/dist/v1/language/value/profile/canonicalize.js +1 -3
  44. package/dist/v1/language/value/syntax/walk.d.ts +2 -0
  45. package/dist/v1/language/value/syntax/walk.js +4 -0
  46. package/dist/v1/schema/compatibility/api.d.ts +2 -0
  47. package/dist/v1/schema/compatibility/api.js +1 -0
  48. package/dist/v1/schema/compatibility/rule.d.ts +13 -0
  49. package/dist/v1/schema/compatibility/rule.js +23 -0
  50. package/dist/v1/schema/enforcement/changes.d.ts +590 -0
  51. package/dist/v1/schema/enforcement/changes.js +566 -0
  52. package/dist/v1/schema/enforcement/derived.d.ts +236 -0
  53. package/dist/v1/schema/enforcement/derived.js +243 -0
  54. package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
  55. package/dist/v1/schema/enforcement/dispose.js +275 -0
  56. package/dist/v1/schema/enforcement/facts.d.ts +89 -0
  57. package/dist/v1/schema/enforcement/facts.js +70 -0
  58. package/dist/v1/schema/enforcement/fields.d.ts +65 -0
  59. package/dist/v1/schema/enforcement/fields.js +36 -0
  60. package/dist/v1/schema/enforcement/index.d.ts +39 -0
  61. package/dist/v1/schema/enforcement/index.js +10 -0
  62. package/dist/v1/schema/enforcement/install.d.ts +1634 -0
  63. package/dist/v1/schema/enforcement/install.js +1223 -0
  64. package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
  65. package/dist/v1/schema/enforcement/lifecycle.js +91 -0
  66. package/dist/v1/schema/enforcement/model.d.ts +253 -0
  67. package/dist/v1/schema/enforcement/model.js +1 -0
  68. package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
  69. package/dist/v1/schema/enforcement/obligations.js +240 -0
  70. package/dist/v1/schema/enforcement/write.d.ts +1314 -0
  71. package/dist/v1/schema/enforcement/write.js +1017 -0
  72. package/dist/v1/schema/index.d.ts +1 -0
  73. package/dist/v1/schema/index.js +1 -0
  74. package/dist/v1/schema/resolution/origins.js +4 -7
  75. package/dist/v1/schema/rule.d.ts +4 -5
  76. package/dist/v1/schema/rule.js +19 -13
  77. package/dist/v1/schema/validation/policy/references.js +5 -11
  78. package/dist/v1/schema/validation/policy/uses.js +3 -8
  79. package/dist/v1/schema/validation/value-api.d.ts +1 -1
  80. package/dist/v1/schema/validation/value-api.js +1 -1
  81. package/dist/value/accept.d.ts +6 -0
  82. package/dist/value/accept.js +25 -1
  83. package/dist/value/canonical.d.ts +16 -1
  84. package/dist/value/canonical.js +90 -33
  85. package/dist/value/immutable.optimization.d.ts +2 -0
  86. package/dist/value/immutable.optimization.js +4 -0
  87. package/dist/value/index.d.ts +3 -1
  88. package/dist/value/index.js +2 -1
  89. package/dist/value/rule.d.ts +12 -0
  90. package/dist/value/rule.js +50 -0
  91. package/package.json +5 -1
@@ -4,5 +4,5 @@ export declare function definitionRefIndex(ref: DefinitionRef): string;
4
4
  export declare function compareDefinitionRefs(left: DefinitionRef, right: DefinitionRef): number;
5
5
  /** Locale-independent Unicode code-point ordering for canonical DSL values. */
6
6
  export declare function compareUnicode(left: string, right: string): number;
7
- /** Order strings by UTF-16 code unit, the order `<` gives strings. */
8
- export declare function compareCodeUnits(left: string, right: string): number;
7
+ /** Order strings by UTF-16 code unit, the order `<` gives strings and canonical JSON its members. */
8
+ export { compareCodeUnits } from '../../value/canonical.js';
@@ -18,7 +18,5 @@ export function compareUnicode(left, right) {
18
18
  }
19
19
  return a.length - b.length;
20
20
  }
21
- /** Order strings by UTF-16 code unit, the order `<` gives strings. */
22
- export function compareCodeUnits(left, right) {
23
- return left < right ? -1 : left > right ? 1 : 0;
24
- }
21
+ /** Order strings by UTF-16 code unit, the order `<` gives strings and canonical JSON its members. */
22
+ export { compareCodeUnits } from '../../value/canonical.js';
@@ -12,6 +12,8 @@ export type { ResolvedDomainOfInput } from './schema/projection.js';
12
12
  export { valueSchema } from './value/schema.js';
13
13
  export { view } from './view/authoring.js';
14
14
  export { BuilderError as Error } from './schema/diagnostic.js';
15
+ export { BUILDER_RULES } from './schema/rule.js';
16
+ export type { BuilderRule, BuilderRuleOnDocument } from './schema/rule.js';
15
17
  export type { BuilderDiagnostic as Diagnostic, BuilderDiagnosticCode as DiagnosticCode, } from './schema/diagnostic.js';
16
18
  export type { CallableInputBase, CallableInput, BinaryInputAuthoring, CallableOutputInput, CallableProjection, CallablePolicyBuilder, CallablePolicyContext, PolicyCheckContext, BinaryOutput, Function, FunctionInput, Method, MethodInput, PolicyObjectInput, StreamOutput, } from './callable/authoring.js';
17
19
  export type { CoreEdge, CoreEndpoint, CoreInput, CoreNode } from './core/authoring.js';
@@ -10,3 +10,4 @@ export { defineSchema } from './schema/define.js';
10
10
  export { valueSchema } from './value/schema.js';
11
11
  export { view } from './view/authoring.js';
12
12
  export { BuilderError as Error } from './schema/diagnostic.js';
13
+ export { BUILDER_RULES } from './schema/rule.js';
@@ -35,6 +35,21 @@ type LocalNameOfOwner<Root extends DomainSchemaInput, Value> = {
35
35
  type UnionIsMultiple<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Value] ? false : true : never;
36
36
  /** Distinguish ambiguous unions from one exact member. */
37
37
  export type IsMultiple<Value> = true extends UnionIsMultiple<Value> ? true : false;
38
+ type ParentsAmong<Root extends DomainSchemaInput, Parents, Owners> = Parents extends readonly [
39
+ infer Parent,
40
+ ...infer Rest
41
+ ] ? [Extract<LocalNameOfReference<Root, ResolveLazy<Parent>>, Owners>] extends [never] ? ParentsAmong<Root, Rest, Owners> : readonly [Parent, ...ParentsAmong<Root, Rest, Owners>] : readonly [];
42
+ type AncestorHoldsOwnersApart<Root extends DomainSchemaInput, Parent, Owners, Seen> = Exclude<LocalNameOfReference<Root, ResolveLazy<Parent>>, Seen> extends infer Name ? Name extends keyof ClassesInputOf<Root> ? HoldsOwnersApart<Root, ClassesInputOf<Root>[Name], Owners, Seen | Name> : never : never;
43
+ /** Whether two parents of the Class, or of a Class it extends, are among the candidate owners. */
44
+ type HoldsOwnersApart<Root extends DomainSchemaInput, Value, Owners, Seen = never> = ClassInputOf<Value> extends {
45
+ readonly extends: infer Parents extends readonly unknown[];
46
+ } ? ParentsAmong<Root, Parents, Owners>['length'] extends 0 | 1 ? true extends AncestorHoldsOwnersApart<Root, Parents[number], Owners, Seen> ? true : false : true : false;
47
+ /**
48
+ * The candidate owners of each Property an inherited member is on the Class. Classes alike in shape
49
+ * are one owner to the types: from one parent among them the Class has one Property, declared by
50
+ * one of them; from two parents among them, each has a Property of its own.
51
+ */
52
+ export type OwnersOfEachProperty<Root extends DomainSchemaInput, Value, Owners> = IsMultiple<Owners> extends true ? HoldsOwnersApart<Root, Value, Owners> extends true ? Owners extends unknown ? readonly [Owners] : never : readonly [Owners] : readonly [Owners];
38
53
  /** Recover the local declaring Class name for an effective member. */
39
54
  export type OwnerNameOf<Root extends DomainSchemaInput, CurrentName extends string, Owner> = Owner extends 'self' ? CurrentName : Owner extends ClassOwnerProjection ? Extract<LocalNameOfOwner<Root, Owner>, string> : Owner extends ClassIdentityProjection ? Extract<LocalNameOfIdentity<Root, Owner>, string> : never;
40
55
  export {};
@@ -1,7 +1,7 @@
1
1
  import type * as language from '../../../language/index.js';
2
2
  import type { AuthoredPropertyProjection } from '../../class/projection.js';
3
3
  import type { DomainSchemaInput } from '../input.js';
4
- import type { RecordField, ClassInputOf, OwnerNameOf } from './identity.js';
4
+ import type { RecordField, ClassInputOf, OwnerNameOf, OwnersOfEachProperty } from './identity.js';
5
5
  import type { PropertyProjection } from './model.js';
6
6
  type PropertyFieldsOf<Value> = RecordField<ClassInputOf<Value>, 'properties'>;
7
7
  interface AuthoredPropertyEntry<Owner, Name extends string, Field> {
@@ -26,7 +26,7 @@ export type OwnPropertyProjectionsOf<Origin extends string, Name extends string,
26
26
  export type EffectivePropertyEntriesOfClass<Value> = ClassInputOf<Value> extends {
27
27
  readonly effectiveProperties: infer Properties;
28
28
  } ? Properties : never;
29
- type EffectivePropertyProjectionOfEntry<Origin extends string, CurrentName extends string, Root extends DomainSchemaInput, Entry> = Entry extends language.ResolvedProperty ? PropertyProjectionOfResolved<Entry> : Entry extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer PropertyName, infer Owner, infer State> ? OwnerNameOf<Root, CurrentName, Owner> extends infer OwnerName extends string ? PropertyProjection<Output, Required, PropertyName, language.PropertyKey<Origin, OwnerName, PropertyName>, State, Input> : never : never;
29
+ type EffectivePropertyProjectionOfEntry<Origin extends string, CurrentName extends string, Value, Root extends DomainSchemaInput, Entry> = Entry extends language.ResolvedProperty ? PropertyProjectionOfResolved<Entry> : Entry extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer PropertyName, infer Owner, infer State> ? OwnersOfEachProperty<Root, Value, OwnerNameOf<Root, CurrentName, Owner>> extends infer Owners ? Owners extends readonly [infer OwnerName extends string] ? PropertyProjection<Output, Required, PropertyName, language.PropertyKey<Origin, OwnerName, PropertyName>, State, Input> : never : never : never;
30
30
  /** Bind effective Property witnesses to their declaring Class coordinates. */
31
- export type EffectivePropertyProjectionsOf<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = EffectivePropertyEntriesOfClass<Value> extends infer Entry ? Entry extends unknown ? EffectivePropertyProjectionOfEntry<Origin, Name, Root, Entry> : never : never;
31
+ export type EffectivePropertyProjectionsOf<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = EffectivePropertyEntriesOfClass<Value> extends infer Entry ? Entry extends unknown ? EffectivePropertyProjectionOfEntry<Origin, Name, Value, Root, Entry> : never : never;
32
32
  export {};
@@ -41,10 +41,10 @@ type ResolvedPropertyOfProjection<Value> = Value extends PropertyProjection<infe
41
41
  readonly name: Name;
42
42
  readonly key: Key;
43
43
  } : never;
44
+ type PropertiesBearing<Entries extends PropertyProjection, Key> = Entries extends unknown ? Key extends Entries['key'] ? Entries : never : never;
45
+ /** A Property under each key it may bear: see `OwnersOfEachProperty`. */
44
46
  type ProjectionPropertyByKey<Entries extends PropertyProjection> = Readonly<{
45
- [Key in Entries['key']]: ResolvedPropertyOfProjection<Extract<Entries, {
46
- readonly key: Key;
47
- }>>;
47
+ [Key in Entries['key']]: ResolvedPropertyOfProjection<PropertiesBearing<Entries, Key>>;
48
48
  }>;
49
49
  type ProjectionPropertyByName<Entries extends PropertyProjection> = Readonly<{
50
50
  [Name in Entries['name'] as IsMultiple<Extract<Entries, {
@@ -0,0 +1,316 @@
1
+ import type { SchemaDiagnosticCode } from '../../schema/diagnostic.js';
2
+ import type { InstallId } from '../../schema/enforcement/install.js';
3
+ /**
4
+ * What answers a Schema document that breaks a rule of the Builder: a document reaches the Kernel
5
+ * without passing through the Builder. `refused`: admission refuses it by `admission`, or the install
6
+ * by the row `install`. `nothing`: it is accepted and installs, so only an authored Schema holds the
7
+ * rule. `unsayable`: the rule is about an authoring value, which a document cannot hold. `unexamined`:
8
+ * a rule of Policies, Functions, Methods or Views, whose document is not compared here.
9
+ */
10
+ export type BuilderRuleOnDocument = {
11
+ readonly holds: 'refused';
12
+ readonly admission?: readonly [SchemaDiagnosticCode, ...SchemaDiagnosticCode[]];
13
+ readonly install?: InstallId;
14
+ } | {
15
+ readonly holds: 'nothing';
16
+ } | {
17
+ readonly holds: 'unsayable';
18
+ } | {
19
+ readonly holds: 'unexamined';
20
+ };
21
+ /** The rule one diagnostic code of the Builder reports. */
22
+ export interface BuilderRule {
23
+ /** The rule, in one plain sentence. */
24
+ readonly statement: string;
25
+ readonly document: BuilderRuleOnDocument;
26
+ }
27
+ /**
28
+ * Every diagnostic code the Builder owns with the rule it reports. A code added to the Builder does
29
+ * not compile until it is described here. A rule of the Language is in `schema.values.RULES`.
30
+ */
31
+ export declare const BUILDER_RULES: Readonly<{
32
+ readonly BUILDER_ABSTRACT_POLICY: {
33
+ readonly statement: 'An abstract Class declares no Class Policy, and an abstract Method no Policy.';
34
+ readonly document: {
35
+ readonly holds: 'unexamined';
36
+ };
37
+ };
38
+ readonly BUILDER_AMBIGUOUS_OWNERSHIP: {
39
+ readonly statement: 'One authoring handle is owned by one Definition.';
40
+ readonly document: {
41
+ readonly holds: 'unsayable';
42
+ };
43
+ };
44
+ readonly BUILDER_AUTO_EVENT_INVALID: {
45
+ readonly statement: 'An automatic Property runs on at least one event, each of them create or update, and a required one runs on create.';
46
+ readonly document: {
47
+ readonly holds: 'refused';
48
+ readonly admission: readonly ["STRUCTURE_MINIMUM", "STRUCTURE_VALUE", "DV_PROPERTY_AUTO"];
49
+ };
50
+ };
51
+ readonly BUILDER_AUTO_IMMUTABLE: {
52
+ readonly statement: 'An automatic Property is not immutable.';
53
+ readonly document: {
54
+ readonly holds: 'refused';
55
+ readonly admission: readonly ["DV_PROPERTY_IMMUTABLE"];
56
+ };
57
+ };
58
+ readonly BUILDER_AUTO_NESTED: {
59
+ readonly statement: '`auto(...)` wraps a Property which is not already automatic.';
60
+ readonly document: {
61
+ readonly holds: 'unsayable';
62
+ };
63
+ };
64
+ readonly BUILDER_AUTO_SET_INVALID: {
65
+ readonly statement: 'The setter of an automatic Property is `instant`.';
66
+ readonly document: {
67
+ readonly holds: 'refused';
68
+ readonly admission: readonly ["STRUCTURE_VALUE"];
69
+ };
70
+ };
71
+ readonly BUILDER_CALLABLE_AUTH: {
72
+ readonly statement: 'A Function declares its auth as anonymous, authenticated or authorized.';
73
+ readonly document: {
74
+ readonly holds: 'unexamined';
75
+ };
76
+ };
77
+ readonly BUILDER_CALLABLE_PLACEMENT: {
78
+ readonly statement: 'A standalone Function declares no staticness or abstractness, and a Method takes a Value input.';
79
+ readonly document: {
80
+ readonly holds: 'unexamined';
81
+ };
82
+ };
83
+ readonly BUILDER_CALLABLE_POLICY_AUTH: {
84
+ readonly statement: 'Only an authorized Function or Method declares a Policy check.';
85
+ readonly document: {
86
+ readonly holds: 'unexamined';
87
+ };
88
+ };
89
+ readonly BUILDER_CLASS_INHERITANCE: {
90
+ readonly statement: 'A Class extends a Class of another Domain only where that Class is open in the revision it binds.';
91
+ readonly document: {
92
+ readonly holds: 'refused';
93
+ readonly admission: readonly ["DV_CLASS_INHERITANCE"];
94
+ readonly install: 'DEPENDENCY_INCOMPATIBLE';
95
+ };
96
+ };
97
+ readonly BUILDER_CORE_CLASS: {
98
+ readonly statement: 'The Class of a Core Node or a Core Edge is local to the owning Domain.';
99
+ readonly document: {
100
+ readonly holds: 'refused';
101
+ readonly admission: readonly ["DV_CORE_NODE_CLASS", "DV_CORE_EDGE_CLASS"];
102
+ };
103
+ };
104
+ readonly BUILDER_CORE_EDGE: {
105
+ readonly statement: 'An entry of `core.edges` is created by `core.edge(...)`.';
106
+ readonly document: {
107
+ readonly holds: 'unsayable';
108
+ };
109
+ };
110
+ readonly BUILDER_CORE_NODE: {
111
+ readonly statement: 'An entry of `core.nodes` is created by `core.node(...)`.';
112
+ readonly document: {
113
+ readonly holds: 'unsayable';
114
+ };
115
+ };
116
+ readonly BUILDER_CORE_PROPERTY: {
117
+ readonly statement: 'A Core fact names a Property of its Class by name, each once, and its Class is concrete and resolves.';
118
+ readonly document: {
119
+ readonly holds: 'refused';
120
+ readonly admission: readonly ["DV_CORE_NODE_PROPERTIES"];
121
+ };
122
+ };
123
+ readonly BUILDER_CORE_REF: {
124
+ readonly statement: 'An endpoint of a Core Edge names the owning Domain or one local Definition, Function, Method, Policy, View or Core Node.';
125
+ readonly document: {
126
+ readonly holds: 'refused';
127
+ readonly admission: readonly ["DV_CORE_REF"];
128
+ };
129
+ };
130
+ readonly BUILDER_DEFINITION: {
131
+ readonly statement: 'An entry of `classes` is created by a Definition builder.';
132
+ readonly document: {
133
+ readonly holds: 'unsayable';
134
+ };
135
+ };
136
+ readonly BUILDER_DEPENDENCY_ALIAS: {
137
+ readonly statement: 'A dependency alias is an ASCII lower-camel identifier and is not reserved.';
138
+ readonly document: {
139
+ readonly holds: 'refused';
140
+ readonly admission: readonly ["STRUCTURE_KEY", "STRUCTURE_DEPENDENCY_ALIAS"];
141
+ };
142
+ };
143
+ readonly BUILDER_DEPENDENCY_CONFLICT: {
144
+ readonly statement: 'One origin is declared under one dependency alias.';
145
+ readonly document: {
146
+ readonly holds: 'refused';
147
+ readonly admission: readonly ["DV_DEPENDENCY_UNIQUE"];
148
+ };
149
+ };
150
+ readonly BUILDER_DEPENDENCY_DIRECT: {
151
+ readonly statement: 'A foreign Definition belongs to a direct dependency.';
152
+ readonly document: {
153
+ readonly holds: 'refused';
154
+ readonly admission: readonly ["DV_REF_RESOLVES", "DV_DEPENDENCY_DIRECT"];
155
+ };
156
+ };
157
+ readonly BUILDER_EDGE_LIFETIME: {
158
+ readonly statement: 'An Edge Class with an endpoint which can hold a Node of another Domain requires no Edge at any endpoint, and an Edge Class keeps the lifetimes of the Edge Classes it extends.';
159
+ readonly document: {
160
+ readonly holds: 'nothing';
161
+ };
162
+ };
163
+ readonly BUILDER_FILE_INVALID: {
164
+ readonly statement: 'A file field states valid constraints, within those of the blob it is copied from.';
165
+ readonly document: {
166
+ readonly holds: 'refused';
167
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
168
+ };
169
+ };
170
+ readonly BUILDER_FOREIGN_POLICY: {
171
+ readonly statement: 'A Policy reference names a local Policy.';
172
+ readonly document: {
173
+ readonly holds: 'unexamined';
174
+ };
175
+ };
176
+ readonly BUILDER_FULL_MATCH_INVALID: {
177
+ readonly statement: '`fullMatch(...)` takes a complete I-Regexp source within the state budget.';
178
+ readonly document: {
179
+ readonly holds: 'refused';
180
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
181
+ };
182
+ };
183
+ readonly BUILDER_FUNCTION: {
184
+ readonly statement: 'An entry of `functions` is created by `func(...)`.';
185
+ readonly document: {
186
+ readonly holds: 'unexamined';
187
+ };
188
+ };
189
+ readonly BUILDER_METHOD: {
190
+ readonly statement: 'An entry of `methods` is created by `method(...)`.';
191
+ readonly document: {
192
+ readonly holds: 'unexamined';
193
+ };
194
+ };
195
+ readonly BUILDER_PATH_DUPLICATE: {
196
+ readonly statement: '`path(...)` names one Node Definition once. A path stands in a Zod input, so the refusal reaches the caller as `ZOD_SCHEMA_NOT_LOSSLESS`, whose message holds this code.';
197
+ readonly document: {
198
+ readonly holds: 'refused';
199
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
200
+ };
201
+ };
202
+ readonly BUILDER_PATH_EMPTY: {
203
+ readonly statement: '`path(...)` names at least one Node Definition.';
204
+ readonly document: {
205
+ readonly holds: 'refused';
206
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
207
+ };
208
+ };
209
+ readonly BUILDER_POLICY: {
210
+ readonly statement: 'A Policy is created by `policy(...)` and its operands take the object it checks.';
211
+ readonly document: {
212
+ readonly holds: 'unexamined';
213
+ };
214
+ };
215
+ readonly BUILDER_POLICY_COMPOSITION: {
216
+ readonly statement: 'A Policy composition is created by `policy.allOf(...)` or `policy.anyOf(...)`.';
217
+ readonly document: {
218
+ readonly holds: 'unexamined';
219
+ };
220
+ };
221
+ readonly BUILDER_POLICY_CYCLE: {
222
+ readonly statement: 'A Policy composition does not reach itself.';
223
+ readonly document: {
224
+ readonly holds: 'unexamined';
225
+ };
226
+ };
227
+ readonly BUILDER_POLICY_EMPTY_COMPOSITION: {
228
+ readonly statement: 'A Policy composition has at least one operand.';
229
+ readonly document: {
230
+ readonly holds: 'unexamined';
231
+ };
232
+ };
233
+ readonly BUILDER_POLICY_EMPTY_EXISTS: {
234
+ readonly statement: '`exists(...)` declares at least one variable Node.';
235
+ readonly document: {
236
+ readonly holds: 'unexamined';
237
+ };
238
+ };
239
+ readonly BUILDER_POLICY_INPUT: {
240
+ readonly statement: 'A Policy input is one direct required field holding one Node path.';
241
+ readonly document: {
242
+ readonly holds: 'unexamined';
243
+ };
244
+ };
245
+ readonly BUILDER_POLICY_REF: {
246
+ readonly statement: 'A Policy `ref(...)` names one local or direct-dependency Definition, Function, Method, Policy, View or Core Node.';
247
+ readonly document: {
248
+ readonly holds: 'unexamined';
249
+ };
250
+ };
251
+ readonly BUILDER_POLICY_SELF: {
252
+ readonly statement: '`self` is available only to a non-static Node Method.';
253
+ readonly document: {
254
+ readonly holds: 'unexamined';
255
+ };
256
+ };
257
+ readonly BUILDER_PROPERTY_IMMUTABLE_INVALID: {
258
+ readonly statement: '`immutable` is `create` or `once`.';
259
+ readonly document: {
260
+ readonly holds: 'refused';
261
+ readonly admission: readonly ["STRUCTURE_VALUE"];
262
+ };
263
+ };
264
+ readonly BUILDER_REFERENCE_CYCLE: {
265
+ readonly statement: 'A lazy reference resolves without reaching itself.';
266
+ readonly document: {
267
+ readonly holds: 'unsayable';
268
+ };
269
+ };
270
+ readonly BUILDER_REFERENCE_KIND: {
271
+ readonly statement: 'A reference names a Class of the kind its position takes.';
272
+ readonly document: {
273
+ readonly holds: 'refused';
274
+ readonly admission: readonly ["DV_CLASS_KIND"];
275
+ };
276
+ };
277
+ readonly BUILDER_REFERENCE_MISSING: {
278
+ readonly statement: 'A local reference names a Definition the Domain declares.';
279
+ readonly document: {
280
+ readonly holds: 'refused';
281
+ readonly admission: readonly ["DV_REF_RESOLVES"];
282
+ };
283
+ };
284
+ readonly BUILDER_UNIQUE_PROPERTY: {
285
+ readonly statement: 'A key names a Property its Class holds.';
286
+ readonly document: {
287
+ readonly holds: 'refused';
288
+ readonly admission: readonly ["DV_NODE_UNIQUE"];
289
+ };
290
+ };
291
+ readonly BUILDER_UNKNOWN_FIELD: {
292
+ readonly statement: 'An authoring input holds no field its builder does not read.';
293
+ readonly document: {
294
+ readonly holds: 'refused';
295
+ readonly admission: readonly ["STRUCTURE_UNKNOWN_FIELD"];
296
+ };
297
+ };
298
+ readonly BUILDER_UNOWNED_REFERENCE: {
299
+ readonly statement: 'A reference to an authoring handle names a handle some Domain owns.';
300
+ readonly document: {
301
+ readonly holds: 'unsayable';
302
+ };
303
+ };
304
+ readonly BUILDER_VIEW: {
305
+ readonly statement: 'An entry of `views` is created by `view(...)`, which names no target.';
306
+ readonly document: {
307
+ readonly holds: 'unexamined';
308
+ };
309
+ };
310
+ readonly ZOD_SCHEMA_NOT_LOSSLESS: {
311
+ readonly statement: 'A Zod schema is one Draft 2020-12 can state with the same acceptance. A document states a value schema directly.';
312
+ readonly document: {
313
+ readonly holds: 'unsayable';
314
+ };
315
+ };
316
+ }>;
@@ -0,0 +1,192 @@
1
+ import { deepFreeze } from '../../language/freeze.js';
2
+ const UNSAYABLE = { holds: 'unsayable' };
3
+ const UNEXAMINED = { holds: 'unexamined' };
4
+ /**
5
+ * Every diagnostic code the Builder owns with the rule it reports. A code added to the Builder does
6
+ * not compile until it is described here. A rule of the Language is in `schema.values.RULES`.
7
+ */
8
+ export const BUILDER_RULES = deepFreeze({
9
+ BUILDER_ABSTRACT_POLICY: {
10
+ statement: 'An abstract Class declares no Class Policy, and an abstract Method no Policy.',
11
+ document: UNEXAMINED,
12
+ },
13
+ BUILDER_AMBIGUOUS_OWNERSHIP: {
14
+ statement: 'One authoring handle is owned by one Definition.',
15
+ document: UNSAYABLE,
16
+ },
17
+ BUILDER_AUTO_EVENT_INVALID: {
18
+ statement: 'An automatic Property runs on at least one event, each of them create or update, and a required one runs on create.',
19
+ document: {
20
+ holds: 'refused',
21
+ admission: ['STRUCTURE_MINIMUM', 'STRUCTURE_VALUE', 'DV_PROPERTY_AUTO'],
22
+ },
23
+ },
24
+ BUILDER_AUTO_IMMUTABLE: {
25
+ statement: 'An automatic Property is not immutable.',
26
+ document: { holds: 'refused', admission: ['DV_PROPERTY_IMMUTABLE'] },
27
+ },
28
+ BUILDER_AUTO_NESTED: {
29
+ statement: '`auto(...)` wraps a Property which is not already automatic.',
30
+ document: UNSAYABLE,
31
+ },
32
+ BUILDER_AUTO_SET_INVALID: {
33
+ statement: 'The setter of an automatic Property is `instant`.',
34
+ document: { holds: 'refused', admission: ['STRUCTURE_VALUE'] },
35
+ },
36
+ BUILDER_CALLABLE_AUTH: {
37
+ statement: 'A Function declares its auth as anonymous, authenticated or authorized.',
38
+ document: UNEXAMINED,
39
+ },
40
+ BUILDER_CALLABLE_PLACEMENT: {
41
+ statement: 'A standalone Function declares no staticness or abstractness, and a Method takes a Value input.',
42
+ document: UNEXAMINED,
43
+ },
44
+ BUILDER_CALLABLE_POLICY_AUTH: {
45
+ statement: 'Only an authorized Function or Method declares a Policy check.',
46
+ document: UNEXAMINED,
47
+ },
48
+ BUILDER_CLASS_INHERITANCE: {
49
+ statement: 'A Class extends a Class of another Domain only where that Class is open in the revision it binds.',
50
+ document: {
51
+ holds: 'refused',
52
+ admission: ['DV_CLASS_INHERITANCE'],
53
+ install: 'DEPENDENCY_INCOMPATIBLE',
54
+ },
55
+ },
56
+ BUILDER_CORE_CLASS: {
57
+ statement: 'The Class of a Core Node or a Core Edge is local to the owning Domain.',
58
+ document: { holds: 'refused', admission: ['DV_CORE_NODE_CLASS', 'DV_CORE_EDGE_CLASS'] },
59
+ },
60
+ BUILDER_CORE_EDGE: {
61
+ statement: 'An entry of `core.edges` is created by `core.edge(...)`.',
62
+ document: UNSAYABLE,
63
+ },
64
+ BUILDER_CORE_NODE: {
65
+ statement: 'An entry of `core.nodes` is created by `core.node(...)`.',
66
+ document: UNSAYABLE,
67
+ },
68
+ BUILDER_CORE_PROPERTY: {
69
+ statement: 'A Core fact names a Property of its Class by name, each once, and its Class is concrete and resolves.',
70
+ document: { holds: 'refused', admission: ['DV_CORE_NODE_PROPERTIES'] },
71
+ },
72
+ BUILDER_CORE_REF: {
73
+ statement: 'An endpoint of a Core Edge names the owning Domain or one local Definition, Function, Method, Policy, View or Core Node.',
74
+ document: { holds: 'refused', admission: ['DV_CORE_REF'] },
75
+ },
76
+ BUILDER_DEFINITION: {
77
+ statement: 'An entry of `classes` is created by a Definition builder.',
78
+ document: UNSAYABLE,
79
+ },
80
+ BUILDER_DEPENDENCY_ALIAS: {
81
+ statement: 'A dependency alias is an ASCII lower-camel identifier and is not reserved.',
82
+ document: { holds: 'refused', admission: ['STRUCTURE_KEY', 'STRUCTURE_DEPENDENCY_ALIAS'] },
83
+ },
84
+ BUILDER_DEPENDENCY_CONFLICT: {
85
+ statement: 'One origin is declared under one dependency alias.',
86
+ document: { holds: 'refused', admission: ['DV_DEPENDENCY_UNIQUE'] },
87
+ },
88
+ BUILDER_DEPENDENCY_DIRECT: {
89
+ statement: 'A foreign Definition belongs to a direct dependency.',
90
+ document: { holds: 'refused', admission: ['DV_REF_RESOLVES', 'DV_DEPENDENCY_DIRECT'] },
91
+ },
92
+ BUILDER_EDGE_LIFETIME: {
93
+ statement: 'An Edge Class with an endpoint which can hold a Node of another Domain requires no Edge at any endpoint, and an Edge Class keeps the lifetimes of the Edge Classes it extends.',
94
+ document: { holds: 'nothing' },
95
+ },
96
+ BUILDER_FILE_INVALID: {
97
+ statement: 'A file field states valid constraints, within those of the blob it is copied from.',
98
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
99
+ },
100
+ BUILDER_FOREIGN_POLICY: {
101
+ statement: 'A Policy reference names a local Policy.',
102
+ document: UNEXAMINED,
103
+ },
104
+ BUILDER_FULL_MATCH_INVALID: {
105
+ statement: '`fullMatch(...)` takes a complete I-Regexp source within the state budget.',
106
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
107
+ },
108
+ BUILDER_FUNCTION: {
109
+ statement: 'An entry of `functions` is created by `func(...)`.',
110
+ document: UNEXAMINED,
111
+ },
112
+ BUILDER_METHOD: {
113
+ statement: 'An entry of `methods` is created by `method(...)`.',
114
+ document: UNEXAMINED,
115
+ },
116
+ BUILDER_PATH_DUPLICATE: {
117
+ statement: '`path(...)` names one Node Definition once. A path stands in a Zod input, so the refusal reaches the caller as `ZOD_SCHEMA_NOT_LOSSLESS`, whose message holds this code.',
118
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
119
+ },
120
+ BUILDER_PATH_EMPTY: {
121
+ statement: '`path(...)` names at least one Node Definition.',
122
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
123
+ },
124
+ BUILDER_POLICY: {
125
+ statement: 'A Policy is created by `policy(...)` and its operands take the object it checks.',
126
+ document: UNEXAMINED,
127
+ },
128
+ BUILDER_POLICY_COMPOSITION: {
129
+ statement: 'A Policy composition is created by `policy.allOf(...)` or `policy.anyOf(...)`.',
130
+ document: UNEXAMINED,
131
+ },
132
+ BUILDER_POLICY_CYCLE: {
133
+ statement: 'A Policy composition does not reach itself.',
134
+ document: UNEXAMINED,
135
+ },
136
+ BUILDER_POLICY_EMPTY_COMPOSITION: {
137
+ statement: 'A Policy composition has at least one operand.',
138
+ document: UNEXAMINED,
139
+ },
140
+ BUILDER_POLICY_EMPTY_EXISTS: {
141
+ statement: '`exists(...)` declares at least one variable Node.',
142
+ document: UNEXAMINED,
143
+ },
144
+ BUILDER_POLICY_INPUT: {
145
+ statement: 'A Policy input is one direct required field holding one Node path.',
146
+ document: UNEXAMINED,
147
+ },
148
+ BUILDER_POLICY_REF: {
149
+ statement: 'A Policy `ref(...)` names one local or direct-dependency Definition, Function, Method, Policy, View or Core Node.',
150
+ document: UNEXAMINED,
151
+ },
152
+ BUILDER_POLICY_SELF: {
153
+ statement: '`self` is available only to a non-static Node Method.',
154
+ document: UNEXAMINED,
155
+ },
156
+ BUILDER_PROPERTY_IMMUTABLE_INVALID: {
157
+ statement: '`immutable` is `create` or `once`.',
158
+ document: { holds: 'refused', admission: ['STRUCTURE_VALUE'] },
159
+ },
160
+ BUILDER_REFERENCE_CYCLE: {
161
+ statement: 'A lazy reference resolves without reaching itself.',
162
+ document: UNSAYABLE,
163
+ },
164
+ BUILDER_REFERENCE_KIND: {
165
+ statement: 'A reference names a Class of the kind its position takes.',
166
+ document: { holds: 'refused', admission: ['DV_CLASS_KIND'] },
167
+ },
168
+ BUILDER_REFERENCE_MISSING: {
169
+ statement: 'A local reference names a Definition the Domain declares.',
170
+ document: { holds: 'refused', admission: ['DV_REF_RESOLVES'] },
171
+ },
172
+ BUILDER_UNIQUE_PROPERTY: {
173
+ statement: 'A key names a Property its Class holds.',
174
+ document: { holds: 'refused', admission: ['DV_NODE_UNIQUE'] },
175
+ },
176
+ BUILDER_UNKNOWN_FIELD: {
177
+ statement: 'An authoring input holds no field its builder does not read.',
178
+ document: { holds: 'refused', admission: ['STRUCTURE_UNKNOWN_FIELD'] },
179
+ },
180
+ BUILDER_UNOWNED_REFERENCE: {
181
+ statement: 'A reference to an authoring handle names a handle some Domain owns.',
182
+ document: UNSAYABLE,
183
+ },
184
+ BUILDER_VIEW: {
185
+ statement: 'An entry of `views` is created by `view(...)`, which names no target.',
186
+ document: UNEXAMINED,
187
+ },
188
+ ZOD_SCHEMA_NOT_LOSSLESS: {
189
+ statement: 'A Zod schema is one Draft 2020-12 can state with the same acceptance. A document states a value schema directly.',
190
+ document: UNSAYABLE,
191
+ },
192
+ });
@@ -14,5 +14,7 @@ export declare function decode(input: string | Uint8Array): Bundle;
14
14
  export declare function encode(bundle: Bundle): Uint8Array;
15
15
  export declare function serialize(bundle: Bundle): string;
16
16
  export { DOMAIN_BUNDLE_FORMAT as FORMAT, DOMAIN_BUNDLE_VERSION as VERSION } from './model.js';
17
+ export { BUNDLE_RULES as RULES } from './rule.js';
18
+ export type { BundleRule as Rule } from './rule.js';
17
19
  export { BundleError as Error } from './diagnostic.js';
18
20
  export type { BundleDiagnostic as Diagnostic, BundleDiagnosticCode as DiagnosticCode, } from './diagnostic.js';
@@ -17,4 +17,5 @@ export function serialize(bundle) {
17
17
  return serializeDomainSchemaBundle(bundle);
18
18
  }
19
19
  export { DOMAIN_BUNDLE_FORMAT as FORMAT, DOMAIN_BUNDLE_VERSION as VERSION } from './model.js';
20
+ export { BUNDLE_RULES as RULES } from './rule.js';
20
21
  export { BundleError as Error } from './diagnostic.js';
@@ -0,0 +1,14 @@
1
+ import type { SchemaDiagnosticCode } from '../schema/diagnostic.js';
2
+ import type { BundleDiagnosticCode } from './diagnostic.js';
3
+ /** The rule one diagnostic code of a Bundle reports. */
4
+ export interface BundleRule {
5
+ /** The positions its diagnostics point at, as the positions of `schema.Rule`. */
6
+ readonly positions: readonly [string, ...string[]];
7
+ /** The rule, in one plain sentence. */
8
+ readonly statement: string;
9
+ }
10
+ /**
11
+ * Every diagnostic code a Bundle owns with the rule it reports, frozen. A refused Schema of a
12
+ * Bundle answers with the codes of `schema.RULES`, rebased under its place in the Bundle.
13
+ */
14
+ export declare const BUNDLE_RULES: Readonly<Record<Exclude<BundleDiagnosticCode, SchemaDiagnosticCode>, BundleRule>>;