@xyo-network/xml-plugin 5.3.1 → 5.3.3
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/neutral/Payload.d.ts +1 -1
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +25 -20
- package/src/Diviner/Config.ts +0 -10
- package/src/Diviner/Diviner.ts +0 -33
- package/src/Diviner/Params.ts +0 -7
- package/src/Diviner/Schema.ts +0 -4
- package/src/Diviner/index.ts +0 -2
- package/src/Diviner/lib/StringDataField.ts +0 -18
- package/src/Diviner/lib/index.ts +0 -2
- package/src/Diviner/lib/toXml.ts +0 -24
- package/src/Payload.ts +0 -27
- package/src/Schema.ts +0 -4
- package/src/index.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Schema.ts","../../src/Diviner/lib/StringDataField.ts","../../src/Diviner/lib/toXml.ts","../../src/Diviner/Schema.ts","../../src/Payload.ts"],"sourcesContent":["import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { Xml } from '../Payload.ts'\nimport { XmlSchema } from '../Schema.ts'\nimport {\n hasStringDataField, StringDataField, toXml,\n} from './lib/index.ts'\nimport { XmlParsingDivinerParams } from './Params.ts'\nimport { XmlParsingDivinerConfigSchema } from './Schema.ts'\n\n@creatableModule()\nexport class XmlParsingDiviner<\n TParams extends XmlParsingDivinerParams = XmlParsingDivinerParams,\n TIn extends Payload<StringDataField> = Payload<StringDataField>,\n TOut extends Xml | Payload = Xml | Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, XmlParsingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = XmlParsingDivinerConfigSchema\n static override readonly targetSchema = XmlSchema\n\n protected override async divineHandler(payloads: TIn[] = []): Promise<TOut[]> {\n const results = await Promise.all(payloads.filter(hasStringDataField).map(toXml))\n return results as TOut[]\n }\n}\n","import { asSchema } from '@xyo-network/payload-model'\n\nexport const XmlSchema = asSchema('network.xyo.xml', true)\nexport type XmlSchema = typeof XmlSchema\n","/**\n * Interface representing an object with a string data field\n */\nexport interface StringDataField {\n /**\n * The string data\n */\n data: string\n}\n\n/**\n * Identity for StringDataField\n * @param obj The input object\n * @returns True if the object is a StringDataField, false otherwise\n */\nexport const hasStringDataField = (obj?: unknown): obj is StringDataField => {\n return typeof obj === 'object' && obj !== null && 'data' in obj && typeof (obj as StringDataField)?.data === 'string'\n}\n","import { Parser } from 'xml2js'\n\nimport type { Xml } from '../../Payload.ts'\nimport { XmlSchema } from '../../Schema.ts'\nimport type { StringDataField } from './StringDataField.ts'\n\n/**\n * Takes a string data field containing xml and converts it to an XML object\n * @param obj The input object which contains the stringified xml data\n * @returns A promise that resolves to an XML payload\n */\nexport const toXml = (obj: StringDataField): Promise<Xml> => {\n const parser = new Parser()\n return new Promise<Xml>((resolve, reject) => {\n parser.parseString(obj.data, (err, result) => {\n if (err) {\n reject(err)\n } else {\n const xml = { schema: XmlSchema, xml: result } as const\n resolve(xml)\n }\n })\n })\n}\n","import { asSchema } from '@xyo-network/payload-model'\n\nexport const XmlParsingDivinerConfigSchema = asSchema('network.xyo.diviner.xml.config', true)\nexport type XmlParsingDivinerConfigSchema = typeof XmlParsingDivinerConfigSchema\n","import type { JsonObject } from '@xylabs/
|
|
1
|
+
{"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Schema.ts","../../src/Diviner/lib/StringDataField.ts","../../src/Diviner/lib/toXml.ts","../../src/Diviner/Schema.ts","../../src/Payload.ts"],"sourcesContent":["import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { creatableModule } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { Xml } from '../Payload.ts'\nimport { XmlSchema } from '../Schema.ts'\nimport {\n hasStringDataField, StringDataField, toXml,\n} from './lib/index.ts'\nimport { XmlParsingDivinerParams } from './Params.ts'\nimport { XmlParsingDivinerConfigSchema } from './Schema.ts'\n\n@creatableModule()\nexport class XmlParsingDiviner<\n TParams extends XmlParsingDivinerParams = XmlParsingDivinerParams,\n TIn extends Payload<StringDataField> = Payload<StringDataField>,\n TOut extends Xml | Payload = Xml | Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, XmlParsingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = XmlParsingDivinerConfigSchema\n static override readonly targetSchema = XmlSchema\n\n protected override async divineHandler(payloads: TIn[] = []): Promise<TOut[]> {\n const results = await Promise.all(payloads.filter(hasStringDataField).map(toXml))\n return results as TOut[]\n }\n}\n","import { asSchema } from '@xyo-network/payload-model'\n\nexport const XmlSchema = asSchema('network.xyo.xml', true)\nexport type XmlSchema = typeof XmlSchema\n","/**\n * Interface representing an object with a string data field\n */\nexport interface StringDataField {\n /**\n * The string data\n */\n data: string\n}\n\n/**\n * Identity for StringDataField\n * @param obj The input object\n * @returns True if the object is a StringDataField, false otherwise\n */\nexport const hasStringDataField = (obj?: unknown): obj is StringDataField => {\n return typeof obj === 'object' && obj !== null && 'data' in obj && typeof (obj as StringDataField)?.data === 'string'\n}\n","import { Parser } from 'xml2js'\n\nimport type { Xml } from '../../Payload.ts'\nimport { XmlSchema } from '../../Schema.ts'\nimport type { StringDataField } from './StringDataField.ts'\n\n/**\n * Takes a string data field containing xml and converts it to an XML object\n * @param obj The input object which contains the stringified xml data\n * @returns A promise that resolves to an XML payload\n */\nexport const toXml = (obj: StringDataField): Promise<Xml> => {\n const parser = new Parser()\n return new Promise<Xml>((resolve, reject) => {\n parser.parseString(obj.data, (err, result) => {\n if (err) {\n reject(err)\n } else {\n const xml = { schema: XmlSchema, xml: result } as const\n resolve(xml)\n }\n })\n })\n}\n","import { asSchema } from '@xyo-network/payload-model'\n\nexport const XmlParsingDivinerConfigSchema = asSchema('network.xyo.diviner.xml.config', true)\nexport type XmlParsingDivinerConfigSchema = typeof XmlParsingDivinerConfigSchema\n","import type { JsonObject } from '@xylabs/sdk-js'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithSources } from '@xyo-network/payload-model'\n\nimport { XmlSchema } from './Schema.ts'\n\n/**\n * The fields of an Xml Payload\n */\nexport interface XmlFields {\n xml: JsonObject\n}\n\n/**\n * An Xml Payload\n */\nexport type Xml = Payload<XmlFields, XmlSchema>\n\n/**\n * Identity function for determine if an object is an Xml Payload\n */\nexport const isXml = isPayloadOfSchemaType<Xml>(XmlSchema)\n\n/**\n * Identity function for determine if an object is an Xml Payload with sources\n */\nexport const isXmlWithSources = isPayloadOfSchemaTypeWithSources<Xml>(XmlSchema)\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;AAEhC,SAAS,uBAAuB;;;ACFhC,SAAS,gBAAgB;AAElB,IAAM,YAAY,SAAS,mBAAmB,IAAI;;;ACalD,IAAM,qBAAqB,CAAC,QAA0C;AAC3E,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,UAAU,OAAO,OAAQ,KAAyB,SAAS;AAC/G;;;ACjBA,SAAS,cAAc;AAWhB,IAAM,QAAQ,CAAC,QAAuC;AAC3D,QAAM,SAAS,IAAI,OAAO;AAC1B,SAAO,IAAI,QAAa,CAAC,SAAS,WAAW;AAC3C,WAAO,YAAY,IAAI,MAAM,CAAC,KAAK,WAAW;AAC5C,UAAI,KAAK;AACP,eAAO,GAAG;AAAA,MACZ,OAAO;AACL,cAAM,MAAM,EAAE,QAAQ,WAAW,KAAK,OAAO;AAC7C,gBAAQ,GAAG;AAAA,MACb;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;;;ACvBA,SAAS,YAAAA,iBAAgB;AAElB,IAAM,gCAAgCA,UAAS,kCAAkC,IAAI;;;AJYrF,IAAM,oBAAN,cASG,gBAAgD;AAAA,EAKxD,MAAyB,cAAc,WAAkB,CAAC,GAAoB;AAC5E,UAAM,UAAU,MAAM,QAAQ,IAAI,SAAS,OAAO,kBAAkB,EAAE,IAAI,KAAK,CAAC;AAChF,WAAO;AAAA,EACT;AACF;AARE,cAVW,mBAUc,iBAA0B,CAAC,GAAG,iDAAM,kBAAe,6BAA6B;AACzG,cAXW,mBAWc,uBAA8B;AACvD,cAZW,mBAYc,gBAAe;AAZ7B,oBAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;;;AKZb,SAAS,uBAAuB,wCAAwC;AAmBjE,IAAM,QAAQ,sBAA2B,SAAS;AAKlD,IAAM,mBAAmB,iCAAsC,SAAS;","names":["asSchema"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/xml-plugin",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.3",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,29 +30,34 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"
|
|
34
|
-
"!**/*.bench.*",
|
|
35
|
-
"!**/*.spec.*",
|
|
36
|
-
"!**/*.test.*"
|
|
33
|
+
"README.md"
|
|
37
34
|
],
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@xylabs/object": "~5.0.64",
|
|
40
|
-
"@xyo-network/diviner-abstract": "~5.3.2",
|
|
41
|
-
"@xyo-network/diviner-model": "~5.3.2",
|
|
42
|
-
"@xyo-network/module-model": "~5.3.2",
|
|
43
|
-
"@xyo-network/payload-model": "~5.3.2",
|
|
44
|
-
"xml2js": "~0.6.2"
|
|
45
|
-
},
|
|
46
35
|
"devDependencies": {
|
|
47
36
|
"@types/xml2js": "~0.4.14",
|
|
48
|
-
"@xylabs/
|
|
49
|
-
"@xylabs/ts-scripts-
|
|
50
|
-
"@xylabs/
|
|
51
|
-
"@xylabs/
|
|
52
|
-
"@xylabs/vitest-
|
|
53
|
-
"@
|
|
37
|
+
"@xylabs/sdk-js": "^5.0.90",
|
|
38
|
+
"@xylabs/ts-scripts-common": "~7.5.10",
|
|
39
|
+
"@xylabs/ts-scripts-yarn3": "~7.5.10",
|
|
40
|
+
"@xylabs/tsconfig": "~7.5.10",
|
|
41
|
+
"@xylabs/vitest-extended": "~5.0.90",
|
|
42
|
+
"@xylabs/vitest-matchers": "~5.0.90",
|
|
43
|
+
"@xyo-network/api-call-witness": "5.3.3",
|
|
44
|
+
"@xyo-network/diviner-abstract": "~5.3.5",
|
|
45
|
+
"@xyo-network/diviner-model": "~5.3.5",
|
|
46
|
+
"@xyo-network/module-model": "~5.3.5",
|
|
47
|
+
"@xyo-network/payload-model": "~5.3.5",
|
|
54
48
|
"typescript": "~5.9.3",
|
|
55
|
-
"vitest": "~4.
|
|
49
|
+
"vitest": "~4.1.2",
|
|
50
|
+
"xml2js": "~0.6.2",
|
|
51
|
+
"zod": "^4.3.6"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@xylabs/sdk-js": "^5",
|
|
55
|
+
"@xyo-network/diviner-abstract": "^5",
|
|
56
|
+
"@xyo-network/diviner-model": "^5",
|
|
57
|
+
"@xyo-network/module-model": "^5",
|
|
58
|
+
"@xyo-network/payload-model": "^5",
|
|
59
|
+
"xml2js": "^0",
|
|
60
|
+
"zod": "^4"
|
|
56
61
|
},
|
|
57
62
|
"publishConfig": {
|
|
58
63
|
"access": "public"
|
package/src/Diviner/Config.ts
DELETED
package/src/Diviner/Diviner.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AbstractDiviner } from '@xyo-network/diviner-abstract'
|
|
2
|
-
import { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'
|
|
3
|
-
import { creatableModule } from '@xyo-network/module-model'
|
|
4
|
-
import { Payload, Schema } from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
import { Xml } from '../Payload.ts'
|
|
7
|
-
import { XmlSchema } from '../Schema.ts'
|
|
8
|
-
import {
|
|
9
|
-
hasStringDataField, StringDataField, toXml,
|
|
10
|
-
} from './lib/index.ts'
|
|
11
|
-
import { XmlParsingDivinerParams } from './Params.ts'
|
|
12
|
-
import { XmlParsingDivinerConfigSchema } from './Schema.ts'
|
|
13
|
-
|
|
14
|
-
@creatableModule()
|
|
15
|
-
export class XmlParsingDiviner<
|
|
16
|
-
TParams extends XmlParsingDivinerParams = XmlParsingDivinerParams,
|
|
17
|
-
TIn extends Payload<StringDataField> = Payload<StringDataField>,
|
|
18
|
-
TOut extends Xml | Payload = Xml | Payload,
|
|
19
|
-
TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<
|
|
20
|
-
DivinerInstance<TParams, TIn, TOut>,
|
|
21
|
-
TIn,
|
|
22
|
-
TOut
|
|
23
|
-
>,
|
|
24
|
-
> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
|
|
25
|
-
static override readonly configSchemas: Schema[] = [...super.configSchemas, XmlParsingDivinerConfigSchema]
|
|
26
|
-
static override readonly defaultConfigSchema: Schema = XmlParsingDivinerConfigSchema
|
|
27
|
-
static override readonly targetSchema = XmlSchema
|
|
28
|
-
|
|
29
|
-
protected override async divineHandler(payloads: TIn[] = []): Promise<TOut[]> {
|
|
30
|
-
const results = await Promise.all(payloads.filter(hasStringDataField).map(toXml))
|
|
31
|
-
return results as TOut[]
|
|
32
|
-
}
|
|
33
|
-
}
|
package/src/Diviner/Params.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DivinerParams } from '@xyo-network/diviner-model'
|
|
2
|
-
import type { AnyConfigSchema } from '@xyo-network/module-model'
|
|
3
|
-
|
|
4
|
-
import type { XmlParsingDivinerConfig } from './Config.ts'
|
|
5
|
-
|
|
6
|
-
export type XmlParsingDivinerParams<TConfig extends AnyConfigSchema<XmlParsingDivinerConfig> = AnyConfigSchema<XmlParsingDivinerConfig>>
|
|
7
|
-
= DivinerParams<TConfig>
|
package/src/Diviner/Schema.ts
DELETED
package/src/Diviner/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface representing an object with a string data field
|
|
3
|
-
*/
|
|
4
|
-
export interface StringDataField {
|
|
5
|
-
/**
|
|
6
|
-
* The string data
|
|
7
|
-
*/
|
|
8
|
-
data: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Identity for StringDataField
|
|
13
|
-
* @param obj The input object
|
|
14
|
-
* @returns True if the object is a StringDataField, false otherwise
|
|
15
|
-
*/
|
|
16
|
-
export const hasStringDataField = (obj?: unknown): obj is StringDataField => {
|
|
17
|
-
return typeof obj === 'object' && obj !== null && 'data' in obj && typeof (obj as StringDataField)?.data === 'string'
|
|
18
|
-
}
|
package/src/Diviner/lib/index.ts
DELETED
package/src/Diviner/lib/toXml.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Parser } from 'xml2js'
|
|
2
|
-
|
|
3
|
-
import type { Xml } from '../../Payload.ts'
|
|
4
|
-
import { XmlSchema } from '../../Schema.ts'
|
|
5
|
-
import type { StringDataField } from './StringDataField.ts'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Takes a string data field containing xml and converts it to an XML object
|
|
9
|
-
* @param obj The input object which contains the stringified xml data
|
|
10
|
-
* @returns A promise that resolves to an XML payload
|
|
11
|
-
*/
|
|
12
|
-
export const toXml = (obj: StringDataField): Promise<Xml> => {
|
|
13
|
-
const parser = new Parser()
|
|
14
|
-
return new Promise<Xml>((resolve, reject) => {
|
|
15
|
-
parser.parseString(obj.data, (err, result) => {
|
|
16
|
-
if (err) {
|
|
17
|
-
reject(err)
|
|
18
|
-
} else {
|
|
19
|
-
const xml = { schema: XmlSchema, xml: result } as const
|
|
20
|
-
resolve(xml)
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
}
|
package/src/Payload.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { JsonObject } from '@xylabs/object'
|
|
2
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
-
import { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithSources } from '@xyo-network/payload-model'
|
|
4
|
-
|
|
5
|
-
import { XmlSchema } from './Schema.ts'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The fields of an Xml Payload
|
|
9
|
-
*/
|
|
10
|
-
export interface XmlFields {
|
|
11
|
-
xml: JsonObject
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An Xml Payload
|
|
16
|
-
*/
|
|
17
|
-
export type Xml = Payload<XmlFields, XmlSchema>
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Identity function for determine if an object is an Xml Payload
|
|
21
|
-
*/
|
|
22
|
-
export const isXml = isPayloadOfSchemaType<Xml>(XmlSchema)
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Identity function for determine if an object is an Xml Payload with sources
|
|
26
|
-
*/
|
|
27
|
-
export const isXmlWithSources = isPayloadOfSchemaTypeWithSources<Xml>(XmlSchema)
|
package/src/Schema.ts
DELETED
package/src/index.ts
DELETED