@coasys/ad4m 0.13.0-test-interpretation-1 → 0.13.0-test-model-layer
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/lib/index.cjs +2409 -625
- package/lib/index.js +2406 -626
- package/lib/src/Literal.js +8 -0
- package/lib/src/ai/AIClient.js +6 -3
- package/lib/src/apiClient.d.ts +40 -4
- package/lib/src/apiClient.js +149 -9
- package/lib/src/generated/api/RunInterpretationRequest.d.ts +16 -0
- package/lib/src/index.d.ts +3 -1
- package/lib/src/index.js +2 -0
- package/lib/src/model/Ad4mModel.d.ts +34 -16
- package/lib/src/model/Ad4mModel.js +302 -63
- package/lib/src/model/Ad4mModel.test.js +480 -735
- package/lib/src/model/ModelQueryBuilder.js +2 -2
- package/lib/src/model/decorators.d.ts +199 -12
- package/lib/src/model/decorators.js +88 -32
- package/lib/src/model/json-schema.js +7 -21
- package/lib/src/model/model-manifest.d.ts +41 -0
- package/lib/src/model/model-manifest.js +11 -0
- package/lib/src/model/query-common.d.ts +2 -2
- package/lib/src/model/query-sparql.d.ts +62 -0
- package/lib/src/model/query-sparql.js +78 -15
- package/lib/src/model/query-sparql.test.js +92 -10
- package/lib/src/model/query-utils.d.ts +7 -2
- package/lib/src/model/query-utils.js +21 -11
- package/lib/src/model/shacl-gen.js +77 -15
- package/lib/src/model/types.d.ts +32 -8
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +33 -33
- package/lib/src/perspectives/AutoProcessor.d.ts +198 -2
- package/lib/src/perspectives/FlowInstance.d.ts +187 -0
- package/lib/src/perspectives/FlowInstance.js +336 -0
- package/lib/src/perspectives/FlowModels.d.ts +94 -0
- package/lib/src/perspectives/FlowModels.js +182 -0
- package/lib/src/perspectives/InterpretationModels.d.ts +41 -3
- package/lib/src/perspectives/InterpretationModels.js +60 -26
- package/lib/src/perspectives/PerspectiveClient.d.ts +88 -7
- package/lib/src/perspectives/PerspectiveClient.js +138 -11
- package/lib/src/perspectives/PerspectiveProxy.d.ts +150 -57
- package/lib/src/perspectives/PerspectiveProxy.js +411 -287
- package/lib/src/perspectives/SparqlBindings.d.ts +24 -3
- package/lib/src/perspectives/SparqlBindings.js +57 -6
- package/lib/src/shacl/SHACLFlow.d.ts +273 -47
- package/lib/src/shacl/SHACLFlow.js +397 -88
- package/lib/src/shacl/SHACLShape.d.ts +19 -3
- package/lib/src/shacl/SHACLShape.js +30 -1
- package/lib/src/shacl/SHACLShape.test.js +82 -0
- package/lib/src/shacl/index.d.ts +1 -1
- package/lib/src/shacl/index.js +1 -1
- package/package.json +3 -3
- package/src/Literal.ts +7 -0
- package/src/ai/AIClient.ts +6 -3
- package/src/apiClient.test.ts +227 -0
- package/src/apiClient.ts +185 -9
- package/src/generated/api/RunInterpretationRequest.ts +19 -3
- package/src/index.ts +3 -1
- package/src/model/Ad4mModel.test.ts +729 -22
- package/src/model/Ad4mModel.ts +305 -66
- package/src/model/ModelQueryBuilder.ts +2 -2
- package/src/model/decorators.ts +278 -44
- package/src/model/json-schema.ts +10 -25
- package/src/model/query-common.ts +2 -2
- package/src/model/query-sparql.test.ts +114 -13
- package/src/model/query-sparql.ts +83 -14
- package/src/model/query-utils.ts +22 -12
- package/src/model/relation-filtering.test.ts +70 -20
- package/src/model/shacl-gen.ts +78 -13
- package/src/model/shacl-roundtrip.test.ts +134 -2
- package/src/model/types.ts +30 -8
- package/src/perspectives/AutoProcessor.ts +204 -2
- package/src/perspectives/FlowInstance.ts +369 -0
- package/src/perspectives/FlowModels.ts +157 -0
- package/src/perspectives/InterpretationModels.ts +91 -21
- package/src/perspectives/PerspectiveClient.test.ts +67 -6
- package/src/perspectives/PerspectiveClient.ts +190 -14
- package/src/perspectives/PerspectiveProxy.test.ts +406 -0
- package/src/perspectives/PerspectiveProxy.ts +494 -308
- package/src/perspectives/SparqlBindings.test.ts +134 -0
- package/src/perspectives/SparqlBindings.ts +57 -6
- package/src/perspectives/shacl-rpc.test.ts +258 -0
- package/src/shacl/SHACLFlow.test.ts +762 -35
- package/src/shacl/SHACLFlow.ts +680 -112
- package/src/shacl/SHACLShape.test.ts +30 -4
- package/src/shacl/SHACLShape.ts +59 -6
- package/src/shacl/index.ts +1 -1
- package/lib/src/generated/rest/AIModelLoadingStatus.d.ts +0 -7
- package/lib/src/generated/rest/AIModelLoadingStatus.js +0 -2
- package/lib/src/generated/rest/AddAgentInfosRequest.d.ts +0 -3
- package/lib/src/generated/rest/AddAgentInfosRequest.js +0 -2
- package/lib/src/generated/rest/AddLinkExpressionRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddLinkExpressionRequest.js +0 -1
- package/lib/src/generated/rest/AddLinkRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddLinkRequest.js +0 -1
- package/lib/src/generated/rest/AddLinksBulkRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddLinksBulkRequest.js +0 -1
- package/lib/src/generated/rest/AddSdnaRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddSdnaRequest.js +0 -2
- package/lib/src/generated/rest/ApplyTemplateRequest.d.ts +0 -4
- package/lib/src/generated/rest/ApplyTemplateRequest.js +0 -2
- package/lib/src/generated/rest/AuthInfoInput.d.ts +0 -10
- package/lib/src/generated/rest/AuthInfoInput.js +0 -1
- package/lib/src/generated/rest/BroadcastRequest.d.ts +0 -6
- package/lib/src/generated/rest/BroadcastRequest.js +0 -1
- package/lib/src/generated/rest/CapabilityInput.d.ts +0 -5
- package/lib/src/generated/rest/CapabilityInput.js +0 -1
- package/lib/src/generated/rest/CommitBatchRequest.d.ts +0 -3
- package/lib/src/generated/rest/CommitBatchRequest.js +0 -2
- package/lib/src/generated/rest/ComputeLogEntry.d.ts +0 -9
- package/lib/src/generated/rest/ComputeLogEntry.js +0 -2
- package/lib/src/generated/rest/CreateExpressionRequest.d.ts +0 -4
- package/lib/src/generated/rest/CreateExpressionRequest.js +0 -2
- package/lib/src/generated/rest/CreatePerspectiveRequest.d.ts +0 -3
- package/lib/src/generated/rest/CreatePerspectiveRequest.js +0 -2
- package/lib/src/generated/rest/CreateSubjectRequest.d.ts +0 -6
- package/lib/src/generated/rest/CreateSubjectRequest.js +0 -2
- package/lib/src/generated/rest/CreateUserRequest.d.ts +0 -4
- package/lib/src/generated/rest/CreateUserRequest.js +0 -2
- package/lib/src/generated/rest/CreateUserResponse.d.ts +0 -5
- package/lib/src/generated/rest/CreateUserResponse.js +0 -2
- package/lib/src/generated/rest/DecoratedExpressionProof.d.ts +0 -6
- package/lib/src/generated/rest/DecoratedExpressionProof.js +0 -2
- package/lib/src/generated/rest/DecoratedLinkExpression.d.ts +0 -10
- package/lib/src/generated/rest/DecoratedLinkExpression.js +0 -1
- package/lib/src/generated/rest/DisposeQueryRequest.d.ts +0 -3
- package/lib/src/generated/rest/DisposeQueryRequest.js +0 -2
- package/lib/src/generated/rest/EmailTestRequest.d.ts +0 -6
- package/lib/src/generated/rest/EmailTestRequest.js +0 -2
- package/lib/src/generated/rest/EmbedRequest.d.ts +0 -4
- package/lib/src/generated/rest/EmbedRequest.js +0 -2
- package/lib/src/generated/rest/EntanglementProofInput.d.ts +0 -6
- package/lib/src/generated/rest/EntanglementProofInput.js +0 -2
- package/lib/src/generated/rest/EntanglementProofPreflightRequest.d.ts +0 -4
- package/lib/src/generated/rest/EntanglementProofPreflightRequest.js +0 -2
- package/lib/src/generated/rest/ExecuteCommandsRequest.d.ts +0 -4
- package/lib/src/generated/rest/ExecuteCommandsRequest.js +0 -2
- package/lib/src/generated/rest/ExportRequest.d.ts +0 -5
- package/lib/src/generated/rest/ExportRequest.js +0 -2
- package/lib/src/generated/rest/ExpressionManyRequest.d.ts +0 -3
- package/lib/src/generated/rest/ExpressionManyRequest.js +0 -2
- package/lib/src/generated/rest/ExpressionProof.d.ts +0 -4
- package/lib/src/generated/rest/ExpressionProof.js +0 -2
- package/lib/src/generated/rest/ExpressionProofInput.d.ts +0 -6
- package/lib/src/generated/rest/ExpressionProofInput.js +0 -2
- package/lib/src/generated/rest/FriendSendMessageRequest.d.ts +0 -3
- package/lib/src/generated/rest/FriendSendMessageRequest.js +0 -2
- package/lib/src/generated/rest/FriendsListRequest.d.ts +0 -3
- package/lib/src/generated/rest/FriendsListRequest.js +0 -2
- package/lib/src/generated/rest/GenerateAgentRequest.d.ts +0 -3
- package/lib/src/generated/rest/GenerateAgentRequest.js +0 -2
- package/lib/src/generated/rest/GenerateJwtRequest.d.ts +0 -4
- package/lib/src/generated/rest/GenerateJwtRequest.js +0 -2
- package/lib/src/generated/rest/GetSubjectDataRequest.d.ts +0 -4
- package/lib/src/generated/rest/GetSubjectDataRequest.js +0 -2
- package/lib/src/generated/rest/HostingInfoResponse.d.ts +0 -5
- package/lib/src/generated/rest/HostingInfoResponse.js +0 -2
- package/lib/src/generated/rest/HostingWalletResponse.d.ts +0 -4
- package/lib/src/generated/rest/HostingWalletResponse.js +0 -2
- package/lib/src/generated/rest/ImportAgentRequest.d.ts +0 -6
- package/lib/src/generated/rest/ImportAgentRequest.js +0 -2
- package/lib/src/generated/rest/ImportRequest.d.ts +0 -4
- package/lib/src/generated/rest/ImportRequest.js +0 -2
- package/lib/src/generated/rest/JoinNeighbourhoodRequest.d.ts +0 -3
- package/lib/src/generated/rest/JoinNeighbourhoodRequest.js +0 -2
- package/lib/src/generated/rest/KeepAliveQueryRequest.d.ts +0 -3
- package/lib/src/generated/rest/KeepAliveQueryRequest.js +0 -2
- package/lib/src/generated/rest/LanguageMetaInput.d.ts +0 -6
- package/lib/src/generated/rest/LanguageMetaInput.js +0 -2
- package/lib/src/generated/rest/Link.d.ts +0 -5
- package/lib/src/generated/rest/Link.js +0 -2
- package/lib/src/generated/rest/LinkExpression.d.ts +0 -10
- package/lib/src/generated/rest/LinkExpression.js +0 -1
- package/lib/src/generated/rest/LinkExpressionInput.d.ts +0 -10
- package/lib/src/generated/rest/LinkExpressionInput.js +0 -1
- package/lib/src/generated/rest/LinkInput.d.ts +0 -5
- package/lib/src/generated/rest/LinkInput.js +0 -2
- package/lib/src/generated/rest/LinkLanguageTemplatesRequest.d.ts +0 -3
- package/lib/src/generated/rest/LinkLanguageTemplatesRequest.js +0 -2
- package/lib/src/generated/rest/LinkMutationRequest.d.ts +0 -12
- package/lib/src/generated/rest/LinkMutationRequest.js +0 -1
- package/lib/src/generated/rest/LinkMutationResponse.d.ts +0 -9
- package/lib/src/generated/rest/LinkMutationResponse.js +0 -1
- package/lib/src/generated/rest/LinkMutations.d.ts +0 -6
- package/lib/src/generated/rest/LinkMutations.js +0 -1
- package/lib/src/generated/rest/LinkMutationsRequest.d.ts +0 -5
- package/lib/src/generated/rest/LinkMutationsRequest.js +0 -1
- package/lib/src/generated/rest/LinkStatus.d.ts +0 -1
- package/lib/src/generated/rest/LinkStatus.js +0 -2
- package/lib/src/generated/rest/LinkUpdateInput.d.ts +0 -5
- package/lib/src/generated/rest/LinkUpdateInput.js +0 -1
- package/lib/src/generated/rest/LockAgentRequest.d.ts +0 -3
- package/lib/src/generated/rest/LockAgentRequest.js +0 -2
- package/lib/src/generated/rest/LoginUserRequest.d.ts +0 -5
- package/lib/src/generated/rest/LoginUserRequest.js +0 -2
- package/lib/src/generated/rest/ModelType.d.ts +0 -1
- package/lib/src/generated/rest/ModelType.js +0 -2
- package/lib/src/generated/rest/NotificationGrantRequest.d.ts +0 -3
- package/lib/src/generated/rest/NotificationGrantRequest.js +0 -2
- package/lib/src/generated/rest/NotificationInput.d.ts +0 -10
- package/lib/src/generated/rest/NotificationInput.js +0 -2
- package/lib/src/generated/rest/OpenLinkRequest.d.ts +0 -3
- package/lib/src/generated/rest/OpenLinkRequest.js +0 -2
- package/lib/src/generated/rest/PermitCapabilityRequest.d.ts +0 -3
- package/lib/src/generated/rest/PermitCapabilityRequest.js +0 -2
- package/lib/src/generated/rest/PerspectiveInput.d.ts +0 -4
- package/lib/src/generated/rest/PerspectiveInput.js +0 -1
- package/lib/src/generated/rest/PromptRequest.d.ts +0 -4
- package/lib/src/generated/rest/PromptRequest.js +0 -2
- package/lib/src/generated/rest/PublicPerspectiveInput.d.ts +0 -4
- package/lib/src/generated/rest/PublicPerspectiveInput.js +0 -1
- package/lib/src/generated/rest/PublishLanguageRequest.d.ts +0 -5
- package/lib/src/generated/rest/PublishLanguageRequest.js +0 -1
- package/lib/src/generated/rest/PublishNeighbourhoodRequest.d.ts +0 -6
- package/lib/src/generated/rest/PublishNeighbourhoodRequest.js +0 -1
- package/lib/src/generated/rest/QueryRequest.d.ts +0 -7
- package/lib/src/generated/rest/QueryRequest.js +0 -2
- package/lib/src/generated/rest/RemoveLinkRequest.d.ts +0 -5
- package/lib/src/generated/rest/RemoveLinkRequest.js +0 -1
- package/lib/src/generated/rest/RemoveLinksBulkRequest.d.ts +0 -5
- package/lib/src/generated/rest/RemoveLinksBulkRequest.js +0 -1
- package/lib/src/generated/rest/RequestCapabilityRequest.d.ts +0 -4
- package/lib/src/generated/rest/RequestCapabilityRequest.js +0 -1
- package/lib/src/generated/rest/RequestPaymentRequest.d.ts +0 -3
- package/lib/src/generated/rest/RequestPaymentRequest.js +0 -2
- package/lib/src/generated/rest/RequestVerificationRequest.d.ts +0 -4
- package/lib/src/generated/rest/RequestVerificationRequest.js +0 -2
- package/lib/src/generated/rest/ResourceInput.d.ts +0 -4
- package/lib/src/generated/rest/ResourceInput.js +0 -2
- package/lib/src/generated/rest/SetDefaultModelRequest.d.ts +0 -4
- package/lib/src/generated/rest/SetDefaultModelRequest.js +0 -1
- package/lib/src/generated/rest/SetFreeHostingEnabledRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetFreeHostingEnabledRequest.js +0 -2
- package/lib/src/generated/rest/SetHotWalletAddressRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetHotWalletAddressRequest.js +0 -2
- package/lib/src/generated/rest/SetMultiUserRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetMultiUserRequest.js +0 -2
- package/lib/src/generated/rest/SetOnlineStatusRequest.d.ts +0 -5
- package/lib/src/generated/rest/SetOnlineStatusRequest.js +0 -1
- package/lib/src/generated/rest/SetStatusRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetStatusRequest.js +0 -2
- package/lib/src/generated/rest/SetUserFreeAccessRequest.d.ts +0 -4
- package/lib/src/generated/rest/SetUserFreeAccessRequest.js +0 -2
- package/lib/src/generated/rest/SignMessageRequest.d.ts +0 -3
- package/lib/src/generated/rest/SignMessageRequest.js +0 -2
- package/lib/src/generated/rest/SignalRequest.d.ts +0 -6
- package/lib/src/generated/rest/SignalRequest.js +0 -1
- package/lib/src/generated/rest/SubscribeQueryRequest.d.ts +0 -3
- package/lib/src/generated/rest/SubscribeQueryRequest.js +0 -2
- package/lib/src/generated/rest/SubscribeQueryResponse.d.ts +0 -4
- package/lib/src/generated/rest/SubscribeQueryResponse.js +0 -2
- package/lib/src/generated/rest/TrustedAgentsRequest.d.ts +0 -3
- package/lib/src/generated/rest/TrustedAgentsRequest.js +0 -2
- package/lib/src/generated/rest/UnlockAgentRequest.d.ts +0 -4
- package/lib/src/generated/rest/UnlockAgentRequest.js +0 -2
- package/lib/src/generated/rest/UpdateLinkRequest.d.ts +0 -7
- package/lib/src/generated/rest/UpdateLinkRequest.js +0 -1
- package/lib/src/generated/rest/UpdatePerspectiveRequest.d.ts +0 -3
- package/lib/src/generated/rest/UpdatePerspectiveRequest.js +0 -2
- package/lib/src/generated/rest/UpdateProfileRequest.d.ts +0 -5
- package/lib/src/generated/rest/UpdateProfileRequest.js +0 -1
- package/lib/src/generated/rest/UserStatistics.d.ts +0 -9
- package/lib/src/generated/rest/UserStatistics.js +0 -2
- package/lib/src/generated/rest/VerificationRequestResult.d.ts +0 -6
- package/lib/src/generated/rest/VerificationRequestResult.js +0 -2
- package/lib/src/generated/rest/VerifyEmailRequest.d.ts +0 -6
- package/lib/src/generated/rest/VerifyEmailRequest.js +0 -2
- package/lib/src/generated/rest/VerifySignatureRequest.d.ts +0 -5
- package/lib/src/generated/rest/VerifySignatureRequest.js +0 -2
- package/lib/src/generated/rest/WriteSettingsRequest.d.ts +0 -3
- package/lib/src/generated/rest/WriteSettingsRequest.js +0 -2
- package/lib/src/generated/rest/index.d.ts +0 -73
- package/lib/src/generated/rest/index.js +0 -8
- package/lib/src/generated/rest/routes.d.ts +0 -587
- package/lib/src/generated/rest/routes.js +0 -3
- package/lib/src/model/query-surreal.d.ts +0 -44
- package/lib/src/model/query-surreal.js +0 -249
- package/lib/src/model/surreal-utils.d.ts +0 -42
- package/lib/src/model/surreal-utils.js +0 -128
- package/lib/src/perspectives/PerspectiveProxy.test.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveProxy.test.js +0 -34
- package/lib/src/restClient.d.ts +0 -52
- package/lib/src/restClient.js +0 -227
package/src/model/decorators.ts
CHANGED
|
@@ -48,6 +48,30 @@ export interface RelationMetadataEntry {
|
|
|
48
48
|
* Overrides auto-derived conformance when set.
|
|
49
49
|
*/
|
|
50
50
|
where?: Where;
|
|
51
|
+
/**
|
|
52
|
+
* SHACL `sh:datatype` for the relation's target values. Set when the
|
|
53
|
+
* relation holds encoded literal values (e.g. `"xsd:string"` for a
|
|
54
|
+
* `HasMany<string>` that stores plain strings). Emitted into SHACL
|
|
55
|
+
* so the executor knows to decode `literal:<type>:<value>` wire form
|
|
56
|
+
* on hydration. Omit for URI relations that point at other model
|
|
57
|
+
* instances — those pass through byte-for-byte.
|
|
58
|
+
*/
|
|
59
|
+
datatype?: string;
|
|
60
|
+
/** Hydrate targets as the class each one actually is — see `RelationOptions.polymorphic`. */
|
|
61
|
+
polymorphic?: boolean;
|
|
62
|
+
/** Model classes this relation's polymorphic results can be constructed as. */
|
|
63
|
+
instantiateAs?: () => Ad4mModelLike[];
|
|
64
|
+
/** CRDT ordering config — see `RelationOptions.ordering`. */
|
|
65
|
+
ordering?: { strategy: 'linkedList' };
|
|
66
|
+
/**
|
|
67
|
+
* Natural-language hint describing what this relation MEANS semantically.
|
|
68
|
+
* Emitted as an `ad4m://interpretation_hint` link on the SHACL property
|
|
69
|
+
* node; read back by the Rust harness and rendered into the
|
|
70
|
+
* `_propose_link_child` tool's `predicate` field description. Mirror of
|
|
71
|
+
* the same field on `RelationOptions` (the decorator arg); this is the
|
|
72
|
+
* memoized registry copy.
|
|
73
|
+
*/
|
|
74
|
+
interpretationHint?: string;
|
|
51
75
|
}
|
|
52
76
|
|
|
53
77
|
/** Registry of property metadata keyed by constructor → { propName → metadata } */
|
|
@@ -280,7 +304,16 @@ export interface PropertyOptions {
|
|
|
280
304
|
readOnly?: boolean;
|
|
281
305
|
|
|
282
306
|
/**
|
|
283
|
-
* The language used to store the property
|
|
307
|
+
* The language used to resolve/store the property value — and the sole
|
|
308
|
+
* selector of storage mode. Not defaulted:
|
|
309
|
+
* - unset (the default for a plain `@Property()`) → deterministic
|
|
310
|
+
* typed literal storage (`literal:string:` / `:number:` / `:boolean:` /
|
|
311
|
+
* `:json:` IRIs stored as XSD-typed RDF literals; POS-index friendly).
|
|
312
|
+
* - `"literal"` → the built-in literal language: values go through
|
|
313
|
+
* `expression_create`, producing a signed-envelope URI with
|
|
314
|
+
* author/timestamp/proof (per-value provenance, e.g. Flux message
|
|
315
|
+
* bodies).
|
|
316
|
+
* - a custom language address → `expression_create` on that language.
|
|
284
317
|
*/
|
|
285
318
|
resolveLanguage?: string;
|
|
286
319
|
|
|
@@ -355,6 +388,17 @@ export interface PropertyOptions {
|
|
|
355
388
|
* should set this.
|
|
356
389
|
*/
|
|
357
390
|
identity?: boolean;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Explicit SHACL `sh:datatype` for the property value. When set, this
|
|
394
|
+
* overrides auto-inference and — importantly — lets custom `getter`
|
|
395
|
+
* properties opt into typed-literal decoding. Auto-inference is disabled
|
|
396
|
+
* for properties with a `getter` (see `shacl-gen.ts`) because such
|
|
397
|
+
* getters typically return URIs; setting `datatype` explicitly declares
|
|
398
|
+
* that this getter returns literal values of the given XSD type
|
|
399
|
+
* (e.g. `"xsd://string"`) and enables the hydration decode gate.
|
|
400
|
+
*/
|
|
401
|
+
datatype?: string;
|
|
358
402
|
}
|
|
359
403
|
|
|
360
404
|
|
|
@@ -398,7 +442,7 @@ function applyPropertyMetadata(opts: PropertyOptions) {
|
|
|
398
442
|
*
|
|
399
443
|
* @description
|
|
400
444
|
* Equivalent to `@Property` but defaults `required` to `false` and does not
|
|
401
|
-
* apply
|
|
445
|
+
* apply any `initial` defaults. Use this when a property
|
|
402
446
|
* may or may not have a value, and you want full control over its configuration.
|
|
403
447
|
*
|
|
404
448
|
* @example
|
|
@@ -557,8 +601,7 @@ export interface ModelConfig {
|
|
|
557
601
|
* @Model({ name: "Recipe" })
|
|
558
602
|
* class Recipe extends Ad4mModel {
|
|
559
603
|
* @Property({
|
|
560
|
-
* through: "recipe://name"
|
|
561
|
-
* resolveLanguage: "literal"
|
|
604
|
+
* through: "recipe://name"
|
|
562
605
|
* })
|
|
563
606
|
* name: string = "";
|
|
564
607
|
*
|
|
@@ -632,7 +675,9 @@ export function Model(opts: ModelConfig) {
|
|
|
632
675
|
* Smart defaults (all overridable):
|
|
633
676
|
* - `required` → `false`
|
|
634
677
|
* - `readOnly` → `false`
|
|
635
|
-
* - `resolveLanguage` →
|
|
678
|
+
* - `resolveLanguage` → unset → deterministic typed literal storage
|
|
679
|
+
* (the perf default). Set `resolveLanguage: "literal"` for a signed-envelope
|
|
680
|
+
* value, or a custom language address to resolve through that language.
|
|
636
681
|
* - `initial` → `undefined` (no link created until a value is explicitly set)
|
|
637
682
|
*
|
|
638
683
|
* Properties are optional by default. When a model instance is created without
|
|
@@ -665,7 +710,8 @@ export function Model(opts: ModelConfig) {
|
|
|
665
710
|
* })
|
|
666
711
|
* role: string = "";
|
|
667
712
|
*
|
|
668
|
-
* // Optional property with literal
|
|
713
|
+
* // Optional property with signed-envelope literal storage
|
|
714
|
+
* // (per-value provenance)
|
|
669
715
|
* @Property({
|
|
670
716
|
* through: "user://bio",
|
|
671
717
|
* resolveLanguage: "literal"
|
|
@@ -678,18 +724,22 @@ export function Model(opts: ModelConfig) {
|
|
|
678
724
|
* @param {string} opts.through - The predicate URI for the property
|
|
679
725
|
* @param {boolean} [opts.required=false] - Whether the property is required (adds query filters and sentinel initial value)
|
|
680
726
|
* @param {string} [opts.initial] - Initial value (defaults to "literal:string:uninitialized" when required)
|
|
681
|
-
* @param {string} [opts.resolveLanguage] -
|
|
727
|
+
* @param {string} [opts.resolveLanguage] - Value-resolution language: unset (deterministic typed literal, the perf default), "literal" (signed envelope), or a custom language address
|
|
682
728
|
* @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
|
|
683
729
|
* @param {string} [opts.prologSetter] - Custom Prolog code for setting the property value
|
|
684
730
|
* @param {boolean} [opts.local] - Whether the property should only be stored locally
|
|
685
731
|
*/
|
|
686
732
|
export function Property(opts: PropertyOptions) {
|
|
687
733
|
const required = opts.required ?? false;
|
|
734
|
+
// `resolveLanguage` is intentionally NOT defaulted here.
|
|
735
|
+
// The effective storage mode is derived from what the user explicitly set:
|
|
736
|
+
// - unset → deterministic typed literal (the perf default)
|
|
737
|
+
// - "literal" → signed literal envelope (per-value provenance)
|
|
738
|
+
// - <custom address> → expression on that custom language
|
|
688
739
|
return applyPropertyMetadata({
|
|
689
740
|
...opts,
|
|
690
741
|
required,
|
|
691
742
|
readOnly: opts.readOnly ?? false,
|
|
692
|
-
resolveLanguage: opts.resolveLanguage ?? "literal",
|
|
693
743
|
initial: opts.initial ?? (required ? "literal:string:uninitialized" : undefined),
|
|
694
744
|
});
|
|
695
745
|
}
|
|
@@ -745,7 +795,7 @@ export function Property(opts: PropertyOptions) {
|
|
|
745
795
|
* @param {PropertyOptions} opts - Property configuration
|
|
746
796
|
* @param {string} opts.through - The predicate URI for the property
|
|
747
797
|
* @param {string} [opts.initial] - Initial value (if property should have one)
|
|
748
|
-
* @param {string} [opts.resolveLanguage] -
|
|
798
|
+
* @param {string} [opts.resolveLanguage] - Value-resolution language: unset (deterministic typed literal, the perf default), "literal" (signed envelope), or a custom language address
|
|
749
799
|
* @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
|
|
750
800
|
* @param {boolean} [opts.local] - Whether the property should only be stored locally
|
|
751
801
|
*/
|
|
@@ -771,15 +821,34 @@ export interface RelationOptions {
|
|
|
771
821
|
*/
|
|
772
822
|
through?: string;
|
|
773
823
|
/** The target model class (use a thunk to avoid circular-dependency issues). Optional for untyped string relations.
|
|
774
|
-
*
|
|
824
|
+
* Combines with `getter`, where it names the class the traversal's values hydrate into. */
|
|
775
825
|
target?: () => Ad4mModelLike;
|
|
776
826
|
/**
|
|
777
827
|
* Custom getter to resolve the relation values. Use this for custom graph traversals.
|
|
778
828
|
* The expression can reference 'Base' which will be replaced with the instance's base expression.
|
|
779
829
|
* Example: "SELECT ?target WHERE { ?target <flux://has_reply> <Base> . }"
|
|
780
830
|
*
|
|
781
|
-
* Mutually exclusive with `through`
|
|
782
|
-
*
|
|
831
|
+
* Mutually exclusive with `through` — a getter replaces link-based resolution,
|
|
832
|
+
* so there is no predicate to add to or remove from. When `getter` is provided
|
|
833
|
+
* the relation is read-only (no adder/remover actions are generated).
|
|
834
|
+
*
|
|
835
|
+
* **Combines with `target`**, which names the class the traversal's values
|
|
836
|
+
* hydrate into — without it `include` has no shape to resolve and the relation
|
|
837
|
+
* can only return bare URIs. Also combines with `where`, applied as a
|
|
838
|
+
* post-getter filter against the target class.
|
|
839
|
+
*
|
|
840
|
+
* @example Traversing a reified edge — a connection stored as a record rather
|
|
841
|
+
* than a predicate, so no `through` can express it:
|
|
842
|
+
* ```typescript
|
|
843
|
+
* @HasMany({
|
|
844
|
+
* getter: `SELECT ?target WHERE {
|
|
845
|
+
* ?citation <paper://cites_from> <Base> .
|
|
846
|
+
* ?citation <paper://cites_to> ?target .
|
|
847
|
+
* }`,
|
|
848
|
+
* target: () => Paper,
|
|
849
|
+
* })
|
|
850
|
+
* cited: Paper[] = [];
|
|
851
|
+
* ```
|
|
783
852
|
*/
|
|
784
853
|
getter?: string;
|
|
785
854
|
/** Whether the link is stored locally (not shared on the network) */
|
|
@@ -800,7 +869,8 @@ export interface RelationOptions {
|
|
|
800
869
|
* auto-derived from the target shape (flags + required properties).
|
|
801
870
|
* Providing `where` overrides this auto-derivation.
|
|
802
871
|
*
|
|
803
|
-
* Mutually exclusive with `
|
|
872
|
+
* Mutually exclusive with `filter: false`. Combines with `getter`, where it
|
|
873
|
+
* is applied as a post-getter filter against the target class.
|
|
804
874
|
*
|
|
805
875
|
* @example
|
|
806
876
|
* ```typescript
|
|
@@ -812,6 +882,124 @@ export interface RelationOptions {
|
|
|
812
882
|
* ```
|
|
813
883
|
*/
|
|
814
884
|
where?: Where;
|
|
885
|
+
/**
|
|
886
|
+
* SHACL `sh:datatype` for the relation's target values. Set when the
|
|
887
|
+
* relation holds encoded literal values (e.g. `"xsd:string"` for a
|
|
888
|
+
* `HasMany<string>` that stores plain strings). The executor uses
|
|
889
|
+
* this to decode `literal:<type>:<value>` wire form on hydration.
|
|
890
|
+
* Omit for URI relations that point at other model instances.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```typescript
|
|
894
|
+
* @HasMany({ through: "run://source", datatype: "xsd:string" })
|
|
895
|
+
* sources: string[] = [];
|
|
896
|
+
* ```
|
|
897
|
+
*/
|
|
898
|
+
datatype?: string;
|
|
899
|
+
/**
|
|
900
|
+
* Hydrate each target as the class it actually **is**, rather than as the
|
|
901
|
+
* class this relation declares.
|
|
902
|
+
*
|
|
903
|
+
* A heterogeneous relation has no single right target. Declaring the base
|
|
904
|
+
* class loses every subclass property — the executor hydrates against the
|
|
905
|
+
* shape it is given, so an `ImagePost` read as a `Post` arrives with its own
|
|
906
|
+
* fields simply absent, not merely mislabelled. Declaring nothing leaves
|
|
907
|
+
* `include` with no shape to resolve at all.
|
|
908
|
+
*
|
|
909
|
+
* With this set, the targets are classified, grouped by concrete class, and
|
|
910
|
+
* hydrated against their own shapes — one query per distinct class present,
|
|
911
|
+
* not per instance.
|
|
912
|
+
*
|
|
913
|
+
* Pair with `instantiateAs` so the results become instances of the right
|
|
914
|
+
* model class rather than plain objects.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* ```typescript
|
|
918
|
+
* @HasMany({
|
|
919
|
+
* through: "we://children",
|
|
920
|
+
* polymorphic: true,
|
|
921
|
+
* instantiateAs: () => [TextBlock, ImageBlock],
|
|
922
|
+
* })
|
|
923
|
+
* children: Post[] = [];
|
|
924
|
+
* ```
|
|
925
|
+
*/
|
|
926
|
+
polymorphic?: boolean;
|
|
927
|
+
/**
|
|
928
|
+
* The model classes a `polymorphic` result may be constructed as.
|
|
929
|
+
*
|
|
930
|
+
* Classification happens in the executor, structurally — there is no
|
|
931
|
+
* `rdf:type` triple to read, so a target's class is derived from the flags
|
|
932
|
+
* and required properties it carries. What cannot cross the wire is the
|
|
933
|
+
* TypeScript constructor, so this names the classes this side can build.
|
|
934
|
+
* `@Model` already records each class's name on the class itself, so the
|
|
935
|
+
* name → class mapping is derived from the list rather than restated
|
|
936
|
+
* alongside it.
|
|
937
|
+
*
|
|
938
|
+
* **This is advisory, not a constraint.** It never narrows what the query
|
|
939
|
+
* returns and never excludes a target: a class missing from the list arrives
|
|
940
|
+
* as plain JSON carrying its class name, so partial knowledge degrades
|
|
941
|
+
* instead of failing. Declaring what this call site can *construct* is a
|
|
942
|
+
* different statement from declaring what the relation may *contain* — a
|
|
943
|
+
* heterogeneous relation is open by definition, and a list that silently
|
|
944
|
+
* dropped unrecognised members would defeat the point of reading it
|
|
945
|
+
* polymorphically at all. Constraining a read to particular classes belongs
|
|
946
|
+
* in the query, not here.
|
|
947
|
+
*
|
|
948
|
+
* A thunk rather than an array, for the same reason `target` is one: it is
|
|
949
|
+
* evaluated at query time, so a class defined later in a circular import
|
|
950
|
+
* graph still resolves.
|
|
951
|
+
*/
|
|
952
|
+
instantiateAs?: () => Ad4mModelLike[];
|
|
953
|
+
/**
|
|
954
|
+
* Give this collection a user-controlled order that survives concurrent edits.
|
|
955
|
+
*
|
|
956
|
+
* A `@HasMany` is a set of links, and hydration sorts them by link timestamp.
|
|
957
|
+
* That is right for an append-only collection — a transcript, a message
|
|
958
|
+
* thread — where timestamp order *is* the order. It cannot express a sequence
|
|
959
|
+
* somebody chose: a kanban column, a playlist, the blocks of a post.
|
|
960
|
+
*
|
|
961
|
+
* **Declaration only, for now.** Setting this emits `ad4m://ordering` on the
|
|
962
|
+
* property shape, where the executor reads it back — but no read or write
|
|
963
|
+
* path acts on it yet, so a relation declaring it still hydrates by link
|
|
964
|
+
* timestamp exactly as one that does not. Wiring save and hydration to the
|
|
965
|
+
* declaration is the next change; nothing about how you write the relation
|
|
966
|
+
* will change when it lands — assign the array in the order you want and
|
|
967
|
+
* save.
|
|
968
|
+
*
|
|
969
|
+
* Ordering is declared in the type system, rather than passed per query, so
|
|
970
|
+
* that *every* writer gets it once it is wired: the ORM, MCP agents, raw
|
|
971
|
+
* WS-RPC callers, another app sharing the neighbourhood. Implemented
|
|
972
|
+
* client-side it would order only what this client wrote.
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```typescript
|
|
976
|
+
* @HasMany(() => Task, {
|
|
977
|
+
* through: "kanban://has_task",
|
|
978
|
+
* ordering: { strategy: "linkedList" },
|
|
979
|
+
* })
|
|
980
|
+
* tasks: Task[] = [];
|
|
981
|
+
* ```
|
|
982
|
+
*/
|
|
983
|
+
ordering?: { strategy: 'linkedList' };
|
|
984
|
+
/**
|
|
985
|
+
* Natural-language hint describing what this relation MEANS semantically —
|
|
986
|
+
* the sentence-level rationale for when to use it, not just its structural
|
|
987
|
+
* shape. Emitted as an `ad4m://interpretation_hint` link on the SHACL
|
|
988
|
+
* property node; read back by the Rust harness (`ClassProposeShape.
|
|
989
|
+
* relations[N].hint`) and rendered into the `_propose_link_child` tool's
|
|
990
|
+
* `predicate` field description so the LLM knows which relation applies
|
|
991
|
+
* to which situation instead of guessing from the predicate name alone.
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* ```typescript
|
|
995
|
+
* @HasMany(() => Belief, {
|
|
996
|
+
* through: "ns://basedOn",
|
|
997
|
+
* interpretationHint: "The prior beliefs this intention derives from.",
|
|
998
|
+
* })
|
|
999
|
+
* basedOn: Belief[] = [];
|
|
1000
|
+
* ```
|
|
1001
|
+
*/
|
|
1002
|
+
interpretationHint?: string;
|
|
815
1003
|
}
|
|
816
1004
|
|
|
817
1005
|
/**
|
|
@@ -846,7 +1034,16 @@ function resolveRelationArgs(
|
|
|
846
1034
|
? { ...(second || {}), target: first }
|
|
847
1035
|
: first;
|
|
848
1036
|
|
|
849
|
-
//
|
|
1037
|
+
// `where` and `filter: false` contradict each other on every relation,
|
|
1038
|
+
// getter-backed ones included — checked before the getter path returns.
|
|
1039
|
+
if (opts.where && opts.filter === false) {
|
|
1040
|
+
throw new Error(
|
|
1041
|
+
'Relation decorator: `where` and `filter: false` are contradictory. ' +
|
|
1042
|
+
'`where` adds filtering constraints; `filter: false` disables filtering.'
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// getter is mutually exclusive with through
|
|
850
1047
|
if (opts.getter) {
|
|
851
1048
|
if (opts.through) {
|
|
852
1049
|
throw new Error(
|
|
@@ -855,19 +1052,38 @@ function resolveRelationArgs(
|
|
|
855
1052
|
'(with optional `target`) for standard link-based relations.'
|
|
856
1053
|
);
|
|
857
1054
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1055
|
+
// `target` and `where` are NOT mutually exclusive with `getter`.
|
|
1056
|
+
//
|
|
1057
|
+
// `target` does two separable jobs: it auto-derives a conformance
|
|
1058
|
+
// getter, and it names the class the relation's values hydrate into.
|
|
1059
|
+
// Only the first conflicts with an explicit getter, and `buildSHACL`
|
|
1060
|
+
// already resolves that on its own — an explicit getter wins the getter
|
|
1061
|
+
// slot, while `sh:class` / `ad4m:targetClassName` are emitted from
|
|
1062
|
+
// `target` independently.
|
|
1063
|
+
//
|
|
1064
|
+
// Refusing the pair cost the one thing a custom getter is for. A getter
|
|
1065
|
+
// expresses a traversal the link-shaped DSL cannot — most usefully
|
|
1066
|
+
// through a reified edge, where the connection is a record rather than
|
|
1067
|
+
// a predicate:
|
|
1068
|
+
//
|
|
1069
|
+
// @HasMany({
|
|
1070
|
+
// getter: "SELECT ?target WHERE { \
|
|
1071
|
+
// ?citation <paper://cites_from> <Base> . \
|
|
1072
|
+
// ?citation <paper://cites_to> ?target . }",
|
|
1073
|
+
// target: () => Paper,
|
|
1074
|
+
// })
|
|
1075
|
+
// cited: Paper[] = [];
|
|
1076
|
+
//
|
|
1077
|
+
// Without `target` the relation has no target class, so `include` on it
|
|
1078
|
+
// resolves a shape named "" and fails — leaving a traversal that can
|
|
1079
|
+
// only ever return bare URIs. With it, the values hydrate like any other
|
|
1080
|
+
// relation, because getters are evaluated before include resolution.
|
|
1081
|
+
//
|
|
1082
|
+
// `where` is the same story: the executor applies post-getter where
|
|
1083
|
+
// filters specifically to getter-backed relations
|
|
1084
|
+
// (`apply_where_filter_to_relation`), and emitting `wherePredicates`
|
|
1085
|
+
// needs `target` to resolve the target's metadata — so the runtime is
|
|
1086
|
+
// built for all three together and only this check said otherwise.
|
|
871
1087
|
return opts;
|
|
872
1088
|
}
|
|
873
1089
|
|
|
@@ -876,16 +1092,6 @@ function resolveRelationArgs(
|
|
|
876
1092
|
opts.through = 'ad4m://has_child';
|
|
877
1093
|
}
|
|
878
1094
|
|
|
879
|
-
// where validation
|
|
880
|
-
if (opts.where) {
|
|
881
|
-
if (opts.filter === false) {
|
|
882
|
-
throw new Error(
|
|
883
|
-
'Relation decorator: `where` and `filter: false` are contradictory. ' +
|
|
884
|
-
'`where` adds filtering constraints; `filter: false` disables filtering.'
|
|
885
|
-
);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
|
|
889
1095
|
return opts;
|
|
890
1096
|
}
|
|
891
1097
|
|
|
@@ -938,6 +1144,11 @@ export function HasMany(
|
|
|
938
1144
|
...(opts.getter && { getter: opts.getter }),
|
|
939
1145
|
...(opts.filter !== undefined && { filter: opts.filter }),
|
|
940
1146
|
...(opts.where && { where: opts.where }),
|
|
1147
|
+
...(opts.datatype && { datatype: opts.datatype }),
|
|
1148
|
+
...(opts.polymorphic && { polymorphic: opts.polymorphic }),
|
|
1149
|
+
...(opts.instantiateAs && { instantiateAs: opts.instantiateAs }),
|
|
1150
|
+
...(opts.ordering && { ordering: opts.ordering }),
|
|
1151
|
+
...(opts.interpretationHint && { interpretationHint: opts.interpretationHint }),
|
|
941
1152
|
};
|
|
942
1153
|
|
|
943
1154
|
const relKey = key as string;
|
|
@@ -1001,6 +1212,11 @@ export function HasOne(
|
|
|
1001
1212
|
local: opts.local,
|
|
1002
1213
|
...(opts.filter !== undefined && { filter: opts.filter }),
|
|
1003
1214
|
...(opts.where && { where: opts.where }),
|
|
1215
|
+
...(opts.datatype && { datatype: opts.datatype }),
|
|
1216
|
+
...(opts.polymorphic && { polymorphic: opts.polymorphic }),
|
|
1217
|
+
...(opts.instantiateAs && { instantiateAs: opts.instantiateAs }),
|
|
1218
|
+
...(opts.ordering && { ordering: opts.ordering }),
|
|
1219
|
+
...(opts.interpretationHint && { interpretationHint: opts.interpretationHint }),
|
|
1004
1220
|
};
|
|
1005
1221
|
|
|
1006
1222
|
const relKey = key as string;
|
|
@@ -1012,15 +1228,23 @@ export function HasOne(
|
|
|
1012
1228
|
local: opts.local,
|
|
1013
1229
|
})(target, key);
|
|
1014
1230
|
|
|
1015
|
-
// Add prototype methods for add/remove/set (mirroring @HasMany)
|
|
1016
|
-
|
|
1017
|
-
|
|
1231
|
+
// Add prototype methods for add/remove/set (mirroring @HasMany).
|
|
1232
|
+
//
|
|
1233
|
+
// `batchId` is part of that mirroring: without it a to-one link
|
|
1234
|
+
// cannot join a write group, so anything that creates a record and
|
|
1235
|
+
// then points it at something has to commit twice and every
|
|
1236
|
+
// subscriber sees the state in between — a record whose to-one
|
|
1237
|
+
// relation is still empty. Anything rendering from a subscription
|
|
1238
|
+
// therefore has a frame in which the record exists and points at
|
|
1239
|
+
// nothing.
|
|
1240
|
+
(target as any)[`add${capitalize(relKey)}`] = async function(this: any, arg: any, batchId?: string) {
|
|
1241
|
+
return (this as any).addRelationValue(relKey, arg, batchId);
|
|
1018
1242
|
};
|
|
1019
|
-
(target as any)[`remove${capitalize(relKey)}`] = async function(this: any, arg: any) {
|
|
1020
|
-
return (this as any).removeRelationValue(relKey, arg);
|
|
1243
|
+
(target as any)[`remove${capitalize(relKey)}`] = async function(this: any, arg: any, batchId?: string) {
|
|
1244
|
+
return (this as any).removeRelationValue(relKey, arg, batchId);
|
|
1021
1245
|
};
|
|
1022
|
-
(target as any)[`set${capitalize(relKey)}`] = async function(this: any, arg: any) {
|
|
1023
|
-
return (this as any).setRelationValues(relKey, arg);
|
|
1246
|
+
(target as any)[`set${capitalize(relKey)}`] = async function(this: any, arg: any, batchId?: string) {
|
|
1247
|
+
return (this as any).setRelationValues(relKey, arg, batchId);
|
|
1024
1248
|
};
|
|
1025
1249
|
} else {
|
|
1026
1250
|
Object.defineProperty(target, relKey, { configurable: true, writable: true });
|
|
@@ -1071,6 +1295,11 @@ export function BelongsToOne(
|
|
|
1071
1295
|
local: opts.local,
|
|
1072
1296
|
...(opts.filter !== undefined && { filter: opts.filter }),
|
|
1073
1297
|
...(opts.where && { where: opts.where }),
|
|
1298
|
+
...(opts.datatype && { datatype: opts.datatype }),
|
|
1299
|
+
...(opts.polymorphic && { polymorphic: opts.polymorphic }),
|
|
1300
|
+
...(opts.instantiateAs && { instantiateAs: opts.instantiateAs }),
|
|
1301
|
+
...(opts.ordering && { ordering: opts.ordering }),
|
|
1302
|
+
...(opts.interpretationHint && { interpretationHint: opts.interpretationHint }),
|
|
1074
1303
|
};
|
|
1075
1304
|
|
|
1076
1305
|
if (opts.through) {
|
|
@@ -1129,6 +1358,11 @@ export function BelongsToMany(
|
|
|
1129
1358
|
...(opts.getter && { getter: opts.getter }),
|
|
1130
1359
|
...(opts.filter !== undefined && { filter: opts.filter }),
|
|
1131
1360
|
...(opts.where && { where: opts.where }),
|
|
1361
|
+
...(opts.datatype && { datatype: opts.datatype }),
|
|
1362
|
+
...(opts.polymorphic && { polymorphic: opts.polymorphic }),
|
|
1363
|
+
...(opts.instantiateAs && { instantiateAs: opts.instantiateAs }),
|
|
1364
|
+
...(opts.ordering && { ordering: opts.ordering }),
|
|
1365
|
+
...(opts.interpretationHint && { interpretationHint: opts.interpretationHint }),
|
|
1132
1366
|
};
|
|
1133
1367
|
|
|
1134
1368
|
// @BelongsToMany is the inverse/read-only side — do NOT generate add*/remove*/set*
|
package/src/model/json-schema.ts
CHANGED
|
@@ -325,13 +325,7 @@ export function buildModelFromJSONSchema(
|
|
|
325
325
|
|
|
326
326
|
} else {
|
|
327
327
|
// Handle regular properties
|
|
328
|
-
let resolveLanguage = getPropertyOption(propertyName, propertySchema, options, 'resolveLanguage');
|
|
329
|
-
// If no specific resolveLanguage for this property, use the global one
|
|
330
|
-
if (!resolveLanguage && options.resolveLanguage) {
|
|
331
|
-
resolveLanguage = options.resolveLanguage;
|
|
332
|
-
}
|
|
333
328
|
const local = getPropertyOption(propertyName, propertySchema, options, 'local');
|
|
334
|
-
// Determine readOnly: check PropertyOptions first, then x-ad4m.writable (inverted) for JSON Schema wire format
|
|
335
329
|
let readOnly = getPropertyOption(propertyName, propertySchema, options, 'readOnly');
|
|
336
330
|
if (readOnly === undefined) {
|
|
337
331
|
const xWritable = propertySchema["x-ad4m"]?.writable;
|
|
@@ -339,26 +333,17 @@ export function buildModelFromJSONSchema(
|
|
|
339
333
|
}
|
|
340
334
|
const writable = !readOnly;
|
|
341
335
|
let initial = getPropertyOption(propertyName, propertySchema, options, 'initial');
|
|
342
|
-
|
|
343
|
-
// Handle nested objects by serializing to JSON
|
|
344
|
-
if (isObjectType(propertySchema) && !resolveLanguage) {
|
|
345
|
-
resolveLanguage = 'literal';
|
|
346
|
-
console.warn(`Property "${propertyName}" is an object type. It will be stored as JSON. Consider flattening complex objects for better semantic querying.`);
|
|
347
|
-
}
|
|
348
336
|
|
|
349
|
-
//
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
337
|
+
// Not defaulted — absence means "deterministic typed literal" (the
|
|
338
|
+
// perf default); an explicit `resolveLanguage: "literal"` selects the
|
|
339
|
+
// signed-envelope path; any other value selects a custom language.
|
|
340
|
+
// See effectiveLiteralStorage().
|
|
341
|
+
const resolveLanguage = getPropertyOption(propertyName, propertySchema, options, 'resolveLanguage');
|
|
353
342
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
// stored as literal: URLs are returned unparsed.
|
|
357
|
-
if (resolveLanguage === undefined || resolveLanguage === null) {
|
|
358
|
-
resolveLanguage = 'literal';
|
|
343
|
+
if (isObjectType(propertySchema)) {
|
|
344
|
+
console.warn(`Property "${propertyName}" is an object type. It will be stored as JSON. Consider flattening complex objects for better semantic querying.`);
|
|
359
345
|
}
|
|
360
|
-
|
|
361
|
-
// If property is required, ensure it has an initial value
|
|
346
|
+
|
|
362
347
|
if (isRequired && !initial) {
|
|
363
348
|
if (isObjectType(propertySchema)) {
|
|
364
349
|
initial = 'literal:json:{}';
|
|
@@ -366,12 +351,12 @@ export function buildModelFromJSONSchema(
|
|
|
366
351
|
initial = "ad4m://undefined";
|
|
367
352
|
}
|
|
368
353
|
}
|
|
369
|
-
|
|
354
|
+
|
|
370
355
|
properties[propertyName] = {
|
|
371
356
|
through: predicate,
|
|
372
357
|
required: isRequired,
|
|
373
358
|
writable: writable,
|
|
374
|
-
...(resolveLanguage && { resolveLanguage }),
|
|
359
|
+
...(resolveLanguage !== undefined && { resolveLanguage }),
|
|
375
360
|
...(local !== undefined && { local }),
|
|
376
361
|
...(initial && { initial })
|
|
377
362
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Shared query helpers used by both the Prolog and SPARQL query pipelines.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { Scope } from "./types";
|
|
6
6
|
import { getRelationsMetadata } from "./decorators";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -15,7 +15,7 @@ import { getRelationsMetadata } from "./decorators";
|
|
|
15
15
|
* - Without `field`: scan for a relation whose `target()` matches `childCtor`
|
|
16
16
|
*/
|
|
17
17
|
export function resolveParentPredicate(
|
|
18
|
-
parent:
|
|
18
|
+
parent: Scope,
|
|
19
19
|
childCtor: Function,
|
|
20
20
|
): string {
|
|
21
21
|
// Raw form — explicit predicate
|