@unchainedshop/api 4.8.10 → 4.8.12

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.
@@ -0,0 +1,9 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ import type { Enrollment } from '@unchainedshop/core-enrollments';
3
+ import DataLoader from 'dataloader';
4
+ declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
5
+ orderId: string;
6
+ }, Enrollment | null, {
7
+ orderId: string;
8
+ }>;
9
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import DataLoader from 'dataloader';
2
+ export default (unchainedAPI) => new DataLoader(async (queries) => {
3
+ const orderIds = [...new Set(queries.map((q) => q.orderId).filter(Boolean))];
4
+ const requestedOrderIds = new Set(orderIds);
5
+ const enrollments = await unchainedAPI.modules.enrollments.findEnrollmentsByOrderIds({
6
+ orderIds,
7
+ });
8
+ const enrollmentMap = {};
9
+ for (const enrollment of enrollments) {
10
+ for (const period of enrollment.periods || []) {
11
+ if (period.orderId && requestedOrderIds.has(period.orderId) && !enrollmentMap[period.orderId]) {
12
+ enrollmentMap[period.orderId] = enrollment;
13
+ }
14
+ }
15
+ }
16
+ return queries.map((q) => enrollmentMap[q.orderId] ?? null);
17
+ });
@@ -166,6 +166,31 @@ declare const loaders: (unchainedAPI: UnchainedCore) => {
166
166
  }, import("@unchainedshop/core-orders").Order, {
167
167
  orderId: string;
168
168
  }>;
