@xyo-network/payload-mongodb 2.89.0 → 2.89.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/{index.js → index.mjs} +1 -1
- package/dist/browser/index.mjs.map +1 -0
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/{node/index.js → neutral/index.mjs} +1 -1
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/node/index.cjs.map +1 -1
- package/dist/{neutral/index.js → node/index.mjs} +1 -1
- package/dist/node/index.mjs.map +1 -0
- package/package.json +14 -14
- package/src/BoundWitness/BoundWitnessMeta.ts +1 -1
- package/src/Mappings/fromDbRepresentation.ts +2 -2
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["export * from './BoundWitness/index.js'\nexport * from './Mappings/index.js'\nexport * from './Payload/index.js'\n","import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["export * from './BoundWitness/index.js'\nexport * from './Mappings/index.js'\nexport * from './Payload/index.js'\n","import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,gCAAiE;AAMjE,IAAMA,kBAAkB,wBAACC,WAAmB,CAACC,GAAYC,QAAAA;AACvDC,8BAAS,OAAOD,QAAQ,UAAU,MAAM,qBAAqBA,GAAAA,KAAQ,OAAOA,GAAAA,GAAM;AAClF,SAAOA,IAAIE,WAAWJ,MAAAA;AACxB,GAHwB;AAKjB,IAAMK,8BAA8B,wBAACC,UAAAA;AAC1C,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M;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,aAAOmB,2CAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","import_boundwitness_model","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAA2CC,sBAAsB;AAMjE,IAAMC,kBAAkB,wBAACC,WAAmB,CAACC,GAAYC,QAAAA;AACvDC,WAAS,OAAOD,QAAQ,UAAU,MAAM,qBAAqBA,GAAA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AAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,SAAOmB,gBAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["assertEx","omitBy","isBoundWitness","omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","isBoundWitness","PayloadBuilder","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["export * from './BoundWitness/index.js'\nexport * from './Mappings/index.js'\nexport * from './Payload/index.js'\n","import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["export * from './BoundWitness/index.js'\nexport * from './Mappings/index.js'\nexport * from './Payload/index.js'\n","import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,gCAAiE;AAMjE,IAAMA,kBAAkB,wBAACC,WAAmB,CAACC,GAAYC,QAAAA;AACvDC,8BAAS,OAAOD,QAAQ,UAAU,MAAM,qBAAqBA,GAAAA,KAAQ,OAAOA,GAAAA,GAAM;AAClF,S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QC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,aAAOmB,2CAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","import_boundwitness_model","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAA2CC,sBAAsB;AAMjE,IAAMC,kBAAkB,wB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,QAAMX,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,SAAOmB,gBAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["assertEx","omitBy","isBoundWitness","omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","isBoundWitness","PayloadBuilder","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["export * from './BoundWitness/index.js'\nexport * from './Mappings/index.js'\nexport * from './Payload/index.js'\n","import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["export * from './BoundWitness/index.js'\nexport * from './Mappings/index.js'\nexport * from './Payload/index.js'\n","import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,gCAAiE;AAMjE,IAAMA,kBAAkB,wBAACC,WAAmB,C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AMF,sCAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,aAAOmB,2CAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","import_boundwitness_model","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation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yC;AAOlC,IAAMc,iCAAiC,8BAA+BC,IAAOf,QAAQ,MAAC;AAC3F,QAAMC,QAAQ,MAAMC,eAAeC,MAAMY,EAAAA;AACzC,QAAMX,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,SAAOmB,gBAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["assertEx","omitBy","isBoundWitness","omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","isBoundWitness","PayloadBuilder","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
package/package.json
CHANGED
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.6.
|
|
14
|
-
"@xylabs/hex": "^3.6.
|
|
15
|
-
"@xylabs/lodash": "^3.6.
|
|
16
|
-
"@xylabs/object": "^3.6.
|
|
17
|
-
"@xyo-network/boundwitness-model": "^2.
|
|
18
|
-
"@xyo-network/payload-builder": "^2.
|
|
19
|
-
"@xyo-network/payload-model": "^2.
|
|
13
|
+
"@xylabs/assert": "^3.6.12",
|
|
14
|
+
"@xylabs/hex": "^3.6.12",
|
|
15
|
+
"@xylabs/lodash": "^3.6.12",
|
|
16
|
+
"@xylabs/object": "^3.6.12",
|
|
17
|
+
"@xyo-network/boundwitness-model": "^2.111.3",
|
|
18
|
+
"@xyo-network/payload-builder": "^2.111.3",
|
|
19
|
+
"@xyo-network/payload-model": "^2.111.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
23
|
-
"@xylabs/tsconfig": "^3.
|
|
22
|
+
"@xylabs/ts-scripts-yarn3": "^3.15.16",
|
|
23
|
+
"@xylabs/tsconfig": "^3.15.16",
|
|
24
24
|
"fake-indexeddb": "^4.0.2",
|
|
25
|
-
"typescript": "^5.5.
|
|
25
|
+
"typescript": "^5.5.4"
|
|
26
26
|
},
|
|
27
27
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
28
28
|
"types": "dist/node/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"import": {
|
|
37
37
|
"types": "./dist/browser/index.d.mts",
|
|
38
|
-
"default": "./dist/browser/index.
|
|
38
|
+
"default": "./dist/browser/index.mjs"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"node": {
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"import": {
|
|
47
47
|
"types": "./dist/node/index.d.mts",
|
|
48
|
-
"default": "./dist/node/index.
|
|
48
|
+
"default": "./dist/node/index.mjs"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"./package.json": "./package.json"
|
|
53
53
|
},
|
|
54
54
|
"main": "dist/node/index.cjs",
|
|
55
|
-
"module": "dist/node/index.
|
|
55
|
+
"module": "dist/node/index.mjs",
|
|
56
56
|
"homepage": "https://xyo.network",
|
|
57
57
|
"license": "LGPL-3.0-only",
|
|
58
58
|
"publishConfig": {
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
64
64
|
},
|
|
65
65
|
"sideEffects": false,
|
|
66
|
-
"version": "2.89.
|
|
66
|
+
"version": "2.89.2",
|
|
67
67
|
"type": "module"
|
|
68
68
|
}
|
|
@@ -4,7 +4,7 @@ import { PayloadWithMongoMeta } from '../Payload/index.js'
|
|
|
4
4
|
|
|
5
5
|
export type BoundWitnessMongoMeta<P extends Payload = Payload> = PayloadWithMongoMeta<
|
|
6
6
|
P & {
|
|
7
|
-
//_payloads?: PayloadWithPartialMongoMeta<P>[]
|
|
7
|
+
// _payloads?: PayloadWithPartialMongoMeta<P>[]
|
|
8
8
|
_source_ip?: string
|
|
9
9
|
_user_agent?: string
|
|
10
10
|
}
|
|
@@ -24,7 +24,7 @@ export const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMet
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {
|
|
27
|
-
return isBoundWitness(value)
|
|
28
|
-
|
|
27
|
+
return isBoundWitness(value)
|
|
28
|
+
? (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)
|
|
29
29
|
: (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)
|
|
30
30
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value) ?\n (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAA2CC,sBAAsB;AAMjE,IAAMC,kBAAkB,wBAACC,WAAmB,CAACC,GAAYC,QAAAA;AACvDC,WAAS,OAAOD,QAAQ,UAAU,MAAM,qBAAqBA,GAAAA,KAAQ,OAAOA,GAAAA,GAAM;AAClF,SAAOA,IAAIE,WAAWJ,MAAAA;AACxB,GAHwB;AAKjB,IAAMK,8BAA8B,wBAACC,UAAAA;AAC1C,QAAM,EAAEC,QAAQC,QAAQ,GAAGC,MAAAA,IAAUH;AACrC,QAAMI,YAAYC,OAAOF,OAAOV,gBAAgB,GAAA,CAAA;AAChD,SAAO;IAAE,GAAGW;IAAWE,OAAOL;IAAQM,OAAOL;EAAO;AACtD,GAJ2C;AAMpC,IAAMM,mCAAmC,wBAACR,UAAAA;AAC/C,QAAM,EAAEC,QAAQC,QAAQ,GAAGC,MAAAA,IAAUH;AACrC,QAAMI,YAAYC,OAAOF,OAAOV,gBAAgB,GAAA,CAAA;AAChD,SAAO;IAAE,GAAGW;IAAWE,OAAOL;IAAQM,OAAOL;EAAO;AACtD,GAJgD;AAMzC,IAAMO,uBAAuB,wBAAuDT,UAAAA;AACzF,SAAOU,eAAeV,KAAAA,IACjBQ,iCAAiCR,KAAAA,IACjCD,4BAA4BC,KAAAA;AACnC,GAJoC;;;ACzBpC,SAAuBW,kBAAAA,uBAAsB;AAC7C,SAASC,sBAAsB;AAMxB,IAAMC,4BAA4B,8BAA0BC,SAAYC,QAAQ,MAAC;AACtF,QAAMC,QAAQ,MAAMC,eAAeC,MAAMJ,OAAAA;AACzC,QAAMK,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYC,KAAKC,IAAG,IAAKb;EAAM;AAC1F,GALyC;AAOlC,IAAMc,iCAAiC,8BAA+BC,IAAOf,QAAQ,MAAC;AAC3F,QAAMC,QAAQ,MAAMC,eAAeC,MAAMY,EAAAA;AACzC,QAAMX,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,SAAOmB,gBAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["assertEx","omitBy","isBoundWitness","omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","isBoundWitness","PayloadBuilder","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value) ?\n (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAA2CC,sBAAsB;AAMjE,IAAMC,kBAAkB,wBAACC,WAAmB,CAACC,GAAYC,QAAAA;AACvDC,WAAS,OAAOD,QAAQ,UAAU,MAAM,qBAAqBA,GAAAA,KAAQ,OAAOA,GAAAA,GAAM;AAClF,SAAOA,IAAIE,WAAWJ,MAAAA;AACxB,GAHwB;AAKjB,IAAMK,8BAA8B,wBAACC,UAAAA;AAC1C,QAAM,EAAEC,QAAQC,QAAQ,GAAGC,MAAAA,IAAUH;AACrC,QAAMI,YAAYC,OAAOF,OAAOV,gBAAgB,GAAA,CAAA;AAChD,SAAO;IAAE,GAAGW;IAAWE,OAAOL;IAAQM,OAAOL;EAAO;AACtD,GAJ2C;AAMpC,IAAMM,mCAAmC,wBAACR,UAAAA;AAC/C,QAAM,EAAEC,QAAQC,QAAQ,GAAGC,MAAAA,IAAUH;AACrC,QAAMI,YAAYC,OAAOF,OAAOV,gBAAgB,GAAA,CAAA;AAChD,SAAO;IAAE,GAAGW;IAAWE,OAAOL;IAAQM,OAAOL;EAAO;AACtD,GAJgD;AAMzC,IAAMO,uBAAuB,wBAAuDT,UAAAA;AACzF,SAAOU,eAAeV,KAAAA,IACjBQ,iCAAiCR,KAAAA,IACjCD,4BAA4BC,KAAAA;AACnC,GAJoC;;;ACzBpC,SAAuBW,kBAAAA,uBAAsB;AAC7C,SAASC,sBAAsB;AAMxB,IAAMC,4BAA4B,8BAA0BC,SAAYC,QAAQ,MAAC;AACtF,QAAMC,QAAQ,MAAMC,eAAeC,MAAMJ,OAAAA;AACzC,QAAMK,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYC,KAAKC,IAAG,IAAKb;EAAM;AAC1F,GALyC;AAOlC,IAAMc,iCAAiC,8BAA+BC,IAAOf,QAAQ,MAAC;AAC3F,QAAMC,QAAQ,MAAMC,eAAeC,MAAMY,EAAAA;AACzC,QAAMX,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,SAAOmB,gBAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["assertEx","omitBy","isBoundWitness","omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","isBoundWitness","PayloadBuilder","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|
package/dist/node/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { omitBy } from '@xylabs/lodash'\nimport { BoundWitness, BoundWitnessFields, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { Payload, PayloadMetaFields } from '@xyo-network/payload-model'\n\nimport { BoundWitnessWithMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nconst omitByPredicate = (prefix: string) => (_: unknown, key: string) => {\n assertEx(typeof key === 'string', () => `Invalid key type [${key}, ${typeof key}]`)\n return key.startsWith(prefix)\n}\n\nexport const payloadFromDbRepresentation = (value: PayloadWithMongoMeta): Payload<PayloadMetaFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as Payload<PayloadMetaFields>\n}\n\nexport const boundWitnessFromDbRepresentation = (value: BoundWitnessWithMongoMeta): BoundWitness<BoundWitnessFields> => {\n const { _$hash, _$meta, ...other } = value\n const sanitized = omitBy(other, omitByPredicate('_'))\n return { ...sanitized, $hash: _$hash, $meta: _$meta } as unknown as BoundWitness<BoundWitnessFields>\n}\n\nexport const fromDbRepresentation = <T = PayloadWithMongoMeta | BoundWitnessWithMongoMeta>(value: T) => {\n return isBoundWitness(value) ?\n (boundWitnessFromDbRepresentation(value as unknown as BoundWitnessWithMongoMeta) as BoundWitness<BoundWitnessFields>)\n : (payloadFromDbRepresentation(value as PayloadWithMongoMeta) as Payload<PayloadMetaFields>)\n}\n","import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = async <T extends Payload>(payload: T, index = 0): Promise<PayloadWithMongoMeta<T>> => {\n const built = await PayloadBuilder.build(payload)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: Date.now() + index } as unknown as PayloadWithMongoMeta<T>\n}\n\nexport const boundWitnessToDbRepresentation = async <T extends BoundWitness>(bw: T, index = 0): Promise<BoundWitnessMongoMeta<T>> => {\n const built = await PayloadBuilder.build(bw)\n const _hash = await PayloadBuilder.hash(built)\n const { $hash, $meta, ...fields } = built\n return { ...fields, _$hash: $hash, _$meta: $meta, _hash, _timestamp: bw.timestamp ?? Date.now() + index } as unknown as BoundWitnessMongoMeta<T>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: T, index = 0) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value, index) : payloadToDbRepresentation(value, index)\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAA2CC,sBAAsB;AAMjE,IAAMC,kBAAkB,wBAACC,WAAmB,CAACC,GAAYC,QAAAA;AACvDC,WAAS,OAAOD,QAAQ,UAAU,MAAM,qBAAqBA,GAAAA,KAAQ,OAAOA,GAAAA,GAAM;AAClF,SAAOA,IAAIE,WAAWJ,MAAAA;AACxB,GAHwB;AAKjB,IAAMK,8BAA8B,wBAACC,UAAAA;AAC1C,QAAM,EAAEC,QAAQC,QAAQ,GAAGC,MAAAA,IAAUH;AACrC,QAAMI,YAAYC,OAAOF,OAAOV,gBAAgB,GAAA,CAAA;AAChD,SAAO;IAAE,GAAGW;IAAWE,OAAOL;IAAQM,OAAOL;EAAO;AACtD,GAJ2C;AAMpC,IAAMM,mCAAmC,wBAACR,UAAAA;AAC/C,QAAM,EAAEC,QAAQC,QAAQ,GAAGC,MAAAA,IAAUH;AACrC,QAAMI,YAAYC,OAAOF,OAAOV,gBAAgB,GAAA,CAAA;AAChD,SAAO;IAAE,GAAGW;IAAWE,OAAOL;IAAQM,OAAOL;EAAO;AACtD,GAJgD;AAMzC,IAAMO,uBAAuB,wBAAuDT,UAAAA;AACzF,SAAOU,eAAeV,KAAAA,IACjBQ,iCAAiCR,KAAAA,IACjCD,4BAA4BC,KAAAA;AACnC,GAJoC;;;ACzBpC,SAAuBW,kBAAAA,uBAAsB;AAC7C,SAASC,sBAAsB;AAMxB,IAAMC,4BAA4B,8BAA0BC,SAAYC,QAAQ,MAAC;AACtF,QAAMC,QAAQ,MAAMC,eAAeC,MAAMJ,OAAAA;AACzC,QAAMK,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYC,KAAKC,IAAG,IAAKb;EAAM;AAC1F,GALyC;AAOlC,IAAMc,iCAAiC,8BAA+BC,IAAOf,QAAQ,MAAC;AAC3F,QAAMC,QAAQ,MAAMC,eAAeC,MAAMY,EAAAA;AACzC,QAAMX,QAAQ,MAAMF,eAAeG,KAAKJ,KAAAA;AACxC,QAAM,EAAEK,OAAOC,OAAO,GAAGC,OAAAA,IAAWP;AACpC,SAAO;IAAE,GAAGO;IAAQC,QAAQH;IAAOI,QAAQH;IAAOH;IAAOO,YAAYI,GAAGC,aAAaJ,KAAKC,IAAG,IAAKb;EAAM;AAC1G,GAL8C;AAOvC,IAAMiB,qBAAqB,wBAAmCC,OAAUlB,QAAQ,MAAC;AACtF,SAAOmB,gBAAeD,KAAAA,IAASJ,+BAA+BI,OAAOlB,KAAAA,IAASF,0BAA0BoB,OAAOlB,KAAAA;AACjH,GAFkC;","names":["assertEx","omitBy","isBoundWitness","omitByPredicate","prefix","_","key","assertEx","startsWith","payloadFromDbRepresentation","value","_$hash","_$meta","other","sanitized","omitBy","$hash","$meta","boundWitnessFromDbRepresentation","fromDbRepresentation","isBoundWitness","isBoundWitness","PayloadBuilder","payloadToDbRepresentation","payload","index","built","PayloadBuilder","build","_hash","hash","$hash","$meta","fields","_$hash","_$meta","_timestamp","Date","now","boundWitnessToDbRepresentation","bw","timestamp","toDbRepresentation","value","isBoundWitness"]}
|