@coasys/ad4m 0.13.0-test-flows-1 → 0.13.1-staging.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/index.cjs +9613 -7069
- package/lib/index.js +7367 -4840
- package/lib/src/Ad4mClient.d.ts +12 -4
- package/lib/src/Ad4mClient.js +15 -11
- package/lib/src/Literal.js +3 -3
- package/lib/src/agent/Agent.d.ts +4 -1
- package/lib/src/agent/Agent.js +6 -0
- package/lib/src/agent/AgentClient.d.ts +9 -23
- package/lib/src/agent/AgentClient.js +68 -148
- package/lib/src/ai/AIClient.d.ts +10 -6
- package/lib/src/ai/AIClient.js +29 -27
- package/lib/src/apiClient.d.ts +54 -42
- package/lib/src/apiClient.js +279 -252
- package/lib/src/expression/Expression.d.ts +13 -4
- package/lib/src/expression/Expression.js +0 -1
- package/lib/src/expression/ExpressionClient.js +1 -1
- package/lib/src/generated/api/AIPromptExamples.d.ts +4 -0
- package/lib/src/generated/api/AIPromptExamples.js +2 -0
- package/lib/src/generated/api/AIPromptExamplesInput.d.ts +4 -0
- package/lib/src/generated/api/AIPromptExamplesInput.js +2 -0
- package/lib/src/generated/api/AITask.d.ts +11 -0
- package/lib/src/generated/api/AITaskInput.d.ts +8 -0
- package/lib/src/generated/api/AddAgentInfosRequest.d.ts +3 -0
- package/lib/src/generated/api/AddAgentInfosRequest.js +2 -0
- package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +2 -2
- package/lib/src/generated/api/AddLinkRequest.d.ts +2 -2
- package/lib/src/generated/api/AddLinksBulkRequest.d.ts +2 -2
- package/lib/src/generated/api/AddSdnaRequest.d.ts +2 -2
- package/lib/src/generated/api/Agent.d.ts +6 -0
- package/lib/src/generated/api/AgentAddEntanglementProofsParams.d.ts +9 -0
- package/lib/src/generated/api/AgentByDidParams.d.ts +3 -0
- package/lib/src/generated/api/AgentByDidParams.js +2 -0
- package/lib/src/generated/api/AgentRemoveAppParams.d.ts +3 -0
- package/lib/src/generated/api/AgentRemoveAppParams.js +2 -0
- package/lib/src/generated/api/AgentRevokeTokenParams.d.ts +3 -0
- package/lib/src/generated/api/AgentRevokeTokenParams.js +2 -0
- package/lib/src/generated/api/AgentSignature.d.ts +4 -0
- package/lib/src/generated/api/AgentSignature.js +2 -0
- package/lib/src/generated/api/AgentStatus.d.ts +8 -0
- package/lib/src/generated/api/AgentStatusChangedEvent.d.ts +7 -0
- package/lib/src/generated/api/AgentUpdatedEvent.d.ts +7 -0
- package/lib/src/generated/api/AgentsByDidsRequest.d.ts +3 -0
- package/lib/src/generated/api/AgentsByDidsRequest.js +2 -0
- package/lib/src/generated/api/AiAddModelParams.d.ts +4 -0
- package/lib/src/generated/api/AiAddTaskParams.d.ts +4 -0
- package/lib/src/generated/api/AiDiscoverModelsParams.d.ts +8 -0
- package/lib/src/generated/api/AiDiscoverModelsParams.js +2 -0
- package/lib/src/generated/api/AiGetDefaultModelParams.d.ts +4 -0
- package/lib/src/generated/api/AiIdParams.d.ts +3 -0
- package/lib/src/generated/api/AiIdParams.js +2 -0
- package/lib/src/generated/api/AiModelLoadingStatusParams.d.ts +7 -0
- package/lib/src/generated/api/AiModelLoadingStatusParams.js +2 -0
- package/lib/src/generated/api/AiSetDefaultModelParams.d.ts +5 -0
- package/lib/src/generated/api/AiSetDefaultModelParams.js +1 -0
- package/lib/src/generated/api/AiTranscriptionCloseParams.d.ts +3 -0
- package/lib/src/generated/api/AiTranscriptionCloseParams.js +2 -0
- package/lib/src/generated/api/AiTranscriptionOpenParams.d.ts +5 -0
- package/lib/src/generated/api/AiTranscriptionOpenParams.js +1 -0
- package/lib/src/generated/api/AiUpdateModelParams.d.ts +5 -0
- package/lib/src/generated/api/AiUpdateModelParams.js +1 -0
- package/lib/src/generated/api/AiUpdateTaskParams.d.ts +4 -0
- package/lib/src/generated/api/AiUpdateTaskParams.js +1 -0
- package/lib/src/generated/api/Apps.d.ts +7 -0
- package/lib/src/generated/api/Apps.js +1 -0
- package/lib/src/generated/api/AuthInfo.d.ts +10 -0
- package/lib/src/generated/api/AuthInfo.js +1 -0
- package/lib/src/generated/api/AuthInfoInput.d.ts +4 -4
- package/lib/src/generated/api/AutoProcessorEvent.d.ts +89 -0
- package/lib/src/generated/api/AutoProcessorEvent.js +1 -0
- package/lib/src/generated/api/AutoProcessorNeighbourhoodState.d.ts +32 -0
- package/lib/src/generated/api/AutoProcessorNeighbourhoodState.js +1 -0
- package/lib/src/generated/api/AutoProcessorStep.d.ts +7 -0
- package/lib/src/generated/api/AutoProcessorStep.js +2 -0
- package/lib/src/generated/api/BroadcastRequest.d.ts +5 -0
- package/lib/src/generated/api/BroadcastRequest.js +2 -0
- package/lib/src/generated/api/CallSessionInfo.d.ts +23 -0
- package/lib/src/generated/api/CallSessionInfo.js +2 -0
- package/lib/src/generated/api/Capability.d.ts +5 -0
- package/lib/src/generated/api/Capability.js +1 -0
- package/lib/src/generated/api/CreateSubjectRequest.d.ts +2 -2
- package/lib/src/generated/api/CreateUserRequest.d.ts +4 -0
- package/lib/src/generated/api/CreateUserRequest.js +2 -0
- package/lib/src/generated/api/DateTime.d.ts +1 -0
- package/lib/src/generated/api/DateTime.js +2 -0
- package/lib/src/generated/api/DecoratedExpressionProof.d.ts +6 -0
- package/lib/src/generated/api/DecoratedExpressionProof.js +2 -0
- package/lib/src/generated/api/DecoratedLinkExpression.d.ts +10 -0
- package/lib/src/generated/api/DecoratedLinkExpression.js +1 -0
- package/lib/src/generated/api/DecoratedNeighbourhoodExpression.d.ts +8 -0
- package/lib/src/generated/api/DecoratedNeighbourhoodExpression.js +1 -0
- package/lib/src/generated/api/DecoratedPerspective.d.ts +4 -0
- package/lib/src/generated/api/DecoratedPerspective.js +1 -0
- package/lib/src/generated/api/DiscardBatchRequest.d.ts +3 -0
- package/lib/src/generated/api/DiscardBatchRequest.js +2 -0
- package/lib/src/generated/api/DisposeQueryRequest.d.ts +3 -0
- package/lib/src/generated/api/DisposeQueryRequest.js +2 -0
- package/lib/src/generated/api/EntanglementProof.d.ts +8 -0
- package/lib/src/generated/api/EntanglementProof.js +2 -0
- package/lib/src/generated/api/EntanglementProofInput.d.ts +1 -1
- package/lib/src/generated/api/EntanglementProofPreflightRequest.d.ts +4 -0
- package/lib/src/generated/api/EntanglementProofPreflightRequest.js +2 -0
- package/lib/src/generated/api/EntanglementProofsWrapper.d.ts +7 -0
- package/lib/src/generated/api/EntanglementProofsWrapper.js +1 -0
- package/lib/src/generated/api/Events.d.ts +56 -0
- package/lib/src/generated/api/Events.js +18 -0
- package/lib/src/generated/api/ExceptionInfo.d.ts +7 -0
- package/lib/src/generated/api/ExceptionInfo.js +1 -0
- package/lib/src/generated/api/ExceptionOccurredEvent.d.ts +7 -0
- package/lib/src/generated/api/ExceptionOccurredEvent.js +1 -0
- package/lib/src/generated/api/ExceptionType.d.ts +1 -0
- package/lib/src/generated/api/ExceptionType.js +2 -0
- package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -2
- package/lib/src/generated/api/ExportRequest.d.ts +1 -1
- package/lib/src/generated/api/ExpressionInteractRequest.d.ts +5 -0
- package/lib/src/generated/api/ExpressionInteractRequest.js +1 -0
- package/lib/src/generated/api/ExpressionProofInput.d.ts +4 -4
- package/lib/src/generated/api/ExpressionRendered.d.ts +11 -0
- package/lib/src/generated/api/ExpressionRendered.js +1 -0
- package/lib/src/generated/api/ExpressionUrlRequest.d.ts +3 -0
- package/lib/src/generated/api/ExpressionUrlRequest.js +2 -0
- package/lib/src/generated/api/FireOutcome.d.ts +14 -0
- package/lib/src/generated/api/FireOutcome.js +2 -0
- package/lib/src/generated/api/FlowStateChangedEvent.d.ts +38 -0
- package/lib/src/generated/api/FlowStateChangedEvent.js +2 -0
- package/lib/src/generated/api/FlowStateEntry.d.ts +18 -0
- package/lib/src/generated/api/FlowStateEntry.js +2 -0
- package/lib/src/generated/api/FriendSendMessageRequest.d.ts +1 -1
- package/lib/src/generated/api/HostRate.d.ts +7 -0
- package/lib/src/generated/api/HostRate.js +2 -0
- package/lib/src/generated/api/HostingInfoResult.d.ts +13 -0
- package/lib/src/generated/api/HostingInfoResult.js +1 -0
- package/lib/src/generated/api/HostingInfoUser.d.ts +9 -0
- package/lib/src/generated/api/HostingInfoUser.js +2 -0
- package/lib/src/generated/api/HostingRequestPaymentResult.d.ts +4 -0
- package/lib/src/generated/api/HostingRequestPaymentResult.js +2 -0
- package/lib/src/generated/api/HostingUserInfo.d.ts +6 -0
- package/lib/src/generated/api/HostingUserInfo.js +2 -0
- package/lib/src/generated/api/HostingVersionInfo.d.ts +7 -0
- package/lib/src/generated/api/HostingVersionInfo.js +2 -0
- package/lib/src/generated/api/HostingWalletResult.d.ts +8 -0
- package/lib/src/generated/api/HostingWalletResult.js +1 -0
- package/lib/src/generated/api/IceServer.d.ts +18 -0
- package/lib/src/generated/api/IceServer.js +2 -0
- package/lib/src/generated/api/Icon.d.ts +3 -0
- package/lib/src/generated/api/Icon.js +2 -0
- package/lib/src/generated/api/ImportResult.d.ts +15 -0
- package/lib/src/generated/api/ImportResult.js +1 -0
- package/lib/src/generated/api/ImportStats.d.ts +7 -0
- package/lib/src/generated/api/ImportStats.js +2 -0
- package/lib/src/generated/api/InteractionCall.d.ts +4 -0
- package/lib/src/generated/api/InteractionCall.js +2 -0
- package/lib/src/generated/api/InteractionCallWrapper.d.ts +6 -0
- package/lib/src/generated/api/InteractionCallWrapper.js +2 -0
- package/lib/src/generated/api/InteractionMeta.d.ts +6 -0
- package/lib/src/generated/api/InteractionMeta.js +1 -0
- package/lib/src/generated/api/InteractionParameter.d.ts +4 -0
- package/lib/src/generated/api/InteractionParameter.js +2 -0
- package/lib/src/generated/api/LanguageAddressParams.d.ts +3 -0
- package/lib/src/generated/api/LanguageAddressParams.js +2 -0
- package/lib/src/generated/api/LanguageHandle.d.ts +9 -0
- package/lib/src/generated/api/LanguageHandle.js +1 -0
- package/lib/src/generated/api/LanguageListParams.d.ts +3 -0
- package/lib/src/generated/api/LanguageListParams.js +2 -0
- package/lib/src/generated/api/LanguageMeta.d.ts +11 -0
- package/lib/src/generated/api/LanguageMeta.js +2 -0
- package/lib/src/generated/api/LanguageMetaInput.d.ts +2 -2
- package/lib/src/generated/api/LanguageRef.d.ts +4 -0
- package/lib/src/generated/api/LanguageRef.js +2 -0
- package/lib/src/generated/api/LanguageSettingsWrapper.d.ts +6 -0
- package/lib/src/generated/api/LanguageSettingsWrapper.js +2 -0
- package/lib/src/generated/api/LanguageWriteSettingsParams.d.ts +4 -0
- package/lib/src/generated/api/LanguageWriteSettingsParams.js +2 -0
- package/lib/src/generated/api/LinkExpressionInput.d.ts +1 -1
- package/lib/src/generated/api/LinkInput.d.ts +1 -1
- package/lib/src/generated/api/LinkMutationRequest.d.ts +12 -0
- package/lib/src/generated/api/LinkMutationRequest.js +1 -0
- package/lib/src/generated/api/LinkMutationsRequest.d.ts +5 -0
- package/lib/src/generated/api/LinkMutationsRequest.js +1 -0
- package/lib/src/generated/api/LinkStatus.d.ts +1 -1
- package/lib/src/generated/api/LinkUpdateInput.d.ts +5 -0
- package/lib/src/generated/api/LinkUpdateInput.js +1 -0
- package/lib/src/generated/api/LocalModel.d.ts +7 -0
- package/lib/src/generated/api/LocalModel.js +1 -0
- package/lib/src/generated/api/LocalModelInput.d.ts +7 -0
- package/lib/src/generated/api/LocalModelInput.js +1 -0
- package/lib/src/generated/api/MessageReceivedEvent.d.ts +7 -0
- package/lib/src/generated/api/MessageReceivedEvent.js +1 -0
- package/lib/src/generated/api/Model.d.ts +10 -0
- package/lib/src/generated/api/Model.js +1 -0
- package/lib/src/generated/api/ModelApi.d.ts +17 -0
- package/lib/src/generated/api/ModelApi.js +1 -0
- package/lib/src/generated/api/ModelApiInput.d.ts +11 -0
- package/lib/src/generated/api/ModelApiInput.js +2 -0
- package/lib/src/generated/api/ModelApiType.d.ts +1 -0
- package/lib/src/generated/api/ModelApiType.js +2 -0
- package/lib/src/generated/api/ModelInput.d.ts +9 -0
- package/lib/src/generated/api/ModelInput.js +1 -0
- package/lib/src/generated/api/ModelType.d.ts +1 -1
- package/lib/src/generated/api/Neighbourhood.d.ts +5 -0
- package/lib/src/generated/api/Neighbourhood.js +1 -0
- package/lib/src/generated/api/NeighbourhoodBroadcastParams.d.ts +7 -0
- package/lib/src/generated/api/NeighbourhoodBroadcastParams.js +1 -0
- package/lib/src/generated/api/NeighbourhoodOnlineStatusParams.d.ts +6 -0
- package/lib/src/generated/api/NeighbourhoodOnlineStatusParams.js +1 -0
- package/lib/src/generated/api/NeighbourhoodPerspectivePayload.d.ts +7 -0
- package/lib/src/generated/api/NeighbourhoodPerspectivePayload.js +1 -0
- package/lib/src/generated/api/NeighbourhoodPhase.d.ts +6 -0
- package/lib/src/generated/api/NeighbourhoodPhase.js +2 -0
- package/lib/src/generated/api/NeighbourhoodSignalFilter.d.ts +8 -0
- package/lib/src/generated/api/NeighbourhoodSignalFilter.js +1 -0
- package/lib/src/generated/api/NeighbourhoodSignalParams.d.ts +7 -0
- package/lib/src/generated/api/NeighbourhoodSignalParams.js +1 -0
- package/lib/src/generated/api/NeighbourhoodSignedPerspective.d.ts +8 -0
- package/lib/src/generated/api/NeighbourhoodSignedPerspective.js +1 -0
- package/lib/src/generated/api/NeighbourhoodUuidParams.d.ts +3 -0
- package/lib/src/generated/api/NeighbourhoodUuidParams.js +2 -0
- package/lib/src/generated/api/Notification.d.ts +16 -0
- package/lib/src/generated/api/Notification.js +2 -0
- package/lib/src/generated/api/NotificationGrantRequest.d.ts +6 -0
- package/lib/src/generated/api/NotificationGrantRequest.js +2 -0
- package/lib/src/generated/api/NotificationInput.d.ts +1 -1
- package/lib/src/generated/api/NotificationTriggeredEvent.d.ts +9 -0
- package/lib/src/generated/api/NotificationTriggeredEvent.js +1 -0
- package/lib/src/generated/api/OnlineAgent.d.ts +9 -0
- package/lib/src/generated/api/OnlineAgent.js +1 -0
- package/lib/src/generated/api/OutputRef.d.ts +12 -0
- package/lib/src/generated/api/OutputRef.js +2 -0
- package/lib/src/generated/api/OverlayView.d.ts +24 -0
- package/lib/src/generated/api/OverlayView.js +1 -0
- package/lib/src/generated/api/Perspective.d.ts +4 -0
- package/lib/src/generated/api/Perspective.js +1 -0
- package/lib/src/generated/api/PerspectiveAddAutoProcessorParams.d.ts +26 -0
- package/lib/src/generated/api/PerspectiveAddAutoProcessorParams.js +2 -0
- package/lib/src/generated/api/PerspectiveAddLinkExpressionParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveAddLinkExpressionParams.js +1 -0
- package/lib/src/generated/api/PerspectiveAddLinkParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveAddLinkParams.js +1 -0
- package/lib/src/generated/api/PerspectiveAddLinksParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveAddLinksParams.js +1 -0
- package/lib/src/generated/api/PerspectiveAddSdnaParams.d.ts +14 -0
- package/lib/src/generated/api/PerspectiveAddSdnaParams.js +1 -0
- package/lib/src/generated/api/PerspectiveAddSdnaResult.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveAddSdnaResult.js +2 -0
- package/lib/src/generated/api/PerspectiveCommitBatchParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveCommitBatchParams.js +2 -0
- package/lib/src/generated/api/PerspectiveCreateSubjectParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveCreateSubjectParams.js +2 -0
- package/lib/src/generated/api/PerspectiveDiscardBatchParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveDiscardBatchParams.js +2 -0
- package/lib/src/generated/api/PerspectiveEvaluateGettersParams.d.ts +9 -0
- package/lib/src/generated/api/PerspectiveEvaluateGettersParams.js +2 -0
- package/lib/src/generated/api/PerspectiveExecuteCommandsParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveExecuteCommandsParams.js +2 -0
- package/lib/src/generated/api/PerspectiveExpression.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveExpression.js +1 -0
- package/lib/src/generated/api/PerspectiveFlowFiredParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveFlowFiredParams.js +2 -0
- package/lib/src/generated/api/PerspectiveFlowProposalParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveFlowProposalParams.js +2 -0
- package/lib/src/generated/api/PerspectiveFlowReceiptVerdict.d.ts +12 -0
- package/lib/src/generated/api/PerspectiveFlowReceiptVerdict.js +1 -0
- package/lib/src/generated/api/PerspectiveFlowStatesParams.d.ts +11 -0
- package/lib/src/generated/api/PerspectiveFlowStatesParams.js +2 -0
- package/lib/src/generated/api/PerspectiveFlowValidOutputsParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveFlowValidOutputsParams.js +2 -0
- package/lib/src/generated/api/PerspectiveGetAllShaclParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveGetAllShaclParams.js +2 -0
- package/lib/src/generated/api/PerspectiveGetSubjectDataParams.d.ts +5 -0
- package/lib/src/generated/api/PerspectiveGetSubjectDataParams.js +2 -0
- package/lib/src/generated/api/PerspectiveHandle.d.ts +10 -0
- package/lib/src/generated/api/PerspectiveHandle.js +1 -0
- package/lib/src/generated/api/PerspectiveLinkDiff.d.ts +9 -0
- package/lib/src/generated/api/PerspectiveLinkDiff.js +1 -0
- package/lib/src/generated/api/PerspectiveLinkMutationsParams.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveLinkMutationsParams.js +1 -0
- package/lib/src/generated/api/PerspectiveLinkUpdatedWithOwner.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveLinkUpdatedWithOwner.js +1 -0
- package/lib/src/generated/api/PerspectiveLinkWithOwner.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveLinkWithOwner.js +1 -0
- package/lib/src/generated/api/PerspectiveMintFlowReceiptParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveMintFlowReceiptParams.js +2 -0
- package/lib/src/generated/api/PerspectiveMintFlowReceiptResult.d.ts +9 -0
- package/lib/src/generated/api/PerspectiveMintFlowReceiptResult.js +1 -0
- package/lib/src/generated/api/PerspectiveModelQueryParams.d.ts +13 -0
- package/lib/src/generated/api/PerspectiveModelQueryParams.js +2 -0
- package/lib/src/generated/api/PerspectiveNamedShacl.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveNamedShacl.js +1 -0
- package/lib/src/generated/api/PerspectiveProposeFlowTransitionParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveProposeFlowTransitionParams.js +1 -0
- package/lib/src/generated/api/PerspectiveQueryLinksParams.d.ts +15 -0
- package/lib/src/generated/api/PerspectiveQueryLinksParams.js +2 -0
- package/lib/src/generated/api/PerspectiveQueryParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveQueryParams.js +2 -0
- package/lib/src/generated/api/PerspectiveReceiptOutcome.d.ts +1 -0
- package/lib/src/generated/api/PerspectiveReceiptOutcome.js +2 -0
- package/lib/src/generated/api/PerspectiveRejectFlowProposalResult.d.ts +3 -0
- package/lib/src/generated/api/PerspectiveRejectFlowProposalResult.js +2 -0
- package/lib/src/generated/api/PerspectiveRemoveAutoProcessorParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveRemoveAutoProcessorParams.js +2 -0
- package/lib/src/generated/api/PerspectiveRemoveLinkParams.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveRemoveLinkParams.js +1 -0
- package/lib/src/generated/api/PerspectiveRemoveLinksParams.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveRemoveLinksParams.js +1 -0
- package/lib/src/generated/api/PerspectiveRemoveSubjectParams.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveRemoveSubjectParams.js +2 -0
- package/lib/src/generated/api/PerspectiveRemovedWithOwner.d.ts +5 -0
- package/lib/src/generated/api/PerspectiveRemovedWithOwner.js +2 -0
- package/lib/src/generated/api/PerspectiveResolveInterpretationParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveResolveInterpretationParams.js +2 -0
- package/lib/src/generated/api/PerspectiveResynced.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveResynced.js +2 -0
- package/lib/src/generated/api/PerspectiveShacl.d.ts +5 -0
- package/lib/src/generated/api/PerspectiveShacl.js +1 -0
- package/lib/src/generated/api/PerspectiveShaclNameParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveShaclNameParams.js +2 -0
- package/lib/src/generated/api/PerspectiveSparqlParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveSparqlParams.js +2 -0
- package/lib/src/generated/api/PerspectiveState.d.ts +1 -0
- package/lib/src/generated/api/PerspectiveState.js +2 -0
- package/lib/src/generated/api/PerspectiveStateFilter.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveStateFilter.js +1 -0
- package/lib/src/generated/api/PerspectiveSubjectClassesOfParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveSubjectClassesOfParams.js +2 -0
- package/lib/src/generated/api/PerspectiveSubscribed.d.ts +10 -0
- package/lib/src/generated/api/PerspectiveSubscribed.js +2 -0
- package/lib/src/generated/api/PerspectiveSubscriptionParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveSubscriptionParams.js +2 -0
- package/lib/src/generated/api/PerspectiveUnsignedInput.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveUnsignedInput.js +1 -0
- package/lib/src/generated/api/PerspectiveUpdateLinkParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveUpdateLinkParams.js +1 -0
- package/lib/src/generated/api/PerspectiveUpdateParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveUpdateParams.js +2 -0
- package/lib/src/generated/api/PerspectiveUpdateSubjectParams.d.ts +10 -0
- package/lib/src/generated/api/PerspectiveUpdateSubjectParams.js +2 -0
- package/lib/src/generated/api/PerspectiveUuidParams.d.ts +3 -0
- package/lib/src/generated/api/PerspectiveUuidParams.js +2 -0
- package/lib/src/generated/api/PerspectiveVerifyFlowReceiptParams.d.ts +9 -0
- package/lib/src/generated/api/PerspectiveVerifyFlowReceiptParams.js +1 -0
- package/lib/src/generated/api/PerspectiveWithOwner.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveWithOwner.js +1 -0
- package/lib/src/generated/api/ProposeOutcome.d.ts +45 -0
- package/lib/src/generated/api/ProposeOutcome.js +1 -0
- package/lib/src/generated/api/PublicPerspectiveInput.d.ts +4 -0
- package/lib/src/generated/api/PublicPerspectiveInput.js +1 -0
- package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +2 -2
- package/lib/src/generated/api/QuerySubscriptionUpdate.d.ts +19 -0
- package/lib/src/generated/api/QuerySubscriptionUpdate.js +2 -0
- package/lib/src/generated/api/QuerySubscriptionUpdateEvent.d.ts +7 -0
- package/lib/src/generated/api/QuerySubscriptionUpdateEvent.js +1 -0
- package/lib/src/generated/api/QueryUpdatesLagged.d.ts +7 -0
- package/lib/src/generated/api/QueryUpdatesLagged.js +2 -0
- package/lib/src/generated/api/RemoveLinkRequest.d.ts +1 -1
- package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +1 -1
- package/lib/src/generated/api/RemoveSubjectRequest.d.ts +9 -0
- package/lib/src/generated/api/RemoveSubjectRequest.js +2 -0
- package/lib/src/generated/api/RequestCapabilityRequest.d.ts +4 -0
- package/lib/src/generated/api/RequestCapabilityRequest.js +1 -0
- package/lib/src/generated/api/RequestPaymentRequest.d.ts +3 -0
- package/lib/src/generated/api/RequestPaymentRequest.js +2 -0
- package/lib/src/generated/api/Resource.d.ts +4 -0
- package/lib/src/generated/api/Resource.js +2 -0
- package/lib/src/generated/api/ResyncSubscriptionRequest.d.ts +3 -0
- package/lib/src/generated/api/ResyncSubscriptionRequest.js +2 -0
- package/lib/src/generated/api/RpcMethods.d.ts +961 -0
- package/lib/src/generated/api/RpcMethods.js +98 -0
- package/lib/src/generated/api/RunInterpretationRequest.d.ts +27 -1
- package/lib/src/generated/api/RunInterpretationWithHarnessRequest.d.ts +52 -0
- package/lib/src/generated/api/RunInterpretationWithHarnessRequest.js +1 -0
- package/lib/src/generated/api/RuntimeComputeLogParams.d.ts +14 -0
- package/lib/src/generated/api/RuntimeComputeLogParams.js +2 -0
- package/lib/src/generated/api/RuntimeFriendStatusParams.d.ts +3 -0
- package/lib/src/generated/api/RuntimeFriendStatusParams.js +2 -0
- package/lib/src/generated/api/RuntimeGrantNotificationParams.d.ts +4 -0
- package/lib/src/generated/api/RuntimeGrantNotificationParams.js +2 -0
- package/lib/src/generated/api/RuntimeImportPerspectiveResult.d.ts +4 -0
- package/lib/src/generated/api/RuntimeImportPerspectiveResult.js +2 -0
- package/lib/src/generated/api/RuntimeImportResult.d.ts +6 -0
- package/lib/src/generated/api/RuntimeImportResult.js +1 -0
- package/lib/src/generated/api/RuntimeInfo.d.ts +5 -0
- package/lib/src/generated/api/RuntimeInfo.js +2 -0
- package/lib/src/generated/api/RuntimeNotificationIdParams.d.ts +3 -0
- package/lib/src/generated/api/RuntimeNotificationIdParams.js +2 -0
- package/lib/src/generated/api/RuntimeSendFriendMessageParams.d.ts +8 -0
- package/lib/src/generated/api/RuntimeSendFriendMessageParams.js +1 -0
- package/lib/src/generated/api/RuntimeSetFreeHostingEnabledParams.d.ts +3 -0
- package/lib/src/generated/api/RuntimeSetFreeHostingEnabledParams.js +2 -0
- package/lib/src/generated/api/RuntimeUnytSendHotParams.d.ts +4 -0
- package/lib/src/generated/api/RuntimeUnytSendHotParams.js +2 -0
- package/lib/src/generated/api/RuntimeUnytWalletHistoryParams.d.ts +4 -0
- package/lib/src/generated/api/RuntimeUnytWalletHistoryParams.js +2 -0
- package/lib/src/generated/api/RuntimeUpdateNotificationParams.d.ts +11 -0
- package/lib/src/generated/api/RuntimeUpdateNotificationParams.js +2 -0
- package/lib/src/generated/api/SentMessage.d.ts +5 -0
- package/lib/src/generated/api/SentMessage.js +1 -0
- package/lib/src/generated/api/SetHostRatesRequest.d.ts +4 -0
- package/lib/src/generated/api/SetHostRatesRequest.js +1 -0
- package/lib/src/generated/api/SetHotWalletAddressRequest.d.ts +3 -0
- package/lib/src/generated/api/SetHotWalletAddressRequest.js +2 -0
- package/lib/src/generated/api/SetOnlineStatusRequest.d.ts +4 -0
- package/lib/src/generated/api/SetOnlineStatusRequest.js +2 -0
- package/lib/src/generated/api/SetUnytMembraneProofRequest.d.ts +6 -0
- package/lib/src/generated/api/SetUnytMembraneProofRequest.js +2 -0
- package/lib/src/generated/api/SetUserFreeAccessRequest.d.ts +4 -0
- package/lib/src/generated/api/SetUserFreeAccessRequest.js +2 -0
- package/lib/src/generated/api/SfuAddIceCandidateParams.d.ts +8 -0
- package/lib/src/generated/api/SfuAddIceCandidateParams.js +2 -0
- package/lib/src/generated/api/SfuAnswerServerOfferParams.d.ts +8 -0
- package/lib/src/generated/api/SfuAnswerServerOfferParams.js +2 -0
- package/lib/src/generated/api/SfuCallJoinParams.d.ts +14 -0
- package/lib/src/generated/api/SfuCallJoinParams.js +2 -0
- package/lib/src/generated/api/SfuCallRenegotiationOffer.d.ts +30 -0
- package/lib/src/generated/api/SfuCallRenegotiationOffer.js +1 -0
- package/lib/src/generated/api/SfuCascadePipe.d.ts +4 -0
- package/lib/src/generated/api/SfuCascadePipe.js +2 -0
- package/lib/src/generated/api/SfuCascadeStatus.d.ts +8 -0
- package/lib/src/generated/api/SfuCascadeStatus.js +1 -0
- package/lib/src/generated/api/SfuConfig.d.ts +52 -0
- package/lib/src/generated/api/SfuConfig.js +1 -0
- package/lib/src/generated/api/SfuDataMessage.d.ts +24 -0
- package/lib/src/generated/api/SfuDataMessage.js +2 -0
- package/lib/src/generated/api/SfuEnsureMembershipParams.d.ts +4 -0
- package/lib/src/generated/api/SfuEnsureMembershipParams.js +2 -0
- package/lib/src/generated/api/SfuMigrateEvent.d.ts +21 -0
- package/lib/src/generated/api/SfuMigrateEvent.js +2 -0
- package/lib/src/generated/api/SfuNeighbourhoodParams.d.ts +3 -0
- package/lib/src/generated/api/SfuNeighbourhoodParams.js +2 -0
- package/lib/src/generated/api/SfuParticipantQualityPreference.d.ts +7 -0
- package/lib/src/generated/api/SfuParticipantQualityPreference.js +2 -0
- package/lib/src/generated/api/SfuPerspectiveParams.d.ts +6 -0
- package/lib/src/generated/api/SfuPerspectiveParams.js +2 -0
- package/lib/src/generated/api/SfuQualityPreferenceParams.d.ts +8 -0
- package/lib/src/generated/api/SfuQualityPreferenceParams.js +2 -0
- package/lib/src/generated/api/SfuRoomInfo.d.ts +11 -0
- package/lib/src/generated/api/SfuRoomInfo.js +1 -0
- package/lib/src/generated/api/SfuRoomParams.d.ts +4 -0
- package/lib/src/generated/api/SfuRoomParams.js +2 -0
- package/lib/src/generated/api/SfuRoomParticipantInfo.d.ts +11 -0
- package/lib/src/generated/api/SfuRoomParticipantInfo.js +2 -0
- package/lib/src/generated/api/SfuRoomRoster.d.ts +13 -0
- package/lib/src/generated/api/SfuRoomRoster.js +2 -0
- package/lib/src/generated/api/SfuSendDataParams.d.ts +10 -0
- package/lib/src/generated/api/SfuSendDataParams.js +2 -0
- package/lib/src/generated/api/SfuSetConfigParams.d.ts +5 -0
- package/lib/src/generated/api/SfuSetConfigParams.js +1 -0
- package/lib/src/generated/api/SfuStatus.d.ts +24 -0
- package/lib/src/generated/api/SfuStatus.js +2 -0
- package/lib/src/generated/api/ShaclLinkTriple.d.ts +10 -0
- package/lib/src/generated/api/ShaclLinkTriple.js +2 -0
- package/lib/src/generated/api/SignalRequest.d.ts +5 -0
- package/lib/src/generated/api/SignalRequest.js +2 -0
- package/lib/src/generated/api/SubscribeQueryRequest.d.ts +3 -0
- package/lib/src/generated/api/SubscribeQueryRequest.js +2 -0
- package/lib/src/generated/api/TokenizerSource.d.ts +5 -0
- package/lib/src/generated/api/TokenizerSource.js +2 -0
- package/lib/src/generated/api/TokenizerSourceInput.d.ts +5 -0
- package/lib/src/generated/api/TokenizerSourceInput.js +2 -0
- package/lib/src/generated/api/TrackMapEntry.d.ts +17 -0
- package/lib/src/generated/api/TrackMapEntry.js +2 -0
- package/lib/src/generated/api/TranscriptionTextFilter.d.ts +5 -0
- package/lib/src/generated/api/TranscriptionTextFilter.js +2 -0
- package/lib/src/generated/api/TriggeredNotification.d.ts +6 -0
- package/lib/src/generated/api/TriggeredNotification.js +1 -0
- package/lib/src/generated/api/TrustedAgentsWrapper.d.ts +6 -0
- package/lib/src/generated/api/TrustedAgentsWrapper.js +2 -0
- package/lib/src/generated/api/UnlockAgentRequest.d.ts +1 -1
- package/lib/src/generated/api/UnytVersionInfo.d.ts +19 -0
- package/lib/src/generated/api/UnytVersionInfo.js +2 -0
- package/lib/src/generated/api/UpdateLinkRequest.d.ts +1 -1
- package/lib/src/generated/api/UpdateProfileRequest.d.ts +5 -0
- package/lib/src/generated/api/UpdateProfileRequest.js +1 -0
- package/lib/src/generated/api/UpdateSubjectRequest.d.ts +12 -0
- package/lib/src/generated/api/UpdateSubjectRequest.js +2 -0
- package/lib/src/generated/api/UserCreationResult.d.ts +5 -0
- package/lib/src/generated/api/UserCreationResult.js +2 -0
- package/lib/src/generated/api/UserStatistics.d.ts +2 -1
- package/lib/src/generated/api/UserStatistics.js +0 -1
- package/lib/src/generated/api/UsersAppInfo.d.ts +6 -0
- package/lib/src/generated/api/UsersAppInfo.js +2 -0
- package/lib/src/generated/api/UsersEmailParams.d.ts +3 -0
- package/lib/src/generated/api/UsersEmailParams.js +2 -0
- package/lib/src/generated/api/UsersEmailTestAction.d.ts +1 -0
- package/lib/src/generated/api/UsersEmailTestAction.js +2 -0
- package/lib/src/generated/api/UsersEmailTestParams.d.ts +14 -0
- package/lib/src/generated/api/UsersEmailTestParams.js +1 -0
- package/lib/src/generated/api/UsersEmailTestResult.d.ts +5 -0
- package/lib/src/generated/api/UsersEmailTestResult.js +2 -0
- package/lib/src/generated/api/UsersLoginParams.d.ts +8 -0
- package/lib/src/generated/api/UsersLoginParams.js +2 -0
- package/lib/src/generated/api/UsersRequestVerificationParams.d.ts +5 -0
- package/lib/src/generated/api/UsersRequestVerificationParams.js +1 -0
- package/lib/src/generated/api/UsersSetCreditsParams.d.ts +4 -0
- package/lib/src/generated/api/UsersSetCreditsParams.js +2 -0
- package/lib/src/generated/api/UsersVerifyEmailParams.d.ts +12 -0
- package/lib/src/generated/api/UsersVerifyEmailParams.js +2 -0
- package/lib/src/generated/api/ValidOutput.d.ts +29 -0
- package/lib/src/generated/api/ValidOutput.js +1 -0
- package/lib/src/generated/api/VoiceActivityParamsInput.d.ts +7 -0
- package/lib/src/generated/api/VoiceActivityParamsInput.js +2 -0
- package/lib/src/generated/api/index.d.ts +11 -0
- package/lib/src/generated/api/index.js +5 -3
- package/lib/src/generated/api/serde_json/JsonValue.d.ts +3 -0
- package/lib/src/generated/api/serde_json/JsonValue.js +2 -0
- package/lib/src/index.d.ts +9 -3
- package/lib/src/index.js +5 -3
- package/lib/src/language/LanguageClient.d.ts +3 -3
- package/lib/src/language/LanguageClient.js +6 -6
- package/lib/src/language/LanguageMeta.d.ts +1 -1
- package/lib/src/links/Links.d.ts +16 -5
- package/lib/src/links/Links.js +34 -0
- package/lib/src/model/Ad4mModel.d.ts +84 -0
- package/lib/src/model/Ad4mModel.js +365 -72
- package/lib/src/model/ModelQueryBuilder.d.ts +15 -13
- package/lib/src/model/ModelQueryBuilder.js +78 -221
- package/lib/src/model/decorators.d.ts +52 -2
- package/lib/src/model/decorators.js +83 -8
- package/lib/src/model/query-sparql.js +2 -3
- package/lib/src/model/shacl-gen.d.ts +3 -1
- package/lib/src/model/shacl-gen.js +40 -10
- package/lib/src/model/types.d.ts +19 -0
- package/lib/src/neighbourhood/MeshManager.d.ts +384 -0
- package/lib/src/neighbourhood/MeshManager.js +1144 -0
- package/lib/src/neighbourhood/Neighbourhood.d.ts +1 -1
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +96 -5
- package/lib/src/neighbourhood/NeighbourhoodClient.js +211 -15
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +55 -1
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +170 -3
- package/lib/src/neighbourhood/Session.d.ts +105 -0
- package/lib/src/neighbourhood/Session.js +412 -0
- package/lib/src/neighbourhood/SfuManager.d.ts +174 -0
- package/lib/src/neighbourhood/SfuManager.js +619 -0
- package/lib/src/neighbourhood/SfuTypes.d.ts +35 -0
- package/lib/src/neighbourhood/SfuTypes.js +8 -0
- package/lib/src/notifyListeners.d.ts +2 -0
- package/lib/src/notifyListeners.js +12 -0
- package/lib/src/perspectives/AutoProcessor.d.ts +12 -80
- package/lib/src/perspectives/FlowInstance.d.ts +73 -26
- package/lib/src/perspectives/FlowInstance.js +96 -31
- package/lib/src/perspectives/FlowModels.d.ts +30 -9
- package/lib/src/perspectives/FlowModels.js +43 -14
- package/lib/src/perspectives/InterpretationModels.d.ts +2 -0
- package/lib/src/perspectives/InterpretationModels.js +6 -0
- package/lib/src/perspectives/LiveQuery.d.ts +49 -0
- package/lib/src/perspectives/LiveQuery.js +169 -0
- package/lib/src/perspectives/Perspective.d.ts +8 -1
- package/lib/src/perspectives/Perspective.js +11 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +38 -65
- package/lib/src/perspectives/PerspectiveClient.js +87 -257
- package/lib/src/perspectives/PerspectiveDiff.d.ts +1 -1
- package/lib/src/perspectives/PerspectiveHandle.d.ts +15 -8
- package/lib/src/perspectives/PerspectiveHandle.js +25 -9
- package/lib/src/perspectives/PerspectiveProxy.d.ts +102 -228
- package/lib/src/perspectives/PerspectiveProxy.js +247 -673
- package/lib/src/perspectives/TextContent.d.ts +31 -0
- package/lib/src/perspectives/TextContent.js +52 -0
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +23 -0
- package/lib/src/perspectives/WakerSubscriptionManager.js +58 -21
- package/lib/src/runtime/RuntimeClient.d.ts +15 -27
- package/lib/src/runtime/RuntimeClient.js +57 -113
- package/lib/src/runtime/RuntimeTypes.d.ts +2 -2
- package/lib/src/runtime/RuntimeTypes.js +2 -2
- package/lib/src/shacl/SHACLFlow.d.ts +34 -6
- package/lib/src/shacl/SHACLFlow.js +62 -15
- package/lib/src/shacl/SHACLShape.d.ts +12 -0
- package/lib/src/shacl/SHACLShape.js +206 -321
- package/package.json +15 -16
- package/pnpm-workspace.yaml +4 -1
- package/src/Ad4mClient.test.ts +481 -144
- package/src/Ad4mClient.ts +16 -12
- package/src/Literal.test.ts +32 -0
- package/src/Literal.ts +3 -3
- package/src/agent/Agent.ts +8 -0
- package/src/agent/AgentClient.ts +87 -195
- package/src/agent/mutatePublicPerspective.test.ts +110 -0
- package/src/ai/AIClient.ts +40 -43
- package/src/ai/transcription-stream.test.ts +54 -0
- package/src/apiClient.test.ts +613 -185
- package/src/apiClient.ts +282 -288
- package/src/cache/cache.test.ts +7 -8
- package/src/expression/Expression.ts +12 -3
- package/src/expression/ExpressionClient.ts +6 -7
- package/src/generated/api/AIPromptExamples.ts +3 -0
- package/src/generated/api/AIPromptExamplesInput.ts +3 -0
- package/src/generated/api/AITask.ts +4 -0
- package/src/generated/api/AITaskInput.ts +4 -0
- package/src/generated/api/AddAgentInfosRequest.ts +3 -0
- package/src/generated/api/AddLinkExpressionRequest.ts +1 -1
- package/src/generated/api/AddLinkRequest.ts +1 -1
- package/src/generated/api/AddLinksBulkRequest.ts +1 -1
- package/src/generated/api/AddSdnaRequest.ts +1 -1
- package/src/generated/api/Agent.ts +4 -0
- package/src/generated/api/AgentAddEntanglementProofsParams.ts +8 -0
- package/src/generated/api/AgentByDidParams.ts +3 -0
- package/src/generated/api/AgentRemoveAppParams.ts +3 -0
- package/src/generated/api/AgentRevokeTokenParams.ts +3 -0
- package/src/generated/api/AgentSignature.ts +3 -0
- package/src/generated/api/AgentStatus.ts +4 -0
- package/src/generated/api/AgentStatusChangedEvent.ts +7 -0
- package/src/generated/api/AgentUpdatedEvent.ts +7 -0
- package/src/generated/api/AgentsByDidsRequest.ts +3 -0
- package/src/generated/api/AiAddModelParams.ts +4 -0
- package/src/generated/api/AiAddTaskParams.ts +4 -0
- package/src/generated/api/AiDiscoverModelsParams.ts +7 -0
- package/src/generated/api/AiGetDefaultModelParams.ts +4 -0
- package/src/generated/api/AiIdParams.ts +3 -0
- package/src/generated/api/AiModelLoadingStatusParams.ts +6 -0
- package/src/generated/api/AiSetDefaultModelParams.ts +4 -0
- package/src/generated/api/AiTranscriptionCloseParams.ts +3 -0
- package/src/generated/api/AiTranscriptionOpenParams.ts +4 -0
- package/src/generated/api/AiUpdateModelParams.ts +4 -0
- package/src/generated/api/AiUpdateTaskParams.ts +4 -0
- package/src/generated/api/Apps.ts +4 -0
- package/src/generated/api/AuthInfo.ts +4 -0
- package/src/generated/api/AuthInfoInput.ts +1 -1
- package/src/generated/api/AutoProcessorEvent.ts +90 -0
- package/src/generated/api/AutoProcessorNeighbourhoodState.ts +33 -0
- package/src/generated/api/AutoProcessorStep.ts +9 -0
- package/src/generated/api/BroadcastRequest.ts +3 -0
- package/src/generated/api/CallSessionInfo.ts +20 -0
- package/src/generated/api/Capability.ts +4 -0
- package/src/generated/api/CreateSubjectRequest.ts +1 -1
- package/src/generated/api/CreateUserRequest.ts +3 -0
- package/src/generated/api/DateTime.ts +3 -0
- package/src/generated/api/DecoratedExpressionProof.ts +3 -0
- package/src/generated/api/DecoratedLinkExpression.ts +6 -0
- package/src/generated/api/DecoratedNeighbourhoodExpression.ts +5 -0
- package/src/generated/api/DecoratedPerspective.ts +4 -0
- package/src/generated/api/DiscardBatchRequest.ts +3 -0
- package/src/generated/api/DisposeQueryRequest.ts +3 -0
- package/src/generated/api/EntanglementProof.ts +3 -0
- package/src/generated/api/EntanglementProofInput.ts +1 -1
- package/src/generated/api/EntanglementProofPreflightRequest.ts +3 -0
- package/src/generated/api/EntanglementProofsWrapper.ts +7 -0
- package/src/generated/api/Events.ts +77 -0
- package/src/generated/api/ExceptionInfo.ts +4 -0
- package/src/generated/api/ExceptionOccurredEvent.ts +7 -0
- package/src/generated/api/ExceptionType.ts +3 -0
- package/src/generated/api/ExecuteCommandsRequest.ts +1 -1
- package/src/generated/api/ExportRequest.ts +1 -1
- package/src/generated/api/ExpressionInteractRequest.ts +4 -0
- package/src/generated/api/ExpressionProofInput.ts +1 -1
- package/src/generated/api/ExpressionRendered.ts +6 -0
- package/src/generated/api/ExpressionUrlRequest.ts +3 -0
- package/src/generated/api/FireOutcome.ts +11 -0
- package/src/generated/api/FlowStateChangedEvent.ts +36 -0
- package/src/generated/api/FlowStateEntry.ts +18 -0
- package/src/generated/api/FriendSendMessageRequest.ts +1 -1
- package/src/generated/api/HostRate.ts +6 -0
- package/src/generated/api/HostingInfoResult.ts +13 -0
- package/src/generated/api/HostingInfoUser.ts +7 -0
- package/src/generated/api/HostingRequestPaymentResult.ts +3 -0
- package/src/generated/api/HostingUserInfo.ts +3 -0
- package/src/generated/api/HostingVersionInfo.ts +7 -0
- package/src/generated/api/HostingWalletResult.ts +8 -0
- package/src/generated/api/IceServer.ts +19 -0
- package/src/generated/api/Icon.ts +3 -0
- package/src/generated/api/ImportResult.ts +4 -0
- package/src/generated/api/ImportStats.ts +3 -0
- package/src/generated/api/InteractionCall.ts +3 -0
- package/src/generated/api/InteractionCallWrapper.ts +6 -0
- package/src/generated/api/InteractionMeta.ts +4 -0
- package/src/generated/api/InteractionParameter.ts +3 -0
- package/src/generated/api/LanguageAddressParams.ts +3 -0
- package/src/generated/api/LanguageHandle.ts +4 -0
- package/src/generated/api/LanguageListParams.ts +3 -0
- package/src/generated/api/LanguageMeta.ts +3 -0
- package/src/generated/api/LanguageMetaInput.ts +1 -1
- package/src/generated/api/LanguageRef.ts +3 -0
- package/src/generated/api/LanguageSettingsWrapper.ts +6 -0
- package/src/generated/api/LanguageWriteSettingsParams.ts +3 -0
- package/src/generated/api/LinkExpressionInput.ts +1 -1
- package/src/generated/api/LinkInput.ts +1 -1
- package/src/generated/api/LinkMutationRequest.ts +8 -0
- package/src/generated/api/LinkMutationsRequest.ts +4 -0
- package/src/generated/api/LinkStatus.ts +1 -1
- package/src/generated/api/LinkUpdateInput.ts +4 -0
- package/src/generated/api/LocalModel.ts +4 -0
- package/src/generated/api/LocalModelInput.ts +4 -0
- package/src/generated/api/MessageReceivedEvent.ts +7 -0
- package/src/generated/api/Model.ts +6 -0
- package/src/generated/api/ModelApi.ts +14 -0
- package/src/generated/api/ModelApiInput.ts +8 -0
- package/src/generated/api/ModelApiType.ts +3 -0
- package/src/generated/api/ModelInput.ts +6 -0
- package/src/generated/api/ModelType.ts +1 -1
- package/src/generated/api/Neighbourhood.ts +4 -0
- package/src/generated/api/NeighbourhoodBroadcastParams.ts +4 -0
- package/src/generated/api/NeighbourhoodOnlineStatusParams.ts +4 -0
- package/src/generated/api/NeighbourhoodPerspectivePayload.ts +9 -0
- package/src/generated/api/NeighbourhoodPhase.ts +8 -0
- package/src/generated/api/NeighbourhoodSignalFilter.ts +5 -0
- package/src/generated/api/NeighbourhoodSignalParams.ts +4 -0
- package/src/generated/api/NeighbourhoodSignedPerspective.ts +8 -0
- package/src/generated/api/NeighbourhoodUuidParams.ts +3 -0
- package/src/generated/api/Notification.ts +7 -0
- package/src/generated/api/NotificationGrantRequest.ts +6 -0
- package/src/generated/api/NotificationInput.ts +1 -1
- package/src/generated/api/NotificationTriggeredEvent.ts +8 -0
- package/src/generated/api/OnlineAgent.ts +9 -0
- package/src/generated/api/OutputRef.ts +11 -0
- package/src/generated/api/OverlayView.ts +25 -0
- package/src/generated/api/Perspective.ts +4 -0
- package/src/generated/api/PerspectiveAddAutoProcessorParams.ts +11 -0
- package/src/generated/api/PerspectiveAddLinkExpressionParams.ts +4 -0
- package/src/generated/api/PerspectiveAddLinkParams.ts +4 -0
- package/src/generated/api/PerspectiveAddLinksParams.ts +4 -0
- package/src/generated/api/PerspectiveAddSdnaParams.ts +7 -0
- package/src/generated/api/PerspectiveAddSdnaResult.ts +6 -0
- package/src/generated/api/PerspectiveCommitBatchParams.ts +3 -0
- package/src/generated/api/PerspectiveCreateSubjectParams.ts +3 -0
- package/src/generated/api/PerspectiveDiscardBatchParams.ts +3 -0
- package/src/generated/api/PerspectiveEvaluateGettersParams.ts +6 -0
- package/src/generated/api/PerspectiveExecuteCommandsParams.ts +3 -0
- package/src/generated/api/PerspectiveExpression.ts +5 -0
- package/src/generated/api/PerspectiveFlowFiredParams.ts +7 -0
- package/src/generated/api/PerspectiveFlowProposalParams.ts +3 -0
- package/src/generated/api/PerspectiveFlowReceiptVerdict.ts +8 -0
- package/src/generated/api/PerspectiveFlowStatesParams.ts +11 -0
- package/src/generated/api/PerspectiveFlowValidOutputsParams.ts +7 -0
- package/src/generated/api/PerspectiveGetAllShaclParams.ts +6 -0
- package/src/generated/api/PerspectiveGetSubjectDataParams.ts +3 -0
- package/src/generated/api/PerspectiveHandle.ts +5 -0
- package/src/generated/api/PerspectiveLinkDiff.ts +7 -0
- package/src/generated/api/PerspectiveLinkMutationsParams.ts +4 -0
- package/src/generated/api/PerspectiveLinkUpdatedWithOwner.ts +4 -0
- package/src/generated/api/PerspectiveLinkWithOwner.ts +4 -0
- package/src/generated/api/PerspectiveMintFlowReceiptParams.ts +3 -0
- package/src/generated/api/PerspectiveMintFlowReceiptResult.ts +9 -0
- package/src/generated/api/PerspectiveModelQueryParams.ts +10 -0
- package/src/generated/api/PerspectiveNamedShacl.ts +4 -0
- package/src/generated/api/PerspectiveProposeFlowTransitionParams.ts +4 -0
- package/src/generated/api/PerspectiveQueryLinksParams.ts +11 -0
- package/src/generated/api/PerspectiveQueryParams.ts +3 -0
- package/src/generated/api/PerspectiveReceiptOutcome.ts +3 -0
- package/src/generated/api/PerspectiveRejectFlowProposalResult.ts +3 -0
- package/src/generated/api/PerspectiveRemoveAutoProcessorParams.ts +3 -0
- package/src/generated/api/PerspectiveRemoveLinkParams.ts +4 -0
- package/src/generated/api/PerspectiveRemoveLinksParams.ts +4 -0
- package/src/generated/api/PerspectiveRemoveSubjectParams.ts +3 -0
- package/src/generated/api/PerspectiveRemovedWithOwner.ts +3 -0
- package/src/generated/api/PerspectiveResolveInterpretationParams.ts +6 -0
- package/src/generated/api/PerspectiveResynced.ts +7 -0
- package/src/generated/api/PerspectiveShacl.ts +4 -0
- package/src/generated/api/PerspectiveShaclNameParams.ts +3 -0
- package/src/generated/api/PerspectiveSparqlParams.ts +7 -0
- package/src/generated/api/PerspectiveState.ts +3 -0
- package/src/generated/api/PerspectiveStateFilter.ts +5 -0
- package/src/generated/api/PerspectiveSubjectClassesOfParams.ts +3 -0
- package/src/generated/api/PerspectiveSubscribed.ts +8 -0
- package/src/generated/api/PerspectiveSubscriptionParams.ts +3 -0
- package/src/generated/api/PerspectiveUnsignedInput.ts +4 -0
- package/src/generated/api/PerspectiveUpdateLinkParams.ts +5 -0
- package/src/generated/api/PerspectiveUpdateParams.ts +3 -0
- package/src/generated/api/PerspectiveUpdateSubjectParams.ts +7 -0
- package/src/generated/api/PerspectiveUuidParams.ts +3 -0
- package/src/generated/api/PerspectiveVerifyFlowReceiptParams.ts +9 -0
- package/src/generated/api/PerspectiveWithOwner.ts +4 -0
- package/src/generated/api/ProposeOutcome.ts +46 -0
- package/src/generated/api/PublicPerspectiveInput.ts +4 -0
- package/src/generated/api/PublishNeighbourhoodRequest.ts +2 -2
- package/src/generated/api/QuerySubscriptionUpdate.ts +10 -0
- package/src/generated/api/QuerySubscriptionUpdateEvent.ts +9 -0
- package/src/generated/api/QueryUpdatesLagged.ts +7 -0
- package/src/generated/api/RemoveLinkRequest.ts +1 -1
- package/src/generated/api/RemoveLinksBulkRequest.ts +1 -1
- package/src/generated/api/RemoveSubjectRequest.ts +7 -0
- package/src/generated/api/RequestCapabilityRequest.ts +4 -0
- package/src/generated/api/RequestPaymentRequest.ts +3 -0
- package/src/generated/api/Resource.ts +3 -0
- package/src/generated/api/ResyncSubscriptionRequest.ts +3 -0
- package/src/generated/api/RpcMethods.ts +479 -0
- package/src/generated/api/RunInterpretationRequest.ts +28 -2
- package/src/generated/api/RunInterpretationWithHarnessRequest.ts +51 -0
- package/src/generated/api/RuntimeComputeLogParams.ts +15 -0
- package/src/generated/api/RuntimeFriendStatusParams.ts +3 -0
- package/src/generated/api/RuntimeGrantNotificationParams.ts +3 -0
- package/src/generated/api/RuntimeImportPerspectiveResult.ts +3 -0
- package/src/generated/api/RuntimeImportResult.ts +8 -0
- package/src/generated/api/RuntimeInfo.ts +3 -0
- package/src/generated/api/RuntimeNotificationIdParams.ts +3 -0
- package/src/generated/api/RuntimeSendFriendMessageParams.ts +8 -0
- package/src/generated/api/RuntimeSetFreeHostingEnabledParams.ts +3 -0
- package/src/generated/api/RuntimeUnytSendHotParams.ts +3 -0
- package/src/generated/api/RuntimeUnytWalletHistoryParams.ts +3 -0
- package/src/generated/api/RuntimeUpdateNotificationParams.ts +3 -0
- package/src/generated/api/SentMessage.ts +4 -0
- package/src/generated/api/SetHostRatesRequest.ts +4 -0
- package/src/generated/api/SetHotWalletAddressRequest.ts +3 -0
- package/src/generated/api/SetOnlineStatusRequest.ts +3 -0
- package/src/generated/api/SetUnytMembraneProofRequest.ts +7 -0
- package/src/generated/api/SetUserFreeAccessRequest.ts +3 -0
- package/src/generated/api/SfuAddIceCandidateParams.ts +7 -0
- package/src/generated/api/SfuAnswerServerOfferParams.ts +7 -0
- package/src/generated/api/SfuCallJoinParams.ts +13 -0
- package/src/generated/api/SfuCallRenegotiationOffer.ts +29 -0
- package/src/generated/api/SfuCascadePipe.ts +3 -0
- package/src/generated/api/SfuCascadeStatus.ts +7 -0
- package/src/generated/api/SfuConfig.ts +53 -0
- package/src/generated/api/SfuDataMessage.ts +23 -0
- package/src/generated/api/SfuEnsureMembershipParams.ts +3 -0
- package/src/generated/api/SfuMigrateEvent.ts +20 -0
- package/src/generated/api/SfuNeighbourhoodParams.ts +3 -0
- package/src/generated/api/SfuParticipantQualityPreference.ts +6 -0
- package/src/generated/api/SfuPerspectiveParams.ts +6 -0
- package/src/generated/api/SfuQualityPreferenceParams.ts +7 -0
- package/src/generated/api/SfuRoomInfo.ts +7 -0
- package/src/generated/api/SfuRoomParams.ts +3 -0
- package/src/generated/api/SfuRoomParticipantInfo.ts +8 -0
- package/src/generated/api/SfuRoomRoster.ts +12 -0
- package/src/generated/api/SfuSendDataParams.ts +7 -0
- package/src/generated/api/SfuSetConfigParams.ts +4 -0
- package/src/generated/api/SfuStatus.ts +24 -0
- package/src/generated/api/ShaclLinkTriple.ts +8 -0
- package/src/generated/api/SignalRequest.ts +3 -0
- package/src/generated/api/SubscribeQueryRequest.ts +3 -0
- package/src/generated/api/TokenizerSource.ts +3 -0
- package/src/generated/api/TokenizerSourceInput.ts +3 -0
- package/src/generated/api/TrackMapEntry.ts +18 -0
- package/src/generated/api/TranscriptionTextFilter.ts +3 -0
- package/src/generated/api/TriggeredNotification.ts +4 -0
- package/src/generated/api/TrustedAgentsWrapper.ts +6 -0
- package/src/generated/api/UnlockAgentRequest.ts +1 -1
- package/src/generated/api/UnytVersionInfo.ts +20 -0
- package/src/generated/api/UpdateLinkRequest.ts +1 -1
- package/src/generated/api/UpdateProfileRequest.ts +4 -0
- package/src/generated/api/UpdateSubjectRequest.ts +10 -0
- package/src/generated/api/UserCreationResult.ts +3 -0
- package/src/generated/api/UserStatistics.ts +2 -1
- package/src/generated/api/UsersAppInfo.ts +6 -0
- package/src/generated/api/UsersEmailParams.ts +3 -0
- package/src/generated/api/UsersEmailTestAction.ts +3 -0
- package/src/generated/api/UsersEmailTestParams.ts +12 -0
- package/src/generated/api/UsersEmailTestResult.ts +7 -0
- package/src/generated/api/UsersLoginParams.ts +7 -0
- package/src/generated/api/UsersRequestVerificationParams.ts +4 -0
- package/src/generated/api/UsersSetCreditsParams.ts +3 -0
- package/src/generated/api/UsersVerifyEmailParams.ts +11 -0
- package/src/generated/api/ValidOutput.ts +30 -0
- package/src/generated/api/VoiceActivityParamsInput.ts +3 -0
- package/src/generated/api/index.ts +14 -2
- package/src/generated/api/serde_json/JsonValue.ts +3 -0
- package/src/index.ts +9 -3
- package/src/language/LanguageClient.ts +12 -13
- package/src/links/Links.ts +49 -3
- package/src/model/Ad4mModel.test.ts +480 -173
- package/src/model/Ad4mModel.ts +407 -77
- package/src/model/ModelQueryBuilder.ts +95 -255
- package/src/model/abstract-classes.test.ts +225 -0
- package/src/model/decorators.ts +145 -9
- package/src/model/query-sparql.ts +2 -3
- package/src/model/relation-filtering.test.ts +191 -0
- package/src/model/shacl-gen.ts +32 -9
- package/src/model/shacl-roundtrip.test.ts +52 -0
- package/src/model/types.ts +19 -0
- package/src/neighbourhood/MeshManager.test.ts +2640 -0
- package/src/neighbourhood/MeshManager.ts +1350 -0
- package/src/neighbourhood/NeighbourhoodClient.test.ts +60 -0
- package/src/neighbourhood/NeighbourhoodClient.ts +298 -27
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +37 -9
- package/src/neighbourhood/NeighbourhoodProxy.ts +247 -1
- package/src/neighbourhood/Session.test.ts +800 -0
- package/src/neighbourhood/Session.ts +525 -0
- package/src/neighbourhood/SfuManager.test.ts +677 -0
- package/src/neighbourhood/SfuManager.ts +803 -0
- package/src/neighbourhood/SfuTypes.ts +40 -0
- package/src/notifyListeners.test.ts +19 -0
- package/src/notifyListeners.ts +10 -0
- package/src/perspectives/AutoProcessor.ts +13 -82
- package/src/perspectives/FlowInstance.ts +136 -32
- package/src/perspectives/FlowModels.ts +46 -11
- package/src/perspectives/InterpretationModels.ts +4 -0
- package/src/perspectives/LiveQuery.test.ts +197 -0
- package/src/perspectives/LiveQuery.ts +189 -0
- package/src/perspectives/Perspective.ts +18 -2
- package/src/perspectives/PerspectiveClient.test.ts +122 -45
- package/src/perspectives/PerspectiveClient.ts +146 -343
- package/src/perspectives/PerspectiveHandle.ts +32 -9
- package/src/perspectives/PerspectiveProxy.test.ts +216 -528
- package/src/perspectives/PerspectiveProxy.ts +259 -736
- package/src/perspectives/TextContent.test.ts +123 -0
- package/src/perspectives/TextContent.ts +36 -0
- package/src/perspectives/WakerSubscriptionManager.test.ts +136 -1
- package/src/perspectives/WakerSubscriptionManager.ts +69 -22
- package/src/perspectives/link-updated-type.test.ts +55 -0
- package/src/perspectives/listener-leaks.test.ts +204 -0
- package/src/perspectives/shacl-rpc.test.ts +22 -27
- package/src/runtime/RuntimeClient.ts +75 -157
- package/src/runtime/RuntimeTypes.ts +3 -3
- package/src/shacl/SHACLFlow.test.ts +49 -1
- package/src/shacl/SHACLFlow.ts +73 -15
- package/src/shacl/SHACLShape.test.ts +161 -16
- package/src/shacl/SHACLShape.ts +210 -439
- package/lib/shims/reflect-metadata.d.ts +0 -0
- package/lib/shims/reflect-metadata.js +0 -0
- package/lib/shims/type-graphql.d.ts +0 -32
- package/lib/shims/type-graphql.js +0 -70
- package/lib/src/PubSub.d.ts +0 -17
- package/lib/src/PubSub.js +0 -17
- package/lib/src/agent/AgentResolver.d.ts +0 -30
- package/lib/src/agent/AgentResolver.js +0 -325
- package/lib/src/ai/AIResolver.d.ts +0 -75
- package/lib/src/ai/AIResolver.js +0 -455
- package/lib/src/buildSchema.d.ts +0 -1
- package/lib/src/buildSchema.js +0 -38
- package/lib/src/expression/ExpressionResolver.d.ts +0 -10
- package/lib/src/expression/ExpressionResolver.js +0 -106
- package/lib/src/language/LanguageContext.d.ts +0 -37
- package/lib/src/language/LanguageContext.js +0 -2
- package/lib/src/language/LanguageResolver.d.ts +0 -19
- package/lib/src/language/LanguageResolver.js +0 -143
- package/lib/src/links/Links.test.js +0 -33
- package/lib/src/model/Ad4mModel.test.js +0 -2055
- package/lib/src/model/Subject.d.ts +0 -25
- package/lib/src/model/Subject.js +0 -164
- package/lib/src/model/hydration-batch.d.ts +0 -34
- package/lib/src/model/hydration-batch.js +0 -147
- package/lib/src/model/hydration-batching.test.d.ts +0 -7
- package/lib/src/model/hydration-batching.test.js +0 -456
- package/lib/src/model/model-manifest.d.ts +0 -41
- package/lib/src/model/model-manifest.js +0 -11
- package/lib/src/model/prolog-facts.d.ts +0 -37
- package/lib/src/model/prolog-facts.js +0 -134
- package/lib/src/model/query-cache.test.js +0 -43
- package/lib/src/model/query-prolog.d.ts +0 -15
- package/lib/src/model/query-prolog.js +0 -140
- package/lib/src/model/query-sparql-batch.d.ts +0 -17
- package/lib/src/model/query-sparql-batch.js +0 -260
- package/lib/src/model/query-sparql.test.js +0 -312
- package/lib/src/model/relation-filtering.test.js +0 -838
- package/lib/src/model/subscription-delta.test.d.ts +0 -24
- package/lib/src/model/subscription-delta.test.js +0 -180
- package/lib/src/model/subscription-pool.d.ts +0 -39
- package/lib/src/model/subscription-pool.js +0 -165
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +0 -73
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +0 -24
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +0 -182
- package/lib/src/perspectives/Perspective.test.js +0 -20
- package/lib/src/perspectives/PerspectiveClient.test.js +0 -224
- package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -56
- package/lib/src/perspectives/PerspectiveResolver.js +0 -519
- package/lib/src/runtime/RuntimeResolver.d.ts +0 -173
- package/lib/src/runtime/RuntimeResolver.js +0 -1122
- package/lib/src/schema.gql +0 -631
- package/lib/src/shacl/SHACLFlow.test.js +0 -205
- package/lib/src/shacl/SHACLShape.test.js +0 -418
- package/lib/src/unwrapApolloResult.d.ts +0 -2
- package/lib/src/unwrapApolloResult.js +0 -14
- /package/lib/src/{links/Links.test.d.ts → generated/api/AITask.js} +0 -0
- /package/lib/src/{model/Ad4mModel.test.d.ts → generated/api/AITaskInput.js} +0 -0
- /package/lib/src/{model/query-cache.test.d.ts → generated/api/Agent.js} +0 -0
- /package/lib/src/{model/query-sparql.test.d.ts → generated/api/AgentAddEntanglementProofsParams.js} +0 -0
- /package/lib/src/{model/relation-filtering.test.d.ts → generated/api/AgentStatus.js} +0 -0
- /package/lib/src/{neighbourhood/NeighbourhoodProxy.test.d.ts → generated/api/AgentStatusChangedEvent.js} +0 -0
- /package/lib/src/{perspectives/Perspective.test.d.ts → generated/api/AgentUpdatedEvent.js} +0 -0
- /package/lib/src/{perspectives/PerspectiveClient.test.d.ts → generated/api/AiAddModelParams.js} +0 -0
- /package/lib/src/{shacl/SHACLFlow.test.d.ts → generated/api/AiAddTaskParams.js} +0 -0
- /package/lib/src/{shacl/SHACLShape.test.d.ts → generated/api/AiGetDefaultModelParams.js} +0 -0
|
@@ -1,2055 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { Ad4mModel } from "./Ad4mModel";
|
|
11
|
-
import { Model, Property, Optional, ReadOnly, HasMany, Flag } from "./decorators";
|
|
12
|
-
describe("Ad4mModel.getModelMetadata()", () => {
|
|
13
|
-
it("should extract basic model metadata with className", () => {
|
|
14
|
-
let SimpleModel = class SimpleModel extends Ad4mModel {
|
|
15
|
-
};
|
|
16
|
-
SimpleModel = __decorate([
|
|
17
|
-
Model({ name: "SimpleModel" })
|
|
18
|
-
], SimpleModel);
|
|
19
|
-
const metadata = SimpleModel.getModelMetadata();
|
|
20
|
-
expect(metadata.className).toBe("SimpleModel");
|
|
21
|
-
expect(metadata.properties).toEqual({});
|
|
22
|
-
expect(metadata.relations).toEqual({});
|
|
23
|
-
});
|
|
24
|
-
it("should extract property metadata with all fields", () => {
|
|
25
|
-
let PropertyModel = class PropertyModel extends Ad4mModel {
|
|
26
|
-
constructor() {
|
|
27
|
-
super(...arguments);
|
|
28
|
-
this.name = "";
|
|
29
|
-
this.optional = "";
|
|
30
|
-
this.readonly = "";
|
|
31
|
-
this.type = "";
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
__decorate([
|
|
35
|
-
Property({ through: "test://name", resolveLanguage: "literal" }),
|
|
36
|
-
__metadata("design:type", String)
|
|
37
|
-
], PropertyModel.prototype, "name", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
Optional({ through: "test://optional" }),
|
|
40
|
-
__metadata("design:type", String)
|
|
41
|
-
], PropertyModel.prototype, "optional", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
ReadOnly({ through: "test://readonly", prologGetter: "custom_getter" }),
|
|
44
|
-
__metadata("design:type", String)
|
|
45
|
-
], PropertyModel.prototype, "readonly", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
Flag({ through: "test://type", value: "test://flag" }),
|
|
48
|
-
__metadata("design:type", String)
|
|
49
|
-
], PropertyModel.prototype, "type", void 0);
|
|
50
|
-
PropertyModel = __decorate([
|
|
51
|
-
Model({ name: "PropertyModel" })
|
|
52
|
-
], PropertyModel);
|
|
53
|
-
const metadata = PropertyModel.getModelMetadata();
|
|
54
|
-
// Should have 4 properties
|
|
55
|
-
expect(Object.keys(metadata.properties)).toHaveLength(4);
|
|
56
|
-
// Verify "name" property
|
|
57
|
-
expect(metadata.properties.name.predicate).toBe("test://name");
|
|
58
|
-
expect(metadata.properties.name.required).toBe(false);
|
|
59
|
-
expect(metadata.properties.name.readOnly).toBe(false);
|
|
60
|
-
expect(metadata.properties.name.resolveLanguage).toBe("literal");
|
|
61
|
-
// Verify "optional" property
|
|
62
|
-
expect(metadata.properties.optional.predicate).toBe("test://optional");
|
|
63
|
-
expect(metadata.properties.optional.readOnly).toBe(false);
|
|
64
|
-
// Verify "readonly" property
|
|
65
|
-
expect(metadata.properties.readonly.predicate).toBe("test://readonly");
|
|
66
|
-
expect(metadata.properties.readonly.readOnly).toBe(true);
|
|
67
|
-
expect(metadata.properties.readonly.prologGetter).toBe("custom_getter");
|
|
68
|
-
// Verify "type" property (flag)
|
|
69
|
-
expect(metadata.properties.type.predicate).toBe("test://type");
|
|
70
|
-
expect(metadata.properties.type.flag).toBe(true);
|
|
71
|
-
expect(metadata.properties.type.initial).toBe("test://flag");
|
|
72
|
-
});
|
|
73
|
-
it("should extract relation metadata with various options", () => {
|
|
74
|
-
let RelationModel = class RelationModel extends Ad4mModel {
|
|
75
|
-
constructor() {
|
|
76
|
-
super(...arguments);
|
|
77
|
-
this.items = [];
|
|
78
|
-
this.local = [];
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
__decorate([
|
|
82
|
-
HasMany({ through: "test://items" }),
|
|
83
|
-
__metadata("design:type", Array)
|
|
84
|
-
], RelationModel.prototype, "items", void 0);
|
|
85
|
-
__decorate([
|
|
86
|
-
HasMany({ through: "test://local", local: true }),
|
|
87
|
-
__metadata("design:type", Array)
|
|
88
|
-
], RelationModel.prototype, "local", void 0);
|
|
89
|
-
RelationModel = __decorate([
|
|
90
|
-
Model({ name: "RelationModel" })
|
|
91
|
-
], RelationModel);
|
|
92
|
-
const metadata = RelationModel.getModelMetadata();
|
|
93
|
-
// Should have 2 relations
|
|
94
|
-
expect(Object.keys(metadata.relations)).toHaveLength(2);
|
|
95
|
-
// Verify "items" relation
|
|
96
|
-
expect(metadata.relations.items.predicate).toBe("test://items");
|
|
97
|
-
// Verify "local" relation
|
|
98
|
-
expect(metadata.relations.local.predicate).toBe("test://local");
|
|
99
|
-
expect(metadata.relations.local.local).toBe(true);
|
|
100
|
-
});
|
|
101
|
-
it("should extract transform function from property metadata", () => {
|
|
102
|
-
let TransformModel = class TransformModel extends Ad4mModel {
|
|
103
|
-
constructor() {
|
|
104
|
-
super(...arguments);
|
|
105
|
-
this.data = "";
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
__decorate([
|
|
109
|
-
Optional({
|
|
110
|
-
through: "test://data",
|
|
111
|
-
transform: (value) => value.toUpperCase()
|
|
112
|
-
}),
|
|
113
|
-
__metadata("design:type", String)
|
|
114
|
-
], TransformModel.prototype, "data", void 0);
|
|
115
|
-
TransformModel = __decorate([
|
|
116
|
-
Model({ name: "TransformModel" })
|
|
117
|
-
], TransformModel);
|
|
118
|
-
const metadata = TransformModel.getModelMetadata();
|
|
119
|
-
// Assert transform is a function
|
|
120
|
-
expect(typeof metadata.properties.data.transform).toBe("function");
|
|
121
|
-
// Test the transform function
|
|
122
|
-
const transformed = metadata.properties.data.transform("test");
|
|
123
|
-
expect(transformed).toBe("TEST");
|
|
124
|
-
});
|
|
125
|
-
it("should extract custom getter and setter from property metadata", () => {
|
|
126
|
-
let CustomModel = class CustomModel extends Ad4mModel {
|
|
127
|
-
constructor() {
|
|
128
|
-
super(...arguments);
|
|
129
|
-
this.computed = 0;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
__decorate([
|
|
133
|
-
Optional({
|
|
134
|
-
through: "test://computed",
|
|
135
|
-
prologGetter: "triple(Base, 'test://value', V), Value is V * 2",
|
|
136
|
-
prologSetter: "Value is V / 2, Actions = [{action: 'setSingleTarget', source: 'this', predicate: 'test://value', target: Value}]"
|
|
137
|
-
}),
|
|
138
|
-
__metadata("design:type", Number)
|
|
139
|
-
], CustomModel.prototype, "computed", void 0);
|
|
140
|
-
CustomModel = __decorate([
|
|
141
|
-
Model({ name: "CustomModel" })
|
|
142
|
-
], CustomModel);
|
|
143
|
-
const metadata = CustomModel.getModelMetadata();
|
|
144
|
-
// Assert prologGetter and prologSetter contain the custom code
|
|
145
|
-
expect(metadata.properties.computed.prologGetter).toContain("triple(Base, 'test://value', V), Value is V * 2");
|
|
146
|
-
expect(metadata.properties.computed.prologSetter).toContain("Value is V / 2");
|
|
147
|
-
expect(metadata.properties.computed.prologSetter).toContain("setSingleTarget");
|
|
148
|
-
});
|
|
149
|
-
it("should handle relation with typed target relation", () => {
|
|
150
|
-
let Comment = class Comment extends Ad4mModel {
|
|
151
|
-
};
|
|
152
|
-
Comment = __decorate([
|
|
153
|
-
Model({ name: "Comment" })
|
|
154
|
-
], Comment);
|
|
155
|
-
let Post = class Post extends Ad4mModel {
|
|
156
|
-
constructor() {
|
|
157
|
-
super(...arguments);
|
|
158
|
-
this.comments = [];
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
__decorate([
|
|
162
|
-
HasMany({
|
|
163
|
-
through: "post://comment",
|
|
164
|
-
target: () => Comment
|
|
165
|
-
}),
|
|
166
|
-
__metadata("design:type", Array)
|
|
167
|
-
], Post.prototype, "comments", void 0);
|
|
168
|
-
Post = __decorate([
|
|
169
|
-
Model({ name: "Post" })
|
|
170
|
-
], Post);
|
|
171
|
-
const metadata = Post.getModelMetadata();
|
|
172
|
-
// Assert relation exists with correct predicate
|
|
173
|
-
expect(metadata.relations.comments).toBeDefined();
|
|
174
|
-
expect(metadata.relations.comments.predicate).toBe("post://comment");
|
|
175
|
-
});
|
|
176
|
-
it("should throw error for class without @Model decorator", () => {
|
|
177
|
-
class NoDecoratorModel extends Ad4mModel {
|
|
178
|
-
}
|
|
179
|
-
// Assert that calling getModelMetadata throws an error
|
|
180
|
-
expect(() => NoDecoratorModel.getModelMetadata()).toThrow("Model class must be decorated with @Model");
|
|
181
|
-
});
|
|
182
|
-
it("should handle complex model with mixed property and relation types", () => {
|
|
183
|
-
let Recipe = class Recipe extends Ad4mModel {
|
|
184
|
-
constructor() {
|
|
185
|
-
super(...arguments);
|
|
186
|
-
this.name = "";
|
|
187
|
-
this.description = "";
|
|
188
|
-
this.rating = 0;
|
|
189
|
-
this.ingredients = [];
|
|
190
|
-
this.steps = [];
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
__decorate([
|
|
194
|
-
Property({ through: "recipe://name", resolveLanguage: "literal" }),
|
|
195
|
-
__metadata("design:type", String)
|
|
196
|
-
], Recipe.prototype, "name", void 0);
|
|
197
|
-
__decorate([
|
|
198
|
-
Optional({ through: "recipe://description" }),
|
|
199
|
-
__metadata("design:type", String)
|
|
200
|
-
], Recipe.prototype, "description", void 0);
|
|
201
|
-
__decorate([
|
|
202
|
-
ReadOnly({ through: "recipe://rating", prologGetter: "avg_rating(Base, Value)" }),
|
|
203
|
-
__metadata("design:type", Number)
|
|
204
|
-
], Recipe.prototype, "rating", void 0);
|
|
205
|
-
__decorate([
|
|
206
|
-
HasMany({ through: "recipe://ingredient" }),
|
|
207
|
-
__metadata("design:type", Array)
|
|
208
|
-
], Recipe.prototype, "ingredients", void 0);
|
|
209
|
-
__decorate([
|
|
210
|
-
HasMany({ through: "recipe://step", local: true }),
|
|
211
|
-
__metadata("design:type", Array)
|
|
212
|
-
], Recipe.prototype, "steps", void 0);
|
|
213
|
-
Recipe = __decorate([
|
|
214
|
-
Model({ name: "Recipe" })
|
|
215
|
-
], Recipe);
|
|
216
|
-
const metadata = Recipe.getModelMetadata();
|
|
217
|
-
// Assert className
|
|
218
|
-
expect(metadata.className).toBe("Recipe");
|
|
219
|
-
// Assert properties has 3 entries
|
|
220
|
-
expect(Object.keys(metadata.properties)).toHaveLength(3);
|
|
221
|
-
expect(metadata.properties.name).toBeDefined();
|
|
222
|
-
expect(metadata.properties.description).toBeDefined();
|
|
223
|
-
expect(metadata.properties.rating).toBeDefined();
|
|
224
|
-
// Assert relations has 2 entries
|
|
225
|
-
expect(Object.keys(metadata.relations)).toHaveLength(2);
|
|
226
|
-
expect(metadata.relations.ingredients).toBeDefined();
|
|
227
|
-
expect(metadata.relations.steps).toBeDefined();
|
|
228
|
-
// Verify all metadata fields are correctly extracted
|
|
229
|
-
expect(metadata.properties.name.predicate).toBe("recipe://name");
|
|
230
|
-
expect(metadata.properties.name.resolveLanguage).toBe("literal");
|
|
231
|
-
expect(metadata.properties.description.predicate).toBe("recipe://description");
|
|
232
|
-
expect(metadata.properties.rating.predicate).toBe("recipe://rating");
|
|
233
|
-
expect(metadata.properties.rating.prologGetter).toBe("avg_rating(Base, Value)");
|
|
234
|
-
expect(metadata.relations.ingredients.predicate).toBe("recipe://ingredient");
|
|
235
|
-
expect(metadata.relations.steps.predicate).toBe("recipe://step");
|
|
236
|
-
expect(metadata.relations.steps.local).toBe(true);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
describe("Ad4mModel.fromJSONSchema() with getModelMetadata()", () => {
|
|
240
|
-
it("should extract metadata from a model created via fromJSONSchema with basic properties", () => {
|
|
241
|
-
const schema = {
|
|
242
|
-
title: "Product",
|
|
243
|
-
type: "object",
|
|
244
|
-
properties: {
|
|
245
|
-
name: { type: "string" },
|
|
246
|
-
price: { type: "number" },
|
|
247
|
-
description: { type: "string" }
|
|
248
|
-
},
|
|
249
|
-
required: ["name", "price"]
|
|
250
|
-
};
|
|
251
|
-
const ProductClass = Ad4mModel.fromJSONSchema(schema, {
|
|
252
|
-
name: "Product",
|
|
253
|
-
namespace: "product://",
|
|
254
|
-
resolveLanguage: "literal"
|
|
255
|
-
});
|
|
256
|
-
const metadata = ProductClass.getModelMetadata();
|
|
257
|
-
// Verify className
|
|
258
|
-
expect(metadata.className).toBe("Product");
|
|
259
|
-
// Verify properties are extracted
|
|
260
|
-
expect(Object.keys(metadata.properties).length).toBeGreaterThan(0);
|
|
261
|
-
expect(metadata.properties.name).toBeDefined();
|
|
262
|
-
expect(metadata.properties.name.predicate).toBe("product://name");
|
|
263
|
-
expect(metadata.properties.name.required).toBe(true);
|
|
264
|
-
expect(metadata.properties.name.readOnly).toBe(false);
|
|
265
|
-
expect(metadata.properties.name.resolveLanguage).toBe("literal");
|
|
266
|
-
expect(metadata.properties.price).toBeDefined();
|
|
267
|
-
expect(metadata.properties.price.predicate).toBe("product://price");
|
|
268
|
-
expect(metadata.properties.price.required).toBe(true);
|
|
269
|
-
expect(metadata.properties.price.resolveLanguage).toBe("literal");
|
|
270
|
-
expect(metadata.properties.description).toBeDefined();
|
|
271
|
-
expect(metadata.properties.description.predicate).toBe("product://description");
|
|
272
|
-
expect(metadata.properties.description.required).toBe(false);
|
|
273
|
-
});
|
|
274
|
-
it("should extract relations from a model created via fromJSONSchema with arrays", () => {
|
|
275
|
-
const schema = {
|
|
276
|
-
title: "Post",
|
|
277
|
-
type: "object",
|
|
278
|
-
properties: {
|
|
279
|
-
title: { type: "string" },
|
|
280
|
-
tags: {
|
|
281
|
-
type: "array",
|
|
282
|
-
items: { type: "string" }
|
|
283
|
-
},
|
|
284
|
-
comments: {
|
|
285
|
-
type: "array",
|
|
286
|
-
items: { type: "string" }
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
required: ["title"]
|
|
290
|
-
};
|
|
291
|
-
const PostClass = Ad4mModel.fromJSONSchema(schema, {
|
|
292
|
-
name: "Post",
|
|
293
|
-
namespace: "post://"
|
|
294
|
-
});
|
|
295
|
-
const metadata = PostClass.getModelMetadata();
|
|
296
|
-
// Verify className
|
|
297
|
-
expect(metadata.className).toBe("Post");
|
|
298
|
-
// Verify relations are extracted
|
|
299
|
-
expect(Object.keys(metadata.relations).length).toBeGreaterThan(0);
|
|
300
|
-
expect(metadata.relations.tags).toBeDefined();
|
|
301
|
-
expect(metadata.relations.tags.predicate).toBe("post://tags");
|
|
302
|
-
expect(metadata.relations.comments).toBeDefined();
|
|
303
|
-
expect(metadata.relations.comments.predicate).toBe("post://comments");
|
|
304
|
-
// Verify properties (should include at least title)
|
|
305
|
-
expect(metadata.properties.title).toBeDefined();
|
|
306
|
-
expect(metadata.properties.title.predicate).toBe("post://title");
|
|
307
|
-
expect(metadata.properties.title.required).toBe(true);
|
|
308
|
-
});
|
|
309
|
-
it("should handle x-ad4m metadata in JSON schema for property options", () => {
|
|
310
|
-
const schema = {
|
|
311
|
-
title: "Contact",
|
|
312
|
-
"x-ad4m": {
|
|
313
|
-
namespace: "contact://"
|
|
314
|
-
},
|
|
315
|
-
type: "object",
|
|
316
|
-
properties: {
|
|
317
|
-
name: {
|
|
318
|
-
type: "string",
|
|
319
|
-
"x-ad4m": {
|
|
320
|
-
through: "foaf://name",
|
|
321
|
-
resolveLanguage: "literal",
|
|
322
|
-
writable: true
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
email: {
|
|
326
|
-
type: "string",
|
|
327
|
-
"x-ad4m": {
|
|
328
|
-
through: "foaf://mbox",
|
|
329
|
-
local: true
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
|
-
required: ["name"]
|
|
334
|
-
};
|
|
335
|
-
const ContactClass = Ad4mModel.fromJSONSchema(schema, {
|
|
336
|
-
name: "Contact"
|
|
337
|
-
});
|
|
338
|
-
const metadata = ContactClass.getModelMetadata();
|
|
339
|
-
// Verify x-ad4m metadata is respected
|
|
340
|
-
expect(metadata.properties.name.predicate).toBe("foaf://name");
|
|
341
|
-
expect(metadata.properties.name.resolveLanguage).toBe("literal");
|
|
342
|
-
expect(metadata.properties.name.readOnly).toBe(false);
|
|
343
|
-
expect(metadata.properties.name.required).toBe(true);
|
|
344
|
-
expect(metadata.properties.email.predicate).toBe("foaf://mbox");
|
|
345
|
-
expect(metadata.properties.email.local).toBe(true);
|
|
346
|
-
});
|
|
347
|
-
it("should handle property mapping override in options", () => {
|
|
348
|
-
const schema = {
|
|
349
|
-
title: "User",
|
|
350
|
-
type: "object",
|
|
351
|
-
properties: {
|
|
352
|
-
username: { type: "string" },
|
|
353
|
-
fullName: { type: "string" }
|
|
354
|
-
},
|
|
355
|
-
required: ["username"]
|
|
356
|
-
};
|
|
357
|
-
const UserClass = Ad4mModel.fromJSONSchema(schema, {
|
|
358
|
-
name: "User",
|
|
359
|
-
namespace: "user://",
|
|
360
|
-
propertyMapping: {
|
|
361
|
-
username: "custom://identifier",
|
|
362
|
-
fullName: "custom://name"
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
const metadata = UserClass.getModelMetadata();
|
|
366
|
-
// Verify property mappings are applied
|
|
367
|
-
expect(metadata.properties.username.predicate).toBe("custom://identifier");
|
|
368
|
-
expect(metadata.properties.fullName.predicate).toBe("custom://name");
|
|
369
|
-
});
|
|
370
|
-
it("should extract metadata from dynamically generated models with mixed types", () => {
|
|
371
|
-
const schema = {
|
|
372
|
-
title: "Article",
|
|
373
|
-
type: "object",
|
|
374
|
-
properties: {
|
|
375
|
-
title: { type: "string" },
|
|
376
|
-
views: { type: "number" },
|
|
377
|
-
published: { type: "boolean" },
|
|
378
|
-
authors: {
|
|
379
|
-
type: "array",
|
|
380
|
-
items: { type: "string" }
|
|
381
|
-
},
|
|
382
|
-
tags: {
|
|
383
|
-
type: "array",
|
|
384
|
-
items: { type: "string" },
|
|
385
|
-
"x-ad4m": {
|
|
386
|
-
local: true
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
required: ["title", "published"]
|
|
391
|
-
};
|
|
392
|
-
const ArticleClass = Ad4mModel.fromJSONSchema(schema, {
|
|
393
|
-
name: "Article",
|
|
394
|
-
namespace: "article://",
|
|
395
|
-
resolveLanguage: "literal"
|
|
396
|
-
});
|
|
397
|
-
const metadata = ArticleClass.getModelMetadata();
|
|
398
|
-
// Verify className
|
|
399
|
-
expect(metadata.className).toBe("Article");
|
|
400
|
-
// Verify properties
|
|
401
|
-
expect(metadata.properties.title).toBeDefined();
|
|
402
|
-
expect(metadata.properties.title.predicate).toBe("article://title");
|
|
403
|
-
expect(metadata.properties.title.required).toBe(true);
|
|
404
|
-
expect(metadata.properties.title.resolveLanguage).toBe("literal");
|
|
405
|
-
expect(metadata.properties.views).toBeDefined();
|
|
406
|
-
expect(metadata.properties.views.predicate).toBe("article://views");
|
|
407
|
-
expect(metadata.properties.views.resolveLanguage).toBe("literal");
|
|
408
|
-
expect(metadata.properties.published).toBeDefined();
|
|
409
|
-
expect(metadata.properties.published.predicate).toBe("article://published");
|
|
410
|
-
expect(metadata.properties.published.required).toBe(true);
|
|
411
|
-
// Verify relations
|
|
412
|
-
expect(metadata.relations.authors).toBeDefined();
|
|
413
|
-
expect(metadata.relations.authors.predicate).toBe("article://authors");
|
|
414
|
-
expect(metadata.relations.tags).toBeDefined();
|
|
415
|
-
expect(metadata.relations.tags.predicate).toBe("article://tags");
|
|
416
|
-
expect(metadata.relations.tags.local).toBe(true);
|
|
417
|
-
});
|
|
418
|
-
it("should handle models with no properties (open-world, no auto-flag)", () => {
|
|
419
|
-
const schema = {
|
|
420
|
-
title: "EmptyModel",
|
|
421
|
-
type: "object",
|
|
422
|
-
properties: {}
|
|
423
|
-
};
|
|
424
|
-
const EmptyModelClass = Ad4mModel.fromJSONSchema(schema, {
|
|
425
|
-
name: "EmptyModel",
|
|
426
|
-
namespace: "empty://"
|
|
427
|
-
});
|
|
428
|
-
const metadata = EmptyModelClass.getModelMetadata();
|
|
429
|
-
// Should have className
|
|
430
|
-
expect(metadata.className).toBe("EmptyModel");
|
|
431
|
-
// Should NOT have an auto-generated __ad4m_type property —
|
|
432
|
-
// models with all-optional properties use open-world structural matching.
|
|
433
|
-
expect(metadata.properties.__ad4m_type).toBeUndefined();
|
|
434
|
-
// SHACL shape should still be valid with empty constructor/destructor
|
|
435
|
-
const { shape } = EmptyModelClass.generateSHACL();
|
|
436
|
-
expect(shape.constructor_actions).toEqual([]);
|
|
437
|
-
expect(shape.destructor_actions).toEqual([]);
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
describe("Ad4mModel.queryToSPARQL()", () => {
|
|
441
|
-
const mockPerspective = {};
|
|
442
|
-
function normalizeQuery(query) {
|
|
443
|
-
return query.replace(/\s+/g, ' ').trim();
|
|
444
|
-
}
|
|
445
|
-
let Recipe = class Recipe extends Ad4mModel {
|
|
446
|
-
constructor() {
|
|
447
|
-
super(...arguments);
|
|
448
|
-
this.name = "";
|
|
449
|
-
this.rating = 0;
|
|
450
|
-
this.ingredients = [];
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
__decorate([
|
|
454
|
-
Property({ through: "recipe://name", required: true }),
|
|
455
|
-
__metadata("design:type", String)
|
|
456
|
-
], Recipe.prototype, "name", void 0);
|
|
457
|
-
__decorate([
|
|
458
|
-
Property({ through: "recipe://rating", required: true }),
|
|
459
|
-
__metadata("design:type", Number)
|
|
460
|
-
], Recipe.prototype, "rating", void 0);
|
|
461
|
-
__decorate([
|
|
462
|
-
HasMany({ through: "recipe://ingredient" }),
|
|
463
|
-
__metadata("design:type", Array)
|
|
464
|
-
], Recipe.prototype, "ingredients", void 0);
|
|
465
|
-
Recipe = __decorate([
|
|
466
|
-
Model({ name: "Recipe" })
|
|
467
|
-
], Recipe);
|
|
468
|
-
it("should generate basic SPARQL query with no filters", async () => {
|
|
469
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, {});
|
|
470
|
-
const norm = normalizeQuery(query);
|
|
471
|
-
// Must be a SPARQL SELECT
|
|
472
|
-
expect(norm).toContain("SELECT ?source ?predicate ?target ?author ?timestamp");
|
|
473
|
-
// Must have conformance JOIN for required properties using direct triple patterns
|
|
474
|
-
expect(norm).toContain("cfTarget_name");
|
|
475
|
-
expect(norm).toContain("recipe://name");
|
|
476
|
-
});
|
|
477
|
-
it("should generate query with simple property filter", async () => {
|
|
478
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: "Pasta" } });
|
|
479
|
-
const norm = normalizeQuery(query);
|
|
480
|
-
expect(norm).toContain("SELECT ?source ?predicate ?target ?author ?timestamp");
|
|
481
|
-
// For literal-stored properties, SPARQL only adds a JOIN (no FILTER value) — filtering is in JS
|
|
482
|
-
expect(norm).toContain("recipe://name");
|
|
483
|
-
// Value should NOT be in SPARQL — filtering happens in JS post-filter
|
|
484
|
-
expect(norm).toContain("?wTarget_name");
|
|
485
|
-
});
|
|
486
|
-
it("should generate query with NOT operator", async () => {
|
|
487
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: { not: "Salad" } } });
|
|
488
|
-
const norm = normalizeQuery(query);
|
|
489
|
-
// For literal-stored properties, NOT filtering is done in JS — no NOT EXISTS in SPARQL
|
|
490
|
-
expect(norm).toContain("recipe://name");
|
|
491
|
-
});
|
|
492
|
-
it("should generate query with NOT IN operator (array)", async () => {
|
|
493
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: { not: ["Salad", "Soup"] } } });
|
|
494
|
-
const norm = normalizeQuery(query);
|
|
495
|
-
// For literal-stored properties, NOT IN filtering is done in JS — no filter values in SPARQL
|
|
496
|
-
expect(norm).toContain("recipe://name");
|
|
497
|
-
});
|
|
498
|
-
it("should generate query with IN clause (array values)", async () => {
|
|
499
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: ["Pasta", "Pizza"] } });
|
|
500
|
-
const norm = normalizeQuery(query);
|
|
501
|
-
// For literal-stored properties, IN filtering is done in JS — only a JOIN exists
|
|
502
|
-
expect(norm).toContain("recipe://name");
|
|
503
|
-
expect(norm).toContain("?wTarget_name");
|
|
504
|
-
});
|
|
505
|
-
it("should generate query with base filter", async () => {
|
|
506
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { base: "ad4m://test123" } });
|
|
507
|
-
const norm = normalizeQuery(query);
|
|
508
|
-
expect(norm).toContain("?source =");
|
|
509
|
-
expect(norm).toContain("ad4m://test123");
|
|
510
|
-
});
|
|
511
|
-
it("should escape special characters in SPARQL strings", async () => {
|
|
512
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: 'O\'Brien' } });
|
|
513
|
-
const norm = normalizeQuery(query);
|
|
514
|
-
// Should not break the query
|
|
515
|
-
expect(norm).toContain("SELECT ?source");
|
|
516
|
-
});
|
|
517
|
-
// =========================================================================
|
|
518
|
-
// Additional models for thorough SPARQL structure tests
|
|
519
|
-
// =========================================================================
|
|
520
|
-
let Task = class Task extends Ad4mModel {
|
|
521
|
-
constructor() {
|
|
522
|
-
super(...arguments);
|
|
523
|
-
this.title = "";
|
|
524
|
-
this.priority = 0;
|
|
525
|
-
this.done = false;
|
|
526
|
-
this.description = "";
|
|
527
|
-
this.tags = [];
|
|
528
|
-
this.assignees = [];
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
__decorate([
|
|
532
|
-
Property({ through: "task://title", resolveLanguage: "literal", required: true }),
|
|
533
|
-
__metadata("design:type", String)
|
|
534
|
-
], Task.prototype, "title", void 0);
|
|
535
|
-
__decorate([
|
|
536
|
-
Property({ through: "task://priority", resolveLanguage: "literal" }),
|
|
537
|
-
__metadata("design:type", Number)
|
|
538
|
-
], Task.prototype, "priority", void 0);
|
|
539
|
-
__decorate([
|
|
540
|
-
Property({ through: "task://done", resolveLanguage: "literal" }),
|
|
541
|
-
__metadata("design:type", Boolean)
|
|
542
|
-
], Task.prototype, "done", void 0);
|
|
543
|
-
__decorate([
|
|
544
|
-
Optional({ through: "task://description" }),
|
|
545
|
-
__metadata("design:type", String)
|
|
546
|
-
], Task.prototype, "description", void 0);
|
|
547
|
-
__decorate([
|
|
548
|
-
HasMany({ through: "task://tag" }),
|
|
549
|
-
__metadata("design:type", Array)
|
|
550
|
-
], Task.prototype, "tags", void 0);
|
|
551
|
-
__decorate([
|
|
552
|
-
HasMany({ through: "task://assignee" }),
|
|
553
|
-
__metadata("design:type", Array)
|
|
554
|
-
], Task.prototype, "assignees", void 0);
|
|
555
|
-
Task = __decorate([
|
|
556
|
-
Model({ name: "Task" })
|
|
557
|
-
], Task);
|
|
558
|
-
let EmptyModel = class EmptyModel extends Ad4mModel {
|
|
559
|
-
constructor() {
|
|
560
|
-
super(...arguments);
|
|
561
|
-
this.optField = "";
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
__decorate([
|
|
565
|
-
Optional({ through: "empty://optField" }),
|
|
566
|
-
__metadata("design:type", String)
|
|
567
|
-
], EmptyModel.prototype, "optField", void 0);
|
|
568
|
-
EmptyModel = __decorate([
|
|
569
|
-
Model({ name: "EmptyModel" })
|
|
570
|
-
], EmptyModel);
|
|
571
|
-
// ---- Comparison operators (gt, lt, gte, lte, between, contains) ----
|
|
572
|
-
// These are handled in JS post-processing, NOT in SPARQL.
|
|
573
|
-
// The tests verify that the SPARQL still generates valid output (conformance filters)
|
|
574
|
-
// but does NOT inject FILTER clauses for these operators.
|
|
575
|
-
it("should inject SPARQL FILTER for gt operator", async () => {
|
|
576
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { gt: 3 } } });
|
|
577
|
-
const norm = normalizeQuery(query);
|
|
578
|
-
expect(norm).toContain("SELECT ?source");
|
|
579
|
-
// gt is now handled via JS post-filter — SPARQL just joins the property
|
|
580
|
-
expect(norm).toContain("wTarget_cmp_rating");
|
|
581
|
-
});
|
|
582
|
-
it("should inject SPARQL FILTER for lt operator", async () => {
|
|
583
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { lt: 5 } } });
|
|
584
|
-
const norm = normalizeQuery(query);
|
|
585
|
-
expect(norm).toContain("SELECT ?source");
|
|
586
|
-
// lt is now handled via JS post-filter
|
|
587
|
-
expect(norm).toContain("wTarget_cmp_rating");
|
|
588
|
-
});
|
|
589
|
-
it("should inject SPARQL FILTER for gte/lte combined", async () => {
|
|
590
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { gte: 2, lte: 8 } } });
|
|
591
|
-
const norm = normalizeQuery(query);
|
|
592
|
-
expect(norm).toContain("SELECT ?source");
|
|
593
|
-
// gte/lte are now handled via JS post-filter
|
|
594
|
-
expect(norm).toContain("wTarget_cmp_rating");
|
|
595
|
-
});
|
|
596
|
-
it("should inject SPARQL FILTER for between operator", async () => {
|
|
597
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { between: [1, 10] } } });
|
|
598
|
-
const norm = normalizeQuery(query);
|
|
599
|
-
expect(norm).toContain("SELECT ?source");
|
|
600
|
-
// between is now handled via JS post-filter
|
|
601
|
-
expect(norm).toContain("wTarget_cmp_rating");
|
|
602
|
-
});
|
|
603
|
-
it("should inject SPARQL FILTER for contains operator", async () => {
|
|
604
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: { contains: "pasta" } } });
|
|
605
|
-
const norm = normalizeQuery(query);
|
|
606
|
-
expect(norm).toContain("SELECT ?source");
|
|
607
|
-
// contains is now handled via JS post-filter
|
|
608
|
-
expect(norm).toContain("wTarget_cmp_name");
|
|
609
|
-
});
|
|
610
|
-
// ---- Multiple property filters combined ----
|
|
611
|
-
it("should combine multiple property equality filters with &&", async () => {
|
|
612
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, {
|
|
613
|
-
where: { name: "Pasta", rating: ["4", "5"] }
|
|
614
|
-
});
|
|
615
|
-
const norm = normalizeQuery(query);
|
|
616
|
-
// Should have EXISTS blocks for both name and rating
|
|
617
|
-
expect(norm).toContain("recipe://name");
|
|
618
|
-
expect(norm).toContain("recipe://rating");
|
|
619
|
-
expect(norm).toContain("&&");
|
|
620
|
-
});
|
|
621
|
-
// ---- ORDER BY, LIMIT, OFFSET are JS post-processed ----
|
|
622
|
-
it("should include ORDER BY/LIMIT/OFFSET in SPARQL pagination subquery", async () => {
|
|
623
|
-
const query = await Recipe.queryToSPARQL(mockPerspective, { order: { name: "ASC" }, limit: 10, offset: 5 });
|
|
624
|
-
const norm = normalizeQuery(query);
|
|
625
|
-
expect(norm).toContain("SELECT ?source");
|
|
626
|
-
// SPARQL-level pagination via subquery
|
|
627
|
-
expect(norm).toContain("ORDER BY");
|
|
628
|
-
expect(norm).toContain("LIMIT 10");
|
|
629
|
-
expect(norm).toContain("OFFSET 5");
|
|
630
|
-
expect(norm).toContain("SELECT DISTINCT ?source");
|
|
631
|
-
});
|
|
632
|
-
});
|
|
633
|
-
describe("Ad4mModel query methods (modelQuery integration)", () => {
|
|
634
|
-
// Test Recipe model
|
|
635
|
-
let Recipe = class Recipe extends Ad4mModel {
|
|
636
|
-
constructor() {
|
|
637
|
-
super(...arguments);
|
|
638
|
-
this.name = "";
|
|
639
|
-
this.rating = 0;
|
|
640
|
-
this.ingredients = [];
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
__decorate([
|
|
644
|
-
Property({ through: "recipe://name" }),
|
|
645
|
-
__metadata("design:type", String)
|
|
646
|
-
], Recipe.prototype, "name", void 0);
|
|
647
|
-
__decorate([
|
|
648
|
-
Property({ through: "recipe://rating" }),
|
|
649
|
-
__metadata("design:type", Number)
|
|
650
|
-
], Recipe.prototype, "rating", void 0);
|
|
651
|
-
__decorate([
|
|
652
|
-
HasMany({ through: "recipe://ingredient" }),
|
|
653
|
-
__metadata("design:type", Array)
|
|
654
|
-
], Recipe.prototype, "ingredients", void 0);
|
|
655
|
-
Recipe = __decorate([
|
|
656
|
-
Model({ name: "Recipe" })
|
|
657
|
-
], Recipe);
|
|
658
|
-
// Mock perspective with querySparql, modelQuery, and infer methods
|
|
659
|
-
const mockPerspective = {
|
|
660
|
-
querySparql: jest.fn(),
|
|
661
|
-
modelQuery: jest.fn(),
|
|
662
|
-
infer: jest.fn(),
|
|
663
|
-
uuid: 'test-perspective-uuid',
|
|
664
|
-
stringOrTemplateObjectToSubjectClassName: jest.fn().mockResolvedValue('Recipe')
|
|
665
|
-
};
|
|
666
|
-
beforeEach(() => {
|
|
667
|
-
jest.clearAllMocks();
|
|
668
|
-
});
|
|
669
|
-
it("should use SPARQL when engine is 'sparql' in findAll()", async () => {
|
|
670
|
-
// modelQuery returns already-hydrated instances from the Rust executor
|
|
671
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
672
|
-
instances: [
|
|
673
|
-
{ id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
|
|
674
|
-
],
|
|
675
|
-
totalCount: 1
|
|
676
|
-
});
|
|
677
|
-
const results = await Recipe.findAll(mockPerspective, {}, 'sparql');
|
|
678
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
679
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
680
|
-
expect(results).toHaveLength(1);
|
|
681
|
-
expect(results[0].name).toBe("Pasta");
|
|
682
|
-
});
|
|
683
|
-
it("should route through modelQuery when engine is 'prolog' in findAll() (prolog is now no-op)", async () => {
|
|
684
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
685
|
-
instances: [
|
|
686
|
-
{ id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
|
|
687
|
-
],
|
|
688
|
-
totalCount: 1
|
|
689
|
-
});
|
|
690
|
-
const results = await Recipe.findAll(mockPerspective, {}, false);
|
|
691
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
692
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
693
|
-
expect(results).toHaveLength(1);
|
|
694
|
-
});
|
|
695
|
-
it("should use SPARQL when engine is 'sparql' in findAllAndCount()", async () => {
|
|
696
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
697
|
-
instances: [
|
|
698
|
-
{ id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
|
|
699
|
-
],
|
|
700
|
-
totalCount: 1
|
|
701
|
-
});
|
|
702
|
-
const { results, totalCount } = await Recipe.findAllAndCount(mockPerspective, {});
|
|
703
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
704
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
705
|
-
expect(results).toHaveLength(1);
|
|
706
|
-
expect(totalCount).toBe(1);
|
|
707
|
-
});
|
|
708
|
-
it("should use SPARQL when engine is 'sparql' in paginate()", async () => {
|
|
709
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
710
|
-
instances: [
|
|
711
|
-
{ id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
|
|
712
|
-
],
|
|
713
|
-
totalCount: 1
|
|
714
|
-
});
|
|
715
|
-
const page = await Recipe.paginate(mockPerspective, 10, 1, {});
|
|
716
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
717
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
718
|
-
expect(page.results).toHaveLength(1);
|
|
719
|
-
expect(page.pageSize).toBe(10);
|
|
720
|
-
expect(page.pageNumber).toBe(1);
|
|
721
|
-
expect(page.totalCount).toBe(1);
|
|
722
|
-
});
|
|
723
|
-
it("should use SPARQL in count()", async () => {
|
|
724
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
725
|
-
instances: [],
|
|
726
|
-
totalCount: 5
|
|
727
|
-
});
|
|
728
|
-
const count = await Recipe.count(mockPerspective, {});
|
|
729
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
730
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
731
|
-
expect(count).toBe(5);
|
|
732
|
-
});
|
|
733
|
-
it("should return count from modelQuery", async () => {
|
|
734
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
735
|
-
instances: [],
|
|
736
|
-
totalCount: 10
|
|
737
|
-
});
|
|
738
|
-
const count = await Recipe.count(mockPerspective, {});
|
|
739
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
740
|
-
expect(mockPerspective.querySparql).not.toHaveBeenCalled();
|
|
741
|
-
expect(count).toBe(10);
|
|
742
|
-
});
|
|
743
|
-
it("should use SPARQL when engine is 'sparql' in ModelQueryBuilder.get()", async () => {
|
|
744
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
745
|
-
instances: [
|
|
746
|
-
{ id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
|
|
747
|
-
],
|
|
748
|
-
totalCount: 1
|
|
749
|
-
});
|
|
750
|
-
const results = await Recipe.query(mockPerspective)
|
|
751
|
-
.where({ name: "Pasta" })
|
|
752
|
-
.engine('sparql')
|
|
753
|
-
.get();
|
|
754
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
755
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
756
|
-
expect(results).toHaveLength(1);
|
|
757
|
-
expect(results[0].name).toBe("Pasta");
|
|
758
|
-
});
|
|
759
|
-
it("should use modelQuery when .engine('prolog') is called (engine is now a no-op)", async () => {
|
|
760
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
761
|
-
instances: [
|
|
762
|
-
{ id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
|
|
763
|
-
],
|
|
764
|
-
totalCount: 1
|
|
765
|
-
});
|
|
766
|
-
const results = await Recipe.query(mockPerspective)
|
|
767
|
-
.where({ name: "Pasta" })
|
|
768
|
-
.engine('prolog')
|
|
769
|
-
.get();
|
|
770
|
-
// engine('prolog') is now a no-op — everything goes through modelQuery
|
|
771
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
772
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
773
|
-
expect(results).toHaveLength(1);
|
|
774
|
-
});
|
|
775
|
-
it("should use SPARQL when engine is 'sparql' in ModelQueryBuilder.count()", async () => {
|
|
776
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
777
|
-
instances: [],
|
|
778
|
-
totalCount: 3
|
|
779
|
-
});
|
|
780
|
-
const count = await Recipe.query(mockPerspective)
|
|
781
|
-
.where({ rating: { gt: 4 } })
|
|
782
|
-
.engine('sparql')
|
|
783
|
-
.count();
|
|
784
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
785
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
786
|
-
expect(count).toBe(3);
|
|
787
|
-
});
|
|
788
|
-
it("should use SPARQL when engine is 'sparql' in ModelQueryBuilder.paginate()", async () => {
|
|
789
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
790
|
-
instances: [
|
|
791
|
-
{ id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
|
|
792
|
-
],
|
|
793
|
-
totalCount: 1
|
|
794
|
-
});
|
|
795
|
-
const page = await Recipe.query(mockPerspective)
|
|
796
|
-
.where({ rating: { gt: 3 } })
|
|
797
|
-
.engine('sparql')
|
|
798
|
-
.paginate(10, 1);
|
|
799
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
800
|
-
expect(mockPerspective.infer).not.toHaveBeenCalled();
|
|
801
|
-
expect(page.results).toHaveLength(1);
|
|
802
|
-
expect(page.pageSize).toBe(10);
|
|
803
|
-
expect(page.pageNumber).toBe(1);
|
|
804
|
-
});
|
|
805
|
-
});
|
|
806
|
-
describe("Ad4mModel.count() with advanced where conditions", () => {
|
|
807
|
-
// Test Recipe model
|
|
808
|
-
let Recipe = class Recipe extends Ad4mModel {
|
|
809
|
-
constructor() {
|
|
810
|
-
super(...arguments);
|
|
811
|
-
this.name = "";
|
|
812
|
-
this.rating = 0;
|
|
813
|
-
this.ingredients = [];
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
__decorate([
|
|
817
|
-
Property({ through: "recipe://name" }),
|
|
818
|
-
__metadata("design:type", String)
|
|
819
|
-
], Recipe.prototype, "name", void 0);
|
|
820
|
-
__decorate([
|
|
821
|
-
Property({ through: "recipe://rating" }),
|
|
822
|
-
__metadata("design:type", Number)
|
|
823
|
-
], Recipe.prototype, "rating", void 0);
|
|
824
|
-
__decorate([
|
|
825
|
-
HasMany({ through: "recipe://ingredient" }),
|
|
826
|
-
__metadata("design:type", Array)
|
|
827
|
-
], Recipe.prototype, "ingredients", void 0);
|
|
828
|
-
Recipe = __decorate([
|
|
829
|
-
Model({ name: "Recipe" })
|
|
830
|
-
], Recipe);
|
|
831
|
-
// Mock perspective
|
|
832
|
-
const mockPerspective = {
|
|
833
|
-
querySparql: jest.fn(),
|
|
834
|
-
modelQuery: jest.fn(),
|
|
835
|
-
infer: jest.fn(),
|
|
836
|
-
uuid: 'test-perspective-uuid',
|
|
837
|
-
stringOrTemplateObjectToSubjectClassName: jest.fn().mockResolvedValue('Recipe')
|
|
838
|
-
};
|
|
839
|
-
beforeEach(() => {
|
|
840
|
-
jest.clearAllMocks();
|
|
841
|
-
});
|
|
842
|
-
it("should apply filtering for gt operator on properties in SPARQL count()", async () => {
|
|
843
|
-
// With the new modelQuery endpoint, filtering happens server-side in Rust
|
|
844
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
845
|
-
instances: [],
|
|
846
|
-
totalCount: 2
|
|
847
|
-
});
|
|
848
|
-
// Count recipes with rating > 3 (should match 2 recipes: rating 4 and 5)
|
|
849
|
-
const count = await Recipe.count(mockPerspective, { where: { rating: { gt: 3 } } });
|
|
850
|
-
expect(count).toBe(2);
|
|
851
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalled();
|
|
852
|
-
});
|
|
853
|
-
it("should apply filtering for between operator on properties in SPARQL count()", async () => {
|
|
854
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
855
|
-
instances: [],
|
|
856
|
-
totalCount: 3
|
|
857
|
-
});
|
|
858
|
-
// Count recipes with rating between 2 and 4 (should match 3 recipes: rating 2, 3, 4)
|
|
859
|
-
const count = await Recipe.count(mockPerspective, { where: { rating: { between: [2, 4] } } });
|
|
860
|
-
expect(count).toBe(3);
|
|
861
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalled();
|
|
862
|
-
});
|
|
863
|
-
it("should apply filtering for timestamp gt operator in SPARQL count()", async () => {
|
|
864
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
865
|
-
instances: [],
|
|
866
|
-
totalCount: 2
|
|
867
|
-
});
|
|
868
|
-
const targetTimestamp = new Date("2023-01-03T00:00:00Z").getTime();
|
|
869
|
-
const count = await Recipe.count(mockPerspective, { where: { timestamp: { gt: targetTimestamp } } });
|
|
870
|
-
expect(count).toBe(2);
|
|
871
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalled();
|
|
872
|
-
});
|
|
873
|
-
it("should apply filtering for timestamp between operator in SPARQL count()", async () => {
|
|
874
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
875
|
-
instances: [],
|
|
876
|
-
totalCount: 3
|
|
877
|
-
});
|
|
878
|
-
const startTimestamp = new Date("2023-01-02T00:00:00Z").getTime();
|
|
879
|
-
const endTimestamp = new Date("2023-01-04T00:00:00Z").getTime();
|
|
880
|
-
const count = await Recipe.count(mockPerspective, {
|
|
881
|
-
where: { timestamp: { between: [startTimestamp, endTimestamp] } }
|
|
882
|
-
});
|
|
883
|
-
expect(count).toBe(3);
|
|
884
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalled();
|
|
885
|
-
});
|
|
886
|
-
it("should apply filtering for author filtering in SPARQL count()", async () => {
|
|
887
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
888
|
-
instances: [],
|
|
889
|
-
totalCount: 3
|
|
890
|
-
});
|
|
891
|
-
// Count recipes by Alice (should match 3 recipes)
|
|
892
|
-
const count = await Recipe.count(mockPerspective, { where: { author: "did:key:alice" } });
|
|
893
|
-
expect(count).toBe(3);
|
|
894
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalled();
|
|
895
|
-
});
|
|
896
|
-
it("should apply filtering in ModelQueryBuilder.count() with gt operator", async () => {
|
|
897
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
898
|
-
instances: [],
|
|
899
|
-
totalCount: 2
|
|
900
|
-
});
|
|
901
|
-
// Count recipes with rating > 3 using ModelQueryBuilder
|
|
902
|
-
const count = await Recipe.query(mockPerspective)
|
|
903
|
-
.where({ rating: { gt: 3 } })
|
|
904
|
-
.engine('sparql')
|
|
905
|
-
.count();
|
|
906
|
-
expect(count).toBe(2);
|
|
907
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalled();
|
|
908
|
-
});
|
|
909
|
-
it("should apply filtering in ModelQueryBuilder.count() with timestamp between", async () => {
|
|
910
|
-
mockPerspective.modelQuery.mockResolvedValue({
|
|
911
|
-
instances: [],
|
|
912
|
-
totalCount: 3
|
|
913
|
-
});
|
|
914
|
-
const startTimestamp = new Date("2023-01-02T00:00:00Z").getTime();
|
|
915
|
-
const endTimestamp = new Date("2023-01-04T00:00:00Z").getTime();
|
|
916
|
-
// Count using ModelQueryBuilder
|
|
917
|
-
const count = await Recipe.query(mockPerspective)
|
|
918
|
-
.where({ timestamp: { between: [startTimestamp, endTimestamp] } })
|
|
919
|
-
.engine('sparql')
|
|
920
|
-
.count();
|
|
921
|
-
expect(count).toBe(3);
|
|
922
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalled();
|
|
923
|
-
});
|
|
924
|
-
});
|
|
925
|
-
describe("SPARQL comparison filters", () => {
|
|
926
|
-
let Item = class Item extends Ad4mModel {
|
|
927
|
-
};
|
|
928
|
-
__decorate([
|
|
929
|
-
Property({ through: "item://price", required: true }),
|
|
930
|
-
__metadata("design:type", String)
|
|
931
|
-
], Item.prototype, "price", void 0);
|
|
932
|
-
__decorate([
|
|
933
|
-
Property({ through: "item://name", required: true }),
|
|
934
|
-
__metadata("design:type", String)
|
|
935
|
-
], Item.prototype, "name", void 0);
|
|
936
|
-
Item = __decorate([
|
|
937
|
-
Model({ name: "Item" })
|
|
938
|
-
], Item);
|
|
939
|
-
it("should generate gt filter", async () => {
|
|
940
|
-
const mockPersp = { getLinks: jest.fn().mockResolvedValue([]) };
|
|
941
|
-
const query = await Item.queryToSPARQL(mockPersp, { where: { price: { gt: 10 } } });
|
|
942
|
-
// gt is now JS post-filter — SPARQL just joins the property
|
|
943
|
-
expect(query).toContain("item://price");
|
|
944
|
-
});
|
|
945
|
-
it("should generate between filter", async () => {
|
|
946
|
-
const mockPersp = { getLinks: jest.fn().mockResolvedValue([]) };
|
|
947
|
-
const query = await Item.queryToSPARQL(mockPersp, { where: { price: { between: [5, 20] } } });
|
|
948
|
-
// between is now JS post-filter
|
|
949
|
-
expect(query).toContain("item://price");
|
|
950
|
-
});
|
|
951
|
-
it("should generate contains filter", async () => {
|
|
952
|
-
const mockPersp = { getLinks: jest.fn().mockResolvedValue([]) };
|
|
953
|
-
const query = await Item.queryToSPARQL(mockPersp, { where: { name: { contains: "widget" } } });
|
|
954
|
-
// contains is now JS post-filter
|
|
955
|
-
expect(query).toContain("item://name");
|
|
956
|
-
});
|
|
957
|
-
});
|
|
958
|
-
// ──────────────────────────────────────────────────────────
|
|
959
|
-
// SPARQL Direct Triple Pattern & IRI Tests
|
|
960
|
-
// ──────────────────────────────────────────────────────────
|
|
961
|
-
import { buildSPARQLQuery, formatSPARQLValue } from "./query-sparql";
|
|
962
|
-
describe("SPARQL direct triple pattern generation", () => {
|
|
963
|
-
let Channel = class Channel extends Ad4mModel {
|
|
964
|
-
constructor() {
|
|
965
|
-
super(...arguments);
|
|
966
|
-
this.type = "";
|
|
967
|
-
this.name = "";
|
|
968
|
-
this.description = "";
|
|
969
|
-
this.messages = [];
|
|
970
|
-
}
|
|
971
|
-
};
|
|
972
|
-
__decorate([
|
|
973
|
-
Flag({ through: "flux://entry_type", value: "flux://channel" }),
|
|
974
|
-
__metadata("design:type", String)
|
|
975
|
-
], Channel.prototype, "type", void 0);
|
|
976
|
-
__decorate([
|
|
977
|
-
Property({ through: "flux://name", resolveLanguage: "literal", required: true }),
|
|
978
|
-
__metadata("design:type", String)
|
|
979
|
-
], Channel.prototype, "name", void 0);
|
|
980
|
-
__decorate([
|
|
981
|
-
Optional({ through: "flux://description" }),
|
|
982
|
-
__metadata("design:type", String)
|
|
983
|
-
], Channel.prototype, "description", void 0);
|
|
984
|
-
__decorate([
|
|
985
|
-
HasMany({ through: "flux://has_message" }),
|
|
986
|
-
__metadata("design:type", Array)
|
|
987
|
-
], Channel.prototype, "messages", void 0);
|
|
988
|
-
Channel = __decorate([
|
|
989
|
-
Model({ name: "Channel" })
|
|
990
|
-
], Channel);
|
|
991
|
-
const mockPersp = {};
|
|
992
|
-
it("generates direct triple pattern with ?source ?predicate ?target", async () => {
|
|
993
|
-
const query = await Channel.queryToSPARQL(mockPersp, {});
|
|
994
|
-
// Must use direct triple pattern, not link-node reification
|
|
995
|
-
expect(query).toContain("?source ?predicate ?target");
|
|
996
|
-
expect(query).not.toContain("rdf:type");
|
|
997
|
-
expect(query).not.toContain("ad4m:Link");
|
|
998
|
-
});
|
|
999
|
-
it("generates Flag filter as ?source <predicate> <value>", async () => {
|
|
1000
|
-
const query = await Channel.queryToSPARQL(mockPersp, {});
|
|
1001
|
-
expect(query).toContain("<flux://entry_type>");
|
|
1002
|
-
expect(query).toContain("<flux://channel>");
|
|
1003
|
-
});
|
|
1004
|
-
it("generates Property binding as ?source <predicate> ?varName", async () => {
|
|
1005
|
-
const query = await Channel.queryToSPARQL(mockPersp, {});
|
|
1006
|
-
expect(query).toContain("<flux://name>");
|
|
1007
|
-
expect(query).toMatch(/\?source\s+<flux:\/\/name>\s+\?cfTarget_name/);
|
|
1008
|
-
});
|
|
1009
|
-
it("uses RDF 1.2 reifier pattern for author/timestamp", async () => {
|
|
1010
|
-
const query = await Channel.queryToSPARQL(mockPersp, {});
|
|
1011
|
-
expect(query).toContain("<http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies>");
|
|
1012
|
-
expect(query).toContain("?source ?predicate ?target .");
|
|
1013
|
-
expect(query).toContain("?_reifier <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source ?predicate ?target )>>");
|
|
1014
|
-
expect(query).toContain("?_reifier <ad4m://ontology/author> ?author");
|
|
1015
|
-
expect(query).toContain("?_reifier <ad4m://ontology/timestamp> ?timestamp");
|
|
1016
|
-
expect(query).not.toContain("GRAPH");
|
|
1017
|
-
});
|
|
1018
|
-
it("uses FILTER(isIRI(?source)) to exclude non-IRI subjects", async () => {
|
|
1019
|
-
const query = await Channel.queryToSPARQL(mockPersp, {});
|
|
1020
|
-
expect(query).toContain("FILTER(isIRI(?source)");
|
|
1021
|
-
});
|
|
1022
|
-
});
|
|
1023
|
-
describe("formatSPARQLValue", () => {
|
|
1024
|
-
it("wraps strings in double quotes", () => {
|
|
1025
|
-
expect(formatSPARQLValue("hello")).toBe('"hello"');
|
|
1026
|
-
});
|
|
1027
|
-
it("escapes special characters", () => {
|
|
1028
|
-
expect(formatSPARQLValue('say "hi"')).toBe('"say \\"hi\\""');
|
|
1029
|
-
});
|
|
1030
|
-
it("converts numbers to quoted strings", () => {
|
|
1031
|
-
expect(formatSPARQLValue(42)).toBe('"42"');
|
|
1032
|
-
});
|
|
1033
|
-
});
|
|
1034
|
-
// ──────────────────────────────────────────────────────────
|
|
1035
|
-
// Comprehensive SPARQL migration unit tests
|
|
1036
|
-
// ──────────────────────────────────────────────────────────
|
|
1037
|
-
import { matchesCondition } from "./hydration";
|
|
1038
|
-
import { Literal } from "../Literal";
|
|
1039
|
-
// Helper: create literal URLs using JSON encoding (which handles all types including booleans)
|
|
1040
|
-
function literalUrl(value) {
|
|
1041
|
-
if (typeof value === 'string')
|
|
1042
|
-
return Literal.from(value).toUrl();
|
|
1043
|
-
// Use JSON encoding for numbers and booleans since Literal.get() doesn't handle boolean: prefix
|
|
1044
|
-
return `literal:json:${encodeURIComponent(JSON.stringify(value))}`;
|
|
1045
|
-
}
|
|
1046
|
-
describe("matchesCondition()", () => {
|
|
1047
|
-
// Simple equality
|
|
1048
|
-
it("simple string equality — match", () => {
|
|
1049
|
-
expect(matchesCondition("hello", "hello")).toBe(true);
|
|
1050
|
-
});
|
|
1051
|
-
it("simple string equality — mismatch", () => {
|
|
1052
|
-
expect(matchesCondition("hello", "world")).toBe(false);
|
|
1053
|
-
});
|
|
1054
|
-
it("simple boolean equality — true", () => {
|
|
1055
|
-
expect(matchesCondition(true, true)).toBe(true);
|
|
1056
|
-
});
|
|
1057
|
-
it("simple boolean equality — false", () => {
|
|
1058
|
-
expect(matchesCondition(false, false)).toBe(true);
|
|
1059
|
-
});
|
|
1060
|
-
it("boolean mismatch", () => {
|
|
1061
|
-
expect(matchesCondition(true, false)).toBe(false);
|
|
1062
|
-
});
|
|
1063
|
-
it("simple number equality", () => {
|
|
1064
|
-
expect(matchesCondition(42, 42)).toBe(true);
|
|
1065
|
-
});
|
|
1066
|
-
it("number mismatch", () => {
|
|
1067
|
-
expect(matchesCondition(42, 99)).toBe(false);
|
|
1068
|
-
});
|
|
1069
|
-
// Array IN clause
|
|
1070
|
-
it("array IN clause — value present", () => {
|
|
1071
|
-
expect(matchesCondition("a", ["a", "b", "c"])).toBe(true);
|
|
1072
|
-
});
|
|
1073
|
-
it("array IN clause — value absent", () => {
|
|
1074
|
-
expect(matchesCondition("d", ["a", "b", "c"])).toBe(false);
|
|
1075
|
-
});
|
|
1076
|
-
// NOT operator
|
|
1077
|
-
it("not operator with string", () => {
|
|
1078
|
-
expect(matchesCondition("bob", { not: "alice" })).toBe(true);
|
|
1079
|
-
expect(matchesCondition("alice", { not: "alice" })).toBe(false);
|
|
1080
|
-
});
|
|
1081
|
-
it("not operator with array (NOT IN)", () => {
|
|
1082
|
-
expect(matchesCondition("a", { not: ["b", "c"] })).toBe(true);
|
|
1083
|
-
expect(matchesCondition("b", { not: ["b", "c"] })).toBe(false);
|
|
1084
|
-
});
|
|
1085
|
-
// Comparison operators
|
|
1086
|
-
it("gt", () => {
|
|
1087
|
-
expect(matchesCondition(10, { gt: 5 })).toBe(true);
|
|
1088
|
-
expect(matchesCondition(5, { gt: 5 })).toBe(false);
|
|
1089
|
-
});
|
|
1090
|
-
it("gte", () => {
|
|
1091
|
-
expect(matchesCondition(5, { gte: 5 })).toBe(true);
|
|
1092
|
-
expect(matchesCondition(4, { gte: 5 })).toBe(false);
|
|
1093
|
-
});
|
|
1094
|
-
it("lt", () => {
|
|
1095
|
-
expect(matchesCondition(3, { lt: 5 })).toBe(true);
|
|
1096
|
-
expect(matchesCondition(5, { lt: 5 })).toBe(false);
|
|
1097
|
-
});
|
|
1098
|
-
it("lte", () => {
|
|
1099
|
-
expect(matchesCondition(5, { lte: 5 })).toBe(true);
|
|
1100
|
-
expect(matchesCondition(6, { lte: 5 })).toBe(false);
|
|
1101
|
-
});
|
|
1102
|
-
it("combined gt + lt (range)", () => {
|
|
1103
|
-
expect(matchesCondition(5, { gt: 3, lt: 7 })).toBe(true);
|
|
1104
|
-
expect(matchesCondition(3, { gt: 3, lt: 7 })).toBe(false);
|
|
1105
|
-
expect(matchesCondition(7, { gt: 3, lt: 7 })).toBe(false);
|
|
1106
|
-
});
|
|
1107
|
-
// Between
|
|
1108
|
-
it("between — inclusive range", () => {
|
|
1109
|
-
expect(matchesCondition(5, { between: [3, 7] })).toBe(true);
|
|
1110
|
-
expect(matchesCondition(3, { between: [3, 7] })).toBe(true);
|
|
1111
|
-
expect(matchesCondition(7, { between: [3, 7] })).toBe(true);
|
|
1112
|
-
expect(matchesCondition(2, { between: [3, 7] })).toBe(false);
|
|
1113
|
-
expect(matchesCondition(8, { between: [3, 7] })).toBe(false);
|
|
1114
|
-
});
|
|
1115
|
-
// Contains
|
|
1116
|
-
it("contains with string", () => {
|
|
1117
|
-
expect(matchesCondition("hello world", { contains: "world" })).toBe(true);
|
|
1118
|
-
expect(matchesCondition("hello world", { contains: "xyz" })).toBe(false);
|
|
1119
|
-
});
|
|
1120
|
-
it("contains with array", () => {
|
|
1121
|
-
expect(matchesCondition(["a", "b", "c"], { contains: "b" })).toBe(true);
|
|
1122
|
-
expect(matchesCondition(["a", "b", "c"], { contains: "d" })).toBe(false);
|
|
1123
|
-
});
|
|
1124
|
-
// Edge cases
|
|
1125
|
-
it("returns false for undefined value with equality check", () => {
|
|
1126
|
-
expect(matchesCondition(undefined, "hello")).toBe(false);
|
|
1127
|
-
});
|
|
1128
|
-
it("returns false for empty string when condition is non-empty", () => {
|
|
1129
|
-
expect(matchesCondition("", "Recipe 2")).toBe(false);
|
|
1130
|
-
});
|
|
1131
|
-
it("returns true for undefined with not operator", () => {
|
|
1132
|
-
expect(matchesCondition(undefined, { not: "hello" })).toBe(true);
|
|
1133
|
-
});
|
|
1134
|
-
});
|
|
1135
|
-
describe("buildSPARQLQuery edge cases", () => {
|
|
1136
|
-
let FlagModel = class FlagModel extends Ad4mModel {
|
|
1137
|
-
constructor() {
|
|
1138
|
-
super(...arguments);
|
|
1139
|
-
this.type = "";
|
|
1140
|
-
this.name = "";
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
__decorate([
|
|
1144
|
-
Flag({ through: "flag://type", value: "flag://FlagModel" }),
|
|
1145
|
-
__metadata("design:type", String)
|
|
1146
|
-
], FlagModel.prototype, "type", void 0);
|
|
1147
|
-
__decorate([
|
|
1148
|
-
Property({ through: "flag://name", resolveLanguage: "literal", required: true }),
|
|
1149
|
-
__metadata("design:type", String)
|
|
1150
|
-
], FlagModel.prototype, "name", void 0);
|
|
1151
|
-
FlagModel = __decorate([
|
|
1152
|
-
Model({ name: "FlagModel" })
|
|
1153
|
-
], FlagModel);
|
|
1154
|
-
let NoFlagModel = class NoFlagModel extends Ad4mModel {
|
|
1155
|
-
constructor() {
|
|
1156
|
-
super(...arguments);
|
|
1157
|
-
this.title = "";
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
__decorate([
|
|
1161
|
-
Property({ through: "noflag://title", resolveLanguage: "literal" }),
|
|
1162
|
-
__metadata("design:type", String)
|
|
1163
|
-
], NoFlagModel.prototype, "title", void 0);
|
|
1164
|
-
NoFlagModel = __decorate([
|
|
1165
|
-
Model({ name: "NoFlagModel" })
|
|
1166
|
-
], NoFlagModel);
|
|
1167
|
-
it("adds conformance JOIN for flag + required properties", () => {
|
|
1168
|
-
const metadata = FlagModel.getModelMetadata();
|
|
1169
|
-
const allRelsMeta = {};
|
|
1170
|
-
const sparql = buildSPARQLQuery(metadata, allRelsMeta, {}, FlagModel);
|
|
1171
|
-
// Should contain flag triple pattern
|
|
1172
|
-
expect(sparql).toContain("<flag://type>");
|
|
1173
|
-
expect(sparql).toContain("<flag://FlagModel>");
|
|
1174
|
-
// Should contain required property pattern
|
|
1175
|
-
expect(sparql).toContain("<flag://name>");
|
|
1176
|
-
});
|
|
1177
|
-
it("uses structural subquery when no conformance patterns exist", () => {
|
|
1178
|
-
const metadata = NoFlagModel.getModelMetadata();
|
|
1179
|
-
const allRelsMeta = {};
|
|
1180
|
-
const sparql = buildSPARQLQuery(metadata, allRelsMeta, {}, NoFlagModel);
|
|
1181
|
-
// Should contain structural subquery with DISTINCT
|
|
1182
|
-
expect(sparql).toContain("SELECT DISTINCT ?source");
|
|
1183
|
-
expect(sparql).toContain("<noflag://title>");
|
|
1184
|
-
});
|
|
1185
|
-
it("adds JOIN for where-clause on literal-stored fields", () => {
|
|
1186
|
-
const metadata = FlagModel.getModelMetadata();
|
|
1187
|
-
const allRelsMeta = {};
|
|
1188
|
-
const sparql = buildSPARQLQuery(metadata, allRelsMeta, { where: { name: "test" } }, FlagModel);
|
|
1189
|
-
// Where clause should add a join pattern for name
|
|
1190
|
-
expect(sparql).toContain("flag://name");
|
|
1191
|
-
});
|
|
1192
|
-
it("handles where: {id: 'specific-id'} with FILTER on ?source", () => {
|
|
1193
|
-
const metadata = FlagModel.getModelMetadata();
|
|
1194
|
-
const allRelsMeta = {};
|
|
1195
|
-
const sparql = buildSPARQLQuery(metadata, allRelsMeta, { where: { id: "expr:123" } }, FlagModel);
|
|
1196
|
-
// Should filter by source
|
|
1197
|
-
expect(sparql).toContain("expr:123");
|
|
1198
|
-
});
|
|
1199
|
-
});
|
|
1200
|
-
// ── Batch hydration for reverse relations (3.4) ─────────────────────────────
|
|
1201
|
-
describe("Batch hydration for reverse relations", () => {
|
|
1202
|
-
it("batch hydration should correctly group targets by parent instance ID", () => {
|
|
1203
|
-
// Test the grouping logic used in batch SPARQL hydration
|
|
1204
|
-
const sparqlResults = [
|
|
1205
|
-
{ target: "inst:1", source: "child:a" },
|
|
1206
|
-
{ target: "inst:1", source: "child:b" },
|
|
1207
|
-
{ target: "inst:2", source: "child:c" },
|
|
1208
|
-
{ target: "inst:3", source: "child:d" },
|
|
1209
|
-
{ target: "inst:3", source: "child:e" },
|
|
1210
|
-
{ target: "inst:3", source: "child:f" },
|
|
1211
|
-
];
|
|
1212
|
-
const reverseLinksMap = new Map();
|
|
1213
|
-
for (const row of sparqlResults) {
|
|
1214
|
-
if (!reverseLinksMap.has(row.target))
|
|
1215
|
-
reverseLinksMap.set(row.target, []);
|
|
1216
|
-
reverseLinksMap.get(row.target).push(row.source);
|
|
1217
|
-
}
|
|
1218
|
-
expect(reverseLinksMap.get("inst:1")).toEqual(["child:a", "child:b"]);
|
|
1219
|
-
expect(reverseLinksMap.get("inst:2")).toEqual(["child:c"]);
|
|
1220
|
-
expect(reverseLinksMap.get("inst:3")).toEqual(["child:d", "child:e", "child:f"]);
|
|
1221
|
-
});
|
|
1222
|
-
it("batch hydration should handle empty relation sets without error", () => {
|
|
1223
|
-
const sparqlResults = [];
|
|
1224
|
-
const reverseLinksMap = new Map();
|
|
1225
|
-
for (const row of sparqlResults) {
|
|
1226
|
-
if (!reverseLinksMap.has(row.target))
|
|
1227
|
-
reverseLinksMap.set(row.target, []);
|
|
1228
|
-
reverseLinksMap.get(row.target).push(row.source);
|
|
1229
|
-
}
|
|
1230
|
-
expect(reverseLinksMap.size).toBe(0);
|
|
1231
|
-
expect(reverseLinksMap.get("nonexistent") || []).toEqual([]);
|
|
1232
|
-
});
|
|
1233
|
-
it("batch hydration should return identical results to N+1 hydration (grouping equivalence)", () => {
|
|
1234
|
-
// Simulate N+1: each instance queries separately
|
|
1235
|
-
const instances = [{ id: "inst:1" }, { id: "inst:2" }];
|
|
1236
|
-
const allLinks = [
|
|
1237
|
-
{ data: { source: "child:a", predicate: "rel://has", target: "inst:1" } },
|
|
1238
|
-
{ data: { source: "child:b", predicate: "rel://has", target: "inst:1" } },
|
|
1239
|
-
{ data: { source: "child:c", predicate: "rel://has", target: "inst:2" } },
|
|
1240
|
-
];
|
|
1241
|
-
// N+1 approach
|
|
1242
|
-
const n1Results = new Map();
|
|
1243
|
-
for (const inst of instances) {
|
|
1244
|
-
const links = allLinks.filter(l => l.data.target === inst.id);
|
|
1245
|
-
n1Results.set(inst.id, links.map(l => l.data.source));
|
|
1246
|
-
}
|
|
1247
|
-
// Batch approach
|
|
1248
|
-
const batchResults = new Map();
|
|
1249
|
-
const sparqlRows = allLinks.map(l => ({ target: l.data.target, source: l.data.source }));
|
|
1250
|
-
for (const row of sparqlRows) {
|
|
1251
|
-
if (!batchResults.has(row.target))
|
|
1252
|
-
batchResults.set(row.target, []);
|
|
1253
|
-
batchResults.get(row.target).push(row.source);
|
|
1254
|
-
}
|
|
1255
|
-
// Results should be identical
|
|
1256
|
-
for (const inst of instances) {
|
|
1257
|
-
expect(batchResults.get(inst.id)).toEqual(n1Results.get(inst.id));
|
|
1258
|
-
}
|
|
1259
|
-
});
|
|
1260
|
-
it("batch hydration with nested includes should use batched queries at each level", () => {
|
|
1261
|
-
// This test verifies the structure: nested includes result in multiple
|
|
1262
|
-
// batch operations, one per relation depth level
|
|
1263
|
-
const depth0Rows = [
|
|
1264
|
-
{ target: "root:1", source: "mid:a" },
|
|
1265
|
-
{ target: "root:1", source: "mid:b" },
|
|
1266
|
-
];
|
|
1267
|
-
const depth1Rows = [
|
|
1268
|
-
{ target: "mid:a", source: "leaf:x" },
|
|
1269
|
-
{ target: "mid:b", source: "leaf:y" },
|
|
1270
|
-
];
|
|
1271
|
-
// Group each level
|
|
1272
|
-
const level0Map = new Map();
|
|
1273
|
-
for (const r of depth0Rows) {
|
|
1274
|
-
if (!level0Map.has(r.target))
|
|
1275
|
-
level0Map.set(r.target, []);
|
|
1276
|
-
level0Map.get(r.target).push(r.source);
|
|
1277
|
-
}
|
|
1278
|
-
const level1Map = new Map();
|
|
1279
|
-
for (const r of depth1Rows) {
|
|
1280
|
-
if (!level1Map.has(r.target))
|
|
1281
|
-
level1Map.set(r.target, []);
|
|
1282
|
-
level1Map.get(r.target).push(r.source);
|
|
1283
|
-
}
|
|
1284
|
-
expect(level0Map.get("root:1")).toEqual(["mid:a", "mid:b"]);
|
|
1285
|
-
expect(level1Map.get("mid:a")).toEqual(["leaf:x"]);
|
|
1286
|
-
expect(level1Map.get("mid:b")).toEqual(["leaf:y"]);
|
|
1287
|
-
});
|
|
1288
|
-
});
|
|
1289
|
-
// ── Push-down FILTER for literal equality (3.5) ──────────────────────────────
|
|
1290
|
-
describe("Push-down FILTER for literal equality", () => {
|
|
1291
|
-
const mockPerspective = {};
|
|
1292
|
-
let FilterTest = class FilterTest extends Ad4mModel {
|
|
1293
|
-
constructor() {
|
|
1294
|
-
super(...arguments);
|
|
1295
|
-
this.name = "";
|
|
1296
|
-
this.rating = 0;
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
__decorate([
|
|
1300
|
-
Property({ through: "ft://name", required: true }),
|
|
1301
|
-
__metadata("design:type", String)
|
|
1302
|
-
], FilterTest.prototype, "name", void 0);
|
|
1303
|
-
__decorate([
|
|
1304
|
-
Property({ through: "ft://rating", required: true }),
|
|
1305
|
-
__metadata("design:type", Number)
|
|
1306
|
-
], FilterTest.prototype, "rating", void 0);
|
|
1307
|
-
FilterTest = __decorate([
|
|
1308
|
-
Model({ name: "FilterTest" })
|
|
1309
|
-
], FilterTest);
|
|
1310
|
-
const normalizeQuery = (q) => q.replace(/\s+/g, " ").trim();
|
|
1311
|
-
it("SPARQL query for where: { name: 'Alice' } should use <ad4m://fn/parse_literal> FILTER", async () => {
|
|
1312
|
-
const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { name: "Alice" } });
|
|
1313
|
-
const norm = normalizeQuery(query);
|
|
1314
|
-
// JOIN pattern exists
|
|
1315
|
-
expect(norm).toContain("?wTarget_name");
|
|
1316
|
-
// parse_literal push-down FILTER is present (using correct SPARQL IRI syntax)
|
|
1317
|
-
expect(norm).toContain("ad4m://fn/parse_literal");
|
|
1318
|
-
expect(norm).not.toContain("fn::parse_literal");
|
|
1319
|
-
});
|
|
1320
|
-
it("SPARQL query for where: { name: ['Alice', 'Bob'] } should use <ad4m://fn/parse_literal> IN FILTER", async () => {
|
|
1321
|
-
const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { name: ["Alice", "Bob"] } });
|
|
1322
|
-
const norm = normalizeQuery(query);
|
|
1323
|
-
expect(norm).toContain("?wTarget_name");
|
|
1324
|
-
expect(norm).toContain("ad4m://fn/parse_literal");
|
|
1325
|
-
expect(norm).not.toContain("fn::parse_literal");
|
|
1326
|
-
});
|
|
1327
|
-
it("SPARQL query for where: { rating: { gt: 5 } } should NOT include parse_literal FILTER", async () => {
|
|
1328
|
-
const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { rating: { gt: 5 } } });
|
|
1329
|
-
const norm = normalizeQuery(query);
|
|
1330
|
-
expect(norm).not.toContain("parse_literal");
|
|
1331
|
-
});
|
|
1332
|
-
it("literal property where clause adds JOIN for JS post-filter", async () => {
|
|
1333
|
-
const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { name: "Alice" } });
|
|
1334
|
-
const norm = normalizeQuery(query);
|
|
1335
|
-
expect(norm).toContain("?wTarget_name");
|
|
1336
|
-
});
|
|
1337
|
-
});
|
|
1338
|
-
// ── Lightweight fingerprint (3.7) ────────────────────────────────────────────
|
|
1339
|
-
describe("Lightweight fingerprint optimization", () => {
|
|
1340
|
-
// Replicate the buildFingerprint logic for testing
|
|
1341
|
-
const buildFingerprint = (results) => {
|
|
1342
|
-
if (results.length === 0)
|
|
1343
|
-
return '0:';
|
|
1344
|
-
const ids = results.map((r) => r.id || '').sort().join(',');
|
|
1345
|
-
const ts = results.map((r) => r.updatedAt || r.timestamp || '').join(',');
|
|
1346
|
-
return `${results.length}:${ids}:${ts}`;
|
|
1347
|
-
};
|
|
1348
|
-
const base = [
|
|
1349
|
-
{ id: "a", updatedAt: "100" },
|
|
1350
|
-
{ id: "b", updatedAt: "200" },
|
|
1351
|
-
];
|
|
1352
|
-
it("lightweight fingerprint should detect instance addition", () => {
|
|
1353
|
-
const fp1 = buildFingerprint(base);
|
|
1354
|
-
const fp2 = buildFingerprint([...base, { id: "c", updatedAt: "300" }]);
|
|
1355
|
-
expect(fp1).not.toBe(fp2);
|
|
1356
|
-
});
|
|
1357
|
-
it("lightweight fingerprint should detect instance removal", () => {
|
|
1358
|
-
const fp1 = buildFingerprint(base);
|
|
1359
|
-
const fp2 = buildFingerprint([base[0]]);
|
|
1360
|
-
expect(fp1).not.toBe(fp2);
|
|
1361
|
-
});
|
|
1362
|
-
it("lightweight fingerprint should detect timestamp change", () => {
|
|
1363
|
-
const fp1 = buildFingerprint(base);
|
|
1364
|
-
const fp2 = buildFingerprint([{ id: "a", updatedAt: "999" }, base[1]]);
|
|
1365
|
-
expect(fp1).not.toBe(fp2);
|
|
1366
|
-
});
|
|
1367
|
-
it("lightweight fingerprint should NOT false-positive for identical sets", () => {
|
|
1368
|
-
const fp1 = buildFingerprint(base);
|
|
1369
|
-
const fp2 = buildFingerprint([...base]); // same data, new array
|
|
1370
|
-
expect(fp1).toBe(fp2);
|
|
1371
|
-
});
|
|
1372
|
-
});
|
|
1373
|
-
// ── Native SPARQL getter evaluation ──────────────────────────────────────────
|
|
1374
|
-
describe("Native SPARQL getter evaluation", () => {
|
|
1375
|
-
const { evaluateCustomGettersForInstance } = require("./hydration");
|
|
1376
|
-
const mockPerspective = {
|
|
1377
|
-
getLinks: jest.fn().mockResolvedValue([]),
|
|
1378
|
-
querySparql: jest.fn(),
|
|
1379
|
-
get: jest.fn().mockResolvedValue([]),
|
|
1380
|
-
};
|
|
1381
|
-
beforeEach(() => {
|
|
1382
|
-
jest.clearAllMocks();
|
|
1383
|
-
});
|
|
1384
|
-
it("should execute SELECT getter directly via querySparql", async () => {
|
|
1385
|
-
const metadata = {
|
|
1386
|
-
properties: {
|
|
1387
|
-
replyingTo: {
|
|
1388
|
-
predicate: "flux://has_reply",
|
|
1389
|
-
getter: 'SELECT ?target WHERE { ?target <flux://has_reply> ?source . } LIMIT 1',
|
|
1390
|
-
type: "string",
|
|
1391
|
-
}
|
|
1392
|
-
},
|
|
1393
|
-
relations: {},
|
|
1394
|
-
};
|
|
1395
|
-
mockPerspective.querySparql.mockResolvedValue([
|
|
1396
|
-
{ target: { value: "literal:string:msg123" } }
|
|
1397
|
-
]);
|
|
1398
|
-
const instance = { id: "test://msg1", replyingTo: undefined };
|
|
1399
|
-
await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
|
|
1400
|
-
expect(mockPerspective.querySparql).toHaveBeenCalledWith(expect.stringContaining("SELECT ?target WHERE"));
|
|
1401
|
-
expect(instance.replyingTo).toBe("literal:string:msg123");
|
|
1402
|
-
});
|
|
1403
|
-
it("should execute ASK getter and return boolean", async () => {
|
|
1404
|
-
const metadata = {
|
|
1405
|
-
properties: {
|
|
1406
|
-
isPopular: {
|
|
1407
|
-
predicate: "flux://is_popular",
|
|
1408
|
-
getter: 'ASK WHERE { SELECT (COUNT(DISTINCT ?reactor) AS ?count) WHERE { ?reactor <flux://reaction> ?source . } HAVING(?count > 5) }',
|
|
1409
|
-
type: "boolean",
|
|
1410
|
-
readOnly: true,
|
|
1411
|
-
}
|
|
1412
|
-
},
|
|
1413
|
-
relations: {},
|
|
1414
|
-
};
|
|
1415
|
-
mockPerspective.querySparql.mockResolvedValue(true);
|
|
1416
|
-
const instance = { id: "test://msg1", isPopular: false };
|
|
1417
|
-
await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
|
|
1418
|
-
expect(mockPerspective.querySparql).toHaveBeenCalledWith(expect.stringContaining("ASK WHERE"));
|
|
1419
|
-
expect(instance.isPopular).toBe(true);
|
|
1420
|
-
});
|
|
1421
|
-
it("should replace ?source with instance ID in SPARQL getter", async () => {
|
|
1422
|
-
const metadata = {
|
|
1423
|
-
properties: {
|
|
1424
|
-
author: {
|
|
1425
|
-
predicate: "test://author",
|
|
1426
|
-
getter: 'SELECT ?target WHERE { ?source <test://author> ?target . }',
|
|
1427
|
-
type: "string",
|
|
1428
|
-
}
|
|
1429
|
-
},
|
|
1430
|
-
relations: {},
|
|
1431
|
-
};
|
|
1432
|
-
mockPerspective.querySparql.mockResolvedValue([
|
|
1433
|
-
{ target: { value: "did:key:abc123" } }
|
|
1434
|
-
]);
|
|
1435
|
-
const instance = { id: "test://post1", author: undefined };
|
|
1436
|
-
await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
|
|
1437
|
-
expect(mockPerspective.querySparql).toHaveBeenCalledWith(expect.stringContaining("<test://post1>"));
|
|
1438
|
-
expect(mockPerspective.querySparql).not.toHaveBeenCalledWith(expect.stringContaining("?source"));
|
|
1439
|
-
});
|
|
1440
|
-
it("should handle empty SPARQL results gracefully", async () => {
|
|
1441
|
-
const metadata = {
|
|
1442
|
-
properties: {
|
|
1443
|
-
replyingTo: {
|
|
1444
|
-
predicate: "flux://has_reply",
|
|
1445
|
-
getter: 'SELECT ?target WHERE { ?target <flux://has_reply> ?source . } LIMIT 1',
|
|
1446
|
-
type: "string",
|
|
1447
|
-
}
|
|
1448
|
-
},
|
|
1449
|
-
relations: {},
|
|
1450
|
-
};
|
|
1451
|
-
mockPerspective.querySparql.mockResolvedValue([]);
|
|
1452
|
-
const instance = { id: "test://msg1", replyingTo: "original" };
|
|
1453
|
-
await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
|
|
1454
|
-
// Should not overwrite with undefined
|
|
1455
|
-
expect(instance.replyingTo).toBe("original");
|
|
1456
|
-
});
|
|
1457
|
-
it("should handle SPARQL getter errors without crashing", async () => {
|
|
1458
|
-
const metadata = {
|
|
1459
|
-
properties: {
|
|
1460
|
-
broken: {
|
|
1461
|
-
predicate: "test://broken",
|
|
1462
|
-
getter: 'SELECT ?target WHERE { INVALID SPARQL }',
|
|
1463
|
-
type: "string",
|
|
1464
|
-
}
|
|
1465
|
-
},
|
|
1466
|
-
relations: {},
|
|
1467
|
-
};
|
|
1468
|
-
mockPerspective.querySparql.mockRejectedValue(new Error("SPARQL parse error"));
|
|
1469
|
-
const instance = { id: "test://msg1", broken: undefined };
|
|
1470
|
-
const consoleSpy = jest.spyOn(console, "warn").mockImplementation();
|
|
1471
|
-
await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
|
|
1472
|
-
consoleSpy.mockRestore();
|
|
1473
|
-
// Should not throw, should warn
|
|
1474
|
-
expect(instance.broken).toBeUndefined();
|
|
1475
|
-
});
|
|
1476
|
-
it("should execute SPARQL getter for relations", async () => {
|
|
1477
|
-
const metadata = {
|
|
1478
|
-
properties: {},
|
|
1479
|
-
relations: {
|
|
1480
|
-
tags: {
|
|
1481
|
-
predicate: "test://has_tag",
|
|
1482
|
-
getter: 'SELECT ?target WHERE { ?source <test://has_tag> ?target . }',
|
|
1483
|
-
direction: "forward",
|
|
1484
|
-
}
|
|
1485
|
-
},
|
|
1486
|
-
};
|
|
1487
|
-
mockPerspective.querySparql.mockResolvedValue([
|
|
1488
|
-
{ target: { value: "tag:a" } },
|
|
1489
|
-
{ target: { value: "tag:b" } },
|
|
1490
|
-
]);
|
|
1491
|
-
const instance = { id: "test://post1", tags: [] };
|
|
1492
|
-
await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
|
|
1493
|
-
expect(instance.tags).toEqual(["tag:a", "tag:b"]);
|
|
1494
|
-
});
|
|
1495
|
-
it("should warn for legacy SurrealDB-style getter syntax instead of converting", async () => {
|
|
1496
|
-
const metadata = {
|
|
1497
|
-
properties: {
|
|
1498
|
-
legacy: {
|
|
1499
|
-
predicate: "test://legacy",
|
|
1500
|
-
getter: "(<-link[WHERE predicate = 'test://legacy'].in.uri)[0]",
|
|
1501
|
-
type: "string",
|
|
1502
|
-
}
|
|
1503
|
-
},
|
|
1504
|
-
relations: {},
|
|
1505
|
-
};
|
|
1506
|
-
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => { });
|
|
1507
|
-
const instance = { id: "test://msg1", legacy: undefined };
|
|
1508
|
-
await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
|
|
1509
|
-
// Should NOT call querySparql — legacy getters are no longer converted
|
|
1510
|
-
expect(mockPerspective.querySparql).not.toHaveBeenCalled();
|
|
1511
|
-
// Should warn about unsupported syntax
|
|
1512
|
-
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("Unsupported legacy getter syntax"));
|
|
1513
|
-
// Value should remain undefined
|
|
1514
|
-
expect(instance.legacy).toBeUndefined();
|
|
1515
|
-
warnSpy.mockRestore();
|
|
1516
|
-
});
|
|
1517
|
-
});
|
|
1518
|
-
// ── Subscribe callback timing ──────────────────────────────────────────
|
|
1519
|
-
describe("ModelQueryBuilder subscribe callback timing", () => {
|
|
1520
|
-
it("subscribe should not invoke callback synchronously before Promise resolves", async () => {
|
|
1521
|
-
// This test verifies that subscribe() uses the Rust model subscription endpoint
|
|
1522
|
-
// and properly handles the subscription lifecycle.
|
|
1523
|
-
const mockSubscriptionId = "test-sub-123";
|
|
1524
|
-
let updateCallback = null;
|
|
1525
|
-
const mockClient = {
|
|
1526
|
-
modelSubscribe: jest.fn().mockResolvedValue({
|
|
1527
|
-
subscriptionId: mockSubscriptionId,
|
|
1528
|
-
result: { instances: [], totalCount: 0 },
|
|
1529
|
-
}),
|
|
1530
|
-
subscribeToQueryUpdates: jest.fn().mockImplementation((_id, cb) => {
|
|
1531
|
-
updateCallback = cb;
|
|
1532
|
-
return () => { }; // unsubscribe function
|
|
1533
|
-
}),
|
|
1534
|
-
keepAliveQuery: jest.fn().mockResolvedValue(true),
|
|
1535
|
-
disposeQuerySubscription: jest.fn().mockResolvedValue(true),
|
|
1536
|
-
};
|
|
1537
|
-
const mockPerspective = {
|
|
1538
|
-
uuid: "test-uuid",
|
|
1539
|
-
client: mockClient,
|
|
1540
|
-
modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
|
|
1541
|
-
return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
|
|
1542
|
-
}),
|
|
1543
|
-
getLinks: jest.fn().mockResolvedValue([]),
|
|
1544
|
-
modelQuery: jest.fn().mockResolvedValue({ instances: [], totalCount: 0 }),
|
|
1545
|
-
};
|
|
1546
|
-
const { Ad4mModel, Model, Property, Flag } = require("./index");
|
|
1547
|
-
let TimingTest = class TimingTest extends Ad4mModel {
|
|
1548
|
-
constructor() {
|
|
1549
|
-
super(...arguments);
|
|
1550
|
-
this.type = "test://timing";
|
|
1551
|
-
this.name = "";
|
|
1552
|
-
}
|
|
1553
|
-
};
|
|
1554
|
-
__decorate([
|
|
1555
|
-
Flag({ through: "test://type", value: "test://timing" }),
|
|
1556
|
-
__metadata("design:type", String)
|
|
1557
|
-
], TimingTest.prototype, "type", void 0);
|
|
1558
|
-
__decorate([
|
|
1559
|
-
Property({ through: "test://name" }),
|
|
1560
|
-
__metadata("design:type", String)
|
|
1561
|
-
], TimingTest.prototype, "name", void 0);
|
|
1562
|
-
TimingTest = __decorate([
|
|
1563
|
-
Model({ name: "TimingTest" })
|
|
1564
|
-
], TimingTest);
|
|
1565
|
-
let callbackInvokedBeforeResolve = false;
|
|
1566
|
-
let promiseResolved = false;
|
|
1567
|
-
const query = TimingTest.query(mockPerspective);
|
|
1568
|
-
const promise = query.subscribe((results) => {
|
|
1569
|
-
if (!promiseResolved) {
|
|
1570
|
-
callbackInvokedBeforeResolve = true;
|
|
1571
|
-
}
|
|
1572
|
-
});
|
|
1573
|
-
// At this point the Promise hasn't resolved yet
|
|
1574
|
-
// The callback should NOT have fired synchronously
|
|
1575
|
-
expect(callbackInvokedBeforeResolve).toBe(false);
|
|
1576
|
-
const initialResults = await promise;
|
|
1577
|
-
promiseResolved = true;
|
|
1578
|
-
expect(initialResults).toEqual([]);
|
|
1579
|
-
expect(mockPerspective.modelSubscribe).toHaveBeenCalled();
|
|
1580
|
-
});
|
|
1581
|
-
});
|
|
1582
|
-
describe("ModelQueryBuilder paginateSubscribe", () => {
|
|
1583
|
-
it("paginateSubscribe should use a single query with count: true", async () => {
|
|
1584
|
-
const mockSubscriptionId = "paginate-sub-123";
|
|
1585
|
-
const mockClient = {
|
|
1586
|
-
modelSubscribe: jest.fn().mockResolvedValue({
|
|
1587
|
-
subscriptionId: mockSubscriptionId,
|
|
1588
|
-
result: { instances: [], totalCount: 0 },
|
|
1589
|
-
}),
|
|
1590
|
-
subscribeToQueryUpdates: jest.fn().mockImplementation((_id, _cb) => {
|
|
1591
|
-
return () => { };
|
|
1592
|
-
}),
|
|
1593
|
-
keepAliveQuery: jest.fn().mockResolvedValue(true),
|
|
1594
|
-
disposeQuerySubscription: jest.fn().mockResolvedValue(true),
|
|
1595
|
-
};
|
|
1596
|
-
const mockPerspective = {
|
|
1597
|
-
uuid: "test-uuid",
|
|
1598
|
-
client: mockClient,
|
|
1599
|
-
modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
|
|
1600
|
-
return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
|
|
1601
|
-
}),
|
|
1602
|
-
modelQuery: jest.fn().mockResolvedValue({ instances: [{ id: "item1", type: "test://paginate" }], totalCount: 42 }),
|
|
1603
|
-
};
|
|
1604
|
-
const { Ad4mModel, Model, Flag, Property } = require("./index");
|
|
1605
|
-
let PaginateTest = class PaginateTest extends Ad4mModel {
|
|
1606
|
-
constructor() {
|
|
1607
|
-
super(...arguments);
|
|
1608
|
-
this.type = "test://paginate";
|
|
1609
|
-
this.name = "";
|
|
1610
|
-
}
|
|
1611
|
-
};
|
|
1612
|
-
__decorate([
|
|
1613
|
-
Flag({ through: "test://type", value: "test://paginate" }),
|
|
1614
|
-
__metadata("design:type", String)
|
|
1615
|
-
], PaginateTest.prototype, "type", void 0);
|
|
1616
|
-
__decorate([
|
|
1617
|
-
Property({ through: "test://name" }),
|
|
1618
|
-
__metadata("design:type", String)
|
|
1619
|
-
], PaginateTest.prototype, "name", void 0);
|
|
1620
|
-
PaginateTest = __decorate([
|
|
1621
|
-
Model({ name: "PaginateTest" })
|
|
1622
|
-
], PaginateTest);
|
|
1623
|
-
const builder = PaginateTest.query(mockPerspective);
|
|
1624
|
-
const result = await builder.paginateSubscribe(10, 1, () => { });
|
|
1625
|
-
// Should return paginated result structure
|
|
1626
|
-
expect(result).toHaveProperty("results");
|
|
1627
|
-
expect(result).toHaveProperty("totalCount");
|
|
1628
|
-
expect(result).toHaveProperty("pageSize", 10);
|
|
1629
|
-
expect(result).toHaveProperty("pageNumber", 1);
|
|
1630
|
-
// modelQuery should be called exactly once (not twice — no separate count query)
|
|
1631
|
-
expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
|
|
1632
|
-
// The query should have count: true
|
|
1633
|
-
const callArgs = mockPerspective.modelQuery.mock.calls[0];
|
|
1634
|
-
const queryJson = JSON.parse(callArgs[1]);
|
|
1635
|
-
expect(queryJson.count).toBe(true);
|
|
1636
|
-
expect(queryJson.limit).toBe(10);
|
|
1637
|
-
expect(queryJson.offset).toBe(0);
|
|
1638
|
-
});
|
|
1639
|
-
it("paginateSubscribe should skip isInit messages from subscription", async () => {
|
|
1640
|
-
const mockSubscriptionId = "paginate-init-sub";
|
|
1641
|
-
let capturedCallback = null;
|
|
1642
|
-
const mockClient = {
|
|
1643
|
-
modelSubscribe: jest.fn().mockResolvedValue({
|
|
1644
|
-
subscriptionId: mockSubscriptionId,
|
|
1645
|
-
result: { instances: [], totalCount: 0 },
|
|
1646
|
-
}),
|
|
1647
|
-
subscribeToQueryUpdates: jest.fn().mockImplementation((_id, cb) => {
|
|
1648
|
-
capturedCallback = cb;
|
|
1649
|
-
return () => { };
|
|
1650
|
-
}),
|
|
1651
|
-
keepAliveQuery: jest.fn().mockResolvedValue(true),
|
|
1652
|
-
disposeQuerySubscription: jest.fn().mockResolvedValue(true),
|
|
1653
|
-
};
|
|
1654
|
-
let modelQueryCallCount = 0;
|
|
1655
|
-
const mockPerspective = {
|
|
1656
|
-
uuid: "test-uuid",
|
|
1657
|
-
client: mockClient,
|
|
1658
|
-
modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
|
|
1659
|
-
return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
|
|
1660
|
-
}),
|
|
1661
|
-
modelQuery: jest.fn().mockImplementation(async () => {
|
|
1662
|
-
modelQueryCallCount++;
|
|
1663
|
-
return { instances: [], totalCount: 0 };
|
|
1664
|
-
}),
|
|
1665
|
-
};
|
|
1666
|
-
const { Ad4mModel, Model, Flag, Property } = require("./index");
|
|
1667
|
-
let InitGuardTest = class InitGuardTest extends Ad4mModel {
|
|
1668
|
-
constructor() {
|
|
1669
|
-
super(...arguments);
|
|
1670
|
-
this.type = "test://init";
|
|
1671
|
-
this.name = "";
|
|
1672
|
-
}
|
|
1673
|
-
};
|
|
1674
|
-
__decorate([
|
|
1675
|
-
Flag({ through: "test://type", value: "test://init" }),
|
|
1676
|
-
__metadata("design:type", String)
|
|
1677
|
-
], InitGuardTest.prototype, "type", void 0);
|
|
1678
|
-
__decorate([
|
|
1679
|
-
Property({ through: "test://name" }),
|
|
1680
|
-
__metadata("design:type", String)
|
|
1681
|
-
], InitGuardTest.prototype, "name", void 0);
|
|
1682
|
-
InitGuardTest = __decorate([
|
|
1683
|
-
Model({ name: "InitGuardTest" })
|
|
1684
|
-
], InitGuardTest);
|
|
1685
|
-
const userCallback = jest.fn();
|
|
1686
|
-
const builder = InitGuardTest.query(mockPerspective);
|
|
1687
|
-
await builder.paginateSubscribe(10, 1, userCallback);
|
|
1688
|
-
// Reset the count after initial fetch
|
|
1689
|
-
const initialCallCount = modelQueryCallCount;
|
|
1690
|
-
// Simulate an isInit message from subscription
|
|
1691
|
-
expect(capturedCallback).not.toBeNull();
|
|
1692
|
-
capturedCallback({ isInit: true });
|
|
1693
|
-
// Wait for any async processing
|
|
1694
|
-
await new Promise(r => setTimeout(r, 50));
|
|
1695
|
-
// modelQuery should NOT have been called again (isInit was filtered)
|
|
1696
|
-
expect(modelQueryCallCount).toBe(initialCallCount);
|
|
1697
|
-
// User callback should NOT have been invoked by isInit
|
|
1698
|
-
expect(userCallback).not.toHaveBeenCalled();
|
|
1699
|
-
});
|
|
1700
|
-
it("paginateSubscribe should re-fetch on real subscription updates", async () => {
|
|
1701
|
-
const mockSubscriptionId = "paginate-update-sub";
|
|
1702
|
-
let capturedCallback = null;
|
|
1703
|
-
const mockClient = {
|
|
1704
|
-
modelSubscribe: jest.fn().mockResolvedValue({
|
|
1705
|
-
subscriptionId: mockSubscriptionId,
|
|
1706
|
-
result: { instances: [], totalCount: 0 },
|
|
1707
|
-
}),
|
|
1708
|
-
subscribeToQueryUpdates: jest.fn().mockImplementation((_id, cb) => {
|
|
1709
|
-
capturedCallback = cb;
|
|
1710
|
-
return () => { };
|
|
1711
|
-
}),
|
|
1712
|
-
keepAliveQuery: jest.fn().mockResolvedValue(true),
|
|
1713
|
-
disposeQuerySubscription: jest.fn().mockResolvedValue(true),
|
|
1714
|
-
};
|
|
1715
|
-
let modelQueryCallCount = 0;
|
|
1716
|
-
const mockPerspective = {
|
|
1717
|
-
uuid: "test-uuid",
|
|
1718
|
-
client: mockClient,
|
|
1719
|
-
modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
|
|
1720
|
-
return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
|
|
1721
|
-
}),
|
|
1722
|
-
modelQuery: jest.fn().mockImplementation(async () => {
|
|
1723
|
-
modelQueryCallCount++;
|
|
1724
|
-
return { instances: [{ id: "new-item", type: "test://update" }], totalCount: 1 };
|
|
1725
|
-
}),
|
|
1726
|
-
};
|
|
1727
|
-
const { Ad4mModel, Model, Flag, Property } = require("./index");
|
|
1728
|
-
let UpdateTest = class UpdateTest extends Ad4mModel {
|
|
1729
|
-
constructor() {
|
|
1730
|
-
super(...arguments);
|
|
1731
|
-
this.type = "test://update";
|
|
1732
|
-
this.name = "";
|
|
1733
|
-
}
|
|
1734
|
-
};
|
|
1735
|
-
__decorate([
|
|
1736
|
-
Flag({ through: "test://type", value: "test://update" }),
|
|
1737
|
-
__metadata("design:type", String)
|
|
1738
|
-
], UpdateTest.prototype, "type", void 0);
|
|
1739
|
-
__decorate([
|
|
1740
|
-
Property({ through: "test://name" }),
|
|
1741
|
-
__metadata("design:type", String)
|
|
1742
|
-
], UpdateTest.prototype, "name", void 0);
|
|
1743
|
-
UpdateTest = __decorate([
|
|
1744
|
-
Model({ name: "UpdateTest" })
|
|
1745
|
-
], UpdateTest);
|
|
1746
|
-
const userCallback = jest.fn();
|
|
1747
|
-
const builder = UpdateTest.query(mockPerspective);
|
|
1748
|
-
await builder.paginateSubscribe(10, 1, userCallback);
|
|
1749
|
-
const initialCallCount = modelQueryCallCount;
|
|
1750
|
-
// Simulate a real subscription update (not isInit)
|
|
1751
|
-
capturedCallback({ instances: [{ id: "new-item" }], totalCount: 1 });
|
|
1752
|
-
// Wait for async processing
|
|
1753
|
-
await new Promise(r => setTimeout(r, 100));
|
|
1754
|
-
// modelQuery should have been called again for the re-fetch
|
|
1755
|
-
expect(modelQueryCallCount).toBeGreaterThan(initialCallCount);
|
|
1756
|
-
// User callback should have been invoked with paginated results
|
|
1757
|
-
expect(userCallback).toHaveBeenCalled();
|
|
1758
|
-
const callArg = userCallback.mock.calls[0][0];
|
|
1759
|
-
expect(callArg).toHaveProperty("totalCount");
|
|
1760
|
-
expect(callArg).toHaveProperty("pageSize", 10);
|
|
1761
|
-
expect(callArg).toHaveProperty("pageNumber", 1);
|
|
1762
|
-
});
|
|
1763
|
-
});
|
|
1764
|
-
// ============================================================================
|
|
1765
|
-
// Performance Optimisation Tests
|
|
1766
|
-
// ============================================================================
|
|
1767
|
-
import { getCachedResult, setCachedResult, clearQueryCache, queryCacheSize } from "./query-cache";
|
|
1768
|
-
import { getPropertiesMetadata, getRelationsMetadata } from "./decorators";
|
|
1769
|
-
describe("QueryCache", () => {
|
|
1770
|
-
beforeEach(() => clearQueryCache());
|
|
1771
|
-
it("should return undefined for cache miss", () => {
|
|
1772
|
-
expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBeUndefined();
|
|
1773
|
-
});
|
|
1774
|
-
it("should return cached result within TTL", () => {
|
|
1775
|
-
const result = [{ s: "test" }];
|
|
1776
|
-
setCachedResult("uuid1", "SELECT ?s WHERE {}", result);
|
|
1777
|
-
expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBe(result);
|
|
1778
|
-
});
|
|
1779
|
-
it("should expire after TTL", async () => {
|
|
1780
|
-
setCachedResult("uuid1", "SELECT ?s WHERE {}", [{ s: "test" }], 50);
|
|
1781
|
-
await new Promise(r => setTimeout(r, 60));
|
|
1782
|
-
expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBeUndefined();
|
|
1783
|
-
});
|
|
1784
|
-
it("should cache independently per perspective", () => {
|
|
1785
|
-
setCachedResult("uuid1", "SELECT ?s WHERE {}", "result1");
|
|
1786
|
-
setCachedResult("uuid2", "SELECT ?s WHERE {}", "result2");
|
|
1787
|
-
expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBe("result1");
|
|
1788
|
-
expect(getCachedResult("uuid2", "SELECT ?s WHERE {}")).toBe("result2");
|
|
1789
|
-
});
|
|
1790
|
-
it("should cache independently per query", () => {
|
|
1791
|
-
setCachedResult("uuid1", "query1", "r1");
|
|
1792
|
-
setCachedResult("uuid1", "query2", "r2");
|
|
1793
|
-
expect(getCachedResult("uuid1", "query1")).toBe("r1");
|
|
1794
|
-
expect(getCachedResult("uuid1", "query2")).toBe("r2");
|
|
1795
|
-
});
|
|
1796
|
-
it("should clear all entries", () => {
|
|
1797
|
-
setCachedResult("uuid1", "q1", "r1");
|
|
1798
|
-
setCachedResult("uuid2", "q2", "r2");
|
|
1799
|
-
expect(queryCacheSize()).toBe(2);
|
|
1800
|
-
clearQueryCache();
|
|
1801
|
-
expect(queryCacheSize()).toBe(0);
|
|
1802
|
-
});
|
|
1803
|
-
});
|
|
1804
|
-
describe("SHACL Memoisation", () => {
|
|
1805
|
-
it("should memoise generateSHACL() per class", () => {
|
|
1806
|
-
let MemoTest1 = class MemoTest1 extends Ad4mModel {
|
|
1807
|
-
constructor() {
|
|
1808
|
-
super(...arguments);
|
|
1809
|
-
this.name = "";
|
|
1810
|
-
}
|
|
1811
|
-
};
|
|
1812
|
-
__decorate([
|
|
1813
|
-
Property({ through: "test://name" }),
|
|
1814
|
-
__metadata("design:type", String)
|
|
1815
|
-
], MemoTest1.prototype, "name", void 0);
|
|
1816
|
-
MemoTest1 = __decorate([
|
|
1817
|
-
Model({ name: "MemoTest1" })
|
|
1818
|
-
], MemoTest1);
|
|
1819
|
-
const result1 = MemoTest1.generateSHACL();
|
|
1820
|
-
const result2 = MemoTest1.generateSHACL();
|
|
1821
|
-
expect(result1).toBe(result2); // Same reference = memoised
|
|
1822
|
-
});
|
|
1823
|
-
it("should memoise getPropertiesMetadata per class", () => {
|
|
1824
|
-
let PropMemoTest = class PropMemoTest extends Ad4mModel {
|
|
1825
|
-
constructor() {
|
|
1826
|
-
super(...arguments);
|
|
1827
|
-
this.x = "";
|
|
1828
|
-
}
|
|
1829
|
-
};
|
|
1830
|
-
__decorate([
|
|
1831
|
-
Property({ through: "test://x" }),
|
|
1832
|
-
__metadata("design:type", String)
|
|
1833
|
-
], PropMemoTest.prototype, "x", void 0);
|
|
1834
|
-
PropMemoTest = __decorate([
|
|
1835
|
-
Model({ name: "PropMemoTest" })
|
|
1836
|
-
], PropMemoTest);
|
|
1837
|
-
const r1 = getPropertiesMetadata(PropMemoTest);
|
|
1838
|
-
const r2 = getPropertiesMetadata(PropMemoTest);
|
|
1839
|
-
expect(r1).toBe(r2); // Same reference
|
|
1840
|
-
});
|
|
1841
|
-
it("should memoise getRelationsMetadata per class", () => {
|
|
1842
|
-
let RelMemoTest = class RelMemoTest extends Ad4mModel {
|
|
1843
|
-
constructor() {
|
|
1844
|
-
super(...arguments);
|
|
1845
|
-
this.items = [];
|
|
1846
|
-
}
|
|
1847
|
-
};
|
|
1848
|
-
__decorate([
|
|
1849
|
-
HasMany({ through: "test://items" }),
|
|
1850
|
-
__metadata("design:type", Array)
|
|
1851
|
-
], RelMemoTest.prototype, "items", void 0);
|
|
1852
|
-
RelMemoTest = __decorate([
|
|
1853
|
-
Model({ name: "RelMemoTest" })
|
|
1854
|
-
], RelMemoTest);
|
|
1855
|
-
const r1 = getRelationsMetadata(RelMemoTest);
|
|
1856
|
-
const r2 = getRelationsMetadata(RelMemoTest);
|
|
1857
|
-
expect(r1).toBe(r2); // Same reference
|
|
1858
|
-
});
|
|
1859
|
-
it("should return different results for different classes", () => {
|
|
1860
|
-
let ClassA = class ClassA extends Ad4mModel {
|
|
1861
|
-
constructor() {
|
|
1862
|
-
super(...arguments);
|
|
1863
|
-
this.a = "";
|
|
1864
|
-
}
|
|
1865
|
-
};
|
|
1866
|
-
__decorate([
|
|
1867
|
-
Property({ through: "test://a" }),
|
|
1868
|
-
__metadata("design:type", String)
|
|
1869
|
-
], ClassA.prototype, "a", void 0);
|
|
1870
|
-
ClassA = __decorate([
|
|
1871
|
-
Model({ name: "ClassA" })
|
|
1872
|
-
], ClassA);
|
|
1873
|
-
let ClassB = class ClassB extends Ad4mModel {
|
|
1874
|
-
constructor() {
|
|
1875
|
-
super(...arguments);
|
|
1876
|
-
this.b = "";
|
|
1877
|
-
}
|
|
1878
|
-
};
|
|
1879
|
-
__decorate([
|
|
1880
|
-
Property({ through: "test://b" }),
|
|
1881
|
-
__metadata("design:type", String)
|
|
1882
|
-
], ClassB.prototype, "b", void 0);
|
|
1883
|
-
ClassB = __decorate([
|
|
1884
|
-
Model({ name: "ClassB" })
|
|
1885
|
-
], ClassB);
|
|
1886
|
-
const propsA = getPropertiesMetadata(ClassA);
|
|
1887
|
-
const propsB = getPropertiesMetadata(ClassB);
|
|
1888
|
-
expect(propsA).not.toBe(propsB);
|
|
1889
|
-
expect(propsA).toHaveProperty("a");
|
|
1890
|
-
expect(propsB).toHaveProperty("b");
|
|
1891
|
-
});
|
|
1892
|
-
});
|
|
1893
|
-
describe("Lazy Conformance Filters", () => {
|
|
1894
|
-
it("should defer conformance filter resolution until property access", () => {
|
|
1895
|
-
let LazyTarget2 = class LazyTarget2 extends Ad4mModel {
|
|
1896
|
-
constructor() {
|
|
1897
|
-
super(...arguments);
|
|
1898
|
-
this.type = "test://lazy";
|
|
1899
|
-
this.name = "";
|
|
1900
|
-
}
|
|
1901
|
-
};
|
|
1902
|
-
__decorate([
|
|
1903
|
-
Flag({ through: "test://type", value: "test://lazy" }),
|
|
1904
|
-
__metadata("design:type", String)
|
|
1905
|
-
], LazyTarget2.prototype, "type", void 0);
|
|
1906
|
-
__decorate([
|
|
1907
|
-
Property({ through: "test://name", required: true }),
|
|
1908
|
-
__metadata("design:type", String)
|
|
1909
|
-
], LazyTarget2.prototype, "name", void 0);
|
|
1910
|
-
LazyTarget2 = __decorate([
|
|
1911
|
-
Model({ name: "LazyTarget2" })
|
|
1912
|
-
], LazyTarget2);
|
|
1913
|
-
let LazyParent2 = class LazyParent2 extends Ad4mModel {
|
|
1914
|
-
constructor() {
|
|
1915
|
-
super(...arguments);
|
|
1916
|
-
this.children = [];
|
|
1917
|
-
}
|
|
1918
|
-
};
|
|
1919
|
-
__decorate([
|
|
1920
|
-
HasMany(() => LazyTarget2, { through: "test://children" }),
|
|
1921
|
-
__metadata("design:type", Array)
|
|
1922
|
-
], LazyParent2.prototype, "children", void 0);
|
|
1923
|
-
LazyParent2 = __decorate([
|
|
1924
|
-
Model({ name: "LazyParent2" })
|
|
1925
|
-
], LazyParent2);
|
|
1926
|
-
// generateSHACL was called during @Model — the shape exists
|
|
1927
|
-
const shacl = LazyParent2.generateSHACL();
|
|
1928
|
-
expect(shacl).toBeDefined();
|
|
1929
|
-
expect(shacl.shape).toBeDefined();
|
|
1930
|
-
expect(shacl.name).toBe("LazyParent2");
|
|
1931
|
-
});
|
|
1932
|
-
});
|
|
1933
|
-
// ──────────────────────────────────────────────────────────
|
|
1934
|
-
// deepQuery opt-in — getter evaluation on collection queries
|
|
1935
|
-
// ──────────────────────────────────────────────────────────
|
|
1936
|
-
describe("deepQuery opt-in — getter evaluation", () => {
|
|
1937
|
-
let DeepQueryTestMessage = class DeepQueryTestMessage extends Ad4mModel {
|
|
1938
|
-
constructor() {
|
|
1939
|
-
super(...arguments);
|
|
1940
|
-
this.type = "";
|
|
1941
|
-
this.body = "";
|
|
1942
|
-
this.isPopular = false;
|
|
1943
|
-
this.reactions = [];
|
|
1944
|
-
}
|
|
1945
|
-
};
|
|
1946
|
-
__decorate([
|
|
1947
|
-
Flag({ through: "flux://entry_type", value: "flux://message" }),
|
|
1948
|
-
__metadata("design:type", String)
|
|
1949
|
-
], DeepQueryTestMessage.prototype, "type", void 0);
|
|
1950
|
-
__decorate([
|
|
1951
|
-
Property({ through: "flux://body", resolveLanguage: "literal" }),
|
|
1952
|
-
__metadata("design:type", String)
|
|
1953
|
-
], DeepQueryTestMessage.prototype, "body", void 0);
|
|
1954
|
-
__decorate([
|
|
1955
|
-
Property({
|
|
1956
|
-
through: "flux://has_reply",
|
|
1957
|
-
getter: `SELECT ?target WHERE { ?source <flux://has_reply> ?target . } LIMIT 1`,
|
|
1958
|
-
}),
|
|
1959
|
-
__metadata("design:type", String)
|
|
1960
|
-
], DeepQueryTestMessage.prototype, "replyingTo", void 0);
|
|
1961
|
-
__decorate([
|
|
1962
|
-
ReadOnly({
|
|
1963
|
-
through: "flux://is_popular",
|
|
1964
|
-
getter: `ASK WHERE { ?source <flux://is_popular> "true" . }`,
|
|
1965
|
-
}),
|
|
1966
|
-
__metadata("design:type", Boolean)
|
|
1967
|
-
], DeepQueryTestMessage.prototype, "isPopular", void 0);
|
|
1968
|
-
__decorate([
|
|
1969
|
-
HasMany({ through: "flux://reaction" }),
|
|
1970
|
-
__metadata("design:type", Array)
|
|
1971
|
-
], DeepQueryTestMessage.prototype, "reactions", void 0);
|
|
1972
|
-
DeepQueryTestMessage = __decorate([
|
|
1973
|
-
Model({ name: "DeepQueryTestMessage" })
|
|
1974
|
-
], DeepQueryTestMessage);
|
|
1975
|
-
let sparqlCalls;
|
|
1976
|
-
const mockPerspective = {
|
|
1977
|
-
uuid: "test-uuid",
|
|
1978
|
-
modelQuery: jest.fn(async (className, queryJson, shapeJson) => {
|
|
1979
|
-
// Return a basic result for the single-instance getData() path
|
|
1980
|
-
const query = JSON.parse(queryJson);
|
|
1981
|
-
const id = query?.where?.id;
|
|
1982
|
-
if (id) {
|
|
1983
|
-
return {
|
|
1984
|
-
instances: [{ id, body: "Hello" }],
|
|
1985
|
-
totalCount: 1,
|
|
1986
|
-
};
|
|
1987
|
-
}
|
|
1988
|
-
return { instances: [], totalCount: 0 };
|
|
1989
|
-
}),
|
|
1990
|
-
querySparql: jest.fn(async (q) => {
|
|
1991
|
-
sparqlCalls.push(q);
|
|
1992
|
-
return [];
|
|
1993
|
-
}),
|
|
1994
|
-
get: jest.fn().mockResolvedValue([]),
|
|
1995
|
-
getExpression: jest.fn().mockResolvedValue(null),
|
|
1996
|
-
stringOrTemplateObjectToSubjectClassName: jest.fn().mockResolvedValue("DeepQueryTestMessage"),
|
|
1997
|
-
};
|
|
1998
|
-
beforeEach(() => {
|
|
1999
|
-
sparqlCalls = [];
|
|
2000
|
-
mockPerspective.querySparql.mockClear();
|
|
2001
|
-
mockPerspective.get.mockClear();
|
|
2002
|
-
});
|
|
2003
|
-
function makeInstances(count) {
|
|
2004
|
-
return Array.from({ length: count }, (_, i) => new DeepQueryTestMessage(mockPerspective, `flux://msg-${i}`));
|
|
2005
|
-
}
|
|
2006
|
-
it("single-instance get() delegates getter evaluation to Rust (no JS-side SPARQL)", async () => {
|
|
2007
|
-
const instance = new DeepQueryTestMessage(mockPerspective, "flux://msg-single");
|
|
2008
|
-
mockPerspective.querySparql.mockImplementation(async (q) => {
|
|
2009
|
-
sparqlCalls.push(q);
|
|
2010
|
-
if (q.includes("flux://msg-single") && !q.includes("flux://has_reply") && !q.includes("flux://is_popular")) {
|
|
2011
|
-
return [
|
|
2012
|
-
{ source: "flux://msg-single", predicate: "flux://entry_type", target: "flux://message", author: "did:key:a", timestamp: "3000" },
|
|
2013
|
-
{ source: "flux://msg-single", predicate: "flux://body", target: "literal:string:Hello", author: "did:key:a", timestamp: "3000" },
|
|
2014
|
-
];
|
|
2015
|
-
}
|
|
2016
|
-
return [];
|
|
2017
|
-
});
|
|
2018
|
-
await instance.get();
|
|
2019
|
-
// Getter evaluation now happens Rust-side via evaluate_getters() — no JS SPARQL calls
|
|
2020
|
-
const getterCalls = sparqlCalls.filter((q) => q.includes("flux://has_reply") || q.includes("flux://is_popular"));
|
|
2021
|
-
expect(getterCalls.length).toBe(0);
|
|
2022
|
-
});
|
|
2023
|
-
describe("Ad4mModel.evaluateGetters()", () => {
|
|
2024
|
-
it("resolves getters for a batch of instances", async () => {
|
|
2025
|
-
const instances = makeInstances(4);
|
|
2026
|
-
sparqlCalls = [];
|
|
2027
|
-
await DeepQueryTestMessage.evaluateGetters(instances.slice(0, 2), mockPerspective, ["replyingTo"]);
|
|
2028
|
-
const replyCalls = sparqlCalls.filter((q) => q.includes("flux://has_reply"));
|
|
2029
|
-
expect(replyCalls.length).toBe(2);
|
|
2030
|
-
const popularCalls = sparqlCalls.filter((q) => q.includes("flux://is_popular"));
|
|
2031
|
-
expect(popularCalls.length).toBe(0);
|
|
2032
|
-
});
|
|
2033
|
-
it("evaluates all getters when propertyNames is omitted", async () => {
|
|
2034
|
-
const instances = makeInstances(2);
|
|
2035
|
-
sparqlCalls = [];
|
|
2036
|
-
await DeepQueryTestMessage.evaluateGetters(instances, mockPerspective);
|
|
2037
|
-
const replyCalls = sparqlCalls.filter((q) => q.includes("flux://has_reply"));
|
|
2038
|
-
const popularCalls = sparqlCalls.filter((q) => q.includes("flux://is_popular"));
|
|
2039
|
-
expect(replyCalls.length).toBe(2);
|
|
2040
|
-
expect(popularCalls.length).toBe(2);
|
|
2041
|
-
});
|
|
2042
|
-
it("handles empty array gracefully", async () => {
|
|
2043
|
-
sparqlCalls = [];
|
|
2044
|
-
await DeepQueryTestMessage.evaluateGetters([], mockPerspective);
|
|
2045
|
-
expect(sparqlCalls.length).toBe(0);
|
|
2046
|
-
});
|
|
2047
|
-
});
|
|
2048
|
-
describe("deepQuery via ModelQueryBuilder", () => {
|
|
2049
|
-
it("deepQuery() method sets deepQuery flag on queryParams", () => {
|
|
2050
|
-
const builder = DeepQueryTestMessage.query(mockPerspective);
|
|
2051
|
-
builder.deepQuery();
|
|
2052
|
-
expect(builder.queryParams.deepQuery).toBe(true);
|
|
2053
|
-
});
|
|
2054
|
-
});
|
|
2055
|
-
});
|