@xyo-network/api-graphql-plugin 3.0.1 → 3.0.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/browser/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import * as _xyo_network_module_model from '@xyo-network/module-model';
|
|
|
6
6
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
7
7
|
import { WitnessConfig, WitnessParams } from '@xyo-network/witness-model';
|
|
8
8
|
import { ExecutionResult } from 'graphql';
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
9
|
+
import * as _store__xyo_network_account_model_virtual_e036bb1dc5_package from '.store/@xyo-network-account-model-virtual-e036bb1dc5/package';
|
|
10
|
+
import * as _store__xylabs_object_npm_4_0_2_c4743812cc_package from '.store/@xylabs-object-npm-4.0.2-c4743812cc/package';
|
|
11
11
|
|
|
12
12
|
declare const ApiGraphqlWitnessConfigSchema = "network.xyo.api.witness.config";
|
|
13
13
|
type ApiGraphqlWitnessConfigSchema = typeof ApiGraphqlWitnessConfigSchema;
|
|
@@ -55,10 +55,10 @@ declare class ApiGraphqlWitness<TParams extends ApiGraphqlWitnessParams = ApiGra
|
|
|
55
55
|
protected observeHandler(payloads?: GraphqlQuery[]): Promise<GraphqlResult[]>;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
declare const ApiGraphqlWitnessPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<ApiGraphqlWitness<
|
|
59
|
-
account?:
|
|
58
|
+
declare const ApiGraphqlWitnessPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<ApiGraphqlWitness<_store__xylabs_object_npm_4_0_2_c4743812cc_package.BaseParamsFields & {
|
|
59
|
+
account?: _store__xyo_network_account_model_virtual_e036bb1dc5_package.AccountInstance | "random";
|
|
60
60
|
addToResolvers?: boolean;
|
|
61
|
-
additionalSigners?:
|
|
61
|
+
additionalSigners?: _store__xyo_network_account_model_virtual_e036bb1dc5_package.AccountInstance[];
|
|
62
62
|
allowNameResolution?: boolean;
|
|
63
63
|
config: _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & {
|
|
64
64
|
schema: "network.xyo.api.witness.config";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.ts'\n\nexport const ApiGraphqlWitnessPlugin = () =>\n createPayloadSetWitnessPlugin<ApiGraphqlWitness>(\n { required: { [GraphqlQuerySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await ApiGraphqlWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.ts'\n\nexport const ApiGraphqlWitnessPlugin = () =>\n createPayloadSetWitnessPlugin<ApiGraphqlWitness>(\n { required: { [GraphqlQuerySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await ApiGraphqlWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport type { ExecutionResult } from 'graphql'\n\nexport const ApiGraphqlWitnessConfigSchema = 'network.xyo.api.witness.config'\nexport type ApiGraphqlWitnessConfigSchema = typeof ApiGraphqlWitnessConfigSchema\n\nexport type ApiGraphqlWitnessConfig = WitnessConfig<{\n endpoint?: string\n schema: ApiGraphqlWitnessConfigSchema\n timeout?: number\n}>\n\nexport type HttpHeaderValue = string | string[] | number | boolean | null\n\nexport interface HttpHeaders {\n [key: string]: HttpHeaderValue\n}\n\nexport type ApiGraphqlWitnessParams = WitnessParams<\n AnyConfigSchema<ApiGraphqlWitnessConfig>,\n {\n endpoint?: string\n headers?: HttpHeaders\n }\n>\n\nexport const GraphqlQuerySchema = 'network.xyo.graphql.query'\nexport type GraphqlQuerySchema = typeof GraphqlQuerySchema\n\nexport type GraphqlQuery = Payload<\n {\n query: string\n variables: Record<string, unknown>\n },\n GraphqlQuerySchema\n>\n\nexport const GraphqlResultSchema = 'network.xyo.graphql.result'\nexport type GraphqlResultSchema = typeof GraphqlResultSchema\n\nexport type GraphqlResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Payload<\n {\n http?: {\n code?: string\n ipAddress?: string\n status?: number\n }\n result?: ExecutionResult<TData, TExtensions>\n },\n GraphqlResultSchema\n>\n\nexport const isGraphqlQuery = isPayloadOfSchemaType<GraphqlQuery>(GraphqlQuerySchema)\n\nexport class ApiGraphqlWitness<TParams extends ApiGraphqlWitnessParams = ApiGraphqlWitnessParams> extends AbstractWitness<\n TParams,\n GraphqlQuery,\n GraphqlResult\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ApiGraphqlWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = ApiGraphqlWitnessConfigSchema\n\n get endpoint() {\n return assertEx(this.config.endpoint ?? this.params.endpoint, () => 'No endpoint specified')\n }\n\n get headers() {\n return this.params.headers\n }\n\n get timeout() {\n return this.config.timeout\n }\n\n protected override async observeHandler(payloads?: GraphqlQuery[]): Promise<GraphqlResult[]> {\n await this.started('throw')\n const queries = payloads?.filter(isGraphqlQuery) ?? []\n const axios = new AxiosJson({ headers: this.headers, timeout: this.timeout })\n const observations = await Promise.all(\n queries.map(async ({ query, variables }) => {\n const httpResult = await axios.post(this.endpoint, { query, variables })\n const result: GraphqlResult = {\n http: {\n status: httpResult.status,\n },\n result: httpResult.data,\n schema: GraphqlResultSchema,\n }\n return result\n }),\n )\n return observations.flat()\n }\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACD9C,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAGhC,SAAS,6BAA6B;AAI/B,IAAM,gCAAgC;AAuBtC,IAAM,qBAAqB;AAW3B,IAAM,sBAAsB;AAe5B,IAAM,iBAAiB,sBAAoC,kBAAkB;AAE7E,IAAM,oBAAN,cAAmG,gBAIxG;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,6BAA6B;AAAA,EACzG,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,WAAW;AACb,WAAO,SAAS,KAAK,OAAO,YAAY,KAAK,OAAO,UAAU,MAAM,uBAAuB;AAAA,EAC7F;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,MAAyB,eAAe,UAAqD;AAC3F,UAAM,KAAK,QAAQ,OAAO;AAC1B,UAAM,UAAU,UAAU,OAAO,cAAc,KAAK,CAAC;AACrD,UAAM,QAAQ,IAAI,UAAU,EAAE,SAAS,KAAK,SAAS,SAAS,KAAK,QAAQ,CAAC;AAC5E,UAAM,eAAe,MAAM,QAAQ;AAAA,MACjC,QAAQ,IAAI,OAAO,EAAE,OAAO,UAAU,MAAM;AAC1C,cAAM,aAAa,MAAM,MAAM,KAAK,KAAK,UAAU,EAAE,OAAO,UAAU,CAAC;AACvE,cAAM,SAAwB;AAAA,UAC5B,MAAM;AAAA,YACJ,QAAQ,WAAW;AAAA,UACrB;AAAA,UACA,QAAQ,WAAW;AAAA,UACnB,QAAQ;AAAA,QACV;AACA,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AACA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;;;AD9FO,IAAM,0BAA0B,MACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,kBAAkB,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EAClE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,kBAAkB,OAAO,MAAM;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import * as _xyo_network_module_model from '@xyo-network/module-model';
|
|
|
6
6
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
7
7
|
import { WitnessConfig, WitnessParams } from '@xyo-network/witness-model';
|
|
8
8
|
import { ExecutionResult } from 'graphql';
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
9
|
+
import * as _store__xyo_network_account_model_virtual_e036bb1dc5_package from '.store/@xyo-network-account-model-virtual-e036bb1dc5/package';
|
|
10
|
+
import * as _store__xylabs_object_npm_4_0_2_c4743812cc_package from '.store/@xylabs-object-npm-4.0.2-c4743812cc/package';
|
|
11
11
|
|
|
12
12
|
declare const ApiGraphqlWitnessConfigSchema = "network.xyo.api.witness.config";
|
|
13
13
|
type ApiGraphqlWitnessConfigSchema = typeof ApiGraphqlWitnessConfigSchema;
|
|
@@ -55,10 +55,10 @@ declare class ApiGraphqlWitness<TParams extends ApiGraphqlWitnessParams = ApiGra
|
|
|
55
55
|
protected observeHandler(payloads?: GraphqlQuery[]): Promise<GraphqlResult[]>;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
declare const ApiGraphqlWitnessPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<ApiGraphqlWitness<
|
|
59
|
-
account?:
|
|
58
|
+
declare const ApiGraphqlWitnessPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<ApiGraphqlWitness<_store__xylabs_object_npm_4_0_2_c4743812cc_package.BaseParamsFields & {
|
|
59
|
+
account?: _store__xyo_network_account_model_virtual_e036bb1dc5_package.AccountInstance | "random";
|
|
60
60
|
addToResolvers?: boolean;
|
|
61
|
-
additionalSigners?:
|
|
61
|
+
additionalSigners?: _store__xyo_network_account_model_virtual_e036bb1dc5_package.AccountInstance[];
|
|
62
62
|
allowNameResolution?: boolean;
|
|
63
63
|
config: _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & {
|
|
64
64
|
schema: "network.xyo.api.witness.config";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.ts'\n\nexport const ApiGraphqlWitnessPlugin = () =>\n createPayloadSetWitnessPlugin<ApiGraphqlWitness>(\n { required: { [GraphqlQuerySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await ApiGraphqlWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.ts'\n\nexport const ApiGraphqlWitnessPlugin = () =>\n createPayloadSetWitnessPlugin<ApiGraphqlWitness>(\n { required: { [GraphqlQuerySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await ApiGraphqlWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport type { ExecutionResult } from 'graphql'\n\nexport const ApiGraphqlWitnessConfigSchema = 'network.xyo.api.witness.config'\nexport type ApiGraphqlWitnessConfigSchema = typeof ApiGraphqlWitnessConfigSchema\n\nexport type ApiGraphqlWitnessConfig = WitnessConfig<{\n endpoint?: string\n schema: ApiGraphqlWitnessConfigSchema\n timeout?: number\n}>\n\nexport type HttpHeaderValue = string | string[] | number | boolean | null\n\nexport interface HttpHeaders {\n [key: string]: HttpHeaderValue\n}\n\nexport type ApiGraphqlWitnessParams = WitnessParams<\n AnyConfigSchema<ApiGraphqlWitnessConfig>,\n {\n endpoint?: string\n headers?: HttpHeaders\n }\n>\n\nexport const GraphqlQuerySchema = 'network.xyo.graphql.query'\nexport type GraphqlQuerySchema = typeof GraphqlQuerySchema\n\nexport type GraphqlQuery = Payload<\n {\n query: string\n variables: Record<string, unknown>\n },\n GraphqlQuerySchema\n>\n\nexport const GraphqlResultSchema = 'network.xyo.graphql.result'\nexport type GraphqlResultSchema = typeof GraphqlResultSchema\n\nexport type GraphqlResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Payload<\n {\n http?: {\n code?: string\n ipAddress?: string\n status?: number\n }\n result?: ExecutionResult<TData, TExtensions>\n },\n GraphqlResultSchema\n>\n\nexport const isGraphqlQuery = isPayloadOfSchemaType<GraphqlQuery>(GraphqlQuerySchema)\n\nexport class ApiGraphqlWitness<TParams extends ApiGraphqlWitnessParams = ApiGraphqlWitnessParams> extends AbstractWitness<\n TParams,\n GraphqlQuery,\n GraphqlResult\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ApiGraphqlWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = ApiGraphqlWitnessConfigSchema\n\n get endpoint() {\n return assertEx(this.config.endpoint ?? this.params.endpoint, () => 'No endpoint specified')\n }\n\n get headers() {\n return this.params.headers\n }\n\n get timeout() {\n return this.config.timeout\n }\n\n protected override async observeHandler(payloads?: GraphqlQuery[]): Promise<GraphqlResult[]> {\n await this.started('throw')\n const queries = payloads?.filter(isGraphqlQuery) ?? []\n const axios = new AxiosJson({ headers: this.headers, timeout: this.timeout })\n const observations = await Promise.all(\n queries.map(async ({ query, variables }) => {\n const httpResult = await axios.post(this.endpoint, { query, variables })\n const result: GraphqlResult = {\n http: {\n status: httpResult.status,\n },\n result: httpResult.data,\n schema: GraphqlResultSchema,\n }\n return result\n }),\n )\n return observations.flat()\n }\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACD9C,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAGhC,SAAS,6BAA6B;AAI/B,IAAM,gCAAgC;AAuBtC,IAAM,qBAAqB;AAW3B,IAAM,sBAAsB;AAe5B,IAAM,iBAAiB,sBAAoC,kBAAkB;AAE7E,IAAM,oBAAN,cAAmG,gBAIxG;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,6BAA6B;AAAA,EACzG,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,WAAW;AACb,WAAO,SAAS,KAAK,OAAO,YAAY,KAAK,OAAO,UAAU,MAAM,uBAAuB;AAAA,EAC7F;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,MAAyB,eAAe,UAAqD;AAC3F,UAAM,KAAK,QAAQ,OAAO;AAC1B,UAAM,UAAU,UAAU,OAAO,cAAc,KAAK,CAAC;AACrD,UAAM,QAAQ,IAAI,UAAU,EAAE,SAAS,KAAK,SAAS,SAAS,KAAK,QAAQ,CAAC;AAC5E,UAAM,eAAe,MAAM,QAAQ;AAAA,MACjC,QAAQ,IAAI,OAAO,EAAE,OAAO,UAAU,MAAM;AAC1C,cAAM,aAAa,MAAM,MAAM,KAAK,KAAK,UAAU,EAAE,OAAO,UAAU,CAAC;AACvE,cAAM,SAAwB;AAAA,UAC5B,MAAM;AAAA,YACJ,QAAQ,WAAW;AAAA,UACrB;AAAA,UACA,QAAQ,WAAW;AAAA,UACnB,QAAQ;AAAA,QACV;AACA,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AACA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;;;AD9FO,IAAM,0BAA0B,MACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,kBAAkB,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EAClE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,kBAAkB,OAAO,MAAM;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import * as _xyo_network_module_model from '@xyo-network/module-model';
|
|
|
6
6
|
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
7
7
|
import { WitnessConfig, WitnessParams } from '@xyo-network/witness-model';
|
|
8
8
|
import { ExecutionResult } from 'graphql';
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
9
|
+
import * as _store__xyo_network_account_model_virtual_e036bb1dc5_package from '.store/@xyo-network-account-model-virtual-e036bb1dc5/package';
|
|
10
|
+
import * as _store__xylabs_object_npm_4_0_2_c4743812cc_package from '.store/@xylabs-object-npm-4.0.2-c4743812cc/package';
|
|
11
11
|
|
|
12
12
|
declare const ApiGraphqlWitnessConfigSchema = "network.xyo.api.witness.config";
|
|
13
13
|
type ApiGraphqlWitnessConfigSchema = typeof ApiGraphqlWitnessConfigSchema;
|
|
@@ -55,10 +55,10 @@ declare class ApiGraphqlWitness<TParams extends ApiGraphqlWitnessParams = ApiGra
|
|
|
55
55
|
protected observeHandler(payloads?: GraphqlQuery[]): Promise<GraphqlResult[]>;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
declare const ApiGraphqlWitnessPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<ApiGraphqlWitness<
|
|
59
|
-
account?:
|
|
58
|
+
declare const ApiGraphqlWitnessPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<ApiGraphqlWitness<_store__xylabs_object_npm_4_0_2_c4743812cc_package.BaseParamsFields & {
|
|
59
|
+
account?: _store__xyo_network_account_model_virtual_e036bb1dc5_package.AccountInstance | "random";
|
|
60
60
|
addToResolvers?: boolean;
|
|
61
|
-
additionalSigners?:
|
|
61
|
+
additionalSigners?: _store__xyo_network_account_model_virtual_e036bb1dc5_package.AccountInstance[];
|
|
62
62
|
allowNameResolution?: boolean;
|
|
63
63
|
config: _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & {
|
|
64
64
|
schema: "network.xyo.api.witness.config";
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.ts'\n\nexport const ApiGraphqlWitnessPlugin = () =>\n createPayloadSetWitnessPlugin<ApiGraphqlWitness>(\n { required: { [GraphqlQuerySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await ApiGraphqlWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.ts'\n\nexport const ApiGraphqlWitnessPlugin = () =>\n createPayloadSetWitnessPlugin<ApiGraphqlWitness>(\n { required: { [GraphqlQuerySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await ApiGraphqlWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'\nimport type { ExecutionResult } from 'graphql'\n\nexport const ApiGraphqlWitnessConfigSchema = 'network.xyo.api.witness.config'\nexport type ApiGraphqlWitnessConfigSchema = typeof ApiGraphqlWitnessConfigSchema\n\nexport type ApiGraphqlWitnessConfig = WitnessConfig<{\n endpoint?: string\n schema: ApiGraphqlWitnessConfigSchema\n timeout?: number\n}>\n\nexport type HttpHeaderValue = string | string[] | number | boolean | null\n\nexport interface HttpHeaders {\n [key: string]: HttpHeaderValue\n}\n\nexport type ApiGraphqlWitnessParams = WitnessParams<\n AnyConfigSchema<ApiGraphqlWitnessConfig>,\n {\n endpoint?: string\n headers?: HttpHeaders\n }\n>\n\nexport const GraphqlQuerySchema = 'network.xyo.graphql.query'\nexport type GraphqlQuerySchema = typeof GraphqlQuerySchema\n\nexport type GraphqlQuery = Payload<\n {\n query: string\n variables: Record<string, unknown>\n },\n GraphqlQuerySchema\n>\n\nexport const GraphqlResultSchema = 'network.xyo.graphql.result'\nexport type GraphqlResultSchema = typeof GraphqlResultSchema\n\nexport type GraphqlResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = Payload<\n {\n http?: {\n code?: string\n ipAddress?: string\n status?: number\n }\n result?: ExecutionResult<TData, TExtensions>\n },\n GraphqlResultSchema\n>\n\nexport const isGraphqlQuery = isPayloadOfSchemaType<GraphqlQuery>(GraphqlQuerySchema)\n\nexport class ApiGraphqlWitness<TParams extends ApiGraphqlWitnessParams = ApiGraphqlWitnessParams> extends AbstractWitness<\n TParams,\n GraphqlQuery,\n GraphqlResult\n> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ApiGraphqlWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = ApiGraphqlWitnessConfigSchema\n\n get endpoint() {\n return assertEx(this.config.endpoint ?? this.params.endpoint, () => 'No endpoint specified')\n }\n\n get headers() {\n return this.params.headers\n }\n\n get timeout() {\n return this.config.timeout\n }\n\n protected override async observeHandler(payloads?: GraphqlQuery[]): Promise<GraphqlResult[]> {\n await this.started('throw')\n const queries = payloads?.filter(isGraphqlQuery) ?? []\n const axios = new AxiosJson({ headers: this.headers, timeout: this.timeout })\n const observations = await Promise.all(\n queries.map(async ({ query, variables }) => {\n const httpResult = await axios.post(this.endpoint, { query, variables })\n const result: GraphqlResult = {\n http: {\n status: httpResult.status,\n },\n result: httpResult.data,\n schema: GraphqlResultSchema,\n }\n return result\n }),\n )\n return observations.flat()\n }\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACD9C,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAGhC,SAAS,6BAA6B;AAI/B,IAAM,gCAAgC;AAuBtC,IAAM,qBAAqB;AAW3B,IAAM,sBAAsB;AAe5B,IAAM,iBAAiB,sBAAoC,kBAAkB;AAE7E,IAAM,oBAAN,cAAmG,gBAIxG;AAAA,EACA,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,6BAA6B;AAAA,EACzG,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,WAAW;AACb,WAAO,SAAS,KAAK,OAAO,YAAY,KAAK,OAAO,UAAU,MAAM,uBAAuB;AAAA,EAC7F;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,MAAyB,eAAe,UAAqD;AAC3F,UAAM,KAAK,QAAQ,OAAO;AAC1B,UAAM,UAAU,UAAU,OAAO,cAAc,KAAK,CAAC;AACrD,UAAM,QAAQ,IAAI,UAAU,EAAE,SAAS,KAAK,SAAS,SAAS,KAAK,QAAQ,CAAC;AAC5E,UAAM,eAAe,MAAM,QAAQ;AAAA,MACjC,QAAQ,IAAI,OAAO,EAAE,OAAO,UAAU,MAAM;AAC1C,cAAM,aAAa,MAAM,MAAM,KAAK,KAAK,UAAU,EAAE,OAAO,UAAU,CAAC;AACvE,cAAM,SAAwB;AAAA,UAC5B,MAAM;AAAA,YACJ,QAAQ,WAAW;AAAA,UACrB;AAAA,UACA,QAAQ,WAAW;AAAA,UACnB,QAAQ;AAAA,QACV;AACA,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AACA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;;;AD9FO,IAAM,0BAA0B,MACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,kBAAkB,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EAClE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,kBAAkB,OAAO,MAAM;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -7,22 +7,22 @@
|
|
|
7
7
|
},
|
|
8
8
|
"bugs": {
|
|
9
9
|
"email": "support@xyo.network",
|
|
10
|
-
"url": "https://github.com/XYOracleNetwork/plugins/issues"
|
|
10
|
+
"url": "git+https://github.com/XYOracleNetwork/plugins/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^4.0.
|
|
14
|
-
"@xylabs/axios": "^4.0.
|
|
15
|
-
"@xyo-network/abstract-witness": "^3.0.
|
|
16
|
-
"@xyo-network/module-model": "^3.0.
|
|
17
|
-
"@xyo-network/payload-model": "^3.0.
|
|
18
|
-
"@xyo-network/payloadset-plugin": "^3.0.
|
|
19
|
-
"@xyo-network/witness-model": "^3.0.
|
|
13
|
+
"@xylabs/assert": "^4.0.2",
|
|
14
|
+
"@xylabs/axios": "^4.0.2",
|
|
15
|
+
"@xyo-network/abstract-witness": "^3.0.3",
|
|
16
|
+
"@xyo-network/module-model": "^3.0.3",
|
|
17
|
+
"@xyo-network/payload-model": "^3.0.3",
|
|
18
|
+
"@xyo-network/payloadset-plugin": "^3.0.3",
|
|
19
|
+
"@xyo-network/witness-model": "^3.0.3",
|
|
20
20
|
"graphql": "^16.9.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@xylabs/jest-helpers": "^4.0.
|
|
24
|
-
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.
|
|
25
|
-
"@xylabs/tsconfig": "^4.0.0-rc.
|
|
23
|
+
"@xylabs/jest-helpers": "^4.0.2",
|
|
24
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.20",
|
|
25
|
+
"@xylabs/tsconfig": "^4.0.0-rc.20",
|
|
26
26
|
"ethers": "^6.13.2",
|
|
27
27
|
"jest": "^29.7.0",
|
|
28
28
|
"typescript": "^5.5.4"
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
},
|
|
45
45
|
"repository": {
|
|
46
46
|
"type": "git",
|
|
47
|
-
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
47
|
+
"url": "git+https://github.com/XYOracleNetwork/plugins.git"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"version": "3.0.
|
|
50
|
+
"version": "3.0.3",
|
|
51
51
|
"type": "module"
|
|
52
52
|
}
|
package/src/Witness.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { AxiosJson } from '@xylabs/axios'
|
|
3
3
|
import { AbstractWitness } from '@xyo-network/abstract-witness'
|
|
4
|
-
import { AnyConfigSchema } from '@xyo-network/module-model'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import type { AnyConfigSchema } from '@xyo-network/module-model'
|
|
5
|
+
import type { Payload, Schema } from '@xyo-network/payload-model'
|
|
6
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
7
|
+
import type { WitnessConfig, WitnessParams } from '@xyo-network/witness-model'
|
|
7
8
|
import type { ExecutionResult } from 'graphql'
|
|
8
9
|
|
|
9
10
|
export const ApiGraphqlWitnessConfigSchema = 'network.xyo.api.witness.config'
|