@xyo-network/api-graphql-plugin 2.99.3 → 2.99.5
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/Plugin.d.cts +3 -3
- package/dist/browser/Plugin.d.mts +3 -3
- package/dist/browser/Plugin.d.ts +3 -3
- package/dist/browser/index.cjs +36 -23
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +2 -2
- package/dist/browser/index.d.mts +2 -2
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/{index.js → index.mjs} +39 -24
- package/dist/{node/index.js.map → browser/index.mjs.map} +1 -1
- package/dist/neutral/Plugin.d.cts +3 -3
- package/dist/neutral/Plugin.d.mts +3 -3
- package/dist/neutral/Plugin.d.ts +3 -3
- package/dist/neutral/index.cjs +36 -23
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +2 -2
- package/dist/neutral/index.d.mts +2 -2
- package/dist/neutral/index.d.ts +2 -2
- package/dist/neutral/{index.js → index.mjs} +39 -24
- package/dist/{browser/index.js.map → neutral/index.mjs.map} +1 -1
- package/dist/node/Plugin.d.cts +3 -3
- package/dist/node/Plugin.d.mts +3 -3
- package/dist/node/Plugin.d.ts +3 -3
- package/dist/node/index.cjs +42 -25
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.mts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.mjs +84 -0
- package/dist/{neutral/index.js.map → node/index.mjs.map} +1 -1
- package/package.json +16 -17
- package/src/Plugin.ts +1 -1
- package/src/index.ts +2 -2
- package/dist/node/index.js +0 -65
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/browser/Plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/browser/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -44,7 +45,13 @@ var GraphqlQuerySchema = "network.xyo.graphql.query";
|
|
|
44
45
|
var GraphqlResultSchema = "network.xyo.graphql.result";
|
|
45
46
|
var isGraphqlQuery = (0, import_payload_model.isPayloadOfSchemaType)(GraphqlQuerySchema);
|
|
46
47
|
var ApiGraphqlWitness = class extends import_abstract_witness.AbstractWitness {
|
|
47
|
-
static
|
|
48
|
+
static {
|
|
49
|
+
__name(this, "ApiGraphqlWitness");
|
|
50
|
+
}
|
|
51
|
+
static configSchemas = [
|
|
52
|
+
...super.configSchemas,
|
|
53
|
+
ApiGraphqlWitnessConfigSchema
|
|
54
|
+
];
|
|
48
55
|
static defaultConfigSchema = ApiGraphqlWitnessConfigSchema;
|
|
49
56
|
get endpoint() {
|
|
50
57
|
return (0, import_assert.assertEx)(this.config.endpoint ?? this.params.endpoint, () => "No endpoint specified");
|
|
@@ -58,31 +65,37 @@ var ApiGraphqlWitness = class extends import_abstract_witness.AbstractWitness {
|
|
|
58
65
|
async observeHandler(payloads) {
|
|
59
66
|
await this.started("throw");
|
|
60
67
|
const queries = payloads?.filter(isGraphqlQuery) ?? [];
|
|
61
|
-
const axios = new import_axios.AxiosJson({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
const axios = new import_axios.AxiosJson({
|
|
69
|
+
headers: this.headers,
|
|
70
|
+
timeout: this.timeout
|
|
71
|
+
});
|
|
72
|
+
const observations = await Promise.all(queries.map(async ({ query, variables }) => {
|
|
73
|
+
const httpResult = await axios.post(this.endpoint, {
|
|
74
|
+
query,
|
|
75
|
+
variables
|
|
76
|
+
});
|
|
77
|
+
const result = {
|
|
78
|
+
http: {
|
|
79
|
+
status: httpResult.status
|
|
80
|
+
},
|
|
81
|
+
result: httpResult.data,
|
|
82
|
+
schema: GraphqlResultSchema
|
|
83
|
+
};
|
|
84
|
+
return result;
|
|
85
|
+
}));
|
|
75
86
|
return observations.flat();
|
|
76
87
|
}
|
|
77
88
|
};
|
|
78
89
|
|
|
79
90
|
// src/Plugin.ts
|
|
80
|
-
var ApiGraphqlWitnessPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
91
|
+
var ApiGraphqlWitnessPlugin = /* @__PURE__ */ __name(() => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)({
|
|
92
|
+
required: {
|
|
93
|
+
[GraphqlQuerySchema]: 1
|
|
94
|
+
},
|
|
95
|
+
schema: import_payload_model2.PayloadSetSchema
|
|
96
|
+
}, {
|
|
97
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
98
|
+
return await ApiGraphqlWitness.create(params);
|
|
99
|
+
}, "witness")
|
|
100
|
+
}), "ApiGraphqlWitnessPlugin");
|
|
88
101
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["// eslint-disable-next-line import/no-default-export\nexport { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["// eslint-disable-next-line import/no-default-export\nexport { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts'\nexport * from './Witness.ts'\n","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 { isPayloadOfSchemaType, Payload, Schema } from '@xyo-network/payload-model'\nimport { 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;;;;;;;;;;;;;ACAA,IAAAA,wBAAiC;AACjC,+BAA8C;;;ACD9C,oBAAyB;AACzB,mBAA0B;AAC1B,8BAAgC;AAEhC,2BAAuD;AAIhD,IAAMC,gCAAgC;AAuBtC,IAAMC,qBAAqB;AAW3B,IAAMC,sBAAsB;AAe5B,IAAMC,qBAAiBC,4CAAoCH,kBAAAA;AAE3D,IAAMI,oBAAN,cAAmGC,wCAAAA;EA3D1G,OA2D0GA;;;EAKxG,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeP;;EAC5E,OAAyBQ,sBAA8BR;EAEvD,IAAIS,WAAW;AACb,eAAOC,wBAAS,KAAKC,OAAOF,YAAY,KAAKG,OAAOH,UAAU,MAAM,uBAAA;EACtE;EAEA,IAAII,UAAU;AACZ,WAAO,KAAKD,OAAOC;EACrB;EAEA,IAAIC,UAAU;AACZ,WAAO,KAAKH,OAAOG;EACrB;EAEA,MAAyBC,eAAeC,UAAqD;AAC3F,UAAM,KAAKC,QAAQ,OAAA;AACnB,UAAMC,UAAUF,UAAUG,OAAOhB,cAAAA,KAAmB,CAAA;AACpD,UAAMiB,QAAQ,IAAIC,uBAAU;MAAER,SAAS,KAAKA;MAASC,SAAS,KAAKA;IAAQ,CAAA;AAC3E,UAAMQ,eAAe,MAAMC,QAAQC,IACjCN,QAAQO,IAAI,OAAO,EAAEC,OAAOC,UAAS,MAAE;AACrC,YAAMC,aAAa,MAAMR,MAAMS,KAAK,KAAKpB,UAAU;QAAEiB;QAAOC;MAAU,CAAA;AACtE,YAAMG,SAAwB;QAC5BC,MAAM;UACJC,QAAQJ,WAAWI;QACrB;QACAF,QAAQF,WAAWK;QACnBC,QAAQhC;MACV;AACA,aAAO4B;IACT,CAAA,CAAA;AAEF,WAAOR,aAAaa,KAAI;EAC1B;AACF;;;AD7FO,IAAMC,0BAA0B,iCACrCC,wDACE;EAAEC,UAAU;IAAE,CAACC,kBAAAA,GAAqB;EAAE;EAAGC,QAAQC;AAAiB,GAClE;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,kBAAkBC,OAAOF,MAAAA;EACxC,GAFS;AAGX,CAAA,GAPmC;","names":["import_payload_model","ApiGraphqlWitnessConfigSchema","GraphqlQuerySchema","GraphqlResultSchema","isGraphqlQuery","isPayloadOfSchemaType","ApiGraphqlWitness","AbstractWitness","configSchemas","defaultConfigSchema","endpoint","assertEx","config","params","headers","timeout","observeHandler","payloads","started","queries","filter","axios","AxiosJson","observations","Promise","all","map","query","variables","httpResult","post","result","http","status","data","schema","flat","ApiGraphqlWitnessPlugin","createPayloadSetWitnessPlugin","required","GraphqlQuerySchema","schema","PayloadSetSchema","witness","params","ApiGraphqlWitness","create"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/Plugin.ts
|
|
2
5
|
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
3
6
|
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
@@ -12,7 +15,13 @@ var GraphqlQuerySchema = "network.xyo.graphql.query";
|
|
|
12
15
|
var GraphqlResultSchema = "network.xyo.graphql.result";
|
|
13
16
|
var isGraphqlQuery = isPayloadOfSchemaType(GraphqlQuerySchema);
|
|
14
17
|
var ApiGraphqlWitness = class extends AbstractWitness {
|
|
15
|
-
static
|
|
18
|
+
static {
|
|
19
|
+
__name(this, "ApiGraphqlWitness");
|
|
20
|
+
}
|
|
21
|
+
static configSchemas = [
|
|
22
|
+
...super.configSchemas,
|
|
23
|
+
ApiGraphqlWitnessConfigSchema
|
|
24
|
+
];
|
|
16
25
|
static defaultConfigSchema = ApiGraphqlWitnessConfigSchema;
|
|
17
26
|
get endpoint() {
|
|
18
27
|
return assertEx(this.config.endpoint ?? this.params.endpoint, () => "No endpoint specified");
|
|
@@ -26,33 +35,39 @@ var ApiGraphqlWitness = class extends AbstractWitness {
|
|
|
26
35
|
async observeHandler(payloads) {
|
|
27
36
|
await this.started("throw");
|
|
28
37
|
const queries = payloads?.filter(isGraphqlQuery) ?? [];
|
|
29
|
-
const axios = new AxiosJson({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const axios = new AxiosJson({
|
|
39
|
+
headers: this.headers,
|
|
40
|
+
timeout: this.timeout
|
|
41
|
+
});
|
|
42
|
+
const observations = await Promise.all(queries.map(async ({ query, variables }) => {
|
|
43
|
+
const httpResult = await axios.post(this.endpoint, {
|
|
44
|
+
query,
|
|
45
|
+
variables
|
|
46
|
+
});
|
|
47
|
+
const result = {
|
|
48
|
+
http: {
|
|
49
|
+
status: httpResult.status
|
|
50
|
+
},
|
|
51
|
+
result: httpResult.data,
|
|
52
|
+
schema: GraphqlResultSchema
|
|
53
|
+
};
|
|
54
|
+
return result;
|
|
55
|
+
}));
|
|
43
56
|
return observations.flat();
|
|
44
57
|
}
|
|
45
58
|
};
|
|
46
59
|
|
|
47
60
|
// src/Plugin.ts
|
|
48
|
-
var ApiGraphqlWitnessPlugin = () => createPayloadSetWitnessPlugin(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
61
|
+
var ApiGraphqlWitnessPlugin = /* @__PURE__ */ __name(() => createPayloadSetWitnessPlugin({
|
|
62
|
+
required: {
|
|
63
|
+
[GraphqlQuerySchema]: 1
|
|
64
|
+
},
|
|
65
|
+
schema: PayloadSetSchema
|
|
66
|
+
}, {
|
|
67
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
68
|
+
return await ApiGraphqlWitness.create(params);
|
|
69
|
+
}, "witness")
|
|
70
|
+
}), "ApiGraphqlWitnessPlugin");
|
|
56
71
|
export {
|
|
57
72
|
ApiGraphqlWitness,
|
|
58
73
|
ApiGraphqlWitnessConfigSchema,
|
|
@@ -62,4 +77,4 @@ export {
|
|
|
62
77
|
ApiGraphqlWitnessPlugin as default,
|
|
63
78
|
isGraphqlQuery
|
|
64
79
|
};
|
|
65
|
-
//# sourceMappingURL=index.
|
|
80
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -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.
|
|
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 { isPayloadOfSchemaType, Payload, Schema } from '@xyo-network/payload-model'\nimport { 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,SAASA,wBAAwB;AACjC,SAASC,qCAAqC;;;ACD9C,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,uBAAuB;AAEhC,SAASC,6BAA8C;AAIhD,IAAMC,gCAAgC;AAuBtC,IAAMC,qBAAqB;AAW3B,IAAMC,sBAAsB;AAe5B,IAAMC,iBAAiBC,sBAAoCH,kBAAAA;AAE3D,IAAMI,oBAAN,cAAmGC,gBAAAA;EA3D1G,OA2D0GA;;;EAKxG,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeP;;EAC5E,OAAyBQ,sBAA8BR;EAEvD,IAAIS,WAAW;AACb,WAAOC,SAAS,KAAKC,OAAOF,YAAY,KAAKG,OAAOH,UAAU,MAAM,uBAAA;EACtE;EAEA,IAAII,UAAU;AACZ,WAAO,KAAKD,OAAOC;EACrB;EAEA,IAAIC,UAAU;AACZ,WAAO,KAAKH,OAAOG;EACrB;EAEA,MAAyBC,eAAeC,UAAqD;AAC3F,UAAM,KAAKC,QAAQ,OAAA;AACnB,UAAMC,UAAUF,UAAUG,OAAOhB,cAAAA,KAAmB,CAAA;AACpD,UAAMiB,QAAQ,IAAIC,UAAU;MAAER,SAAS,KAAKA;MAASC,SAAS,KAAKA;IAAQ,CAAA;AAC3E,UAAMQ,eAAe,MAAMC,QAAQC,IACjCN,QAAQO,IAAI,OAAO,EAAEC,OAAOC,UAAS,MAAE;AACrC,YAAMC,aAAa,MAAMR,MAAMS,KAAK,KAAKpB,UAAU;QAAEiB;QAAOC;MAAU,CAAA;AACtE,YAAMG,SAAwB;QAC5BC,MAAM;UACJC,QAAQJ,WAAWI;QACrB;QACAF,QAAQF,WAAWK;QACnBC,QAAQhC;MACV;AACA,aAAO4B;IACT,CAAA,CAAA;AAEF,WAAOR,aAAaa,KAAI;EAC1B;AACF;;;AD7FO,IAAMC,0BAA0B,6BACrCC,8BACE;EAAEC,UAAU;IAAE,CAACC,kBAAAA,GAAqB;EAAE;EAAGC,QAAQC;AAAiB,GAClE;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,kBAAkBC,OAAOF,MAAAA;EACxC,GAFS;AAGX,CAAA,GAPmC;","names":["PayloadSetSchema","createPayloadSetWitnessPlugin","assertEx","AxiosJson","AbstractWitness","isPayloadOfSchemaType","ApiGraphqlWitnessConfigSchema","GraphqlQuerySchema","GraphqlResultSchema","isGraphqlQuery","isPayloadOfSchemaType","ApiGraphqlWitness","AbstractWitness","configSchemas","defaultConfigSchema","endpoint","assertEx","config","params","headers","timeout","observeHandler","payloads","started","queries","filter","axios","AxiosJson","observations","Promise","all","map","query","variables","httpResult","post","result","http","status","data","schema","flat","ApiGraphqlWitnessPlugin","createPayloadSetWitnessPlugin","required","GraphqlQuerySchema","schema","PayloadSetSchema","witness","params","ApiGraphqlWitness","create"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/neutral/Plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -44,7 +45,13 @@ var GraphqlQuerySchema = "network.xyo.graphql.query";
|
|
|
44
45
|
var GraphqlResultSchema = "network.xyo.graphql.result";
|
|
45
46
|
var isGraphqlQuery = (0, import_payload_model.isPayloadOfSchemaType)(GraphqlQuerySchema);
|
|
46
47
|
var ApiGraphqlWitness = class extends import_abstract_witness.AbstractWitness {
|
|
47
|
-
static
|
|
48
|
+
static {
|
|
49
|
+
__name(this, "ApiGraphqlWitness");
|
|
50
|
+
}
|
|
51
|
+
static configSchemas = [
|
|
52
|
+
...super.configSchemas,
|
|
53
|
+
ApiGraphqlWitnessConfigSchema
|
|
54
|
+
];
|
|
48
55
|
static defaultConfigSchema = ApiGraphqlWitnessConfigSchema;
|
|
49
56
|
get endpoint() {
|
|
50
57
|
return (0, import_assert.assertEx)(this.config.endpoint ?? this.params.endpoint, () => "No endpoint specified");
|
|
@@ -58,31 +65,37 @@ var ApiGraphqlWitness = class extends import_abstract_witness.AbstractWitness {
|
|
|
58
65
|
async observeHandler(payloads) {
|
|
59
66
|
await this.started("throw");
|
|
60
67
|
const queries = payloads?.filter(isGraphqlQuery) ?? [];
|
|
61
|
-
const axios = new import_axios.AxiosJson({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
const axios = new import_axios.AxiosJson({
|
|
69
|
+
headers: this.headers,
|
|
70
|
+
timeout: this.timeout
|
|
71
|
+
});
|
|
72
|
+
const observations = await Promise.all(queries.map(async ({ query, variables }) => {
|
|
73
|
+
const httpResult = await axios.post(this.endpoint, {
|
|
74
|
+
query,
|
|
75
|
+
variables
|
|
76
|
+
});
|
|
77
|
+
const result = {
|
|
78
|
+
http: {
|
|
79
|
+
status: httpResult.status
|
|
80
|
+
},
|
|
81
|
+
result: httpResult.data,
|
|
82
|
+
schema: GraphqlResultSchema
|
|
83
|
+
};
|
|
84
|
+
return result;
|
|
85
|
+
}));
|
|
75
86
|
return observations.flat();
|
|
76
87
|
}
|
|
77
88
|
};
|
|
78
89
|
|
|
79
90
|
// src/Plugin.ts
|
|
80
|
-
var ApiGraphqlWitnessPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
91
|
+
var ApiGraphqlWitnessPlugin = /* @__PURE__ */ __name(() => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)({
|
|
92
|
+
required: {
|
|
93
|
+
[GraphqlQuerySchema]: 1
|
|
94
|
+
},
|
|
95
|
+
schema: import_payload_model2.PayloadSetSchema
|
|
96
|
+
}, {
|
|
97
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
98
|
+
return await ApiGraphqlWitness.create(params);
|
|
99
|
+
}, "witness")
|
|
100
|
+
}), "ApiGraphqlWitnessPlugin");
|
|
88
101
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["// eslint-disable-next-line import/no-default-export\nexport { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["// eslint-disable-next-line import/no-default-export\nexport { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts'\nexport * from './Witness.ts'\n","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 { isPayloadOfSchemaType, Payload, Schema } from '@xyo-network/payload-model'\nimport { 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;;;;;;;;;;;;;ACAA,IAAAA,wBAAiC;AACjC,+BAA8C;;;ACD9C,oBAAyB;AACzB,mBAA0B;AAC1B,8BAAgC;AAEhC,2BAAuD;AAIhD,IAAMC,gCAAgC;AAuBtC,IAAMC,qBAAqB;AAW3B,IAAMC,sBAAsB;AAe5B,IAAMC,qBAAiBC,4CAAoCH,kBAAAA;AAE3D,IAAMI,oBAAN,cAAmGC,wCAAAA;EA3D1G,OA2D0GA;;;EAKxG,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeP;;EAC5E,OAAyBQ,sBAA8BR;EAEvD,IAAIS,WAAW;AACb,eAAOC,wBAAS,KAAKC,OAAOF,YAAY,KAAKG,OAAOH,UAAU,MAAM,uBAAA;EACtE;EAEA,IAAII,UAAU;AACZ,WAAO,KAAKD,OAAOC;EACrB;EAEA,IAAIC,UAAU;AACZ,WAAO,KAAKH,OAAOG;EACrB;EAEA,MAAyBC,eAAeC,UAAqD;AAC3F,UAAM,KAAKC,QAAQ,OAAA;AACnB,UAAMC,UAAUF,UAAUG,OAAOhB,cAAAA,KAAmB,CAAA;AACpD,UAAMiB,QAAQ,IAAIC,uBAAU;MAAER,SAAS,KAAKA;MAASC,SAAS,KAAKA;IAAQ,CAAA;AAC3E,UAAMQ,eAAe,MAAMC,QAAQC,IACjCN,QAAQO,IAAI,OAAO,EAAEC,OAAOC,UAAS,MAAE;AACrC,YAAMC,aAAa,MAAMR,MAAMS,KAAK,KAAKpB,UAAU;QAAEiB;QAAOC;MAAU,CAAA;AACtE,YAAMG,SAAwB;QAC5BC,MAAM;UACJC,QAAQJ,WAAWI;QACrB;QACAF,QAAQF,WAAWK;QACnBC,QAAQhC;MACV;AACA,aAAO4B;IACT,CAAA,CAAA;AAEF,WAAOR,aAAaa,KAAI;EAC1B;AACF;;;AD7FO,IAAMC,0BAA0B,iCACrCC,wDACE;EAAEC,UAAU;IAAE,CAACC,kBAAAA,GAAqB;EAAE;EAAGC,QAAQC;AAAiB,GAClE;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,kBAAkBC,OAAOF,MAAAA;EACxC,GAFS;AAGX,CAAA,GAPmC;","names":["import_payload_model","ApiGraphqlWitnessConfigSchema","GraphqlQuerySchema","GraphqlResultSchema","isGraphqlQuery","isPayloadOfSchemaType","ApiGraphqlWitness","AbstractWitness","configSchemas","defaultConfigSchema","endpoint","assertEx","config","params","headers","timeout","observeHandler","payloads","started","queries","filter","axios","AxiosJson","observations","Promise","all","map","query","variables","httpResult","post","result","http","status","data","schema","flat","ApiGraphqlWitnessPlugin","createPayloadSetWitnessPlugin","required","GraphqlQuerySchema","schema","PayloadSetSchema","witness","params","ApiGraphqlWitness","create"]}
|
package/dist/neutral/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/neutral/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/Plugin.ts
|
|
2
5
|
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
3
6
|
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
@@ -12,7 +15,13 @@ var GraphqlQuerySchema = "network.xyo.graphql.query";
|
|
|
12
15
|
var GraphqlResultSchema = "network.xyo.graphql.result";
|
|
13
16
|
var isGraphqlQuery = isPayloadOfSchemaType(GraphqlQuerySchema);
|
|
14
17
|
var ApiGraphqlWitness = class extends AbstractWitness {
|
|
15
|
-
static
|
|
18
|
+
static {
|
|
19
|
+
__name(this, "ApiGraphqlWitness");
|
|
20
|
+
}
|
|
21
|
+
static configSchemas = [
|
|
22
|
+
...super.configSchemas,
|
|
23
|
+
ApiGraphqlWitnessConfigSchema
|
|
24
|
+
];
|
|
16
25
|
static defaultConfigSchema = ApiGraphqlWitnessConfigSchema;
|
|
17
26
|
get endpoint() {
|
|
18
27
|
return assertEx(this.config.endpoint ?? this.params.endpoint, () => "No endpoint specified");
|
|
@@ -26,33 +35,39 @@ var ApiGraphqlWitness = class extends AbstractWitness {
|
|
|
26
35
|
async observeHandler(payloads) {
|
|
27
36
|
await this.started("throw");
|
|
28
37
|
const queries = payloads?.filter(isGraphqlQuery) ?? [];
|
|
29
|
-
const axios = new AxiosJson({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const axios = new AxiosJson({
|
|
39
|
+
headers: this.headers,
|
|
40
|
+
timeout: this.timeout
|
|
41
|
+
});
|
|
42
|
+
const observations = await Promise.all(queries.map(async ({ query, variables }) => {
|
|
43
|
+
const httpResult = await axios.post(this.endpoint, {
|
|
44
|
+
query,
|
|
45
|
+
variables
|
|
46
|
+
});
|
|
47
|
+
const result = {
|
|
48
|
+
http: {
|
|
49
|
+
status: httpResult.status
|
|
50
|
+
},
|
|
51
|
+
result: httpResult.data,
|
|
52
|
+
schema: GraphqlResultSchema
|
|
53
|
+
};
|
|
54
|
+
return result;
|
|
55
|
+
}));
|
|
43
56
|
return observations.flat();
|
|
44
57
|
}
|
|
45
58
|
};
|
|
46
59
|
|
|
47
60
|
// src/Plugin.ts
|
|
48
|
-
var ApiGraphqlWitnessPlugin = () => createPayloadSetWitnessPlugin(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
61
|
+
var ApiGraphqlWitnessPlugin = /* @__PURE__ */ __name(() => createPayloadSetWitnessPlugin({
|
|
62
|
+
required: {
|
|
63
|
+
[GraphqlQuerySchema]: 1
|
|
64
|
+
},
|
|
65
|
+
schema: PayloadSetSchema
|
|
66
|
+
}, {
|
|
67
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
68
|
+
return await ApiGraphqlWitness.create(params);
|
|
69
|
+
}, "witness")
|
|
70
|
+
}), "ApiGraphqlWitnessPlugin");
|
|
56
71
|
export {
|
|
57
72
|
ApiGraphqlWitness,
|
|
58
73
|
ApiGraphqlWitnessConfigSchema,
|
|
@@ -62,4 +77,4 @@ export {
|
|
|
62
77
|
ApiGraphqlWitnessPlugin as default,
|
|
63
78
|
isGraphqlQuery
|
|
64
79
|
};
|
|
65
|
-
//# sourceMappingURL=index.
|
|
80
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -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.
|
|
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 { isPayloadOfSchemaType, Payload, Schema } from '@xyo-network/payload-model'\nimport { 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,SAASA,wBAAwB;AACjC,SAASC,qCAAqC;;;ACD9C,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,uBAAuB;AAEhC,SAASC,6BAA8C;AAIhD,IAAMC,gCAAgC;AAuBtC,IAAMC,qBAAqB;AAW3B,IAAMC,sBAAsB;AAe5B,IAAMC,iBAAiBC,sBAAoCH,kBAAAA;AAE3D,IAAMI,oBAAN,cAAmGC,gBAAAA;EA3D1G,OA2D0GA;;;EAKxG,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeP;;EAC5E,OAAyBQ,sBAA8BR;EAEvD,IAAIS,WAAW;AACb,WAAOC,SAAS,KAAKC,OAAOF,YAAY,KAAKG,OAAOH,UAAU,MAAM,uBAAA;EACtE;EAEA,IAAII,UAAU;AACZ,WAAO,KAAKD,OAAOC;EACrB;EAEA,IAAIC,UAAU;AACZ,WAAO,KAAKH,OAAOG;EACrB;EAEA,MAAyBC,eAAeC,UAAqD;AAC3F,UAAM,KAAKC,QAAQ,OAAA;AACnB,UAAMC,UAAUF,UAAUG,OAAOhB,cAAAA,KAAmB,CAAA;AACpD,UAAMiB,QAAQ,IAAIC,UAAU;MAAER,SAAS,KAAKA;MAASC,SAAS,KAAKA;IAAQ,CAAA;AAC3E,UAAMQ,eAAe,MAAMC,QAAQC,IACjCN,QAAQO,IAAI,OAAO,EAAEC,OAAOC,UAAS,MAAE;AACrC,YAAMC,aAAa,MAAMR,MAAMS,KAAK,KAAKpB,UAAU;QAAEiB;QAAOC;MAAU,CAAA;AACtE,YAAMG,SAAwB;QAC5BC,MAAM;UACJC,QAAQJ,WAAWI;QACrB;QACAF,QAAQF,WAAWK;QACnBC,QAAQhC;MACV;AACA,aAAO4B;IACT,CAAA,CAAA;AAEF,WAAOR,aAAaa,KAAI;EAC1B;AACF;;;AD7FO,IAAMC,0BAA0B,6BACrCC,8BACE;EAAEC,UAAU;IAAE,CAACC,kBAAAA,GAAqB;EAAE;EAAGC,QAAQC;AAAiB,GAClE;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,kBAAkBC,OAAOF,MAAAA;EACxC,GAFS;AAGX,CAAA,GAPmC;","names":["PayloadSetSchema","createPayloadSetWitnessPlugin","assertEx","AxiosJson","AbstractWitness","isPayloadOfSchemaType","ApiGraphqlWitnessConfigSchema","GraphqlQuerySchema","GraphqlResultSchema","isGraphqlQuery","isPayloadOfSchemaType","ApiGraphqlWitness","AbstractWitness","configSchemas","defaultConfigSchema","endpoint","assertEx","config","params","headers","timeout","observeHandler","payloads","started","queries","filter","axios","AxiosJson","observations","Promise","all","map","query","variables","httpResult","post","result","http","status","data","schema","flat","ApiGraphqlWitnessPlugin","createPayloadSetWitnessPlugin","required","GraphqlQuerySchema","schema","PayloadSetSchema","witness","params","ApiGraphqlWitness","create"]}
|
package/dist/node/Plugin.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/node/Plugin.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/node/Plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiGraphqlWitness } from './Witness.
|
|
1
|
+
import { ApiGraphqlWitness } from './Witness.ts';
|
|
2
2
|
export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<ApiGraphqlWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
8
8
|
schema: "network.xyo.api.witness.config";
|
|
9
9
|
} & {
|
|
10
10
|
endpoint?: string;
|
|
11
|
-
schema: import("./Witness.
|
|
11
|
+
schema: import("./Witness.ts").ApiGraphqlWitnessConfigSchema;
|
|
12
12
|
timeout?: number;
|
|
13
13
|
}, "schema"> & {
|
|
14
14
|
schema: "network.xyo.api.witness.config";
|
|
@@ -19,6 +19,6 @@ export declare const ApiGraphqlWitnessPlugin: () => import("@xyo-network/payload
|
|
|
19
19
|
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
|
|
20
20
|
} & {
|
|
21
21
|
endpoint?: string;
|
|
22
|
-
headers?: import("./Witness.
|
|
22
|
+
headers?: import("./Witness.ts").HttpHeaders;
|
|
23
23
|
}>>;
|
|
24
24
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/dist/node/index.cjs
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __reflectGet = Reflect.get;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
10
|
var __export = (target, all) => {
|
|
7
11
|
for (var name in all)
|
|
8
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,6 +20,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
18
22
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
19
25
|
|
|
20
26
|
// src/index.ts
|
|
21
27
|
var src_exports = {};
|
|
@@ -43,9 +49,7 @@ var ApiGraphqlWitnessConfigSchema = "network.xyo.api.witness.config";
|
|
|
43
49
|
var GraphqlQuerySchema = "network.xyo.graphql.query";
|
|
44
50
|
var GraphqlResultSchema = "network.xyo.graphql.result";
|
|
45
51
|
var isGraphqlQuery = (0, import_payload_model.isPayloadOfSchemaType)(GraphqlQuerySchema);
|
|
46
|
-
var
|
|
47
|
-
static configSchemas = [...super.configSchemas, ApiGraphqlWitnessConfigSchema];
|
|
48
|
-
static defaultConfigSchema = ApiGraphqlWitnessConfigSchema;
|
|
52
|
+
var _ApiGraphqlWitness = class _ApiGraphqlWitness extends import_abstract_witness.AbstractWitness {
|
|
49
53
|
get endpoint() {
|
|
50
54
|
return (0, import_assert.assertEx)(this.config.endpoint ?? this.params.endpoint, () => "No endpoint specified");
|
|
51
55
|
}
|
|
@@ -58,33 +62,46 @@ var ApiGraphqlWitness = class extends import_abstract_witness.AbstractWitness {
|
|
|
58
62
|
async observeHandler(payloads) {
|
|
59
63
|
await this.started("throw");
|
|
60
64
|
const queries = (payloads == null ? void 0 : payloads.filter(isGraphqlQuery)) ?? [];
|
|
61
|
-
const axios = new import_axios.AxiosJson({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
const axios = new import_axios.AxiosJson({
|
|
66
|
+
headers: this.headers,
|
|
67
|
+
timeout: this.timeout
|
|
68
|
+
});
|
|
69
|
+
const observations = await Promise.all(queries.map(async ({ query, variables }) => {
|
|
70
|
+
const httpResult = await axios.post(this.endpoint, {
|
|
71
|
+
query,
|
|
72
|
+
variables
|
|
73
|
+
});
|
|
74
|
+
const result = {
|
|
75
|
+
http: {
|
|
76
|
+
status: httpResult.status
|
|
77
|
+
},
|
|
78
|
+
result: httpResult.data,
|
|
79
|
+
schema: GraphqlResultSchema
|
|
80
|
+
};
|
|
81
|
+
return result;
|
|
82
|
+
}));
|
|
75
83
|
return observations.flat();
|
|
76
84
|
}
|
|
77
85
|
};
|
|
86
|
+
__name(_ApiGraphqlWitness, "ApiGraphqlWitness");
|
|
87
|
+
__publicField(_ApiGraphqlWitness, "configSchemas", [
|
|
88
|
+
...__superGet(_ApiGraphqlWitness, _ApiGraphqlWitness, "configSchemas"),
|
|
89
|
+
ApiGraphqlWitnessConfigSchema
|
|
90
|
+
]);
|
|
91
|
+
__publicField(_ApiGraphqlWitness, "defaultConfigSchema", ApiGraphqlWitnessConfigSchema);
|
|
92
|
+
var ApiGraphqlWitness = _ApiGraphqlWitness;
|
|
78
93
|
|
|
79
94
|
// src/Plugin.ts
|
|
80
|
-
var ApiGraphqlWitnessPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
95
|
+
var ApiGraphqlWitnessPlugin = /* @__PURE__ */ __name(() => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)({
|
|
96
|
+
required: {
|
|
97
|
+
[GraphqlQuerySchema]: 1
|
|
98
|
+
},
|
|
99
|
+
schema: import_payload_model2.PayloadSetSchema
|
|
100
|
+
}, {
|
|
101
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
102
|
+
return await ApiGraphqlWitness.create(params);
|
|
103
|
+
}, "witness")
|
|
104
|
+
}), "ApiGraphqlWitnessPlugin");
|
|
88
105
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
106
|
0 && (module.exports = {
|
|
90
107
|
ApiGraphqlWitness,
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["// eslint-disable-next-line import/no-default-export\nexport { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["// eslint-disable-next-line import/no-default-export\nexport { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts'\nexport * from './Witness.ts'\n","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 { isPayloadOfSchemaType, Payload, Schema } from '@xyo-network/payload-model'\nimport { 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;;;;;;;;;;;;;ACAA,IAAAA,wBAAiC;AACjC,+BAA8C;;;ACD9C,oBAAyB;AACzB,mBAA0B;AAC1B,8BAAgC;AAEhC,2BAAuD;AAIhD,IAAMC,gCAAgC;AAuBtC,IAAMC,qBAAqB;AAW3B,IAAMC,sBAAsB;AAe5B,IAAMC,qBAAiBC,4CAAoCH,kBAAAA;AAE3D,IAAMI,qBAAN,MAAMA,2BAA6FC,wCAAAA;EAQxG,IAAIC,WAAW;AACb,eAAOC,wBAAS,KAAKC,OAAOF,YAAY,KAAKG,OAAOH,UAAU,MAAM,uBAAA;EACtE;EAEA,IAAII,UAAU;AACZ,WAAO,KAAKD,OAAOC;EACrB;EAEA,IAAIC,UAAU;AACZ,WAAO,KAAKH,OAAOG;EACrB;EAEA,MAAyBC,eAAeC,UAAqD;AAC3F,UAAM,KAAKC,QAAQ,OAAA;AACnB,UAAMC,WAAUF,qCAAUG,OAAOd,oBAAmB,CAAA;AACpD,UAAMe,QAAQ,IAAIC,uBAAU;MAAER,SAAS,KAAKA;MAASC,SAAS,KAAKA;IAAQ,CAAA;AAC3E,UAAMQ,eAAe,MAAMC,QAAQC,IACjCN,QAAQO,IAAI,OAAO,EAAEC,OAAOC,UAAS,MAAE;AACrC,YAAMC,aAAa,MAAMR,MAAMS,KAAK,KAAKpB,UAAU;QAAEiB;QAAOC;MAAU,CAAA;AACtE,YAAMG,SAAwB;QAC5BC,MAAM;UACJC,QAAQJ,WAAWI;QACrB;QACAF,QAAQF,WAAWK;QACnBC,QAAQ9B;MACV;AACA,aAAO0B;IACT,CAAA,CAAA;AAEF,WAAOR,aAAaa,KAAI;EAC1B;AACF;AAvC0G3B;AAKxG,cALWD,oBAKc6B,iBAA0B;KAAI,mDAAMA;EAAelC;;AAC5E,cANWK,oBAMc8B,uBAA8BnC;AANlD,IAAMK,oBAAN;;;ADtDA,IAAM+B,0BAA0B,iCACrCC,wDACE;EAAEC,UAAU;IAAE,CAACC,kBAAAA,GAAqB;EAAE;EAAGC,QAAQC;AAAiB,GAClE;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,kBAAkBC,OAAOF,MAAAA;EACxC,GAFS;AAGX,CAAA,GAPmC;","names":["import_payload_model","ApiGraphqlWitnessConfigSchema","GraphqlQuerySchema","GraphqlResultSchema","isGraphqlQuery","isPayloadOfSchemaType","ApiGraphqlWitness","AbstractWitness","endpoint","assertEx","config","params","headers","timeout","observeHandler","payloads","started","queries","filter","axios","AxiosJson","observations","Promise","all","map","query","variables","httpResult","post","result","http","status","data","schema","flat","configSchemas","defaultConfigSchema","ApiGraphqlWitnessPlugin","createPayloadSetWitnessPlugin","required","GraphqlQuerySchema","schema","PayloadSetSchema","witness","params","ApiGraphqlWitness","create"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
2
|
-
export * from './Witness.
|
|
1
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts';
|
|
2
|
+
export * from './Witness.ts';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
+
var __reflectGet = Reflect.get;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
8
|
+
|
|
9
|
+
// src/Plugin.ts
|
|
10
|
+
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
11
|
+
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
12
|
+
|
|
13
|
+
// src/Witness.ts
|
|
14
|
+
import { assertEx } from "@xylabs/assert";
|
|
15
|
+
import { AxiosJson } from "@xylabs/axios";
|
|
16
|
+
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
17
|
+
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
18
|
+
var ApiGraphqlWitnessConfigSchema = "network.xyo.api.witness.config";
|
|
19
|
+
var GraphqlQuerySchema = "network.xyo.graphql.query";
|
|
20
|
+
var GraphqlResultSchema = "network.xyo.graphql.result";
|
|
21
|
+
var isGraphqlQuery = isPayloadOfSchemaType(GraphqlQuerySchema);
|
|
22
|
+
var _ApiGraphqlWitness = class _ApiGraphqlWitness extends AbstractWitness {
|
|
23
|
+
get endpoint() {
|
|
24
|
+
return assertEx(this.config.endpoint ?? this.params.endpoint, () => "No endpoint specified");
|
|
25
|
+
}
|
|
26
|
+
get headers() {
|
|
27
|
+
return this.params.headers;
|
|
28
|
+
}
|
|
29
|
+
get timeout() {
|
|
30
|
+
return this.config.timeout;
|
|
31
|
+
}
|
|
32
|
+
async observeHandler(payloads) {
|
|
33
|
+
await this.started("throw");
|
|
34
|
+
const queries = (payloads == null ? void 0 : payloads.filter(isGraphqlQuery)) ?? [];
|
|
35
|
+
const axios = new AxiosJson({
|
|
36
|
+
headers: this.headers,
|
|
37
|
+
timeout: this.timeout
|
|
38
|
+
});
|
|
39
|
+
const observations = await Promise.all(queries.map(async ({ query, variables }) => {
|
|
40
|
+
const httpResult = await axios.post(this.endpoint, {
|
|
41
|
+
query,
|
|
42
|
+
variables
|
|
43
|
+
});
|
|
44
|
+
const result = {
|
|
45
|
+
http: {
|
|
46
|
+
status: httpResult.status
|
|
47
|
+
},
|
|
48
|
+
result: httpResult.data,
|
|
49
|
+
schema: GraphqlResultSchema
|
|
50
|
+
};
|
|
51
|
+
return result;
|
|
52
|
+
}));
|
|
53
|
+
return observations.flat();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__name(_ApiGraphqlWitness, "ApiGraphqlWitness");
|
|
57
|
+
__publicField(_ApiGraphqlWitness, "configSchemas", [
|
|
58
|
+
...__superGet(_ApiGraphqlWitness, _ApiGraphqlWitness, "configSchemas"),
|
|
59
|
+
ApiGraphqlWitnessConfigSchema
|
|
60
|
+
]);
|
|
61
|
+
__publicField(_ApiGraphqlWitness, "defaultConfigSchema", ApiGraphqlWitnessConfigSchema);
|
|
62
|
+
var ApiGraphqlWitness = _ApiGraphqlWitness;
|
|
63
|
+
|
|
64
|
+
// src/Plugin.ts
|
|
65
|
+
var ApiGraphqlWitnessPlugin = /* @__PURE__ */ __name(() => createPayloadSetWitnessPlugin({
|
|
66
|
+
required: {
|
|
67
|
+
[GraphqlQuerySchema]: 1
|
|
68
|
+
},
|
|
69
|
+
schema: PayloadSetSchema
|
|
70
|
+
}, {
|
|
71
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
72
|
+
return await ApiGraphqlWitness.create(params);
|
|
73
|
+
}, "witness")
|
|
74
|
+
}), "ApiGraphqlWitnessPlugin");
|
|
75
|
+
export {
|
|
76
|
+
ApiGraphqlWitness,
|
|
77
|
+
ApiGraphqlWitnessConfigSchema,
|
|
78
|
+
ApiGraphqlWitnessPlugin,
|
|
79
|
+
GraphqlQuerySchema,
|
|
80
|
+
GraphqlResultSchema,
|
|
81
|
+
ApiGraphqlWitnessPlugin as default,
|
|
82
|
+
isGraphqlQuery
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -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.
|
|
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 { isPayloadOfSchemaType, Payload, Schema } from '@xyo-network/payload-model'\nimport { 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,SAASA,wBAAwB;AACjC,SAASC,qCAAqC;;;ACD9C,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,uBAAuB;AAEhC,SAASC,6BAA8C;AAIhD,IAAMC,gCAAgC;AAuBtC,IAAMC,qBAAqB;AAW3B,IAAMC,sBAAsB;AAe5B,IAAMC,iBAAiBC,sBAAoCH,kBAAAA;AAE3D,IAAMI,qBAAN,MAAMA,2BAA6FC,gBAAAA;EAQxG,IAAIC,WAAW;AACb,WAAOC,SAAS,KAAKC,OAAOF,YAAY,KAAKG,OAAOH,UAAU,MAAM,uBAAA;EACtE;EAEA,IAAII,UAAU;AACZ,WAAO,KAAKD,OAAOC;EACrB;EAEA,IAAIC,UAAU;AACZ,WAAO,KAAKH,OAAOG;EACrB;EAEA,MAAyBC,eAAeC,UAAqD;AAC3F,UAAM,KAAKC,QAAQ,OAAA;AACnB,UAAMC,WAAUF,qCAAUG,OAAOd,oBAAmB,CAAA;AACpD,UAAMe,QAAQ,IAAIC,UAAU;MAAER,SAAS,KAAKA;MAASC,SAAS,KAAKA;IAAQ,CAAA;AAC3E,UAAMQ,eAAe,MAAMC,QAAQC,IACjCN,QAAQO,IAAI,OAAO,EAAEC,OAAOC,UAAS,MAAE;AACrC,YAAMC,aAAa,MAAMR,MAAMS,KAAK,KAAKpB,UAAU;QAAEiB;QAAOC;MAAU,CAAA;AACtE,YAAMG,SAAwB;QAC5BC,MAAM;UACJC,QAAQJ,WAAWI;QACrB;QACAF,QAAQF,WAAWK;QACnBC,QAAQ9B;MACV;AACA,aAAO0B;IACT,CAAA,CAAA;AAEF,WAAOR,aAAaa,KAAI;EAC1B;AACF;AAvC0G3B;AAKxG,cALWD,oBAKc6B,iBAA0B;KAAI,mDAAMA;EAAelC;;AAC5E,cANWK,oBAMc8B,uBAA8BnC;AANlD,IAAMK,oBAAN;;;ADtDA,IAAM+B,0BAA0B,6BACrCC,8BACE;EAAEC,UAAU;IAAE,CAACC,kBAAAA,GAAqB;EAAE;EAAGC,QAAQC;AAAiB,GAClE;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,kBAAkBC,OAAOF,MAAAA;EACxC,GAFS;AAGX,CAAA,GAPmC;","names":["PayloadSetSchema","createPayloadSetWitnessPlugin","assertEx","AxiosJson","AbstractWitness","isPayloadOfSchemaType","ApiGraphqlWitnessConfigSchema","GraphqlQuerySchema","GraphqlResultSchema","isGraphqlQuery","isPayloadOfSchemaType","ApiGraphqlWitness","AbstractWitness","endpoint","assertEx","config","params","headers","timeout","observeHandler","payloads","started","queries","filter","axios","AxiosJson","observations","Promise","all","map","query","variables","httpResult","post","result","http","status","data","schema","flat","configSchemas","defaultConfigSchema","ApiGraphqlWitnessPlugin","createPayloadSetWitnessPlugin","required","GraphqlQuerySchema","schema","PayloadSetSchema","witness","params","ApiGraphqlWitness","create"]}
|
package/package.json
CHANGED
|
@@ -10,23 +10,22 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/plugins/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.6.
|
|
14
|
-
"@xylabs/axios": "^3.6.
|
|
15
|
-
"@xyo-network/abstract-witness": "^2.
|
|
16
|
-
"@xyo-network/module-model": "^2.
|
|
17
|
-
"@xyo-network/payload-model": "^2.
|
|
18
|
-
"@xyo-network/payloadset-plugin": "^2.
|
|
19
|
-
"@xyo-network/witness-model": "^2.
|
|
13
|
+
"@xylabs/assert": "^3.6.8",
|
|
14
|
+
"@xylabs/axios": "^3.6.8",
|
|
15
|
+
"@xyo-network/abstract-witness": "^2.111.2",
|
|
16
|
+
"@xyo-network/module-model": "^2.111.2",
|
|
17
|
+
"@xyo-network/payload-model": "^2.111.2",
|
|
18
|
+
"@xyo-network/payloadset-plugin": "^2.111.2",
|
|
19
|
+
"@xyo-network/witness-model": "^2.111.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/jest-helpers": "^3.6.
|
|
23
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
24
|
-
"@xylabs/tsconfig": "^3.
|
|
25
|
-
"
|
|
26
|
-
"ethers": "^6.13.1",
|
|
22
|
+
"@xylabs/jest-helpers": "^3.6.8",
|
|
23
|
+
"@xylabs/ts-scripts-yarn3": "^3.15.13",
|
|
24
|
+
"@xylabs/tsconfig": "^3.15.13",
|
|
25
|
+
"ethers": "^6.13.2",
|
|
27
26
|
"graphql": "^16.9.0",
|
|
28
27
|
"jest": "^29.7.0",
|
|
29
|
-
"typescript": "^5.5.
|
|
28
|
+
"typescript": "^5.5.4"
|
|
30
29
|
},
|
|
31
30
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
32
31
|
"types": "dist/node/index.d.ts",
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
},
|
|
40
39
|
"import": {
|
|
41
40
|
"types": "./dist/browser/index.d.mts",
|
|
42
|
-
"default": "./dist/browser/index.
|
|
41
|
+
"default": "./dist/browser/index.mjs"
|
|
43
42
|
}
|
|
44
43
|
},
|
|
45
44
|
"node": {
|
|
@@ -49,14 +48,14 @@
|
|
|
49
48
|
},
|
|
50
49
|
"import": {
|
|
51
50
|
"types": "./dist/node/index.d.mts",
|
|
52
|
-
"default": "./dist/node/index.
|
|
51
|
+
"default": "./dist/node/index.mjs"
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
},
|
|
56
55
|
"./package.json": "./package.json"
|
|
57
56
|
},
|
|
58
57
|
"main": "dist/node/index.cjs",
|
|
59
|
-
"module": "dist/node/index.
|
|
58
|
+
"module": "dist/node/index.mjs",
|
|
60
59
|
"homepage": "https://xyo.network",
|
|
61
60
|
"license": "LGPL-3.0-only",
|
|
62
61
|
"publishConfig": {
|
|
@@ -67,6 +66,6 @@
|
|
|
67
66
|
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
68
67
|
},
|
|
69
68
|
"sideEffects": false,
|
|
70
|
-
"version": "2.99.
|
|
69
|
+
"version": "2.99.5",
|
|
71
70
|
"type": "module"
|
|
72
71
|
}
|
package/src/Plugin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PayloadSetSchema } from '@xyo-network/payload-model'
|
|
2
2
|
import { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'
|
|
3
3
|
|
|
4
|
-
import { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.
|
|
4
|
+
import { ApiGraphqlWitness, GraphqlQuerySchema } from './Witness.ts'
|
|
5
5
|
|
|
6
6
|
export const ApiGraphqlWitnessPlugin = () =>
|
|
7
7
|
createPayloadSetWitnessPlugin<ApiGraphqlWitness>(
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-default-export
|
|
2
|
-
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.
|
|
3
|
-
export * from './Witness.
|
|
2
|
+
export { ApiGraphqlWitnessPlugin, ApiGraphqlWitnessPlugin as default } from './Plugin.ts'
|
|
3
|
+
export * from './Witness.ts'
|
package/dist/node/index.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// src/Plugin.ts
|
|
2
|
-
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
3
|
-
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
4
|
-
|
|
5
|
-
// src/Witness.ts
|
|
6
|
-
import { assertEx } from "@xylabs/assert";
|
|
7
|
-
import { AxiosJson } from "@xylabs/axios";
|
|
8
|
-
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
9
|
-
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
10
|
-
var ApiGraphqlWitnessConfigSchema = "network.xyo.api.witness.config";
|
|
11
|
-
var GraphqlQuerySchema = "network.xyo.graphql.query";
|
|
12
|
-
var GraphqlResultSchema = "network.xyo.graphql.result";
|
|
13
|
-
var isGraphqlQuery = isPayloadOfSchemaType(GraphqlQuerySchema);
|
|
14
|
-
var ApiGraphqlWitness = class extends AbstractWitness {
|
|
15
|
-
static configSchemas = [...super.configSchemas, ApiGraphqlWitnessConfigSchema];
|
|
16
|
-
static defaultConfigSchema = ApiGraphqlWitnessConfigSchema;
|
|
17
|
-
get endpoint() {
|
|
18
|
-
return assertEx(this.config.endpoint ?? this.params.endpoint, () => "No endpoint specified");
|
|
19
|
-
}
|
|
20
|
-
get headers() {
|
|
21
|
-
return this.params.headers;
|
|
22
|
-
}
|
|
23
|
-
get timeout() {
|
|
24
|
-
return this.config.timeout;
|
|
25
|
-
}
|
|
26
|
-
async observeHandler(payloads) {
|
|
27
|
-
await this.started("throw");
|
|
28
|
-
const queries = (payloads == null ? void 0 : payloads.filter(isGraphqlQuery)) ?? [];
|
|
29
|
-
const axios = new AxiosJson({ headers: this.headers, timeout: this.timeout });
|
|
30
|
-
const observations = await Promise.all(
|
|
31
|
-
queries.map(async ({ query, variables }) => {
|
|
32
|
-
const httpResult = await axios.post(this.endpoint, { query, variables });
|
|
33
|
-
const result = {
|
|
34
|
-
http: {
|
|
35
|
-
status: httpResult.status
|
|
36
|
-
},
|
|
37
|
-
result: httpResult.data,
|
|
38
|
-
schema: GraphqlResultSchema
|
|
39
|
-
};
|
|
40
|
-
return result;
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
return observations.flat();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// src/Plugin.ts
|
|
48
|
-
var ApiGraphqlWitnessPlugin = () => createPayloadSetWitnessPlugin(
|
|
49
|
-
{ required: { [GraphqlQuerySchema]: 1 }, schema: PayloadSetSchema },
|
|
50
|
-
{
|
|
51
|
-
witness: async (params) => {
|
|
52
|
-
return await ApiGraphqlWitness.create(params);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
export {
|
|
57
|
-
ApiGraphqlWitness,
|
|
58
|
-
ApiGraphqlWitnessConfigSchema,
|
|
59
|
-
ApiGraphqlWitnessPlugin,
|
|
60
|
-
GraphqlQuerySchema,
|
|
61
|
-
GraphqlResultSchema,
|
|
62
|
-
ApiGraphqlWitnessPlugin as default,
|
|
63
|
-
isGraphqlQuery
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=index.js.map
|