@xyo-network/payload-mongodb 4.0.3 → 4.1.0

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.
Files changed (27) hide show
  1. package/dist/node/index.d.ts +34 -0
  2. package/package.json +14 -16
  3. package/xy.config.ts +11 -0
  4. package/dist/browser/index.mjs +0 -51
  5. package/dist/browser/index.mjs.map +0 -1
  6. package/dist/neutral/index.mjs +0 -51
  7. package/dist/neutral/index.mjs.map +0 -1
  8. /package/{dist/types → build/node}/BoundWitness/BoundWitnessMongoMeta.d.ts +0 -0
  9. /package/{dist/types → build/node}/BoundWitness/BoundWitnessMongoMeta.d.ts.map +0 -0
  10. /package/{dist/types → build/node}/BoundWitness/BoundWitnessWithMongoMeta.d.ts +0 -0
  11. /package/{dist/types → build/node}/BoundWitness/BoundWitnessWithMongoMeta.d.ts.map +0 -0
  12. /package/{dist/types → build/node}/BoundWitness/index.d.ts +0 -0
  13. /package/{dist/types → build/node}/BoundWitness/index.d.ts.map +0 -0
  14. /package/{dist/types → build/node}/Mappings/fromDbRepresentation.d.ts +0 -0
  15. /package/{dist/types → build/node}/Mappings/fromDbRepresentation.d.ts.map +0 -0
  16. /package/{dist/types → build/node}/Mappings/index.d.ts +0 -0
  17. /package/{dist/types → build/node}/Mappings/index.d.ts.map +0 -0
  18. /package/{dist/types → build/node}/Mappings/toDbRepresentation.d.ts +0 -0
  19. /package/{dist/types → build/node}/Mappings/toDbRepresentation.d.ts.map +0 -0
  20. /package/{dist/types → build/node}/Payload/PayloadMongoMeta.d.ts +0 -0
  21. /package/{dist/types → build/node}/Payload/PayloadMongoMeta.d.ts.map +0 -0
  22. /package/{dist/types → build/node}/Payload/PayloadWithMongoMeta.d.ts +0 -0
  23. /package/{dist/types → build/node}/Payload/PayloadWithMongoMeta.d.ts.map +0 -0
  24. /package/{dist/types → build/node}/Payload/index.d.ts +0 -0
  25. /package/{dist/types → build/node}/Payload/index.d.ts.map +0 -0
  26. /package/{dist/types → build/node}/index.d.ts +0 -0
  27. /package/{dist/types → build/node}/index.d.ts.map +0 -0
@@ -0,0 +1,34 @@
1
+ import { StorageMeta, Payload, WithStorageMeta } from '@xyo-network/payload-model';
2
+ import { BoundWitness } from '@xyo-network/boundwitness-model';
3
+
4
+ interface PayloadMongoMeta extends StorageMeta {
5
+ __archive?: string;
6
+ __client?: string;
7
+ __observeDuration?: number;
8
+ __schemaValid?: boolean;
9
+ __sources?: Payload[];
10
+ __timestamp: number;
11
+ __user_agent?: string;
12
+ }
13
+
14
+ type PayloadWithMongoMeta<T extends Payload = Payload> = T & PayloadMongoMeta;
15
+ type PayloadWithPartialMongoMeta<T extends Payload = Payload> = T & Partial<PayloadMongoMeta>;
16
+
17
+ type BoundWitnessMongoMeta<P extends Payload = Payload> = PayloadWithMongoMeta<P & {
18
+ __source_ip?: string;
19
+ __user_agent?: string;
20
+ }>;
21
+
22
+ type BoundWitnessWithMongoMeta<T extends BoundWitness = BoundWitness, P extends PayloadWithPartialMongoMeta<T> = PayloadWithPartialMongoMeta<T>> = T & BoundWitnessMongoMeta<P>;
23
+ type BoundWitnessWithPartialMongoMeta<T extends BoundWitness = BoundWitness, P extends PayloadWithPartialMongoMeta<T> = PayloadWithPartialMongoMeta<T>> = T & Partial<BoundWitnessMongoMeta<P>>;
24
+
25
+ declare const payloadFromDbRepresentation: <T extends Payload = Payload>(value: PayloadWithMongoMeta<T>) => WithStorageMeta<T>;
26
+ declare const boundWitnessFromDbRepresentation: <T extends BoundWitness = BoundWitness>(value: BoundWitnessWithMongoMeta<T>) => WithStorageMeta<T>;
27
+ declare const fromDbRepresentation: <T extends Payload = Payload>(value: PayloadWithMongoMeta<T>) => WithStorageMeta<T>;
28
+
29
+ declare const payloadToDbRepresentation: <T extends Payload>(payload: WithStorageMeta<T>) => PayloadWithMongoMeta<WithStorageMeta<T>>;
30
+ declare const boundWitnessToDbRepresentation: <T extends BoundWitness>(bw: WithStorageMeta<T>) => BoundWitnessMongoMeta<WithStorageMeta<T>>;
31
+ declare const toDbRepresentation: <T extends Payload | BoundWitness>(value: WithStorageMeta<T>) => PayloadWithMongoMeta<WithStorageMeta<T>>;
32
+
33
+ export { boundWitnessFromDbRepresentation, boundWitnessToDbRepresentation, fromDbRepresentation, payloadFromDbRepresentation, payloadToDbRepresentation, toDbRepresentation };
34
+ export type { BoundWitnessMongoMeta, BoundWitnessWithMongoMeta, BoundWitnessWithPartialMongoMeta, PayloadMongoMeta, PayloadWithMongoMeta, PayloadWithPartialMongoMeta };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/payload-mongodb",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -21,32 +21,30 @@
21
21
  "type": "module",
