@adaas/a-frame 0.0.22 → 0.0.23
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/.conf/tsconfig.browser.json +13 -0
- package/.conf/tsconfig.node.json +14 -0
- package/.env.example +12 -0
- package/dist/browser/A-FrameBrowserStorageBlobs.context-OEQr85oq.d.mts +40 -0
- package/dist/browser/A-FrameBundle.types-DaaUvViw.d.mts +33 -0
- package/dist/browser/A-FrameChannel.types-DWOEUs28.d.mts +142 -0
- package/dist/browser/A-FrameDefinition.entity-DWGN_Ujr.d.mts +329 -0
- package/dist/browser/A-FrameDynamicStructure.entity-DaBgSRCR.d.mts +188 -0
- package/dist/browser/A-FrameLogger.component.env-browser-BIPAP4oQ.d.mts +112 -0
- package/dist/browser/A-FrameNamespace.entity-rCm1AavP.d.mts +125 -0
- package/dist/browser/bundle.d.mts +8 -0
- package/dist/browser/bundle.mjs +2 -0
- package/dist/browser/bundle.mjs.map +1 -0
- package/dist/browser/channel.d.mts +165 -0
- package/dist/browser/channel.mjs +3 -0
- package/dist/browser/channel.mjs.map +1 -0
- package/dist/browser/chunk-5TTVFB3G.mjs +2 -0
- package/dist/browser/chunk-5TTVFB3G.mjs.map +1 -0
- package/dist/browser/chunk-AYN7KUQT.mjs +3 -0
- package/dist/browser/chunk-AYN7KUQT.mjs.map +1 -0
- package/dist/browser/chunk-DMGQW3AO.mjs +2 -0
- package/dist/browser/chunk-DMGQW3AO.mjs.map +1 -0
- package/dist/browser/chunk-G66IL2DR.mjs +2 -0
- package/dist/browser/chunk-G66IL2DR.mjs.map +1 -0
- package/dist/browser/chunk-H6OZP4ZV.mjs +2 -0
- package/dist/browser/chunk-H6OZP4ZV.mjs.map +1 -0
- package/dist/browser/chunk-INS7RO3B.mjs +2 -0
- package/dist/browser/chunk-INS7RO3B.mjs.map +1 -0
- package/dist/browser/chunk-K4MZY4ME.mjs +2 -0
- package/dist/browser/chunk-K4MZY4ME.mjs.map +1 -0
- package/dist/browser/chunk-OFKV5GNB.mjs +3 -0
- package/dist/browser/chunk-OFKV5GNB.mjs.map +1 -0
- package/dist/browser/chunk-QATIN7CO.mjs +3 -0
- package/dist/browser/chunk-QATIN7CO.mjs.map +1 -0
- package/dist/browser/chunk-QBBQ37P3.mjs +2 -0
- package/dist/browser/chunk-QBBQ37P3.mjs.map +1 -0
- package/dist/browser/chunk-VDVJWU5T.mjs +2 -0
- package/dist/browser/chunk-VDVJWU5T.mjs.map +1 -0
- package/dist/browser/chunk-X3C4I6YJ.mjs +2 -0
- package/dist/browser/chunk-X3C4I6YJ.mjs.map +1 -0
- package/dist/browser/chunk-ZVCTU2DN.mjs +3 -0
- package/dist/browser/chunk-ZVCTU2DN.mjs.map +1 -0
- package/dist/browser/core.d.mts +97 -0
- package/dist/browser/core.mjs +2 -0
- package/dist/browser/core.mjs.map +1 -0
- package/dist/browser/crypto.d.mts +35 -0
- package/dist/browser/crypto.mjs +2 -0
- package/dist/browser/crypto.mjs.map +1 -0
- package/dist/browser/definition.d.mts +13 -0
- package/dist/browser/definition.mjs +2 -0
- package/dist/browser/definition.mjs.map +1 -0
- package/dist/browser/dynamic-feature.d.mts +10 -0
- package/dist/browser/dynamic-feature.mjs +2 -0
- package/dist/browser/dynamic-feature.mjs.map +1 -0
- package/dist/browser/dynamic-structure.d.mts +12 -0
- package/dist/browser/dynamic-structure.mjs +2 -0
- package/dist/browser/dynamic-structure.mjs.map +1 -0
- package/dist/browser/env.d.mts +2 -0
- package/dist/browser/env.mjs +2 -0
- package/dist/browser/env.mjs.map +1 -0
- package/dist/browser/frame-index.d.mts +95 -0
- package/dist/browser/frame-index.mjs +2 -0
- package/dist/browser/frame-index.mjs.map +1 -0
- package/dist/browser/index.browser-CZlhzfSP.d.mts +22 -0
- package/dist/browser/index.d.mts +1 -144
- package/dist/browser/index.mjs +1 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/logger.d.mts +41 -0
- package/dist/browser/logger.mjs +2 -0
- package/dist/browser/logger.mjs.map +1 -0
- package/dist/browser/namespace.d.mts +13 -0
- package/dist/browser/namespace.mjs +2 -0
- package/dist/browser/namespace.mjs.map +1 -0
- package/dist/browser/storage.d.mts +194 -0
- package/dist/browser/storage.mjs +2 -0
- package/dist/browser/storage.mjs.map +1 -0
- package/dist/browser/vector.d.mts +15 -0
- package/dist/browser/vector.mjs +2 -0
- package/dist/browser/vector.mjs.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/node/A-FrameChannel.component-BfBcs734.d.ts +62 -0
- package/dist/node/A-FrameChannel.component-NNKcFViw.d.mts +62 -0
- package/dist/node/A-FrameChannel.types-DQF-IiRq.d.mts +146 -0
- package/dist/node/A-FrameChannel.types-DQF-IiRq.d.ts +146 -0
- package/dist/node/A-FrameDefinition.entity-CAUOdEvU.d.ts +329 -0
- package/dist/node/A-FrameDefinition.entity-DWGN_Ujr.d.mts +329 -0
- package/dist/node/A-FrameDynamicStructure.entity-DaBgSRCR.d.mts +188 -0
- package/dist/node/A-FrameDynamicStructure.entity-DaBgSRCR.d.ts +188 -0
- package/dist/node/A-FrameNamespace.entity-D3fZBGDx.d.ts +125 -0
- package/dist/node/A-FrameNamespace.entity-rCm1AavP.d.mts +125 -0
- package/dist/node/A-FrameStorage.component-BYjHfHJJ.d.mts +107 -0
- package/dist/node/A-FrameStorage.component-CT01fs-t.d.ts +107 -0
- package/dist/node/bundle.cjs +101 -0
- package/dist/node/bundle.cjs.map +1 -0
- package/dist/node/bundle.d.mts +69 -0
- package/dist/node/bundle.d.ts +69 -0
- package/dist/node/bundle.mjs +76 -0
- package/dist/node/bundle.mjs.map +1 -0
- package/dist/node/channel.cjs +60 -0
- package/dist/node/channel.cjs.map +1 -0
- package/dist/node/channel.d.mts +61 -0
- package/dist/node/channel.d.ts +61 -0
- package/dist/node/channel.mjs +11 -0
- package/dist/node/channel.mjs.map +1 -0
- package/dist/node/chunk-3LOMGNWA.cjs +8 -0
- package/dist/node/chunk-3LOMGNWA.cjs.map +1 -0
- package/dist/node/chunk-3ONWH75E.mjs +257 -0
- package/dist/node/chunk-3ONWH75E.mjs.map +1 -0
- package/dist/node/chunk-3TD2PEDZ.mjs +53 -0
- package/dist/node/chunk-3TD2PEDZ.mjs.map +1 -0
- package/dist/node/chunk-442DXGOD.mjs +16 -0
- package/dist/node/chunk-442DXGOD.mjs.map +1 -0
- package/dist/node/chunk-6EFXNUL4.mjs +6 -0
- package/dist/node/chunk-6EFXNUL4.mjs.map +1 -0
- package/dist/node/chunk-7A6XGT5J.cjs +541 -0
- package/dist/node/chunk-7A6XGT5J.cjs.map +1 -0
- package/dist/node/chunk-AOQRXZPC.mjs +207 -0
- package/dist/node/chunk-AOQRXZPC.mjs.map +1 -0
- package/dist/node/chunk-APRYHBEF.mjs +171 -0
- package/dist/node/chunk-APRYHBEF.mjs.map +1 -0
- package/dist/node/chunk-B7BXP7K4.mjs +253 -0
- package/dist/node/chunk-B7BXP7K4.mjs.map +1 -0
- package/dist/node/chunk-B7ZDJXD3.cjs +35 -0
- package/dist/node/chunk-B7ZDJXD3.cjs.map +1 -0
- package/dist/node/chunk-CP6JHUU6.cjs +541 -0
- package/dist/node/chunk-CP6JHUU6.cjs.map +1 -0
- package/dist/node/chunk-DDCEMKBP.mjs +655 -0
- package/dist/node/chunk-DDCEMKBP.mjs.map +1 -0
- package/dist/node/chunk-DMY44VUG.mjs +655 -0
- package/dist/node/chunk-DMY44VUG.mjs.map +1 -0
- package/dist/node/chunk-F4UCOZW5.mjs +33 -0
- package/dist/node/chunk-F4UCOZW5.mjs.map +1 -0
- package/dist/node/chunk-GBTFMT3K.cjs +256 -0
- package/dist/node/chunk-GBTFMT3K.cjs.map +1 -0
- package/dist/node/chunk-GNVXVK2B.cjs +8 -0
- package/dist/node/chunk-GNVXVK2B.cjs.map +1 -0
- package/dist/node/chunk-IIVYTS5M.mjs +239 -0
- package/dist/node/chunk-IIVYTS5M.mjs.map +1 -0
- package/dist/node/chunk-JQBYDEMW.mjs +33 -0
- package/dist/node/chunk-JQBYDEMW.mjs.map +1 -0
- package/dist/node/chunk-K4MZY4ME.mjs +3 -0
- package/dist/node/chunk-K4MZY4ME.mjs.map +1 -0
- package/dist/node/chunk-KK64VLZN.cjs +4 -0
- package/dist/node/chunk-KK64VLZN.cjs.map +1 -0
- package/dist/node/chunk-KLG6HKFU.cjs +175 -0
- package/dist/node/chunk-KLG6HKFU.cjs.map +1 -0
- package/dist/node/chunk-LJIZ47HO.cjs +688 -0
- package/dist/node/chunk-LJIZ47HO.cjs.map +1 -0
- package/dist/node/chunk-NIXKAQVP.cjs +35 -0
- package/dist/node/chunk-NIXKAQVP.cjs.map +1 -0
- package/dist/node/chunk-OI76LHVT.mjs +21 -0
- package/dist/node/chunk-OI76LHVT.mjs.map +1 -0
- package/dist/node/chunk-OJGCQNAH.mjs +529 -0
- package/dist/node/chunk-OJGCQNAH.mjs.map +1 -0
- package/dist/node/chunk-QFHZIG7Y.cjs +25 -0
- package/dist/node/chunk-QFHZIG7Y.cjs.map +1 -0
- package/dist/node/chunk-QFUZVN4Y.cjs +259 -0
- package/dist/node/chunk-QFUZVN4Y.cjs.map +1 -0
- package/dist/node/chunk-RRLTGGM7.cjs +209 -0
- package/dist/node/chunk-RRLTGGM7.cjs.map +1 -0
- package/dist/node/chunk-TO4BPKCY.mjs +6 -0
- package/dist/node/chunk-TO4BPKCY.mjs.map +1 -0
- package/dist/node/chunk-UKKCN7CQ.cjs +688 -0
- package/dist/node/chunk-UKKCN7CQ.cjs.map +1 -0
- package/dist/node/chunk-UPA7VN4R.mjs +153 -0
- package/dist/node/chunk-UPA7VN4R.mjs.map +1 -0
- package/dist/node/chunk-UTJ7CVVB.cjs +248 -0
- package/dist/node/chunk-UTJ7CVVB.cjs.map +1 -0
- package/dist/node/chunk-YVX4W6SI.cjs +155 -0
- package/dist/node/chunk-YVX4W6SI.cjs.map +1 -0
- package/dist/node/chunk-YWWGJ6EJ.cjs +55 -0
- package/dist/node/chunk-YWWGJ6EJ.cjs.map +1 -0
- package/dist/node/chunk-Z4HUCRK2.mjs +529 -0
- package/dist/node/chunk-Z4HUCRK2.mjs.map +1 -0
- package/dist/node/chunk-ZM2RLVVH.cjs +18 -0
- package/dist/node/chunk-ZM2RLVVH.cjs.map +1 -0
- package/dist/node/core.cjs +261 -0
- package/dist/node/core.cjs.map +1 -0
- package/dist/node/core.d.mts +76 -0
- package/dist/node/core.d.ts +76 -0
- package/dist/node/core.mjs +250 -0
- package/dist/node/core.mjs.map +1 -0
- package/dist/node/crypto.cjs +13 -0
- package/dist/node/crypto.cjs.map +1 -0
- package/dist/node/crypto.d.mts +44 -0
- package/dist/node/crypto.d.ts +44 -0
- package/dist/node/crypto.mjs +4 -0
- package/dist/node/crypto.mjs.map +1 -0
- package/dist/node/definition.cjs +19 -0
- package/dist/node/definition.cjs.map +1 -0
- package/dist/node/definition.d.mts +13 -0
- package/dist/node/definition.d.ts +13 -0
- package/dist/node/definition.mjs +6 -0
- package/dist/node/definition.mjs.map +1 -0
- package/dist/node/dynamic-feature.cjs +14 -0
- package/dist/node/dynamic-feature.cjs.map +1 -0
- package/dist/node/dynamic-feature.d.mts +10 -0
- package/dist/node/dynamic-feature.d.ts +10 -0
- package/dist/node/dynamic-feature.mjs +12 -0
- package/dist/node/dynamic-feature.mjs.map +1 -0
- package/dist/node/dynamic-structure.cjs +143 -0
- package/dist/node/dynamic-structure.cjs.map +1 -0
- package/dist/node/dynamic-structure.d.mts +12 -0
- package/dist/node/dynamic-structure.d.ts +12 -0
- package/dist/node/dynamic-structure.mjs +138 -0
- package/dist/node/dynamic-structure.mjs.map +1 -0
- package/dist/node/env.cjs +14 -0
- package/dist/node/env.cjs.map +1 -0
- package/dist/node/env.d.mts +22 -0
- package/dist/node/env.d.ts +22 -0
- package/dist/node/env.mjs +5 -0
- package/dist/node/env.mjs.map +1 -0
- package/dist/node/frame-index.cjs +16 -0
- package/dist/node/frame-index.cjs.map +1 -0
- package/dist/node/frame-index.d.mts +95 -0
- package/dist/node/frame-index.d.ts +95 -0
- package/dist/node/frame-index.mjs +7 -0
- package/dist/node/frame-index.mjs.map +1 -0
- package/dist/node/index.cjs +0 -288
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.mts +1 -144
- package/dist/node/index.d.ts +1 -144
- package/dist/node/index.mjs +0 -284
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/logger.cjs +41 -0
- package/dist/node/logger.cjs.map +1 -0
- package/dist/node/logger.d.mts +150 -0
- package/dist/node/logger.d.ts +150 -0
- package/dist/node/logger.mjs +4 -0
- package/dist/node/logger.mjs.map +1 -0
- package/dist/node/namespace.cjs +24 -0
- package/dist/node/namespace.cjs.map +1 -0
- package/dist/node/namespace.d.mts +13 -0
- package/dist/node/namespace.d.ts +13 -0
- package/dist/node/namespace.mjs +7 -0
- package/dist/node/namespace.mjs.map +1 -0
- package/dist/node/storage.cjs +42 -0
- package/dist/node/storage.cjs.map +1 -0
- package/dist/node/storage.d.mts +110 -0
- package/dist/node/storage.d.ts +110 -0
- package/dist/node/storage.mjs +13 -0
- package/dist/node/storage.mjs.map +1 -0
- package/dist/node/vector.cjs +13 -0
- package/dist/node/vector.cjs.map +1 -0
- package/dist/node/vector.d.mts +15 -0
- package/dist/node/vector.d.ts +15 -0
- package/dist/node/vector.mjs +4 -0
- package/dist/node/vector.mjs.map +1 -0
- package/jest.config.browser.ts +41 -0
- package/jest.config.ts +18 -8
- package/package.json +125 -13
- package/{index.ts → src/concept.ts} +5 -2
- package/src/helpers/Hash.helper.ts +14 -0
- package/src/index.ts +0 -24
- package/src/lib/A-Frame/A-Frame.component.env-browser.ts +124 -0
- package/src/lib/A-Frame/A-Frame.component.env-node.ts +106 -0
- package/src/lib/A-Frame/A-Frame.component.ts +62 -0
- package/src/lib/A-Frame/A-Frame.context.ts +40 -0
- package/src/lib/{components/Index.component.ts/Index.error.ts → A-Frame/A-Frame.error.ts} +1 -1
- package/src/lib/{components/Index.component.ts/Index.guard.ts → A-Frame/A-Frame.guard.ts} +9 -6
- package/src/lib/A-Frame/A-Frame.meta.ts +27 -0
- package/src/lib/{components/Index.component.ts/Index.types.ts → A-Frame/A-Frame.types.ts} +52 -17
- package/src/lib/A-Frame/decorators/A-FrameDefine.decorator.ts +104 -0
- package/src/lib/A-Frame/decorators/A-FrameNamespace.decorator.ts +33 -0
- package/src/lib/A-Frame/index.browser.ts +10 -0
- package/src/lib/A-Frame/index.ts +10 -0
- package/src/lib/A-FrameBundle/A-FrameBundle.builder.env-node.ts +95 -0
- package/src/lib/A-FrameBundle/A-FrameBundle.constants.ts +5 -0
- package/src/lib/A-FrameBundle/A-FrameBundle.types.ts +31 -0
- package/src/lib/A-FrameBundle/index.browser.ts +6 -0
- package/src/lib/A-FrameBundle/index.ts +7 -0
- package/src/lib/A-FrameCLI/A-FrameCLI.container.ts +333 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.component.env-browser.ts +63 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.component.env-node.ts +586 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.component.ts +273 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.constants.ts +39 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.error.ts +10 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.types.ts +143 -0
- package/src/lib/A-FrameChannel/A-FrameChannelEvent.context.ts +28 -0
- package/src/lib/A-FrameChannel/A-FrameChannelRequest.context.ts +36 -0
- package/src/lib/A-FrameChannel/A-FrameChannelSocket.entity.ts +189 -0
- package/src/lib/A-FrameChannel/A-FrameChannelStream.entity.ts +144 -0
- package/src/lib/A-FrameChannel/index.browser.ts +3 -0
- package/src/lib/A-FrameChannel/index.ts +10 -0
- package/src/lib/A-FrameCrypto/A-FrameCrypto.component.env-browser.ts +123 -0
- package/src/lib/A-FrameCrypto/A-FrameCrypto.component.env-node.ts +204 -0
- package/src/lib/A-FrameCrypto/index.browser.ts +1 -0
- package/src/lib/A-FrameCrypto/index.ts +1 -0
- package/src/lib/A-FrameDefinition/A-FrameDefinition.constants.ts +8 -0
- package/src/lib/A-FrameDefinition/A-FrameDefinition.entity.ts +290 -0
- package/src/lib/A-FrameDefinition/A-FrameDefinition.types.ts +109 -0
- package/src/lib/A-FrameDefinition/index.ts +3 -0
- package/src/lib/A-FrameDynamicFeature/A-FrameDynamicFeature.entity.ts +13 -0
- package/src/lib/A-FrameDynamicFeature/A-FrameDynamicFeature.types.ts +10 -0
- package/src/lib/A-FrameDynamicFeature/index.ts +2 -0
- package/src/lib/A-FrameDynamicPatch/A-FrameDynamicPatch.entity.ts +38 -0
- package/src/lib/A-FrameDynamicPatch/A-FrameDynamicPatch.types.ts +20 -0
- package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.constants.ts +9 -0
- package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.entity.ts +91 -0
- package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.types.ts +18 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.constants.ts +13 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.entity.ts +187 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.error.ts +13 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.types.ts +128 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructureOperation.context.ts +32 -0
- package/src/lib/A-FrameDynamicStructure/index.ts +5 -0
- package/src/lib/A-FrameEnv/A-FrameEnv.fragment.env-browser.ts +31 -0
- package/src/lib/A-FrameEnv/A-FrameEnv.fragment.env-node.ts +39 -0
- package/src/lib/A-FrameEnv/A-FrameEnv.types.ts +7 -0
- package/src/lib/A-FrameEnv/index.browser.ts +1 -0
- package/src/lib/A-FrameEnv/index.ts +1 -0
- package/src/lib/A-FrameIndex/A-FrameIndex.context.ts +321 -0
- package/src/lib/A-FrameIndex/A-FrameIndex.types.ts +63 -0
- package/src/lib/A-FrameIndex/index.browser.ts +3 -0
- package/src/lib/A-FrameIndex/index.ts +3 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.component.env-browser.ts +99 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.component.env-node.ts +129 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.component.ts +123 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.constants.ts +66 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.types.ts +67 -0
- package/src/lib/A-FrameLogger/index.browser.ts +4 -0
- package/src/lib/A-FrameLogger/index.ts +4 -0
- package/src/lib/A-FrameNamespace/A-FrameNamespace.constants.ts +12 -0
- package/src/lib/A-FrameNamespace/A-FrameNamespace.entity.ts +211 -0
- package/src/lib/A-FrameNamespace/A-FrameNamespace.types.ts +72 -0
- package/src/lib/A-FrameNamespace/index.ts +3 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.codec.ts +338 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.component.ts +191 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.constants.ts +11 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.error.ts +13 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.types.ts +98 -0
- package/src/lib/A-FrameStorage/A-FrameStorageOperation.context.ts +59 -0
- package/src/lib/A-FrameStorage/browser/A-FrameBrowserStorage.component.ts +312 -0
- package/src/lib/A-FrameStorage/browser/A-FrameBrowserStorageBlobs.context.ts +77 -0
- package/src/lib/A-FrameStorage/index.browser.ts +11 -0
- package/src/lib/A-FrameStorage/index.ts +10 -0
- package/src/lib/A-FrameStorage/node/A-FrameNodeStorage.component.ts +464 -0
- package/src/lib/A-FrameStorage/server/A-FrameServerStorage.component.ts +177 -0
- package/src/lib/{entities/A_FrameVector/A_FrameVector.entity.ts → A-FrameVector/A-FrameVector.entity.ts} +10 -0
- package/src/lib/A-FrameVector/index.ts +3 -0
- package/tests/A-Frame.browser.test.ts +94 -0
- package/tests/A-Frame.test.ts +73 -68
- package/tests/jest.browser-environment.js +30 -0
- package/tests/jest.polyfills.browser.ts +13 -0
- package/tests/jest.setup.browser.ts +33 -0
- package/tsconfig.browser.json +54 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +32 -2
- package/src/lib/components/Builder.component.ts/Builder.component.ts +0 -0
- package/src/lib/components/Index.component.ts/Index.component.ts +0 -79
- package/src/lib/components/Index.component.ts/Index.constants.ts +0 -0
- package/src/lib/components/Index.component.ts/Index.meta.ts +0 -28
- package/src/lib/components/Index.component.ts/IndexConfigurations.meta.ts +0 -78
- package/src/lib/components/Index.component.ts/decorators/IndexComponent.decorator.ts +0 -97
- package/src/lib/components/Index.component.ts/decorators/IndexDescribe.decorator.ts +0 -59
- package/src/lib/components/Index.component.ts/decorators/IndexNamespace.decorator.ts +0 -57
- package/src/lib/components/Search/A_FrameSearch.component.ts +0 -66
- package/src/lib/containers/CLI.container.ts +0 -27
- package/src/lib/entities/Namespace/Namespace.entity.ts +0 -8
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { A_Caller, A_Feature, A_Inject } from "@adaas/a-concept";
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { A_FrameStorageFeatures } from "../A-FrameStorage.constants";
|
|
5
|
+
import { A_FrameStorage } from "../A-FrameStorage.component";
|
|
6
|
+
import { A_FrameEnv } from "../../A-FrameEnv/A-FrameEnv.fragment.env-node";
|
|
7
|
+
import { A_FrameStorageOperation } from "../A-FrameStorageOperation.context";
|
|
8
|
+
import { A_FrameCrypto } from "../../A-FrameCrypto/A-FrameCrypto.component.env-node";
|
|
9
|
+
import { A_FrameNamespace_Serialized } from "../../A-FrameNamespace/A-FrameNamespace.types";
|
|
10
|
+
import { A_FrameStorageCodec } from "../A-FrameStorage.codec";
|
|
11
|
+
import { A_FrameDefinitionFeatures } from "../../A-FrameDefinition/A-FrameDefinition.constants";
|
|
12
|
+
import { A_FrameDefinition } from "../../A-FrameDefinition";
|
|
13
|
+
import { A_FrameDefinition_Serialized } from "../../A-FrameDefinition/A-FrameDefinition.types";
|
|
14
|
+
import { A_FrameContext } from "../../A-Frame/A-Frame.context";
|
|
15
|
+
import { A_FrameNamespace } from "../../A-FrameNamespace";
|
|
16
|
+
import { A_FrameNamespaceFeatures } from "../../A-FrameNamespace/A-FrameNamespace.constants";
|
|
17
|
+
import { A_FrameStorageDestroyDefinitionsOperation, A_FrameStorageDestroyNamespacesOperation, A_FrameStorageLoadDefinitionsOperation, A_FrameStorageLoadNamespacesOperation, A_FrameStorageSaveDefinitionOperation, A_FrameStorageSaveNamespaceOperation } from "../A-FrameStorage.types";
|
|
18
|
+
import { A_FrameStorageError } from "../A-FrameStorage.error";
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/** Reserved filename for the namespace binary index */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A_FrameStorageProvider — Node.js environment
|
|
25
|
+
*
|
|
26
|
+
* Reads and writes encrypted binary index files (*.bin) on the local filesystem.
|
|
27
|
+
* Definition records are grouped by namespace into <namespace>.bin files.
|
|
28
|
+
* Namespace records are stored in the reserved __namespaces.bin file.
|
|
29
|
+
*
|
|
30
|
+
* File layout on disk: [IV 12B][AuthTag 16B][Ciphertext ...]
|
|
31
|
+
*/
|
|
32
|
+
export class A_FrameNodeStorage extends A_FrameStorage {
|
|
33
|
+
|
|
34
|
+
/** Returns file contents, or null when the file does not exist yet. Re-throws all other I/O errors. */
|
|
35
|
+
private async tryReadFile(filePath: string): Promise<Buffer | null> {
|
|
36
|
+
try {
|
|
37
|
+
return await fs.readFile(filePath);
|
|
38
|
+
} catch (err: any) {
|
|
39
|
+
if (err?.code === 'ENOENT') return null;
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//---------------------------------------------------------------------------------------
|
|
45
|
+
//--------------------------Definition Features Extensions-------------------------------
|
|
46
|
+
//---------------------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Save a single definition to local file storage. This is called as part of A_FrameDefinition.save() when using the local file storage provider. It reads the existing namespace file, merges in the new or updated definition, and writes back the encrypted file.
|
|
49
|
+
*
|
|
50
|
+
* @param definition
|
|
51
|
+
* @param env
|
|
52
|
+
* @param context
|
|
53
|
+
* @param codec
|
|
54
|
+
*/
|
|
55
|
+
@A_Feature.Extend({
|
|
56
|
+
name: A_FrameDefinitionFeatures.Save,
|
|
57
|
+
scope: [A_FrameDefinition]
|
|
58
|
+
})
|
|
59
|
+
async saveDefinitionToDisk(
|
|
60
|
+
@A_Inject(A_Caller) definition: A_FrameDefinition,
|
|
61
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
62
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
63
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
64
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
65
|
+
): Promise<void> {
|
|
66
|
+
const namespace = definition.namespace
|
|
67
|
+
|
|
68
|
+
const incoming = definition.toJSON();
|
|
69
|
+
if (!incoming.embedding)
|
|
70
|
+
throw new Error('Only definitions with embeddings can be saved to storage');
|
|
71
|
+
|
|
72
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace.id)));
|
|
73
|
+
const existing: A_FrameDefinition_Serialized[] = rawBuf
|
|
74
|
+
? codec.decodePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
75
|
+
: [];
|
|
76
|
+
|
|
77
|
+
const merged = new Map<string, A_FrameDefinition_Serialized>();
|
|
78
|
+
for (const r of existing) merged.set(r.hash, r);
|
|
79
|
+
merged.set(incoming.hash, incoming);
|
|
80
|
+
|
|
81
|
+
const records = Array.from(merged.values());
|
|
82
|
+
const payload = codec.encodePayload(records);
|
|
83
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
84
|
+
|
|
85
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
86
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace.id)), encrypted);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Load a single definition from local file storage. This is called as part of A_FrameDefinition.load() when using the local file storage provider. It reads the namespace file, finds the record for the requested definition, and if found and hash matches, populates the definition with the stored data.
|
|
90
|
+
*/
|
|
91
|
+
@A_Feature.Extend({
|
|
92
|
+
name: A_FrameDefinitionFeatures.Load,
|
|
93
|
+
scope: [A_FrameDefinition]
|
|
94
|
+
})
|
|
95
|
+
async loadDefinitionFromDisk(
|
|
96
|
+
@A_Inject(A_Caller) definition: A_FrameDefinition,
|
|
97
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
98
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
99
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
100
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
101
|
+
): Promise<void> {
|
|
102
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(definition.namespace.id)));
|
|
103
|
+
if (!rawBuf) return;
|
|
104
|
+
|
|
105
|
+
const plain = await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!);
|
|
106
|
+
const records = codec.decodePayload(plain);
|
|
107
|
+
|
|
108
|
+
const record = records.find(r => r.aseid === definition.aseid.toString());
|
|
109
|
+
|
|
110
|
+
if (
|
|
111
|
+
record &&
|
|
112
|
+
record.hash === definition.hash &&
|
|
113
|
+
record.aFrameServerVersion === context.serverVersion
|
|
114
|
+
) {
|
|
115
|
+
definition.fromJSON(record);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Delete a single definition from local file storage. This is called as part of A_FrameDefinition.destroy() when using the local file storage provider. It reads the namespace file, removes the record for the requested definition, and writes back the encrypted file.
|
|
122
|
+
*
|
|
123
|
+
* @param definition
|
|
124
|
+
* @param env
|
|
125
|
+
* @param context
|
|
126
|
+
* @param codec
|
|
127
|
+
*/
|
|
128
|
+
@A_Feature.Extend({
|
|
129
|
+
name: A_FrameDefinitionFeatures.Destroy,
|
|
130
|
+
scope: [A_FrameDefinition]
|
|
131
|
+
})
|
|
132
|
+
async destroyDefinitionFromDisk(
|
|
133
|
+
@A_Inject(A_Caller) definition: A_FrameDefinition,
|
|
134
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
135
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
136
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
137
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
138
|
+
|
|
139
|
+
): Promise<void> {
|
|
140
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(definition.namespace.id)));
|
|
141
|
+
if (!rawBuf) return;
|
|
142
|
+
|
|
143
|
+
const plain = await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!);
|
|
144
|
+
const records = codec.decodePayload(plain);
|
|
145
|
+
|
|
146
|
+
const filtered = records.filter(r => r.aseid !== definition.aseid.toString());
|
|
147
|
+
|
|
148
|
+
const payload = codec.encodePayload(filtered);
|
|
149
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
150
|
+
|
|
151
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
152
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(definition.namespace.id)), encrypted);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ---------------------------------------------------------------------------------------
|
|
156
|
+
//--------------------------Namespaces Features Extensions-------------------------------
|
|
157
|
+
//---------------------------------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
@A_Feature.Extend({
|
|
160
|
+
name: A_FrameNamespaceFeatures.Save,
|
|
161
|
+
scope: [A_FrameNamespace]
|
|
162
|
+
})
|
|
163
|
+
async saveNamespaceToDisk(
|
|
164
|
+
@A_Inject(A_Caller) namespace: A_FrameNamespace,
|
|
165
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
166
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
167
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
168
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
169
|
+
): Promise<void> {
|
|
170
|
+
const incoming = namespace.toJSON();
|
|
171
|
+
|
|
172
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()));
|
|
173
|
+
const existing: A_FrameNamespace_Serialized[] = rawBuf
|
|
174
|
+
? codec.decodeNamespacePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
175
|
+
: [];
|
|
176
|
+
|
|
177
|
+
const merged = new Map<string, A_FrameNamespace_Serialized>();
|
|
178
|
+
for (const r of existing) merged.set(r.aseid, r);
|
|
179
|
+
merged.set(incoming.aseid.toString(), incoming);
|
|
180
|
+
|
|
181
|
+
const records = Array.from(merged.values());
|
|
182
|
+
const payload = codec.encodeNamespacePayload(records);
|
|
183
|
+
|
|
184
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
185
|
+
|
|
186
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
187
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()), encrypted);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@A_Feature.Extend({
|
|
191
|
+
name: A_FrameNamespaceFeatures.Load,
|
|
192
|
+
scope: [A_FrameNamespace]
|
|
193
|
+
})
|
|
194
|
+
async loadNamespaceFromDisk(
|
|
195
|
+
@A_Inject(A_Caller) namespace: A_FrameNamespace,
|
|
196
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
197
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
198
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
199
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
200
|
+
): Promise<void> {
|
|
201
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()));
|
|
202
|
+
if (!rawBuf) return;
|
|
203
|
+
|
|
204
|
+
const plain = await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!);
|
|
205
|
+
const records = codec.decodeNamespacePayload(plain);
|
|
206
|
+
|
|
207
|
+
const record = records.find(r => r.aseid === namespace.aseid.toString());
|
|
208
|
+
|
|
209
|
+
if (
|
|
210
|
+
record &&
|
|
211
|
+
record.hash === namespace.hash &&
|
|
212
|
+
record.aFrameServerVersion === context.serverVersion
|
|
213
|
+
) {
|
|
214
|
+
namespace.fromJSON(record);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@A_Feature.Extend({
|
|
219
|
+
name: A_FrameNamespaceFeatures.Destroy,
|
|
220
|
+
scope: [A_FrameNamespace]
|
|
221
|
+
})
|
|
222
|
+
async destroyNamespaceFromLocalFileStorage(
|
|
223
|
+
@A_Inject(A_Caller) namespace: A_FrameNamespace,
|
|
224
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
225
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
226
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
227
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
228
|
+
): Promise<void> {
|
|
229
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()));
|
|
230
|
+
if (!rawBuf) return;
|
|
231
|
+
|
|
232
|
+
const plain = await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!);
|
|
233
|
+
const records = codec.decodeNamespacePayload(plain);
|
|
234
|
+
|
|
235
|
+
const filtered = records.filter(r => r.aseid !== namespace.aseid.toString());
|
|
236
|
+
|
|
237
|
+
const payload = codec.encodeNamespacePayload(filtered);
|
|
238
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
239
|
+
|
|
240
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
241
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()), encrypted);
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 2. Then drop definitions file related to the namespace.
|
|
245
|
+
*/
|
|
246
|
+
try {
|
|
247
|
+
await fs.unlink(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace.id)));
|
|
248
|
+
} catch {
|
|
249
|
+
// no-op if file doesn't exist
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
// ---------------------------------------------------------------------------------------
|
|
258
|
+
//--------------------------Storage Features Extensions-------------------------------
|
|
259
|
+
//---------------------------------------------------------------------------------------
|
|
260
|
+
@A_Feature.Extend({
|
|
261
|
+
name: A_FrameStorageFeatures.SaveDefinitions,
|
|
262
|
+
scope: [A_FrameStorage]
|
|
263
|
+
})
|
|
264
|
+
async saveDefinitionsToDisk(
|
|
265
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
266
|
+
@A_Inject(A_FrameStorageOperation) operation: A_FrameStorageSaveDefinitionOperation,
|
|
267
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
268
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
269
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
270
|
+
): Promise<void> {
|
|
271
|
+
const records = operation.params.records;
|
|
272
|
+
const namespace = records[0].namespace;
|
|
273
|
+
|
|
274
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace)));
|
|
275
|
+
const existing: A_FrameDefinition_Serialized[] = rawBuf
|
|
276
|
+
? codec.decodePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
277
|
+
: [];
|
|
278
|
+
|
|
279
|
+
const merged = new Map<string, A_FrameDefinition_Serialized>();
|
|
280
|
+
for (const r of existing) merged.set(r.hash, r);
|
|
281
|
+
for (const d of records) merged.set(d.hash, d);
|
|
282
|
+
|
|
283
|
+
const result = Array.from(merged.values());
|
|
284
|
+
const payload = codec.encodePayload(result);
|
|
285
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
286
|
+
|
|
287
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
288
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace)), encrypted);
|
|
289
|
+
|
|
290
|
+
operation.complete({
|
|
291
|
+
saved: records.length
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
@A_Feature.Extend({
|
|
296
|
+
name: A_FrameStorageFeatures.LoadDefinitions,
|
|
297
|
+
scope: [A_FrameStorage]
|
|
298
|
+
})
|
|
299
|
+
async loadDefinitionsFromDisk(
|
|
300
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
301
|
+
@A_Inject(A_FrameStorageOperation) operation: A_FrameStorageLoadDefinitionsOperation,
|
|
302
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
303
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
304
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
305
|
+
): Promise<void> {
|
|
306
|
+
const namespace = operation.params.namespaceId;
|
|
307
|
+
|
|
308
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace)));
|
|
309
|
+
const records: A_FrameDefinition_Serialized[] = rawBuf
|
|
310
|
+
? codec.decodePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
311
|
+
: [];
|
|
312
|
+
|
|
313
|
+
operation.complete({
|
|
314
|
+
records
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
@A_Feature.Extend({
|
|
322
|
+
name: A_FrameStorageFeatures.DestroyDefinitions,
|
|
323
|
+
scope: [A_FrameStorage]
|
|
324
|
+
})
|
|
325
|
+
async destroyDefinitionsFromDisk(
|
|
326
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
327
|
+
@A_Inject(A_FrameStorageOperation) operation: A_FrameStorageDestroyDefinitionsOperation,
|
|
328
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
329
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
330
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
331
|
+
): Promise<void> {
|
|
332
|
+
const namespace = operation.params.namespaceId;
|
|
333
|
+
const definitionId = operation.params.definitionId;
|
|
334
|
+
|
|
335
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace)));
|
|
336
|
+
const records: A_FrameDefinition_Serialized[] = rawBuf
|
|
337
|
+
? codec.decodePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
338
|
+
: [];
|
|
339
|
+
|
|
340
|
+
const filtered = records.filter(r => r.aseid !== definitionId);
|
|
341
|
+
|
|
342
|
+
const payload = codec.encodePayload(filtered);
|
|
343
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
344
|
+
|
|
345
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
346
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(namespace)), encrypted);
|
|
347
|
+
|
|
348
|
+
operation.complete({
|
|
349
|
+
records: filtered
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
@A_Feature.Extend({
|
|
356
|
+
name: A_FrameStorageFeatures.SaveNamespaces,
|
|
357
|
+
scope: [A_FrameStorage]
|
|
358
|
+
})
|
|
359
|
+
async saveNamespacesToDisk(
|
|
360
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
361
|
+
@A_Inject(A_FrameStorageOperation) operation: A_FrameStorageSaveNamespaceOperation,
|
|
362
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
363
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
364
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
365
|
+
): Promise<void> {
|
|
366
|
+
const records = operation.params.records;
|
|
367
|
+
|
|
368
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()));
|
|
369
|
+
const existing: A_FrameNamespace_Serialized[] = rawBuf
|
|
370
|
+
? codec.decodeNamespacePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
371
|
+
: [];
|
|
372
|
+
|
|
373
|
+
const merged = new Map<string, A_FrameNamespace_Serialized>();
|
|
374
|
+
for (const r of existing) merged.set(r.aseid, r);
|
|
375
|
+
for (const d of records) merged.set(d.aseid.toString(), d);
|
|
376
|
+
|
|
377
|
+
const result = Array.from(merged.values());
|
|
378
|
+
const payload = codec.encodeNamespacePayload(result);
|
|
379
|
+
|
|
380
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
381
|
+
|
|
382
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
383
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()), encrypted);
|
|
384
|
+
|
|
385
|
+
operation.complete({
|
|
386
|
+
success: true
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
@A_Feature.Extend({
|
|
391
|
+
name: A_FrameStorageFeatures.LoadNamespaces,
|
|
392
|
+
scope: [A_FrameStorage]
|
|
393
|
+
})
|
|
394
|
+
async loadNamespacesFromDisk(
|
|
395
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
396
|
+
@A_Inject(A_FrameStorageOperation) operation: A_FrameStorageLoadNamespacesOperation,
|
|
397
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
398
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
399
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
400
|
+
): Promise<void> {
|
|
401
|
+
const ids = operation.params.namespaces;
|
|
402
|
+
|
|
403
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()));
|
|
404
|
+
const records: A_FrameNamespace_Serialized[] = rawBuf
|
|
405
|
+
? codec.decodeNamespacePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
406
|
+
: [];
|
|
407
|
+
|
|
408
|
+
operation.complete({
|
|
409
|
+
records: ids ? records.filter(r => ids.includes(r.name)) : records
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
@A_Feature.Extend({
|
|
416
|
+
name: A_FrameStorageFeatures.DestroyNamespaces,
|
|
417
|
+
scope: [A_FrameStorage]
|
|
418
|
+
})
|
|
419
|
+
async destroyNamespacesFromDisk(
|
|
420
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
421
|
+
@A_Inject(A_FrameStorageOperation) operation: A_FrameStorageDestroyNamespacesOperation,
|
|
422
|
+
@A_Inject(A_FrameContext) context: A_FrameContext,
|
|
423
|
+
@A_Inject(A_FrameStorageCodec) codec: A_FrameStorageCodec,
|
|
424
|
+
@A_Inject(A_FrameCrypto) aFrameCrypto: A_FrameCrypto,
|
|
425
|
+
): Promise<void> {
|
|
426
|
+
const ids = operation.params.namespaces;
|
|
427
|
+
|
|
428
|
+
const rawBuf = await this.tryReadFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()));
|
|
429
|
+
const records: A_FrameNamespace_Serialized[] = rawBuf
|
|
430
|
+
? codec.decodeNamespacePayload(await aFrameCrypto.decryptBytes(new Uint8Array(rawBuf), context.encryptionKey!))
|
|
431
|
+
: [];
|
|
432
|
+
|
|
433
|
+
const filtered = records.filter(r => !ids.includes(r.aseid));
|
|
434
|
+
|
|
435
|
+
const payload = codec.encodeNamespacePayload(filtered);
|
|
436
|
+
const encrypted = await aFrameCrypto.encryptBytes(payload, context.encryptionKey!);
|
|
437
|
+
|
|
438
|
+
await fs.mkdir(env.A_FRAME_STORAGE_DIR, { recursive: true });
|
|
439
|
+
await fs.writeFile(path.join(env.A_FRAME_STORAGE_DIR, codec.getNamespaceFileName()), encrypted);
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* 2. Then drop definitions file related to the namespace.
|
|
443
|
+
*/
|
|
444
|
+
try {
|
|
445
|
+
for (const id of ids) {
|
|
446
|
+
await fs.unlink(path.join(env.A_FRAME_STORAGE_DIR, codec.getFileName(id)));
|
|
447
|
+
}
|
|
448
|
+
operation.complete({
|
|
449
|
+
success: true
|
|
450
|
+
});
|
|
451
|
+
} catch (error) {
|
|
452
|
+
|
|
453
|
+
operation.fail(new A_FrameStorageError({
|
|
454
|
+
title: A_FrameStorageError.DestroyNamespacesFailed,
|
|
455
|
+
description: `Failed to destroy namespace records.`,
|
|
456
|
+
}));
|
|
457
|
+
|
|
458
|
+
operation.complete({
|
|
459
|
+
success: false
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { A_Feature, A_Inject } from "@adaas/a-concept";
|
|
2
|
+
import { A_FrameStorageFeatures } from "../A-FrameStorage.constants";
|
|
3
|
+
import { A_FrameStorage } from "../A-FrameStorage.component";
|
|
4
|
+
import { A_FrameEnv } from "../../A-FrameEnv/A-FrameEnv.fragment.env-node";
|
|
5
|
+
import { A_FrameStorageOperation } from "../A-FrameStorageOperation.context";
|
|
6
|
+
import {
|
|
7
|
+
A_FrameStorageLoad,
|
|
8
|
+
A_FrameStorageSave,
|
|
9
|
+
A_FrameStorageSaveNamespaces,
|
|
10
|
+
} from "../A-FrameStorage.types";
|
|
11
|
+
import { A_FrameDefinition_Record } from "../../A-FrameDefinition/A-FrameDefinition.types";
|
|
12
|
+
import { A_FrameNamespace_Record } from "../../A-FrameNamespace/A-FrameNamespace.types";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// ─── JSON-wire types ──────────────────────────────────────────────────────────
|
|
16
|
+
// Float32Array is not JSON-serialisable; the remote server API uses number[].
|
|
17
|
+
|
|
18
|
+
type DefinitionRecordJSON = Omit<A_FrameDefinition_Record, 'embedding'> & { embedding: number[] };
|
|
19
|
+
type NamespaceRecordJSON = Omit<A_FrameNamespace_Record, 'embedding'> & { embedding: number[] };
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A_FrameServerStorageProvider — Remote HTTP storage
|
|
24
|
+
*
|
|
25
|
+
* Delegates all storage operations to a remote A-Frame storage server via
|
|
26
|
+
* plain HTTP/JSON, without touching the local filesystem or in-memory blobs.
|
|
27
|
+
* Works in both Node.js and browser environments (uses the global fetch).
|
|
28
|
+
*
|
|
29
|
+
* Expected server API:
|
|
30
|
+
* POST /api/storage/definitions — save definition records
|
|
31
|
+
* GET /api/storage/definitions/:namespace — load records for a namespace
|
|
32
|
+
* GET /api/storage/namespaces — list namespace slugs
|
|
33
|
+
* POST /api/storage/namespaces/index — save namespace records
|
|
34
|
+
* GET /api/storage/namespaces/index — load namespace records
|
|
35
|
+
*/
|
|
36
|
+
export class A_FrameServerStorageProvider extends A_FrameStorage {
|
|
37
|
+
|
|
38
|
+
// ─── Definition features ──────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
@A_Feature.Extend({
|
|
41
|
+
name: A_FrameStorageFeatures.SAVE,
|
|
42
|
+
scope: [A_FrameStorage],
|
|
43
|
+
})
|
|
44
|
+
async saveToRemoteServer(
|
|
45
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
46
|
+
@A_Inject(A_FrameStorageOperation) context: A_FrameStorageSave,
|
|
47
|
+
): Promise<void> {
|
|
48
|
+
const namespace = context.request.records[0]?.namespace || 'default';
|
|
49
|
+
const records: DefinitionRecordJSON[] = context.request.records.map(r => ({
|
|
50
|
+
...r,
|
|
51
|
+
embedding: Array.from(r.embedding),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
await this._post(env, '/api/storage/definitions', { namespace, records });
|
|
55
|
+
context.complete({ success: true });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@A_Feature.Extend({
|
|
59
|
+
name: A_FrameStorageFeatures.LOAD,
|
|
60
|
+
scope: [A_FrameStorage],
|
|
61
|
+
})
|
|
62
|
+
async loadFromRemoteServer(
|
|
63
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
64
|
+
@A_Inject(A_FrameStorageOperation) context: A_FrameStorageLoad,
|
|
65
|
+
): Promise<void> {
|
|
66
|
+
const namespace = context.request.namespaces?.[0] ?? 'default';
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const data = await this._get<{ records: DefinitionRecordJSON[] }>(
|
|
70
|
+
env, `/api/storage/definitions/${encodeURIComponent(namespace)}`
|
|
71
|
+
);
|
|
72
|
+
context.complete({
|
|
73
|
+
records: data.records.map(r => ({
|
|
74
|
+
...r,
|
|
75
|
+
embedding: new Float32Array(r.embedding),
|
|
76
|
+
})),
|
|
77
|
+
});
|
|
78
|
+
} catch {
|
|
79
|
+
context.complete({ records: [] });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@A_Feature.Extend({
|
|
84
|
+
name: A_FrameStorageFeatures.LIST,
|
|
85
|
+
scope: [A_FrameStorage],
|
|
86
|
+
})
|
|
87
|
+
async listNamespacesFromRemoteServer(
|
|
88
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
89
|
+
@A_Inject(A_FrameStorageOperation) context: A_FrameStorageOperation,
|
|
90
|
+
): Promise<void> {
|
|
91
|
+
try {
|
|
92
|
+
const data = await this._get<{ namespaces: string[] }>(env, '/api/storage/namespaces');
|
|
93
|
+
context.complete({ recordIds: data.namespaces });
|
|
94
|
+
} catch {
|
|
95
|
+
context.complete({ recordIds: [] });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// ─── Namespace features ───────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
@A_Feature.Extend({
|
|
103
|
+
name: A_FrameStorageFeatures.SAVE_NAMESPACES,
|
|
104
|
+
scope: [A_FrameStorage],
|
|
105
|
+
})
|
|
106
|
+
async saveNamespacesToRemoteServer(
|
|
107
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
108
|
+
@A_Inject(A_FrameStorageOperation) context: A_FrameStorageSaveNamespaces,
|
|
109
|
+
): Promise<void> {
|
|
110
|
+
const namespaces: NamespaceRecordJSON[] = context.request.namespaces.map(r => ({
|
|
111
|
+
...r,
|
|
112
|
+
embedding: Array.from(r.embedding),
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
await this._post(env, '/api/storage/namespaces/index', { namespaces });
|
|
116
|
+
context.complete({ success: true });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@A_Feature.Extend({
|
|
120
|
+
name: A_FrameStorageFeatures.LOAD_NAMESPACES,
|
|
121
|
+
scope: [A_FrameStorage],
|
|
122
|
+
})
|
|
123
|
+
async loadNamespacesFromRemoteServer(
|
|
124
|
+
@A_Inject(A_FrameEnv) env: A_FrameEnv,
|
|
125
|
+
@A_Inject(A_FrameStorageOperation) context: A_FrameStorageOperation,
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
try {
|
|
128
|
+
const data = await this._get<{ namespaces: NamespaceRecordJSON[] }>(
|
|
129
|
+
env, '/api/storage/namespaces/index'
|
|
130
|
+
);
|
|
131
|
+
context.complete({
|
|
132
|
+
namespaces: data.namespaces.map(r => ({
|
|
133
|
+
...r,
|
|
134
|
+
embedding: new Float32Array(r.embedding),
|
|
135
|
+
})),
|
|
136
|
+
});
|
|
137
|
+
} catch {
|
|
138
|
+
context.complete({ namespaces: [] });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
// ─── HTTP helpers ──────────────────────────────────────────────────────────
|
|
144
|
+
|
|
145
|
+
private authHeaders(env: A_FrameEnv): Record<string, string> {
|
|
146
|
+
return {
|
|
147
|
+
'Content-Type': 'application/json',
|
|
148
|
+
Authorization: `Bearer ${env.A_FRAME_TOKEN}`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private async _get<T>(env: A_FrameEnv, path: string): Promise<T> {
|
|
153
|
+
const resp = await fetch(`${env.A_FRAME_SERVER_URL}${path}`, {
|
|
154
|
+
method: 'GET',
|
|
155
|
+
headers: this.authHeaders(env),
|
|
156
|
+
});
|
|
157
|
+
if (!resp.ok) {
|
|
158
|
+
const text = await resp.text();
|
|
159
|
+
throw new Error(`GET ${path} → ${resp.status}: ${text}`);
|
|
160
|
+
}
|
|
161
|
+
return resp.json() as Promise<T>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private async _post<T = void>(env: A_FrameEnv, path: string, body: unknown): Promise<T> {
|
|
165
|
+
const resp = await fetch(`${env.A_FRAME_SERVER_URL}${path}`, {
|
|
166
|
+
method: 'POST',
|
|
167
|
+
headers: this.authHeaders(env),
|
|
168
|
+
body: JSON.stringify(body),
|
|
169
|
+
});
|
|
170
|
+
if (!resp.ok) {
|
|
171
|
+
const text = await resp.text();
|
|
172
|
+
throw new Error(`POST ${path} → ${resp.status}: ${text}`);
|
|
173
|
+
}
|
|
174
|
+
if (resp.status === 204) return undefined as T;
|
|
175
|
+
return resp.json() as Promise<T>;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { A_Entity } from "@adaas/a-concept"
|
|
2
2
|
|
|
3
3
|
export class A_FrameVector extends A_Entity {
|
|
4
|
+
|
|
5
|
+
static get concept(): string {
|
|
6
|
+
return 'a-frame';
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
readonly values: Float32Array
|
|
5
10
|
|
|
6
11
|
constructor(values: number[] | Float32Array) {
|
|
@@ -51,4 +56,9 @@ export class A_FrameVector extends A_Entity {
|
|
|
51
56
|
)
|
|
52
57
|
}
|
|
53
58
|
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
toArray(): number[] {
|
|
62
|
+
return Array.from(this.values)
|
|
63
|
+
}
|
|
54
64
|
}
|