@xyo-network/payload-plugin 5.3.22 → 5.3.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/payload-plugin",
3
- "version": "5.3.22",
3
+ "version": "5.3.25",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,34 +30,34 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
33
  "!**/*.bench.*",
35
34
  "!**/*.spec.*",
36
35
  "!**/*.test.*",
37
36
  "README.md"
38
37
  ],
39
38
  "dependencies": {
40
- "@xyo-network/payload-builder": "~5.3.22",
41
- "@xyo-network/payload-model": "~5.3.22",
42
- "@xyo-network/payload-validator": "~5.3.22",
43
- "@xyo-network/payload-wrapper": "~5.3.22"
39
+ "@xyo-network/payload-builder": "~5.3.25",
40
+ "@xyo-network/payload-model": "~5.3.25",
41
+ "@xyo-network/payload-wrapper": "~5.3.25",
42
+ "@xyo-network/payload-validator": "~5.3.25"
44
43
  },
45
44
  "devDependencies": {
46
45
  "@opentelemetry/api": "^1.9.1",
47
46
  "@types/node": "^25.5.0",
48
- "@xylabs/sdk-js": "^5.0.91",
49
- "@xylabs/ts-scripts-common": "~7.6.8",
50
- "@xylabs/ts-scripts-yarn3": "~7.6.8",
51
- "@xylabs/tsconfig": "~7.6.8",
47
+ "@xylabs/sdk-js": "^5.0.93",
48
+ "@xylabs/ts-scripts-common": "~7.6.16",
49
+ "@xylabs/ts-scripts-pnpm": "~7.6.16",
50
+ "@xylabs/tsconfig": "~7.6.16",
52
51
  "acorn": "^8.16.0",
53
52
  "ajv": "^8.18.0",
54
53
  "axios": "^1.14.0",
55
- "cosmiconfig": "^9.0.1",
56
- "esbuild": "^0.27.4",
57
- "eslint": "^10.1.0",
58
- "rollup": "^4.60.1",
54
+ "esbuild": "^0.28.0",
59
55
  "typescript": "~5.9.3",
60
- "zod": "^4.3.6"
56
+ "zod": "^4.3.6",
57
+ "@xyo-network/payload-model": "~5.3.25",
58
+ "@xyo-network/payload-builder": "~5.3.25",
59
+ "@xyo-network/payload-validator": "~5.3.25",
60
+ "@xyo-network/payload-wrapper": "~5.3.25"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@xylabs/sdk-js": "^5",
@@ -72,4 +72,4 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  }
75
- }
75
+ }
package/src/Plugin.ts DELETED
@@ -1,23 +0,0 @@
1
- import type { Validator } from '@xylabs/sdk-js'
2
- import type { PayloadBuilder } from '@xyo-network/payload-builder'
3
- import type { Payload } from '@xyo-network/payload-model'
4
- import type { PayloadWrapper } from '@xyo-network/payload-wrapper'
5
- // eslint-disable-next-line import-x/no-internal-modules
6
- import type { SomeJSONSchema } from 'ajv/dist/types/json-schema.js'
7
- import type { ZodType } from 'zod'
8
-
9
- export type PayloadPluginFunc<TPayload extends Payload = Payload> = () => PayloadPlugin<TPayload>
10
-
11
- export type PayloadPlugin<TPayload extends Payload = Payload> = {
12
- build?: () => PayloadBuilder<TPayload>
13
- /** @deprecated use zod instead */
14
- jsonSchema?: SomeJSONSchema
15
- schema: TPayload['schema']
16
- /** @deprecated use zod defaults instead */
17
- template?: () => Partial<TPayload>
18
- validate?: (payload: Payload) => Validator<Payload>
19
- wrap?: (payload: Payload) => PayloadWrapper
20
- zod?: ZodType
21
- }
22
-
23
- /* We use PartialWitnessConfig to allow people to config witnesses without having to pass in all the schema info */
package/src/Resolver.ts DELETED
@@ -1,63 +0,0 @@
1
- import type { Validator } from '@xylabs/sdk-js'
2
- import { isDefined } from '@xylabs/sdk-js'
3
- import type { Payload } from '@xyo-network/payload-model'
4
- import { PayloadSchema } from '@xyo-network/payload-model'
5
- import type { PayloadWrapper } from '@xyo-network/payload-wrapper'
6
-
7
- import { createPayloadPlugin } from './createPlugin.ts'
8
- import type { PayloadPlugin } from './Plugin.ts'
9
-
10
- export class PayloadPluginResolver {
11
- schema = PayloadSchema
12
-
13
- protected _plugins: Record<string, PayloadPlugin> = {}
14
- protected defaultPlugin: PayloadPlugin
15
-
16
- constructor(
17
- /** @param plugins The initial set of plugins */
18
- plugins?: PayloadPlugin<Payload>[],
19
- /** @param defaultPlugin Specifies the plugin to be used if no plugins resolve */
20
- defaultPlugin = createPayloadPlugin<Payload>({ schema: PayloadSchema }),
21
- ) {
22
- for (const plugin of plugins ?? []) this.register(plugin)
23
- this.defaultPlugin = defaultPlugin
24
- }
25
-
26
- /** @description Create list of plugins, optionally filtered by ability to witness/divine */
27
- plugins() {
28
- const result: PayloadPlugin[] = []
29
- for (const value of Object.values(this._plugins)) {
30
- result.push(value)
31
- }
32
- return result
33
- }
34
-
35
- register<TPlugin extends PayloadPlugin = PayloadPlugin>(plugin: TPlugin) {
36
- this._plugins[plugin.schema] = plugin
37
-
38
- return this
39
- }
40
-
41
- resolve(schema?: string): PayloadPlugin
42
- resolve(payload: Payload): PayloadPlugin
43
- resolve(value: Payload | string | undefined): PayloadPlugin {
44
- return isDefined(value) ? (this._plugins[typeof value === 'string' ? value : value.schema] ?? this.defaultPlugin) : this.defaultPlugin
45
- }
46
-
47
- /** @description Create list of schema, optionally filtered by ability to witness/divine */
48
- schemas() {
49
- const result: string[] = []
50
- for (const value of Object.values(this._plugins)) {
51
- result.push(value.schema)
52
- }
53
- return result
54
- }
55
-
56
- validate(payload: Payload): Validator<Payload> | undefined {
57
- return this.resolve(payload).validate?.(payload)
58
- }
59
-
60
- wrap(payload: Payload): PayloadWrapper<Payload> | undefined {
61
- return this.resolve(payload).wrap?.(payload)
62
- }
63
- }
@@ -1,29 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import { PayloadBuilder } from '@xyo-network/payload-builder'
3
- import type { Payload, Schema } from '@xyo-network/payload-model'
4
- import { PayloadValidator } from '@xyo-network/payload-validator'
5
- import { PayloadWrapper } from '@xyo-network/payload-wrapper'
6
-
7
- import type { PayloadPlugin } from './Plugin.ts'
8
-
9
- export const defaultPayloadPluginFunctions = <T extends Payload>(schema: Schema): PayloadPlugin<T> => {
10
- return {
11
- build: (): PayloadBuilder<T> => {
12
- return new PayloadBuilder<T>({ schema })
13
- },
14
- schema,
15
- validate: (payload: Payload): PayloadValidator<T> => {
16
- return new PayloadValidator<T>(payload as T)
17
- },
18
- wrap: (payload: Payload): PayloadWrapper<T> => {
19
- return PayloadWrapper.wrap<T>(payload as T)
20
- },
21
- }
22
- }
23
-
24
- export const createPayloadPlugin = <TPayload extends Payload = Payload>(plugin: PayloadPlugin<TPayload>): PayloadPlugin<TPayload> => {
25
- return {
26
- ...defaultPayloadPluginFunctions<TPayload>(assertEx(plugin.schema, () => 'schema field required to create plugin')),
27
- ...plugin,
28
- }
29
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './createPlugin.ts'
2
- export * from './Plugin.ts'
3
- export * from './Resolver.ts'