22
22
  "exports": {
23
23
  ".": {
24
- "browser": {
25
- "types": "./dist/types/index.d.ts",
26
- "default": "./dist/browser/index.mjs"
27
- },
24
+ "browser": {},
28
25
  "node": {
29
- "types": "./dist/types/index.d.ts",
26
+ "types": "./dist/node/index.d.ts",
30
27
  "default": "./dist/node/index.mjs"
31
- },
32
- "types": "./dist/types/index.d.ts",
33
- "default": "./dist/node/index.mjs"
28
+ }
34
29
  },
35
30
  "./package.json": "./package.json"
36
31
  },
37
32
  "module": "dist/node/index.mjs",
38
- "types": "dist/types/index.d.ts",
33
+ "types": "dist/node/index.d.ts",
39
34
  "dependencies": {
40
- "@xyo-network/boundwitness-model": "^4.0.3",
41
- "@xyo-network/payload-builder": "^4.0.3",
42
- "@xyo-network/payload-model": "^4.0.3"
35
+ "@xyo-network/boundwitness-model": "^4.1.0",
36
+ "@xyo-network/payload-builder": "^4.1.0",
37
+ "@xyo-network/payload-model": "^4.1.0"
43
38
  },
44
39
  "devDependencies": {
45
- "@xylabs/object": "^4.13.4",
46
- "@xylabs/ts-scripts-yarn3": "^6.5.18",
47
- "@xylabs/tsconfig": "^6.5.18",
40
+ "@xylabs/object": "^4.13.15",
41
+ "@xylabs/ts-scripts-yarn3": "^7.0.0-rc.20",
42
+ "@xylabs/tsconfig": "^7.0.0-rc.20",
48
43
  "typescript": "^5.8.3"
49
44
  },
45
+ "engines": {
46
+ "node": ">=16"
47
+ },
50
48
  "publishConfig": {
51
49
  "access": "public"
52
50
  }
