mindoodb 0.0.23 → 0.0.32
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-server.md +9 -1
- package/README.md +5 -3
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts +1 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +24 -5
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.d.ts +14 -2
- package/dist/appendonlystores/network/HttpTransport.d.ts.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.js +124 -27
- package/dist/appendonlystores/network/HttpTransport.js.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +159 -4
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +334 -25
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts +9 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts.map +1 -1
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js +77 -5
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js.map +1 -1
- package/dist/browser/index.mjs +103 -0
- package/dist/core/BaseMindooDB.d.ts +697 -4
- package/dist/core/BaseMindooDB.d.ts.map +1 -1
- package/dist/core/BaseMindooDB.js +3273 -180
- package/dist/core/BaseMindooDB.js.map +1 -1
- package/dist/core/BaseMindooTenant.d.ts +192 -1
- package/dist/core/BaseMindooTenant.d.ts.map +1 -1
- package/dist/core/BaseMindooTenant.js +633 -88
- package/dist/core/BaseMindooTenant.js.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.d.ts +770 -10
- package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.js +2715 -292
- package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
- package/dist/core/BaseMindooTenantFactory.d.ts +2 -0
- package/dist/core/BaseMindooTenantFactory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantFactory.js +20 -0
- package/dist/core/BaseMindooTenantFactory.js.map +1 -1
- package/dist/core/accesscontrol/AccessDeniedError.d.ts +22 -0
- package/dist/core/accesscontrol/AccessDeniedError.d.ts.map +1 -0
- package/dist/core/accesscontrol/AccessDeniedError.js +28 -0
- package/dist/core/accesscontrol/AccessDeniedError.js.map +1 -0
- package/dist/core/accesscontrol/DirectoryStateNode.d.ts +220 -0
- package/dist/core/accesscontrol/DirectoryStateNode.d.ts.map +1 -0
- package/dist/core/accesscontrol/DirectoryStateNode.js +297 -0
- package/dist/core/accesscontrol/DirectoryStateNode.js.map +1 -0
- package/dist/core/accesscontrol/DirectoryTimeTravelIndex.d.ts +118 -0
- package/dist/core/accesscontrol/DirectoryTimeTravelIndex.d.ts.map +1 -0
- package/dist/core/accesscontrol/DirectoryTimeTravelIndex.js +173 -0
- package/dist/core/accesscontrol/DirectoryTimeTravelIndex.js.map +1 -0
- package/dist/core/accesscontrol/directoryProjection.d.ts +26 -0
- package/dist/core/accesscontrol/directoryProjection.d.ts.map +1 -0
- package/dist/core/accesscontrol/directoryProjection.js +174 -0
- package/dist/core/accesscontrol/directoryProjection.js.map +1 -0
- package/dist/core/accesscontrol/evaluate.d.ts +77 -0
- package/dist/core/accesscontrol/evaluate.d.ts.map +1 -0
- package/dist/core/accesscontrol/evaluate.js +206 -0
- package/dist/core/accesscontrol/evaluate.js.map +1 -0
- package/dist/core/accesscontrol/grantKeys.d.ts +113 -0
- package/dist/core/accesscontrol/grantKeys.d.ts.map +1 -0
- package/dist/core/accesscontrol/grantKeys.js +302 -0
- package/dist/core/accesscontrol/grantKeys.js.map +1 -0
- package/dist/core/accesscontrol/keyBagReconciler.d.ts +22 -0
- package/dist/core/accesscontrol/keyBagReconciler.d.ts.map +1 -0
- package/dist/core/accesscontrol/keyBagReconciler.js +3 -0
- package/dist/core/accesscontrol/keyBagReconciler.js.map +1 -0
- package/dist/core/accesscontrol/materializationGuard.d.ts +89 -0
- package/dist/core/accesscontrol/materializationGuard.d.ts.map +1 -0
- package/dist/core/accesscontrol/materializationGuard.js +69 -0
- package/dist/core/accesscontrol/materializationGuard.js.map +1 -0
- package/dist/core/accesscontrol/quarantine.d.ts +65 -0
- package/dist/core/accesscontrol/quarantine.d.ts.map +1 -0
- package/dist/core/accesscontrol/quarantine.js +79 -0
- package/dist/core/accesscontrol/quarantine.js.map +1 -0
- package/dist/core/accesscontrol/receiptValidation.d.ts +113 -0
- package/dist/core/accesscontrol/receiptValidation.d.ts.map +1 -0
- package/dist/core/accesscontrol/receiptValidation.js +142 -0
- package/dist/core/accesscontrol/receiptValidation.js.map +1 -0
- package/dist/core/accesscontrol/timestamp/Ed25519WitnessProvider.d.ts +31 -0
- package/dist/core/accesscontrol/timestamp/Ed25519WitnessProvider.d.ts.map +1 -0
- package/dist/core/accesscontrol/timestamp/Ed25519WitnessProvider.js +66 -0
- package/dist/core/accesscontrol/timestamp/Ed25519WitnessProvider.js.map +1 -0
- package/dist/core/accesscontrol/timestamp/TimestampProvider.d.ts +79 -0
- package/dist/core/accesscontrol/timestamp/TimestampProvider.d.ts.map +1 -0
- package/dist/core/accesscontrol/timestamp/TimestampProvider.js +22 -0
- package/dist/core/accesscontrol/timestamp/TimestampProvider.js.map +1 -0
- package/dist/core/accesscontrol/types.d.ts +825 -0
- package/dist/core/accesscontrol/types.d.ts.map +1 -0
- package/dist/core/accesscontrol/types.js +534 -0
- package/dist/core/accesscontrol/types.js.map +1 -0
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts +9 -0
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts.map +1 -1
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js +54 -0
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js.map +1 -1
- package/dist/core/appendonlystores/network/AuthenticationService.d.ts +38 -2
- package/dist/core/appendonlystores/network/AuthenticationService.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/AuthenticationService.js +199 -26
- package/dist/core/appendonlystores/network/AuthenticationService.js.map +1 -1
- package/dist/core/appendonlystores/network/NetworkTransport.d.ts +17 -3
- package/dist/core/appendonlystores/network/NetworkTransport.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/types.d.ts +58 -4
- package/dist/core/appendonlystores/network/types.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/types.js +4 -0
- package/dist/core/appendonlystores/network/types.js.map +1 -1
- package/dist/core/appendonlystores/scanUtils.d.ts +27 -0
- package/dist/core/appendonlystores/scanUtils.d.ts.map +1 -0
- package/dist/core/appendonlystores/scanUtils.js +87 -0
- package/dist/core/appendonlystores/scanUtils.js.map +1 -0
- package/dist/core/appendonlystores/types.d.ts +23 -2
- package/dist/core/appendonlystores/types.d.ts.map +1 -1
- package/dist/core/cache/CacheManager.d.ts +13 -3
- package/dist/core/cache/CacheManager.d.ts.map +1 -1
- package/dist/core/cache/CacheManager.js +7 -4
- package/dist/core/cache/CacheManager.js.map +1 -1
- package/dist/core/crypto/EntrySignature.d.ts +137 -0
- package/dist/core/crypto/EntrySignature.d.ts.map +1 -0
- package/dist/core/crypto/EntrySignature.js +210 -0
- package/dist/core/crypto/EntrySignature.js.map +1 -0
- package/dist/core/crypto/MindooDocSigner.d.ts.map +1 -1
- package/dist/core/crypto/MindooDocSigner.js +6 -2
- package/dist/core/crypto/MindooDocSigner.js.map +1 -1
- package/dist/core/crypto/WitnessReceipt.d.ts +137 -0
- package/dist/core/crypto/WitnessReceipt.d.ts.map +1 -0
- package/dist/core/crypto/WitnessReceipt.js +182 -0
- package/dist/core/crypto/WitnessReceipt.js.map +1 -0
- package/dist/core/crypto/encryptedFields.d.ts +27 -0
- package/dist/core/crypto/encryptedFields.d.ts.map +1 -0
- package/dist/core/crypto/encryptedFields.js +58 -0
- package/dist/core/crypto/encryptedFields.js.map +1 -0
- package/dist/core/crypto/pbkdf2Iterations.d.ts +12 -0
- package/dist/core/crypto/pbkdf2Iterations.d.ts.map +1 -1
- package/dist/core/crypto/pbkdf2Iterations.js +23 -0
- package/dist/core/crypto/pbkdf2Iterations.js.map +1 -1
- package/dist/core/crypto/privateKeyEncryption.d.ts.map +1 -1
- package/dist/core/crypto/privateKeyEncryption.js +3 -1
- package/dist/core/crypto/privateKeyEncryption.js.map +1 -1
- package/dist/core/databaseIdValidation.d.ts +1 -1
- package/dist/core/databaseIdValidation.d.ts.map +1 -1
- package/dist/core/databaseIdValidation.js +4 -4
- package/dist/core/databaseIdValidation.js.map +1 -1
- package/dist/core/errors.d.ts +26 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +42 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/expressions/builder.d.ts +102 -0
- package/dist/core/expressions/builder.d.ts.map +1 -0
- package/dist/core/expressions/builder.js +249 -0
- package/dist/core/expressions/builder.js.map +1 -0
- package/dist/core/expressions/evaluateExpression.d.ts +78 -0
- package/dist/core/expressions/evaluateExpression.d.ts.map +1 -0
- package/dist/core/expressions/evaluateExpression.js +386 -0
- package/dist/core/expressions/evaluateExpression.js.map +1 -0
- package/dist/core/expressions/formulaSource.d.ts +24 -0
- package/dist/core/expressions/formulaSource.d.ts.map +1 -0
- package/dist/core/expressions/formulaSource.js +765 -0
- package/dist/core/expressions/formulaSource.js.map +1 -0
- package/dist/core/expressions/index.d.ts +8 -0
- package/dist/core/expressions/index.d.ts.map +1 -0
- package/dist/core/expressions/index.js +46 -0
- package/dist/core/expressions/index.js.map +1 -0
- package/dist/core/expressions/metadata.d.ts +23 -0
- package/dist/core/expressions/metadata.d.ts.map +1 -0
- package/dist/core/expressions/metadata.js +191 -0
- package/dist/core/expressions/metadata.js.map +1 -0
- package/dist/core/expressions/types.d.ts +164 -0
- package/dist/core/expressions/types.d.ts.map +1 -0
- package/dist/core/expressions/types.js +3 -0
- package/dist/core/expressions/types.js.map +1 -0
- package/dist/core/extraction/types.d.ts +47 -0
- package/dist/core/extraction/types.d.ts.map +1 -0
- package/dist/core/extraction/types.js +42 -0
- package/dist/core/extraction/types.js.map +1 -0
- package/dist/core/index.d.ts +13 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +113 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/indexing/createViewDataProvider.d.ts +84 -0
- package/dist/core/indexing/createViewDataProvider.d.ts.map +1 -0
- package/dist/core/indexing/createViewDataProvider.js +139 -0
- package/dist/core/indexing/createViewDataProvider.js.map +1 -0
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.d.ts +180 -0
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.d.ts.map +1 -0
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.js +548 -0
- package/dist/core/indexing/fulltext/DocumentFullTextIndex.js.map +1 -0
- package/dist/core/indexing/fulltext/SearchEngineAdapter.d.ts +69 -0
- package/dist/core/indexing/fulltext/SearchEngineAdapter.d.ts.map +1 -0
- package/dist/core/indexing/fulltext/SearchEngineAdapter.js +183 -0
- package/dist/core/indexing/fulltext/SearchEngineAdapter.js.map +1 -0
- package/dist/core/indexing/fulltext/extractFulltextText.d.ts +34 -0
- package/dist/core/indexing/fulltext/extractFulltextText.d.ts.map +1 -0
- package/dist/core/indexing/fulltext/extractFulltextText.js +129 -0
- package/dist/core/indexing/fulltext/extractFulltextText.js.map +1 -0
- package/dist/core/indexing/fulltext/index.d.ts +5 -0
- package/dist/core/indexing/fulltext/index.d.ts.map +1 -0
- package/dist/core/indexing/fulltext/index.js +20 -0
- package/dist/core/indexing/fulltext/index.js.map +1 -0
- package/dist/core/indexing/fulltext/types.d.ts +168 -0
- package/dist/core/indexing/fulltext/types.d.ts.map +1 -0
- package/dist/core/indexing/fulltext/types.js +89 -0
- package/dist/core/indexing/fulltext/types.js.map +1 -0
- package/dist/core/indexing/summary/DocumentSummaryStore.d.ts +137 -0
- package/dist/core/indexing/summary/DocumentSummaryStore.d.ts.map +1 -0
- package/dist/core/indexing/summary/DocumentSummaryStore.js +438 -0
- package/dist/core/indexing/summary/DocumentSummaryStore.js.map +1 -0
- package/dist/core/indexing/summary/SummaryVirtualViewDataProvider.d.ts +72 -0
- package/dist/core/indexing/summary/SummaryVirtualViewDataProvider.d.ts.map +1 -0
- package/dist/core/indexing/summary/SummaryVirtualViewDataProvider.js +221 -0
- package/dist/core/indexing/summary/SummaryVirtualViewDataProvider.js.map +1 -0
- package/dist/core/indexing/summary/extractSummaryFields.d.ts +75 -0
- package/dist/core/indexing/summary/extractSummaryFields.d.ts.map +1 -0
- package/dist/core/indexing/summary/extractSummaryFields.js +266 -0
- package/dist/core/indexing/summary/extractSummaryFields.js.map +1 -0
- package/dist/core/indexing/summary/index.d.ts +5 -0
- package/dist/core/indexing/summary/index.d.ts.map +1 -0
- package/dist/core/indexing/summary/index.js +23 -0
- package/dist/core/indexing/summary/index.js.map +1 -0
- package/dist/core/indexing/summary/types.d.ts +119 -0
- package/dist/core/indexing/summary/types.d.ts.map +1 -0
- package/dist/core/indexing/summary/types.js +81 -0
- package/dist/core/indexing/summary/types.js.map +1 -0
- package/dist/core/indexing/virtualviews/IVirtualViewDataProvider.d.ts +47 -1
- package/dist/core/indexing/virtualviews/IVirtualViewDataProvider.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.d.ts +24 -8
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js +96 -41
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js.map +1 -1
- package/dist/core/indexing/virtualviews/ViewEntrySortKey.d.ts +2 -0
- package/dist/core/indexing/virtualviews/ViewEntrySortKey.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/ViewEntrySortKey.js +8 -3
- package/dist/core/indexing/virtualviews/ViewEntrySortKey.js.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualView.d.ts +111 -5
- package/dist/core/indexing/virtualviews/VirtualView.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualView.js +266 -75
- package/dist/core/indexing/virtualviews/VirtualView.js.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewColumn.d.ts +12 -0
- package/dist/core/indexing/virtualviews/VirtualViewColumn.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewColumn.js +1 -0
- package/dist/core/indexing/virtualviews/VirtualViewColumn.js.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.d.ts +12 -0
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.js +66 -5
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.js.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewFactory.d.ts +50 -6
- package/dist/core/indexing/virtualviews/VirtualViewFactory.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewFactory.js +54 -12
- package/dist/core/indexing/virtualviews/VirtualViewFactory.js.map +1 -1
- package/dist/core/indexing/virtualviews/index.d.ts +3 -3
- package/dist/core/indexing/virtualviews/index.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/index.js.map +1 -1
- package/dist/core/indexing/virtualviews/types.d.ts +6 -0
- package/dist/core/indexing/virtualviews/types.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/types.js +11 -3
- package/dist/core/indexing/virtualviews/types.js.map +1 -1
- package/dist/core/keys/KeyBag.d.ts +25 -0
- package/dist/core/keys/KeyBag.d.ts.map +1 -1
- package/dist/core/keys/KeyBag.js +37 -1
- package/dist/core/keys/KeyBag.js.map +1 -1
- package/dist/core/query/executeQuery.d.ts +18 -0
- package/dist/core/query/executeQuery.d.ts.map +1 -0
- package/dist/core/query/executeQuery.js +313 -0
- package/dist/core/query/executeQuery.js.map +1 -0
- package/dist/core/query/index.d.ts +5 -0
- package/dist/core/query/index.d.ts.map +1 -0
- package/dist/core/query/index.js +14 -0
- package/dist/core/query/index.js.map +1 -0
- package/dist/core/query/queryLive.d.ts +27 -0
- package/dist/core/query/queryLive.d.ts.map +1 -0
- package/dist/core/query/queryLive.js +104 -0
- package/dist/core/query/queryLive.js.map +1 -0
- package/dist/core/query/queryView.d.ts +156 -0
- package/dist/core/query/queryView.d.ts.map +1 -0
- package/dist/core/query/queryView.js +266 -0
- package/dist/core/query/queryView.js.map +1 -0
- package/dist/core/query/types.d.ts +121 -0
- package/dist/core/query/types.d.ts.map +1 -0
- package/dist/core/query/types.js +18 -0
- package/dist/core/query/types.js.map +1 -0
- package/dist/core/storeEntryTime.d.ts +57 -0
- package/dist/core/storeEntryTime.d.ts.map +1 -0
- package/dist/core/storeEntryTime.js +72 -0
- package/dist/core/storeEntryTime.js.map +1 -0
- package/dist/core/types.d.ts +1509 -39
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +13 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/uri/MindooURI.d.ts +53 -1
- package/dist/core/uri/MindooURI.d.ts.map +1 -1
- package/dist/core/uri/MindooURI.js +135 -0
- package/dist/core/uri/MindooURI.js.map +1 -1
- package/dist/core/utils/urlSafety.d.ts +46 -0
- package/dist/core/utils/urlSafety.d.ts.map +1 -0
- package/dist/core/utils/urlSafety.js +144 -0
- package/dist/core/utils/urlSafety.js.map +1 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +14 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -1
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js +95 -4
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -1
- package/dist/node/server/CapabilityMatcher.d.ts +10 -0
- package/dist/node/server/CapabilityMatcher.d.ts.map +1 -1
- package/dist/node/server/CapabilityMatcher.js +14 -2
- package/dist/node/server/CapabilityMatcher.js.map +1 -1
- package/dist/node/server/MindooDBServer.d.ts.map +1 -1
- package/dist/node/server/MindooDBServer.js +117 -8
- package/dist/node/server/MindooDBServer.js.map +1 -1
- package/dist/node/server/PurgedDocRegistry.d.ts +32 -0
- package/dist/node/server/PurgedDocRegistry.d.ts.map +1 -0
- package/dist/node/server/PurgedDocRegistry.js +94 -0
- package/dist/node/server/PurgedDocRegistry.js.map +1 -0
- package/dist/node/server/ServerSync.d.ts.map +1 -1
- package/dist/node/server/ServerSync.js +5 -2
- package/dist/node/server/ServerSync.js.map +1 -1
- package/dist/node/server/SystemAdminAuth.d.ts +10 -0
- package/dist/node/server/SystemAdminAuth.d.ts.map +1 -1
- package/dist/node/server/SystemAdminAuth.js +25 -0
- package/dist/node/server/SystemAdminAuth.js.map +1 -1
- package/dist/node/server/TenantManager.d.ts +95 -1
- package/dist/node/server/TenantManager.d.ts.map +1 -1
- package/dist/node/server/TenantManager.js +382 -15
- package/dist/node/server/TenantManager.js.map +1 -1
- package/dist/node/server/config.d.ts.map +1 -1
- package/dist/node/server/config.js +5 -1
- package/dist/node/server/config.js.map +1 -1
- package/dist/node/server/types.d.ts +29 -3
- package/dist/node/server/types.d.ts.map +1 -1
- package/dist/node/server/types.js +12 -0
- package/dist/node/server/types.js.map +1 -1
- package/dist/node/server/validation.d.ts +6 -0
- package/dist/node/server/validation.d.ts.map +1 -1
- package/dist/node/server/validation.js +7 -1
- package/dist/node/server/validation.js.map +1 -1
- package/package.json +4 -3
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts +0 -8
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts.map +0 -1
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js +0 -16
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js.map +0 -1
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +0 -68
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +0 -1
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js +0 -659
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js.map +0 -1
- package/dist/node/attachments/writeAttachmentToFile.d.ts +0 -15
- package/dist/node/attachments/writeAttachmentToFile.d.ts.map +0 -1
- package/dist/node/attachments/writeAttachmentToFile.js +0 -73
- package/dist/node/attachments/writeAttachmentToFile.js.map +0 -1
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MindooDBFormulaSyntaxError = void 0;
|
|
4
|
+
exports.parseMindooDBFormulaExpression = parseMindooDBFormulaExpression;
|
|
5
|
+
exports.parseMindooDBFormulaBooleanExpression = parseMindooDBFormulaBooleanExpression;
|
|
6
|
+
exports.formatMindooDBFormulaExpression = formatMindooDBFormulaExpression;
|
|
7
|
+
exports.isMindooDBFormulaLikelyBoolean = isMindooDBFormulaLikelyBoolean;
|
|
8
|
+
const OP_TO_HELPER = {
|
|
9
|
+
createdAt: "createdAt",
|
|
10
|
+
decryptionKeyId: "decryptionKeyId",
|
|
11
|
+
isWitnessed: "isWitnessed",
|
|
12
|
+
isAwaitingWitness: "isAwaitingWitness",
|
|
13
|
+
attachmentNames: "attachmentNames",
|
|
14
|
+
attachmentLengths: "attachmentLengths",
|
|
15
|
+
attachmentCount: "attachmentCount",
|
|
16
|
+
childCount: "childCount",
|
|
17
|
+
childCategoryCount: "childCategoryCount",
|
|
18
|
+
childDocumentCount: "childDocumentCount",
|
|
19
|
+
descendantCount: "descendantCount",
|
|
20
|
+
descendantCategoryCount: "descendantCategoryCount",
|
|
21
|
+
descendantDocumentCount: "descendantDocumentCount",
|
|
22
|
+
siblingCount: "siblingCount",
|
|
23
|
+
add: "add",
|
|
24
|
+
sub: "sub",
|
|
25
|
+
mul: "mul",
|
|
26
|
+
div: "div",
|
|
27
|
+
mod: "mod",
|
|
28
|
+
eq: "eq",
|
|
29
|
+
neq: "neq",
|
|
30
|
+
gt: "gt",
|
|
31
|
+
gte: "gte",
|
|
32
|
+
lt: "lt",
|
|
33
|
+
lte: "lte",
|
|
34
|
+
and: "and",
|
|
35
|
+
or: "or",
|
|
36
|
+
not: "not",
|
|
37
|
+
concat: "concat",
|
|
38
|
+
lower: "lower",
|
|
39
|
+
upper: "upper",
|
|
40
|
+
trim: "trim",
|
|
41
|
+
left: "left",
|
|
42
|
+
right: "right",
|
|
43
|
+
number: "toNumber",
|
|
44
|
+
string: "toString",
|
|
45
|
+
boolean: "toBoolean",
|
|
46
|
+
contains: "contains",
|
|
47
|
+
startsWith: "startsWith",
|
|
48
|
+
endsWith: "endsWith",
|
|
49
|
+
coalesce: "coalesce",
|
|
50
|
+
exists: "exists",
|
|
51
|
+
notExists: "notExists",
|
|
52
|
+
pathJoin: "pathJoin",
|
|
53
|
+
datePart: "datePart",
|
|
54
|
+
};
|
|
55
|
+
const BOOLEAN_HELPERS = new Set([
|
|
56
|
+
"boolean",
|
|
57
|
+
"eq",
|
|
58
|
+
"neq",
|
|
59
|
+
"gt",
|
|
60
|
+
"gte",
|
|
61
|
+
"lt",
|
|
62
|
+
"lte",
|
|
63
|
+
"and",
|
|
64
|
+
"or",
|
|
65
|
+
"not",
|
|
66
|
+
"contains",
|
|
67
|
+
"startsWith",
|
|
68
|
+
"endsWith",
|
|
69
|
+
"exists",
|
|
70
|
+
"notExists",
|
|
71
|
+
"toBoolean",
|
|
72
|
+
"isWitnessed",
|
|
73
|
+
"isAwaitingWitness",
|
|
74
|
+
]);
|
|
75
|
+
const DATE_PARTS = new Set(["year", "month", "day", "quarter"]);
|
|
76
|
+
/** Syntax error raised while parsing Formula source text into the shared AST. */
|
|
77
|
+
class MindooDBFormulaSyntaxError extends Error {
|
|
78
|
+
constructor(message, index) {
|
|
79
|
+
super(message);
|
|
80
|
+
this.name = "MindooDBFormulaSyntaxError";
|
|
81
|
+
this.index = index;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.MindooDBFormulaSyntaxError = MindooDBFormulaSyntaxError;
|
|
85
|
+
/**
|
|
86
|
+
* Parses builder-call style Formula source into the shared expression AST.
|
|
87
|
+
*
|
|
88
|
+
* Example: `v.eq(v.field("status"), "approved")`
|
|
89
|
+
*/
|
|
90
|
+
function parseMindooDBFormulaExpression(source) {
|
|
91
|
+
const parser = new FormulaParser(source);
|
|
92
|
+
const expression = parser.parseExpression();
|
|
93
|
+
parser.skipWhitespace();
|
|
94
|
+
if (!parser.isEof()) {
|
|
95
|
+
throw parser.error("Unexpected trailing input");
|
|
96
|
+
}
|
|
97
|
+
return expression;
|
|
98
|
+
}
|
|
99
|
+
/** Parses Formula source and narrows the result to a boolean expression for filter use cases. */
|
|
100
|
+
function parseMindooDBFormulaBooleanExpression(source) {
|
|
101
|
+
return parseMindooDBFormulaExpression(source);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Formats an expression into canonical Formula source with stable indentation
|
|
105
|
+
* and literal shorthand.
|
|
106
|
+
*/
|
|
107
|
+
function formatMindooDBFormulaExpression(expression, options = {}) {
|
|
108
|
+
const indent = options.indent ?? " ";
|
|
109
|
+
return formatExpression(expression, 0, indent);
|
|
110
|
+
}
|
|
111
|
+
/** Best-effort heuristic used by editor integrations to warn about non-boolean filters. */
|
|
112
|
+
function isMindooDBFormulaLikelyBoolean(expression) {
|
|
113
|
+
switch (expression.kind) {
|
|
114
|
+
case "literal":
|
|
115
|
+
return typeof expression.value === "boolean";
|
|
116
|
+
case "if":
|
|
117
|
+
return isMindooDBFormulaLikelyBoolean(expression.whenTrue) && isMindooDBFormulaLikelyBoolean(expression.whenFalse);
|
|
118
|
+
case "operation":
|
|
119
|
+
return BOOLEAN_HELPERS.has(OP_TO_HELPER[expression.op]);
|
|
120
|
+
default:
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Internal formatter for a single expression node. */
|
|
125
|
+
function formatExpression(expression, level, indent) {
|
|
126
|
+
switch (expression.kind) {
|
|
127
|
+
case "literal":
|
|
128
|
+
return formatLiteralExpression(expression.value);
|
|
129
|
+
case "field":
|
|
130
|
+
return `v.field(${JSON.stringify(expression.path)})`;
|
|
131
|
+
case "value":
|
|
132
|
+
return `v.value(${JSON.stringify(expression.path)})`;
|
|
133
|
+
case "origin":
|
|
134
|
+
return "v.origin()";
|
|
135
|
+
case "variable":
|
|
136
|
+
return expression.name;
|
|
137
|
+
case "if": {
|
|
138
|
+
// Flatten else-if chains into the variadic Domino-style form:
|
|
139
|
+
// v.ifElse(cond1, val1, cond2, val2, ..., default).
|
|
140
|
+
const parts = [];
|
|
141
|
+
let current = expression;
|
|
142
|
+
while (current.kind === "if") {
|
|
143
|
+
parts.push(current.condition, current.whenTrue);
|
|
144
|
+
current = current.whenFalse;
|
|
145
|
+
}
|
|
146
|
+
parts.push(current);
|
|
147
|
+
return [
|
|
148
|
+
"v.ifElse(",
|
|
149
|
+
...parts.map((part) => `${repeatIndent(level + 1, indent)}${formatExpression(part, level + 1, indent)},`),
|
|
150
|
+
`${repeatIndent(level, indent)})`,
|
|
151
|
+
].join("\n");
|
|
152
|
+
}
|
|
153
|
+
case "let": {
|
|
154
|
+
const entries = Object.entries(expression.bindings);
|
|
155
|
+
const bindingBlock = entries.length === 0
|
|
156
|
+
? "{}"
|
|
157
|
+
: [
|
|
158
|
+
"{",
|
|
159
|
+
...entries.map(([name, value]) => `${repeatIndent(level + 2, indent)}${name}: ${formatExpression(value, level + 2, indent)},`),
|
|
160
|
+
`${repeatIndent(level + 1, indent)}}`,
|
|
161
|
+
].join("\n");
|
|
162
|
+
const refList = entries.map(([name]) => name).join(", ");
|
|
163
|
+
return [
|
|
164
|
+
"v.let(",
|
|
165
|
+
`${repeatIndent(level + 1, indent)}${bindingBlock},`,
|
|
166
|
+
`${repeatIndent(level + 1, indent)}({ ${refList} }) => ${formatExpression(expression.result, level + 1, indent)},`,
|
|
167
|
+
`${repeatIndent(level, indent)})`,
|
|
168
|
+
].join("\n");
|
|
169
|
+
}
|
|
170
|
+
case "decrypt": {
|
|
171
|
+
const field = JSON.stringify(expression.field);
|
|
172
|
+
if (!expression.json) {
|
|
173
|
+
return expression.key
|
|
174
|
+
? `v.decryptField(${field}, ${formatExpression(expression.key, level, indent)})`
|
|
175
|
+
: `v.decryptField(${field})`;
|
|
176
|
+
}
|
|
177
|
+
if (expression.key) {
|
|
178
|
+
return `v.decryptJson(${field}, ${JSON.stringify(expression.path ?? "")}, ${formatExpression(expression.key, level, indent)})`;
|
|
179
|
+
}
|
|
180
|
+
if (expression.path !== undefined) {
|
|
181
|
+
return `v.decryptJson(${field}, ${JSON.stringify(expression.path)})`;
|
|
182
|
+
}
|
|
183
|
+
return `v.decryptJson(${field})`;
|
|
184
|
+
}
|
|
185
|
+
case "json": {
|
|
186
|
+
const field = JSON.stringify(expression.field);
|
|
187
|
+
return expression.path !== undefined
|
|
188
|
+
? `v.json(${field}, ${JSON.stringify(expression.path)})`
|
|
189
|
+
: `v.json(${field})`;
|
|
190
|
+
}
|
|
191
|
+
case "operation": {
|
|
192
|
+
const helper = OP_TO_HELPER[expression.op];
|
|
193
|
+
if (expression.op === "datePart") {
|
|
194
|
+
return `v.datePart(${formatExpression(expression.args[0], level, indent)}, ${JSON.stringify(expression.part ?? "year")})`;
|
|
195
|
+
}
|
|
196
|
+
if (shouldFormatOperationMultiline(expression)) {
|
|
197
|
+
return [
|
|
198
|
+
`v.${helper}(`,
|
|
199
|
+
...expression.args.map((arg) => `${repeatIndent(level + 1, indent)}${formatExpression(arg, level + 1, indent)},`),
|
|
200
|
+
`${repeatIndent(level, indent)})`,
|
|
201
|
+
].join("\n");
|
|
202
|
+
}
|
|
203
|
+
return `v.${helper}(${expression.args.map((arg) => formatExpression(arg, level, indent)).join(", ")})`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Expands multi-argument wrappers once nested expressions become hard to read inline. */
|
|
208
|
+
function shouldFormatOperationMultiline(expression) {
|
|
209
|
+
return expression.args.length > 1 && expression.args.some((arg) => arg.kind === "operation" || arg.kind === "if" || arg.kind === "let" || !isInlineExpression(arg));
|
|
210
|
+
}
|
|
211
|
+
/** Identifies expressions that stay readable on a single line. */
|
|
212
|
+
function isInlineExpression(expression) {
|
|
213
|
+
switch (expression.kind) {
|
|
214
|
+
case "literal":
|
|
215
|
+
case "field":
|
|
216
|
+
case "value":
|
|
217
|
+
case "origin":
|
|
218
|
+
case "variable":
|
|
219
|
+
case "json":
|
|
220
|
+
return true;
|
|
221
|
+
case "decrypt":
|
|
222
|
+
return expression.key ? isInlineExpression(expression.key) : true;
|
|
223
|
+
case "operation":
|
|
224
|
+
if (expression.op === "datePart") {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
return expression.args.every(isInlineExpression);
|
|
228
|
+
case "if":
|
|
229
|
+
case "let":
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** Emits canonical literal shorthand whenever possible. */
|
|
234
|
+
function formatLiteralExpression(value) {
|
|
235
|
+
if (typeof value === "number") {
|
|
236
|
+
return Number.isFinite(value) ? String(value) : "0";
|
|
237
|
+
}
|
|
238
|
+
return formatJsonLike(value);
|
|
239
|
+
}
|
|
240
|
+
/** Serializes JSON-like literal values, including the explicit `undefined` sentinel. */
|
|
241
|
+
function formatJsonLike(value) {
|
|
242
|
+
if (value === undefined) {
|
|
243
|
+
return "undefined";
|
|
244
|
+
}
|
|
245
|
+
const serialized = JSON.stringify(value);
|
|
246
|
+
return serialized ?? "null";
|
|
247
|
+
}
|
|
248
|
+
function repeatIndent(level, indent) {
|
|
249
|
+
return indent.repeat(level);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Small hand-written recursive descent parser for Formula source.
|
|
253
|
+
*
|
|
254
|
+
* It only understands the supported helper-call grammar plus JSON-like
|
|
255
|
+
* literals so editor tooling can validate and prettify formulas without
|
|
256
|
+
* executing JavaScript.
|
|
257
|
+
*/
|
|
258
|
+
class FormulaParser {
|
|
259
|
+
constructor(source) {
|
|
260
|
+
this.source = source;
|
|
261
|
+
this.index = 0;
|
|
262
|
+
}
|
|
263
|
+
isEof() {
|
|
264
|
+
return this.index >= this.source.length;
|
|
265
|
+
}
|
|
266
|
+
skipWhitespace() {
|
|
267
|
+
while (!this.isEof() && /\s/.test(this.source[this.index])) {
|
|
268
|
+
this.index += 1;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
error(message) {
|
|
272
|
+
return new MindooDBFormulaSyntaxError(message, this.index);
|
|
273
|
+
}
|
|
274
|
+
parseExpression() {
|
|
275
|
+
this.skipWhitespace();
|
|
276
|
+
const char = this.peek();
|
|
277
|
+
if (!char) {
|
|
278
|
+
throw this.error("Expected expression");
|
|
279
|
+
}
|
|
280
|
+
if (char === "(") {
|
|
281
|
+
this.index += 1;
|
|
282
|
+
const expression = this.parseExpression();
|
|
283
|
+
this.expectChar(")");
|
|
284
|
+
return expression;
|
|
285
|
+
}
|
|
286
|
+
if (char === '"' || char === "'") {
|
|
287
|
+
return { kind: "literal", value: this.parseStringLiteral() };
|
|
288
|
+
}
|
|
289
|
+
if (char === "[" || char === "{") {
|
|
290
|
+
return { kind: "literal", value: this.parseJsonLikeValue() };
|
|
291
|
+
}
|
|
292
|
+
if (char === "-" || /\d/.test(char)) {
|
|
293
|
+
return { kind: "literal", value: this.parseNumberLiteral() };
|
|
294
|
+
}
|
|
295
|
+
const identifier = this.parseIdentifier();
|
|
296
|
+
if (identifier === "v") {
|
|
297
|
+
this.expectChar(".");
|
|
298
|
+
return this.parseHelperCall();
|
|
299
|
+
}
|
|
300
|
+
if (identifier === "true") {
|
|
301
|
+
return { kind: "literal", value: true };
|
|
302
|
+
}
|
|
303
|
+
if (identifier === "false") {
|
|
304
|
+
return { kind: "literal", value: false };
|
|
305
|
+
}
|
|
306
|
+
if (identifier === "null") {
|
|
307
|
+
return { kind: "literal", value: null };
|
|
308
|
+
}
|
|
309
|
+
if (identifier === "undefined") {
|
|
310
|
+
return { kind: "literal", value: undefined };
|
|
311
|
+
}
|
|
312
|
+
return { kind: "variable", name: identifier };
|
|
313
|
+
}
|
|
314
|
+
/** Parses a `v.helper(...)` call and maps it to the corresponding AST node. */
|
|
315
|
+
parseHelperCall() {
|
|
316
|
+
const helper = this.parseIdentifier();
|
|
317
|
+
this.expectChar("(");
|
|
318
|
+
switch (helper) {
|
|
319
|
+
case "literal": {
|
|
320
|
+
const value = this.parseJsonLikeValue();
|
|
321
|
+
this.expectChar(")");
|
|
322
|
+
return { kind: "literal", value };
|
|
323
|
+
}
|
|
324
|
+
case "string": {
|
|
325
|
+
const value = this.parseStringLiteral();
|
|
326
|
+
this.expectChar(")");
|
|
327
|
+
return { kind: "literal", value };
|
|
328
|
+
}
|
|
329
|
+
case "number": {
|
|
330
|
+
const value = this.parseNumberLiteral();
|
|
331
|
+
this.expectChar(")");
|
|
332
|
+
return { kind: "literal", value };
|
|
333
|
+
}
|
|
334
|
+
case "boolean": {
|
|
335
|
+
const value = this.parseBooleanLiteral();
|
|
336
|
+
this.expectChar(")");
|
|
337
|
+
return { kind: "literal", value };
|
|
338
|
+
}
|
|
339
|
+
case "field": {
|
|
340
|
+
const path = this.parseStringLiteral();
|
|
341
|
+
this.expectChar(")");
|
|
342
|
+
return { kind: "field", path };
|
|
343
|
+
}
|
|
344
|
+
case "value": {
|
|
345
|
+
const path = this.parseStringLiteral();
|
|
346
|
+
this.expectChar(")");
|
|
347
|
+
return { kind: "value", path };
|
|
348
|
+
}
|
|
349
|
+
case "origin": {
|
|
350
|
+
this.expectChar(")");
|
|
351
|
+
return { kind: "origin" };
|
|
352
|
+
}
|
|
353
|
+
case "ifElse": {
|
|
354
|
+
// Domino-@If-style variadic form: cond1, val1, [cond2, val2, ...], default.
|
|
355
|
+
// Desugars right-to-left into nested `if` nodes.
|
|
356
|
+
const args = [this.parseExpression()];
|
|
357
|
+
while (true) {
|
|
358
|
+
this.skipWhitespace();
|
|
359
|
+
if (this.peek() === ",") {
|
|
360
|
+
this.index += 1;
|
|
361
|
+
this.skipWhitespace();
|
|
362
|
+
if (this.peek() === ")") {
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
args.push(this.parseExpression());
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
this.expectChar(")");
|
|
371
|
+
if (args.length < 3 || args.length % 2 === 0) {
|
|
372
|
+
throw this.error("ifElse expects condition/value pairs followed by one default value (odd argument count >= 3)");
|
|
373
|
+
}
|
|
374
|
+
let result = args[args.length - 1];
|
|
375
|
+
for (let i = args.length - 3; i >= 0; i -= 2) {
|
|
376
|
+
result = {
|
|
377
|
+
kind: "if",
|
|
378
|
+
condition: args[i],
|
|
379
|
+
whenTrue: args[i + 1],
|
|
380
|
+
whenFalse: result,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
return result;
|
|
384
|
+
}
|
|
385
|
+
case "let": {
|
|
386
|
+
const bindings = this.parseBindingsObject();
|
|
387
|
+
this.expectChar(",");
|
|
388
|
+
const bindingNames = this.parseArrowBindingNames();
|
|
389
|
+
const bindingSet = new Set(Object.keys(bindings));
|
|
390
|
+
for (const name of bindingNames) {
|
|
391
|
+
if (!bindingSet.has(name)) {
|
|
392
|
+
throw this.error(`Unknown let binding '${name}'`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
this.expectArrow();
|
|
396
|
+
const result = this.parseExpression();
|
|
397
|
+
this.consumeOptionalComma();
|
|
398
|
+
this.expectChar(")");
|
|
399
|
+
return { kind: "let", bindings, result };
|
|
400
|
+
}
|
|
401
|
+
case "datePart": {
|
|
402
|
+
const value = this.parseExpression();
|
|
403
|
+
this.expectChar(",");
|
|
404
|
+
const part = this.parseStringLiteral();
|
|
405
|
+
if (!DATE_PARTS.has(part)) {
|
|
406
|
+
throw this.error(`Unsupported date part '${part}'`);
|
|
407
|
+
}
|
|
408
|
+
this.consumeOptionalComma();
|
|
409
|
+
this.expectChar(")");
|
|
410
|
+
return { kind: "operation", op: "datePart", args: [value], part: part };
|
|
411
|
+
}
|
|
412
|
+
case "decryptField": {
|
|
413
|
+
const field = this.parseStringLiteral();
|
|
414
|
+
let key;
|
|
415
|
+
this.skipWhitespace();
|
|
416
|
+
if (this.peek() === ",") {
|
|
417
|
+
this.index += 1;
|
|
418
|
+
this.skipWhitespace();
|
|
419
|
+
if (this.peek() !== ")") {
|
|
420
|
+
key = this.parseExpression();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
this.consumeOptionalComma();
|
|
424
|
+
this.expectChar(")");
|
|
425
|
+
return { kind: "decrypt", field, key };
|
|
426
|
+
}
|
|
427
|
+
case "decryptJson": {
|
|
428
|
+
const field = this.parseStringLiteral();
|
|
429
|
+
let path;
|
|
430
|
+
let key;
|
|
431
|
+
this.skipWhitespace();
|
|
432
|
+
if (this.peek() === ",") {
|
|
433
|
+
this.index += 1;
|
|
434
|
+
this.skipWhitespace();
|
|
435
|
+
if (this.peek() !== ")") {
|
|
436
|
+
path = this.parseStringLiteral();
|
|
437
|
+
this.skipWhitespace();
|
|
438
|
+
if (this.peek() === ",") {
|
|
439
|
+
this.index += 1;
|
|
440
|
+
this.skipWhitespace();
|
|
441
|
+
if (this.peek() !== ")") {
|
|
442
|
+
key = this.parseExpression();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
this.consumeOptionalComma();
|
|
448
|
+
this.expectChar(")");
|
|
449
|
+
return { kind: "decrypt", field, json: true, path: path === "" ? undefined : path, key };
|
|
450
|
+
}
|
|
451
|
+
case "json": {
|
|
452
|
+
const field = this.parseStringLiteral();
|
|
453
|
+
let path;
|
|
454
|
+
this.skipWhitespace();
|
|
455
|
+
if (this.peek() === ",") {
|
|
456
|
+
this.index += 1;
|
|
457
|
+
this.skipWhitespace();
|
|
458
|
+
if (this.peek() !== ")") {
|
|
459
|
+
path = this.parseStringLiteral();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
this.consumeOptionalComma();
|
|
463
|
+
this.expectChar(")");
|
|
464
|
+
return { kind: "json", field, path: path === "" ? undefined : path };
|
|
465
|
+
}
|
|
466
|
+
default: {
|
|
467
|
+
const args = this.parseExpressionList();
|
|
468
|
+
this.expectChar(")");
|
|
469
|
+
return this.buildOperation(helper, args);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/** Converts a parsed helper name plus arguments into a generic operation node. */
|
|
474
|
+
buildOperation(helper, args) {
|
|
475
|
+
const op = helperToOperation(helper);
|
|
476
|
+
if (!op) {
|
|
477
|
+
throw this.error(`Unknown helper 'v.${helper}'`);
|
|
478
|
+
}
|
|
479
|
+
return { kind: "operation", op, args };
|
|
480
|
+
}
|
|
481
|
+
/** Parses comma-separated expression arguments and accepts a trailing comma. */
|
|
482
|
+
parseExpressionList() {
|
|
483
|
+
const args = [];
|
|
484
|
+
this.skipWhitespace();
|
|
485
|
+
if (this.peek() === ")") {
|
|
486
|
+
return args;
|
|
487
|
+
}
|
|
488
|
+
while (true) {
|
|
489
|
+
args.push(this.parseExpression());
|
|
490
|
+
this.skipWhitespace();
|
|
491
|
+
if (this.peek() === ",") {
|
|
492
|
+
this.index += 1;
|
|
493
|
+
this.skipWhitespace();
|
|
494
|
+
if (this.peek() === ")") {
|
|
495
|
+
return args;
|
|
496
|
+
}
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
return args;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
/** Parses the first object argument of `v.let(...)` into named bindings. */
|
|
503
|
+
parseBindingsObject() {
|
|
504
|
+
const bindings = {};
|
|
505
|
+
this.expectChar("{");
|
|
506
|
+
this.skipWhitespace();
|
|
507
|
+
if (this.peek() === "}") {
|
|
508
|
+
this.index += 1;
|
|
509
|
+
return bindings;
|
|
510
|
+
}
|
|
511
|
+
while (true) {
|
|
512
|
+
const key = this.parsePropertyKey();
|
|
513
|
+
this.expectChar(":");
|
|
514
|
+
bindings[key] = this.parseExpression();
|
|
515
|
+
this.skipWhitespace();
|
|
516
|
+
if (this.peek() === ",") {
|
|
517
|
+
this.index += 1;
|
|
518
|
+
this.skipWhitespace();
|
|
519
|
+
if (this.peek() === "}") {
|
|
520
|
+
this.index += 1;
|
|
521
|
+
return bindings;
|
|
522
|
+
}
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
this.expectChar("}");
|
|
526
|
+
return bindings;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
/** Parses the destructured parameter list of the `({ a, b }) => ...` let callback. */
|
|
530
|
+
parseArrowBindingNames() {
|
|
531
|
+
this.skipWhitespace();
|
|
532
|
+
this.expectChar("(");
|
|
533
|
+
this.expectChar("{");
|
|
534
|
+
const names = [];
|
|
535
|
+
this.skipWhitespace();
|
|
536
|
+
if (this.peek() === "}") {
|
|
537
|
+
this.index += 1;
|
|
538
|
+
this.expectChar(")");
|
|
539
|
+
return names;
|
|
540
|
+
}
|
|
541
|
+
while (true) {
|
|
542
|
+
names.push(this.parseIdentifier());
|
|
543
|
+
this.skipWhitespace();
|
|
544
|
+
if (this.peek() === ",") {
|
|
545
|
+
this.index += 1;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
this.expectChar("}");
|
|
549
|
+
this.expectChar(")");
|
|
550
|
+
return names;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
expectArrow() {
|
|
554
|
+
this.skipWhitespace();
|
|
555
|
+
if (!this.source.startsWith("=>", this.index)) {
|
|
556
|
+
throw this.error("Expected =>");
|
|
557
|
+
}
|
|
558
|
+
this.index += 2;
|
|
559
|
+
}
|
|
560
|
+
consumeOptionalComma() {
|
|
561
|
+
this.skipWhitespace();
|
|
562
|
+
if (this.peek() === ",") {
|
|
563
|
+
this.index += 1;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
parsePropertyKey() {
|
|
567
|
+
this.skipWhitespace();
|
|
568
|
+
const char = this.peek();
|
|
569
|
+
if (char === '"' || char === "'") {
|
|
570
|
+
return this.parseStringLiteral();
|
|
571
|
+
}
|
|
572
|
+
return this.parseIdentifier();
|
|
573
|
+
}
|
|
574
|
+
/** Parses JSON-like literal syntax used by `v.literal(...)` and raw shorthand literals. */
|
|
575
|
+
parseJsonLikeValue() {
|
|
576
|
+
this.skipWhitespace();
|
|
577
|
+
const char = this.peek();
|
|
578
|
+
if (!char) {
|
|
579
|
+
throw this.error("Expected value");
|
|
580
|
+
}
|
|
581
|
+
if (char === "{") {
|
|
582
|
+
return this.parseJsonLikeObject();
|
|
583
|
+
}
|
|
584
|
+
if (char === "[") {
|
|
585
|
+
return this.parseJsonLikeArray();
|
|
586
|
+
}
|
|
587
|
+
if (char === '"' || char === "'") {
|
|
588
|
+
return this.parseStringLiteral();
|
|
589
|
+
}
|
|
590
|
+
if (char === "-" || /\d/.test(char)) {
|
|
591
|
+
return this.parseNumberLiteral();
|
|
592
|
+
}
|
|
593
|
+
const identifier = this.parseIdentifier();
|
|
594
|
+
if (identifier === "true") {
|
|
595
|
+
return true;
|
|
596
|
+
}
|
|
597
|
+
if (identifier === "false") {
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
if (identifier === "null") {
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
if (identifier === "undefined") {
|
|
604
|
+
return undefined;
|
|
605
|
+
}
|
|
606
|
+
throw this.error(`Unsupported literal '${identifier}'`);
|
|
607
|
+
}
|
|
608
|
+
/** Parses JSON-like object syntax with optional trailing commas. */
|
|
609
|
+
parseJsonLikeObject() {
|
|
610
|
+
const result = {};
|
|
611
|
+
this.expectChar("{");
|
|
612
|
+
this.skipWhitespace();
|
|
613
|
+
if (this.peek() === "}") {
|
|
614
|
+
this.index += 1;
|
|
615
|
+
return result;
|
|
616
|
+
}
|
|
617
|
+
while (true) {
|
|
618
|
+
const key = this.parsePropertyKey();
|
|
619
|
+
this.expectChar(":");
|
|
620
|
+
result[key] = this.parseJsonLikeValue();
|
|
621
|
+
this.skipWhitespace();
|
|
622
|
+
if (this.peek() === ",") {
|
|
623
|
+
this.index += 1;
|
|
624
|
+
this.skipWhitespace();
|
|
625
|
+
if (this.peek() === "}") {
|
|
626
|
+
this.index += 1;
|
|
627
|
+
return result;
|
|
628
|
+
}
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
this.expectChar("}");
|
|
632
|
+
return result;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
/** Parses JSON-like array syntax. */
|
|
636
|
+
parseJsonLikeArray() {
|
|
637
|
+
const result = [];
|
|
638
|
+
this.expectChar("[");
|
|
639
|
+
this.skipWhitespace();
|
|
640
|
+
if (this.peek() === "]") {
|
|
641
|
+
this.index += 1;
|
|
642
|
+
return result;
|
|
643
|
+
}
|
|
644
|
+
while (true) {
|
|
645
|
+
result.push(this.parseJsonLikeValue());
|
|
646
|
+
this.skipWhitespace();
|
|
647
|
+
if (this.peek() === ",") {
|
|
648
|
+
this.index += 1;
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
this.expectChar("]");
|
|
652
|
+
return result;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
/** Parses a quoted string literal with the supported escape sequences. */
|
|
656
|
+
parseStringLiteral() {
|
|
657
|
+
this.skipWhitespace();
|
|
658
|
+
const quote = this.peek();
|
|
659
|
+
if (quote !== '"' && quote !== "'") {
|
|
660
|
+
throw this.error("Expected string literal");
|
|
661
|
+
}
|
|
662
|
+
this.index += 1;
|
|
663
|
+
let value = "";
|
|
664
|
+
while (!this.isEof()) {
|
|
665
|
+
const char = this.source[this.index];
|
|
666
|
+
this.index += 1;
|
|
667
|
+
if (char === quote) {
|
|
668
|
+
return value;
|
|
669
|
+
}
|
|
670
|
+
if (char === "\\") {
|
|
671
|
+
const next = this.source[this.index];
|
|
672
|
+
this.index += 1;
|
|
673
|
+
switch (next) {
|
|
674
|
+
case "\\":
|
|
675
|
+
value += "\\";
|
|
676
|
+
break;
|
|
677
|
+
case '"':
|
|
678
|
+
value += '"';
|
|
679
|
+
break;
|
|
680
|
+
case "'":
|
|
681
|
+
value += "'";
|
|
682
|
+
break;
|
|
683
|
+
case "n":
|
|
684
|
+
value += "\n";
|
|
685
|
+
break;
|
|
686
|
+
case "r":
|
|
687
|
+
value += "\r";
|
|
688
|
+
break;
|
|
689
|
+
case "t":
|
|
690
|
+
value += "\t";
|
|
691
|
+
break;
|
|
692
|
+
default:
|
|
693
|
+
value += next;
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
value += char;
|
|
699
|
+
}
|
|
700
|
+
throw this.error("Unterminated string literal");
|
|
701
|
+
}
|
|
702
|
+
/** Parses an integer or decimal number literal. */
|
|
703
|
+
parseNumberLiteral() {
|
|
704
|
+
this.skipWhitespace();
|
|
705
|
+
const start = this.index;
|
|
706
|
+
if (this.peek() === "-") {
|
|
707
|
+
this.index += 1;
|
|
708
|
+
}
|
|
709
|
+
while (!this.isEof() && /\d/.test(this.source[this.index])) {
|
|
710
|
+
this.index += 1;
|
|
711
|
+
}
|
|
712
|
+
if (this.peek() === ".") {
|
|
713
|
+
this.index += 1;
|
|
714
|
+
while (!this.isEof() && /\d/.test(this.source[this.index])) {
|
|
715
|
+
this.index += 1;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
const raw = this.source.slice(start, this.index);
|
|
719
|
+
const parsed = Number(raw);
|
|
720
|
+
if (!raw || !Number.isFinite(parsed)) {
|
|
721
|
+
throw this.error("Expected number literal");
|
|
722
|
+
}
|
|
723
|
+
return parsed;
|
|
724
|
+
}
|
|
725
|
+
/** Parses the `true` / `false` literals used by `v.boolean(...)`. */
|
|
726
|
+
parseBooleanLiteral() {
|
|
727
|
+
const identifier = this.parseIdentifier();
|
|
728
|
+
if (identifier === "true") {
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
if (identifier === "false") {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
throw this.error("Expected boolean literal");
|
|
735
|
+
}
|
|
736
|
+
parseIdentifier() {
|
|
737
|
+
this.skipWhitespace();
|
|
738
|
+
const start = this.index;
|
|
739
|
+
const first = this.peek();
|
|
740
|
+
if (!first || !/[A-Za-z_$]/.test(first)) {
|
|
741
|
+
throw this.error("Expected identifier");
|
|
742
|
+
}
|
|
743
|
+
this.index += 1;
|
|
744
|
+
while (!this.isEof() && /[A-Za-z0-9_$]/.test(this.source[this.index])) {
|
|
745
|
+
this.index += 1;
|
|
746
|
+
}
|
|
747
|
+
return this.source.slice(start, this.index);
|
|
748
|
+
}
|
|
749
|
+
expectChar(expected) {
|
|
750
|
+
this.skipWhitespace();
|
|
751
|
+
if (this.peek() !== expected) {
|
|
752
|
+
throw this.error(`Expected '${expected}'`);
|
|
753
|
+
}
|
|
754
|
+
this.index += 1;
|
|
755
|
+
}
|
|
756
|
+
peek() {
|
|
757
|
+
return this.source[this.index];
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function helperToOperation(helper) {
|
|
761
|
+
const entries = Object.entries(OP_TO_HELPER);
|
|
762
|
+
const match = entries.find(([, helperName]) => helperName === helper);
|
|
763
|
+
return match?.[0] ?? null;
|
|
764
|
+
}
|
|
765
|
+
//# sourceMappingURL=formulaSource.js.map
|