169
+ orderPaymentLoader: import("dataloader")<{
170
+ orderPaymentId: string;
171
+ }, import("@unchainedshop/core-orders").OrderPayment | null, {
172
+ orderPaymentId: string;
173
+ }>;
174
+ orderDeliveryLoader: import("dataloader")<{
175
+ orderDeliveryId: string;
176
+ }, import("@unchainedshop/core-orders").OrderDelivery | null, {
177
+ orderDeliveryId: string;
178
+ }>;
179
+ orderPositionsLoader: import("dataloader")<{
180
+ orderId: string;
181
+ }, import("@unchainedshop/core-orders").OrderPosition[], {
182
+ orderId: string;
183
+ }>;
184
+ orderDiscountsLoader: import("dataloader")<{
185
+ orderId: string;
186
+ }, import("@unchainedshop/core-orders").OrderDiscount[], {
187
+ orderId: string;
188
+ }>;
189
+ enrollmentByOrderLoader: import("dataloader")<{
190
+ orderId: string;
191
+ }, import("@unchainedshop/core-enrollments").Enrollment | null, {
192
+ orderId: string;
193
+ }>;
169
194
  quotationLoader: import("dataloader")<{
170
195
  quotationId: string;
171
196
  }, import("@unchainedshop/core-quotations").Quotation | null, {
@@ -26,6 +26,11 @@ import deliveryProviderLoader from "./deliveryProviderLoader.js";
26
26
  import paymentProviderLoader from "./paymentProviderLoader.js";
27
27
  import warehousingProviderLoader from "./warehousingProviderLoader.js";
28
28
  import orderLoader from "./orderLoader.js";
29
+ import orderPaymentLoader from "./orderPaymentLoader.js";
30
+ import orderDeliveryLoader from "./orderDeliveryLoader.js";
31
+ import orderPositionsLoader from "./orderPositionsLoader.js";
32
+ import orderDiscountsLoader from "./orderDiscountsLoader.js";
33
+ import enrollmentByOrderLoader from "./enrollmentByOrderLoader.js";
29
34
  import quotationLoader from "./quotationLoader.js";
30
35
  import tokenExportStatusLoader from "./tokenExportStatusLoader.js";
31
36
  const loaders = (unchainedAPI) => {
@@ -58,6 +63,11 @@ const loaders = (unchainedAPI) => {
58
63
  paymentProviderLoader: paymentProviderLoader(unchainedAPI),
59
64
  warehousingProviderLoader: warehousingProviderLoader(unchainedAPI),
60
65
  orderLoader: orderLoader(unchainedAPI),
66
+ orderPaymentLoader: orderPaymentLoader(unchainedAPI),
67
+ orderDeliveryLoader: orderDeliveryLoader(unchainedAPI),
68
+ orderPositionsLoader: orderPositionsLoader(unchainedAPI),
69
+ orderDiscountsLoader: orderDiscountsLoader(unchainedAPI),
70
+ enrollmentByOrderLoader: enrollmentByOrderLoader(unchainedAPI),
61
71
  quotationLoader: quotationLoader(unchainedAPI),
62
72
  tokenExportStatusLoader: tokenExportStatusLoader(unchainedAPI),
63
73
  };
@@ -0,0 +1,9 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ import type { OrderDelivery } from '@unchainedshop/core-orders';
3
+ import DataLoader from 'dataloader';
4
+ declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
5
+ orderDeliveryId: string;
6
+ }, OrderDelivery | null, {
7
+ orderDeliveryId: string;
8
+ }>;
9
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import DataLoader from 'dataloader';
2
+ export default (unchainedAPI) => new DataLoader(async (queries) => {
3
+ const orderDeliveryIds = [...new Set(queries.map((q) => q.orderDeliveryId).filter(Boolean))];
4
+ const deliveries = await unchainedAPI.modules.orders.deliveries.findDeliveries({
5
+ orderDeliveryIds,
6
+ });
7
+ const deliveryMap = {};
8
+ for (const delivery of deliveries) {
9
+ deliveryMap[delivery._id] = delivery;
10
+ }
11
+ return queries.map((q) => deliveryMap[q.orderDeliveryId] ?? null);
12
+ });
@@ -0,0 +1,9 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ import type { OrderDiscount } from '@unchainedshop/core-orders';
3
+ import DataLoader from 'dataloader';
4
+ declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
5
+ orderId: string;
6
+ }, OrderDiscount[], {
7
+ orderId: string;
8
+ }>;
9
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import DataLoader from 'dataloader';
2
+ export default (unchainedAPI) => new DataLoader(async (queries) => {
3
+ const orderIds = [...new Set(queries.map((q) => q.orderId).filter(Boolean))];
4
+ const discounts = await unchainedAPI.modules.orders.discounts.findOrderDiscounts({
5
+ orderIds,
6
+ });
7
+ const discountsMap = {};
8
+ for (const discount of discounts) {
9
+ if (!discountsMap[discount.orderId]) {
10
+ discountsMap[discount.orderId] = [discount];
11
+ }
12
+ else {
13
+ discountsMap[discount.orderId].push(discount);
14
+ }
15
+ }
16
+ return queries.map((q) => discountsMap[q.orderId] || []);
17
+ });
@@ -0,0 +1,9 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ import type { OrderPayment } from '@unchainedshop/core-orders';
3
+ import DataLoader from 'dataloader';
4
+ declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
5
+ orderPaymentId: string;
6
+ }, OrderPayment | null, {
7
+ orderPaymentId: string;
8
+ }>;
9
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import DataLoader from 'dataloader';
2
+ export default (unchainedAPI) => new DataLoader(async (queries) => {
3
+ const orderPaymentIds = [...new Set(queries.map((q) => q.orderPaymentId).filter(Boolean))];
4
+ const payments = await unchainedAPI.modules.orders.payments.findOrderPayments({
5
+ orderPaymentIds,
6
+ });
7
+ const paymentMap = {};
8
+ for (const payment of payments) {
9
+ paymentMap[payment._id] = payment;
10
+ }
11
+ return queries.map((q) => paymentMap[q.orderPaymentId] ?? null);
12
+ });
@@ -0,0 +1,9 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ import type { OrderPosition } from '@unchainedshop/core-orders';
3
+ import DataLoader from 'dataloader';
4
+ declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
5
+ orderId: string;
6
+ }, OrderPosition[], {
7
+ orderId: string;
8
+ }>;
9
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import DataLoader from 'dataloader';
2
+ export default (unchainedAPI) => new DataLoader(async (queries) => {
3
+ const orderIds = [...new Set(queries.map((q) => q.orderId).filter(Boolean))];
4
+ const positions = await unchainedAPI.modules.orders.positions.findOrderPositions({
5
+ orderIds,
6
+ });
7
+ const positionsMap = {};
8
+ for (const position of positions) {
9
+ if (!positionsMap[position.orderId]) {
10
+ positionsMap[position.orderId] = [position];
11
+ }
12
+ else {
13
+ positionsMap[position.orderId].push(position);
14
+ }
15
+ }
16
+ return queries.map((q) => positionsMap[q.orderId] || []);
17
+ });
@@ -305,11 +305,11 @@ declare const types: {
305
305
  supportedPaymentProviders(order: import("@unchainedshop/core-orders").Order, _: any, context: import("../../context.ts").Context): Promise<import("@unchainedshop/core-payment").PaymentProvider[]>;
306
306
  currency(order: import("@unchainedshop/core-orders").Order, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-currencies").Currency>;
307
307
  country(order: import("@unchainedshop/core-orders").Order, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-countries").Country>;
308
- discounts(order: import("@unchainedshop/core-orders").Order, _: any, { modules }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderDiscount[]>;
309
- delivery(order: import("@unchainedshop/core-orders").Order, _: any, { modules }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderDelivery | null>;
310
- enrollment(order: import("@unchainedshop/core-orders").Order, _: any, { modules }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-enrollments").Enrollment | null>;
311
- items(order: import("@unchainedshop/core-orders").Order, _: any, { modules }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderPosition[]>;
312
- payment(order: import("@unchainedshop/core-orders").Order, _: any, { modules }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderPayment | null>;
308
+ discounts(order: import("@unchainedshop/core-orders").Order, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderDiscount[]>;
309
+ delivery(order: import("@unchainedshop/core-orders").Order, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderDelivery | null>;
310
+ enrollment(order: import("@unchainedshop/core-orders").Order, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-enrollments").Enrollment | null>;
311
+ items(order: import("@unchainedshop/core-orders").Order, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderPosition[]>;
312
+ payment(order: import("@unchainedshop/core-orders").Order, _: any, { loaders }: import("../../context.ts").Context): Promise<import("@unchainedshop/core-orders").OrderPayment | null>;
313
313
  status(order: import("@unchainedshop/core-orders").Order): string;
314
314
  total(order: import("@unchainedshop/core-orders").Order, params: {
315
315
  category: string;
@@ -11,11 +11,11 @@ export declare const Order: {
11
11
  supportedPaymentProviders(order: OrderType, _: any, context: Context): Promise<import("@unchainedshop/core-payment").PaymentProvider[]>;
12
12
  currency(order: OrderType, _: any, { loaders }: Context): Promise<Currency>;
13
13
  country(order: OrderType, _: any, { loaders }: Context): Promise<Country>;
14
- discounts(order: OrderType, _: any, { modules }: Context): Promise<OrderDiscount[]>;
15
- delivery(order: OrderType, _: any, { modules }: Context): Promise<OrderDelivery | null>;
16
- enrollment(order: OrderType, _: any, { modules }: Context): Promise<Enrollment | null>;
17
- items(order: OrderType, _: any, { modules }: Context): Promise<OrderPosition[]>;
18
- payment(order: OrderType, _: any, { modules }: Context): Promise<OrderPayment | null>;
14
+ discounts(order: OrderType, _: any, { loaders }: Context): Promise<OrderDiscount[]>;
15
+ delivery(order: OrderType, _: any, { loaders }: Context): Promise<OrderDelivery | null>;
16
+ enrollment(order: OrderType, _: any, { loaders }: Context): Promise<Enrollment | null>;
17
+ items(order: OrderType, _: any, { loaders }: Context): Promise<OrderPosition[]>;
18
+ payment(order: OrderType, _: any, { loaders }: Context): Promise<OrderPayment | null>;
19
19
  status(order: OrderType): string;
20
20
  total(order: OrderType, params: {
21
21
  category: string;
@@ -16,39 +16,24 @@ export const Order = {
16
16
  async country(order, _, { loaders }) {
17
17
  return loaders.countryLoader.load({ isoCode: order.countryCode });
18
18
  },
19
- async discounts(order, _, { modules }) {
20
- return modules.orders.discounts.findOrderDiscounts({ orderId: order._id });
19
+ async discounts(order, _, { loaders }) {
20
+ return loaders.orderDiscountsLoader.load({ orderId: order._id });
21
21
  },
22
- async delivery(order, _, { modules }) {
23
- const orderDelivery = order.deliveryId &&
24
- (await modules.orders.deliveries.findDelivery({
25
- orderDeliveryId: order.deliveryId,
26
- }));
27
- if (!orderDelivery)
22
+ async delivery(order, _, { loaders }) {
23
+ if (!order.deliveryId)
28
24
  return null;
29
- return orderDelivery;
25
+ return loaders.orderDeliveryLoader.load({ orderDeliveryId: order.deliveryId });
30
26
  },
31
- async enrollment(order, _, { modules }) {
32
- const enrollment = await modules.enrollments.findEnrollment({
33
- orderId: order._id,
34
- });
35
- if (!enrollment)
36
- return null;
37
- return enrollment;
27
+ async enrollment(order, _, { loaders }) {
28
+ return loaders.enrollmentByOrderLoader.load({ orderId: order._id });
38
29
  },
39
- async items(order, _, { modules }) {
40
- return modules.orders.positions.findOrderPositions({
41
- orderId: order._id,
42
- });
30
+ async items(order, _, { loaders }) {
31
+ return loaders.orderPositionsLoader.load({ orderId: order._id });
43
32
  },
44
- async payment(order, _, { modules }) {
45
- const payment = order.paymentId &&
46
- (await modules.orders.payments.findOrderPayment({
47
- orderPaymentId: order.paymentId,
48
- }));
49
- if (!payment)
33
+ async payment(order, _, { loaders }) {
34
+ if (!order.paymentId)
50
35
  return null;
51
- return payment;
36
+ return loaders.orderPaymentLoader.load({ orderPaymentId: order.paymentId });
52
37
  },
53
38
  status(order) {
54
39
  if (order.status === null) {
@@ -20,7 +20,7 @@ export interface PushSubscription {
20
20
  }
21
21
  export interface Web3Address {
22
22
  address: string;
23
- nonce?: number;
23
+ nonce?: string;
24
24
  verified: boolean;
25
25
  }
26
26
  export interface WebAuthnCredentials {
@@ -82,7 +82,7 @@ export default [
82
82
 
83
83
  type Web3Address {
84
84
  address: String!
85
- nonce: Int
85
+ nonce: String
86
86
  verified: Boolean!
87
87
  }
88
88
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/api",
3
3
  "description": "GraphQL API layer for the Unchained Engine with Express/Fastify adapters and MCP server",
4
- "version": "4.8.10",
4
+ "version": "4.8.12",
5
5
  "main": "lib/api-index.js",
6
6
  "types": "lib/api-index.d.ts",
7
7
  "type": "module",
@@ -62,7 +62,7 @@
62
62
  "peerDependencies": {
63
63
  "@ai-sdk/mcp": "^1",
64
64
  "@fastify/cookie": ">= 11 < 12",
65
- "@fastify/multipart": ">= 9 < 10",
65
+ "@fastify/multipart": ">= 9 < 11",
66
66
  "@fastify/session": ">= 11 < 12",
67
67
  "@fastify/static": ">= 9 < 10",
68
68
  "@modelcontextprotocol/sdk": ">= 1 < 2",
@@ -131,7 +131,7 @@
131
131
  "devDependencies": {
132
132
  "@ai-sdk/mcp": "^1.0.5",
133
133
  "@fastify/cookie": "^11.0.2",
134
- "@fastify/multipart": "^9.0.3",
134
+ "@fastify/multipart": "^10.0.0",
135
135
  "@fastify/session": "^11.1.0",
136
136
  "@fastify/static": "^9.0.0",
137
137
  "@modelcontextprotocol/sdk": "^1.15.1",