package/xy.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
+ const config: XyTsupConfig = {
3
+ compile: {
4
+ entryMode: 'custom',
5
+ neutral: {},
6
+ browser: {},
7
+ node: { src: { entry: ['index.ts'] } },
8
+ },
9
+ }
10
+
11
+ export default config
@@ -1,51 +0,0 @@
1
- // src/Mappings/fromDbRepresentation.ts
2
- import { isBoundWitness } from "@xyo-network/boundwitness-model";
3
- import { PayloadBuilder } from "@xyo-network/payload-builder";
4
- var payloadFromDbRepresentation = (value) => {
5
- const clone = structuredClone(value);
6
- const metaNormalized = {};
7
- for (const key of Object.keys(clone)) {
8
- if (key.startsWith("_$")) {
9
- metaNormalized[key.slice(1)] = clone[key];
10
- } else if (key !== "_id") {
11
- metaNormalized[key] = clone[key];
12
- }
13
- }
14
- return PayloadBuilder.omitPrivateStorageMeta(metaNormalized);
15
- };
16
- var boundWitnessFromDbRepresentation = (value) => {
17
- return payloadFromDbRepresentation(value);
18
- };
19
- var fromDbRepresentation = (value) => {
20
- return isBoundWitness(value) ? boundWitnessFromDbRepresentation(value) : payloadFromDbRepresentation(value);
21
- };
22
-
23
- // src/Mappings/toDbRepresentation.ts
24
- import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
25
- var payloadToDbRepresentation = (payload) => {
26
- const clone = structuredClone(payload);
27
- const metaNormalized = {};
28
- for (const key of Object.keys(clone)) {
29
- if (key.startsWith("$")) {
30
- metaNormalized[`_${key}`] = clone[key];
31
- } else {
32
- metaNormalized[key] = clone[key];
33
- }
34
- }
35
- return metaNormalized;
36
- };
37
- var boundWitnessToDbRepresentation = (bw) => {
38
- return payloadToDbRepresentation(bw);
39
- };
40
- var toDbRepresentation = (value) => {
41
- return isBoundWitness2(value) ? boundWitnessToDbRepresentation(value) : payloadToDbRepresentation(value);
42
- };
43
- export {
44
- boundWitnessFromDbRepresentation,
45
- boundWitnessToDbRepresentation,
46
- fromDbRepresentation,
47
- payloadFromDbRepresentation,
48
- payloadToDbRepresentation,
49
- toDbRepresentation
50
- };
51
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import type { JsonObject } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessWithMongoMeta } from '../BoundWitness/index.ts'\nimport type { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadFromDbRepresentation = <T extends Payload = Payload>(value: PayloadWithMongoMeta<T>): WithStorageMeta<T> => {\n const clone: JsonObject = structuredClone(value) as unknown as JsonObject\n const metaNormalized: JsonObject = {}\n for (const key of Object.keys(clone)) {\n if (key.startsWith('_$')) {\n // remove _ from _$ fields\n metaNormalized[key.slice(1)] = clone[key]\n } else if (key !== '_id') {\n // special case for _id, which is reserved by MongoDB\n metaNormalized[key] = clone[key]\n }\n }\n return PayloadBuilder.omitPrivateStorageMeta(metaNormalized as Payload) as WithStorageMeta<T>\n}\n\nexport const boundWitnessFromDbRepresentation = <T extends BoundWitness = BoundWitness>(value: BoundWitnessWithMongoMeta<T>): WithStorageMeta<T> => {\n return payloadFromDbRepresentation(value)\n}\n\nexport const fromDbRepresentation = <T extends Payload = Payload>(value: PayloadWithMongoMeta<T>): WithStorageMeta<T> => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value))\n : (payloadFromDbRepresentation(value))\n}\n","import type { JsonObject } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport type { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = <T extends Payload>(payload: WithStorageMeta<T>): PayloadWithMongoMeta<WithStorageMeta<T>> => {\n const clone: JsonObject = structuredClone(payload) as unknown as JsonObject\n const metaNormalized: JsonObject = {}\n for (const key of Object.keys(clone)) {\n if (key.startsWith('$')) {\n metaNormalized[`_${key}`] = clone[key]\n } else {\n metaNormalized[key] = clone[key]\n }\n }\n return (metaNormalized as unknown as PayloadWithMongoMeta<T>)\n}\n\nexport const boundWitnessToDbRepresentation = <T extends BoundWitness>(bw: WithStorageMeta<T>): BoundWitnessMongoMeta<WithStorageMeta<T>> => {\n return payloadToDbRepresentation(bw) as BoundWitnessMongoMeta<WithStorageMeta<T>>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: WithStorageMeta<T>) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value) : payloadToDbRepresentation(value)\n}\n"],"mappings":";AAEA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAMxB,IAAM,8BAA8B,CAA8B,UAAuD;AAC9H,QAAM,QAAoB,gBAAgB,KAAK;AAC/C,QAAM,iBAA6B,CAAC;AACpC,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,QAAI,IAAI,WAAW,IAAI,GAAG;AAExB,qBAAe,IAAI,MAAM,CAAC,CAAC,IAAI,MAAM,GAAG;AAAA,IAC1C,WAAW,QAAQ,OAAO;AAExB,qBAAe,GAAG,IAAI,MAAM,GAAG;AAAA,IACjC;AAAA,EACF;AACA,SAAO,eAAe,uBAAuB,cAAyB;AACxE;AAEO,IAAM,mCAAmC,CAAwC,UAA4D;AAClJ,SAAO,4BAA4B,KAAK;AAC1C;AAEO,IAAM,uBAAuB,CAA8B,UAAuD;AACvH,SAAO,eAAe,KAAK,IACtB,iCAAiC,KAAK,IACtC,4BAA4B,KAAK;AACxC;;;AC9BA,SAAS,kBAAAA,uBAAsB;AAMxB,IAAM,4BAA4B,CAAoB,YAA0E;AACrI,QAAM,QAAoB,gBAAgB,OAAO;AACjD,QAAM,iBAA6B,CAAC;AACpC,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,QAAI,IAAI,WAAW,GAAG,GAAG;AACvB,qBAAe,IAAI,GAAG,EAAE,IAAI,MAAM,GAAG;AAAA,IACvC,OAAO;AACL,qBAAe,GAAG,IAAI,MAAM,GAAG;AAAA,IACjC;AAAA,EACF;AACA,SAAQ;AACV;AAEO,IAAM,iCAAiC,CAAyB,OAAsE;AAC3I,SAAO,0BAA0B,EAAE;AACrC;AAEO,IAAM,qBAAqB,CAAmC,UAA8B;AACjG,SAAOA,gBAAe,KAAK,IAAI,+BAA+B,KAAK,IAAI,0BAA0B,KAAK;AACxG;","names":["isBoundWitness"]}
@@ -1,51 +0,0 @@
1
- // src/Mappings/fromDbRepresentation.ts
2
- import { isBoundWitness } from "@xyo-network/boundwitness-model";
3
- import { PayloadBuilder } from "@xyo-network/payload-builder";
4
- var payloadFromDbRepresentation = (value) => {
5
- const clone = structuredClone(value);
6
- const metaNormalized = {};
7
- for (const key of Object.keys(clone)) {
8
- if (key.startsWith("_$")) {
9
- metaNormalized[key.slice(1)] = clone[key];
10
- } else if (key !== "_id") {
11
- metaNormalized[key] = clone[key];
12
- }
13
- }
14
- return PayloadBuilder.omitPrivateStorageMeta(metaNormalized);
15
- };
16
- var boundWitnessFromDbRepresentation = (value) => {
17
- return payloadFromDbRepresentation(value);
18
- };
19
- var fromDbRepresentation = (value) => {
20
- return isBoundWitness(value) ? boundWitnessFromDbRepresentation(value) : payloadFromDbRepresentation(value);
21
- };
22
-
23
- // src/Mappings/toDbRepresentation.ts
24
- import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
25
- var payloadToDbRepresentation = (payload) => {
26
- const clone = structuredClone(payload);
27
- const metaNormalized = {};
28
- for (const key of Object.keys(clone)) {
29
- if (key.startsWith("$")) {
30
- metaNormalized[`_${key}`] = clone[key];
31
- } else {
32
- metaNormalized[key] = clone[key];
33
- }
34
- }
35
- return metaNormalized;
36
- };
37
- var boundWitnessToDbRepresentation = (bw) => {
38
- return payloadToDbRepresentation(bw);
39
- };
40
- var toDbRepresentation = (value) => {
41
- return isBoundWitness2(value) ? boundWitnessToDbRepresentation(value) : payloadToDbRepresentation(value);
42
- };
43
- export {
44
- boundWitnessFromDbRepresentation,
45
- boundWitnessToDbRepresentation,
46
- fromDbRepresentation,
47
- payloadFromDbRepresentation,
48
- payloadToDbRepresentation,
49
- toDbRepresentation
50
- };
51
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Mappings/fromDbRepresentation.ts","../../src/Mappings/toDbRepresentation.ts"],"sourcesContent":["import type { JsonObject } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessWithMongoMeta } from '../BoundWitness/index.ts'\nimport type { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadFromDbRepresentation = <T extends Payload = Payload>(value: PayloadWithMongoMeta<T>): WithStorageMeta<T> => {\n const clone: JsonObject = structuredClone(value) as unknown as JsonObject\n const metaNormalized: JsonObject = {}\n for (const key of Object.keys(clone)) {\n if (key.startsWith('_$')) {\n // remove _ from _$ fields\n metaNormalized[key.slice(1)] = clone[key]\n } else if (key !== '_id') {\n // special case for _id, which is reserved by MongoDB\n metaNormalized[key] = clone[key]\n }\n }\n return PayloadBuilder.omitPrivateStorageMeta(metaNormalized as Payload) as WithStorageMeta<T>\n}\n\nexport const boundWitnessFromDbRepresentation = <T extends BoundWitness = BoundWitness>(value: BoundWitnessWithMongoMeta<T>): WithStorageMeta<T> => {\n return payloadFromDbRepresentation(value)\n}\n\nexport const fromDbRepresentation = <T extends Payload = Payload>(value: PayloadWithMongoMeta<T>): WithStorageMeta<T> => {\n return isBoundWitness(value)\n ? (boundWitnessFromDbRepresentation(value))\n : (payloadFromDbRepresentation(value))\n}\n","import type { JsonObject } from '@xylabs/object'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\n\nimport type { BoundWitnessMongoMeta } from '../BoundWitness/index.js'\nimport type { PayloadWithMongoMeta } from '../Payload/index.js'\n\nexport const payloadToDbRepresentation = <T extends Payload>(payload: WithStorageMeta<T>): PayloadWithMongoMeta<WithStorageMeta<T>> => {\n const clone: JsonObject = structuredClone(payload) as unknown as JsonObject\n const metaNormalized: JsonObject = {}\n for (const key of Object.keys(clone)) {\n if (key.startsWith('$')) {\n metaNormalized[`_${key}`] = clone[key]\n } else {\n metaNormalized[key] = clone[key]\n }\n }\n return (metaNormalized as unknown as PayloadWithMongoMeta<T>)\n}\n\nexport const boundWitnessToDbRepresentation = <T extends BoundWitness>(bw: WithStorageMeta<T>): BoundWitnessMongoMeta<WithStorageMeta<T>> => {\n return payloadToDbRepresentation(bw) as BoundWitnessMongoMeta<WithStorageMeta<T>>\n}\n\nexport const toDbRepresentation = <T extends Payload | BoundWitness>(value: WithStorageMeta<T>) => {\n return isBoundWitness(value) ? boundWitnessToDbRepresentation(value) : payloadToDbRepresentation(value)\n}\n"],"mappings":";AAEA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAMxB,IAAM,8BAA8B,CAA8B,UAAuD;AAC9H,QAAM,QAAoB,gBAAgB,KAAK;AAC/C,QAAM,iBAA6B,CAAC;AACpC,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,QAAI,IAAI,WAAW,IAAI,GAAG;AAExB,qBAAe,IAAI,MAAM,CAAC,CAAC,IAAI,MAAM,GAAG;AAAA,IAC1C,WAAW,QAAQ,OAAO;AAExB,qBAAe,GAAG,IAAI,MAAM,GAAG;AAAA,IACjC;AAAA,EACF;AACA,SAAO,eAAe,uBAAuB,cAAyB;AACxE;AAEO,IAAM,mCAAmC,CAAwC,UAA4D;AAClJ,SAAO,4BAA4B,KAAK;AAC1C;AAEO,IAAM,uBAAuB,CAA8B,UAAuD;AACvH,SAAO,eAAe,KAAK,IACtB,iCAAiC,KAAK,IACtC,4BAA4B,KAAK;AACxC;;;AC9BA,SAAS,kBAAAA,uBAAsB;AAMxB,IAAM,4BAA4B,CAAoB,YAA0E;AACrI,QAAM,QAAoB,gBAAgB,OAAO;AACjD,QAAM,iBAA6B,CAAC;AACpC,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,QAAI,IAAI,WAAW,GAAG,GAAG;AACvB,qBAAe,IAAI,GAAG,EAAE,IAAI,MAAM,GAAG;AAAA,IACvC,OAAO;AACL,qBAAe,GAAG,IAAI,MAAM,GAAG;AAAA,IACjC;AAAA,EACF;AACA,SAAQ;AACV;AAEO,IAAM,iCAAiC,CAAyB,OAAsE;AAC3I,SAAO,0BAA0B,EAAE;AACrC;AAEO,IAAM,qBAAqB,CAAmC,UAA8B;AACjG,SAAOA,gBAAe,KAAK,IAAI,+BAA+B,KAAK,IAAI,0BAA0B,KAAK;AACxG;","names":["isBoundWitness"]}
File without changes
File without changes
File without changes
File without changes