@dokamerce/web-sdk 0.9.0 → 0.9.1
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/README.md +61 -19
- package/package.json +16 -4
- package/.ls-lint.yml +0 -8
- package/.nvmrc +0 -1
- package/.prettierignore +0 -0
- package/.prettierrc.js +0 -3
- package/codegen.yml +0 -11
- package/src/constants/graphql-base.constant.ts +0 -1
- package/src/contexts/index.ts +0 -33
- package/src/functions/init-sdk-client.function.ts +0 -19
- package/src/functions/init-sdk.function.ts +0 -26
- package/src/functions/safe-call.function.ts +0 -29
- package/src/index.d.ts +0 -0
- package/src/index.ts +0 -74
- package/src/services/attributes.ts +0 -42
- package/src/services/brands.ts +0 -41
- package/src/services/categories.ts +0 -41
- package/src/services/colors.ts +0 -41
- package/src/services/customers.ts +0 -60
- package/src/services/files.ts +0 -58
- package/src/services/index.ts +0 -9
- package/src/services/metrics.ts +0 -39
- package/src/services/orders.ts +0 -59
- package/src/services/products.ts +0 -65
- package/src/services/sellers.ts +0 -91
- package/src/typings/pagination.typing.ts +0 -18
- package/src/typings/sdk.typing.ts +0 -27
- package/src/utils/fetch-all-infinite.util.ts +0 -41
- package/tsconfig.dev.json +0 -32
- package/tsconfig.json +0 -37
package/README.md
CHANGED
|
@@ -1,47 +1,89 @@
|
|
|
1
|
+
# @dokamerce/web-sdk
|
|
2
|
+
|
|
3
|
+
A lightweight, TypeScript‑ready SDK for interacting with Dokamerce GraphQL APIs.
|
|
4
|
+
It provides a simple, intuitive interface for creating, updating, listing, and deleting products, with built‑in support for pagination and infinite fetching.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🚀 Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @dokamerce/web-sdk graphql graphql-request
|
|
12
|
+
# or
|
|
13
|
+
yarn add @dokamerce/web-sdk graphql graphql-request
|
|
14
|
+
|
|
15
|
+
📦 Features
|
|
16
|
+
🔗 Easy GraphQL client integration
|
|
17
|
+
|
|
18
|
+
🛍️ Product CRUD operations (create, update, delete)
|
|
19
|
+
|
|
20
|
+
📑 Pagination and infinite fetch helpers
|
|
21
|
+
|
|
22
|
+
✅ TypeScript definitions included
|
|
23
|
+
|
|
24
|
+
⚡ Lightweight and modular
|
|
25
|
+
🛠 Usage Example
|
|
26
|
+
ts
|
|
1
27
|
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import { createProductsSdk } from "
|
|
28
|
+
import { createProductsSdk } from "@dokamerce/web-sdk";
|
|
3
29
|
|
|
4
30
|
async function main() {
|
|
5
|
-
// 1️⃣ Initialize GraphQL client
|
|
6
31
|
const client = new GraphQLClient("https://api.example.com/graphql", {
|
|
7
|
-
headers: {
|
|
8
|
-
Authorization: `Bearer YOUR_API_TOKEN`,
|
|
9
|
-
},
|
|
32
|
+
headers: { Authorization: `Bearer YOUR_API_TOKEN` },
|
|
10
33
|
});
|
|
11
34
|
|
|
12
|
-
// 2️⃣ Create the Products SDK
|
|
13
35
|
const productsSdk = createProductsSdk(client);
|
|
14
36
|
|
|
15
|
-
// 3️⃣ Create a new product
|
|
16
37
|
const newProduct = await productsSdk.create({
|
|
17
|
-
input: {
|
|
18
|
-
name: "Sample Product",
|
|
19
|
-
price: 19.99,
|
|
20
|
-
description: "This is a sample product",
|
|
21
|
-
},
|
|
38
|
+
input: { name: "Sample Product", price: 19.99, description: "This is a sample product" },
|
|
22
39
|
});
|
|
23
40
|
console.log("Created Product:", newProduct.createProduct);
|
|
24
41
|
|
|
25
|
-
// 4️⃣ Update the product
|
|
26
42
|
const updatedProduct = await productsSdk.update({
|
|
27
43
|
id: newProduct.createProduct.id,
|
|
28
|
-
input: {
|
|
29
|
-
price: 24.99,
|
|
30
|
-
},
|
|
44
|
+
input: { price: 24.99 },
|
|
31
45
|
});
|
|
32
46
|
console.log("Updated Product Price:", updatedProduct.updateProduct.price);
|
|
33
47
|
|
|
34
|
-
// 5️⃣ Fetch products (paginated)
|
|
35
48
|
const paginated = await productsSdk.list({ page: 1, limit: 10 });
|
|
36
49
|
console.log("Paginated Products:", paginated.paginatedProducts.items);
|
|
37
50
|
|
|
38
|
-
// 6️⃣ Fetch products (infinite)
|
|
39
51
|
const allProducts = await productsSdk.fetchAll({ cursor: null, limit: 5 });
|
|
40
52
|
console.log("All Products via Infinite Fetch:", allProducts);
|
|
41
53
|
|
|
42
|
-
// 7️⃣ Delete the product
|
|
43
54
|
await productsSdk.delete({ id: newProduct.createProduct.id });
|
|
44
55
|
console.log("Product deleted!");
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
main().catch(console.error);
|
|
59
|
+
📖 API Reference
|
|
60
|
+
createProductsSdk(client: GraphQLClient)
|
|
61
|
+
Initializes the SDK with a GraphQL client.
|
|
62
|
+
|
|
63
|
+
Methods
|
|
64
|
+
create({ input }) → Creates a new product.
|
|
65
|
+
|
|
66
|
+
update({ id, input }) → Updates an existing product.
|
|
67
|
+
|
|
68
|
+
list({ page, limit }) → Fetches products with pagination.
|
|
69
|
+
|
|
70
|
+
fetchAll({ cursor, limit }) → Fetches products using infinite scrolling.
|
|
71
|
+
|
|
72
|
+
delete({ id }) → Deletes a product by ID.
|
|
73
|
+
|
|
74
|
+
🧩 Requirements
|
|
75
|
+
Node.js ≥ 16
|
|
76
|
+
|
|
77
|
+
GraphQL API endpoint
|
|
78
|
+
|
|
79
|
+
Valid API token
|
|
80
|
+
|
|
81
|
+
📜 License
|
|
82
|
+
MIT © Dokamerce
|
|
83
|
+
🤝 Contributing
|
|
84
|
+
Contributions, issues, and feature requests are welcome!
|
|
85
|
+
Feel free to open a PR or start a discussion in the GitHub repository.
|
|
86
|
+
|
|
87
|
+
Code
|
|
88
|
+
|
|
89
|
+
I’ll now prepare this as a **downloadable `README.md` file card** so you can grab it direc
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dokamerce/web-sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
7
17
|
"scripts": {
|
|
8
18
|
"build": "rimraf dist && tsc",
|
|
9
19
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
@@ -13,7 +23,9 @@
|
|
|
13
23
|
},
|
|
14
24
|
"dependencies": {
|
|
15
25
|
"graphql": "^16.12.0",
|
|
16
|
-
"graphql-request": "^7.2.0"
|
|
26
|
+
"graphql-request": "^7.2.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
17
29
|
"rimraf": "^6.1.2",
|
|
18
30
|
"typescript": "^5.9.2"
|
|
19
31
|
}
|
package/.ls-lint.yml
DELETED
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v22.13.1
|
package/.prettierignore
DELETED
|
File without changes
|
package/.prettierrc.js
DELETED
package/codegen.yml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
schema: "https://api.example.com/graphql"
|
|
2
|
-
documents: "src/queries/**/*.graphql"
|
|
3
|
-
generates:
|
|
4
|
-
src/types/graphql.ts:
|
|
5
|
-
plugins:
|
|
6
|
-
- "typescript"
|
|
7
|
-
- "typescript-operations"
|
|
8
|
-
- "typescript-graphql-request"
|
|
9
|
-
config:
|
|
10
|
-
rawRequest: false
|
|
11
|
-
useTypeImports: true
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const GRAPHQL_BASE_URL = ""
|
package/src/contexts/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
|
|
3
|
-
type SDKStatus = "unknown" | "ready" | "initializing" | "change" | "fails"
|
|
4
|
-
|
|
5
|
-
interface ContextInterface {
|
|
6
|
-
status: SDKStatus;
|
|
7
|
-
client: GraphQLClient | undefined | null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const _context: ContextInterface = {
|
|
11
|
-
status: "unknown",
|
|
12
|
-
client: null,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function setSdkClient(client: GraphQLClient) {
|
|
16
|
-
if (!_context.client) {
|
|
17
|
-
_context.client = client;
|
|
18
|
-
}
|
|
19
|
-
return _context.client;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getSdkClient(): GraphQLClient {
|
|
23
|
-
if (!_context.client) throw new Error("ou must initialize first");
|
|
24
|
-
return _context.client;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function setSdkStatus(status: SDKStatus) {
|
|
28
|
-
_context.status = status;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function getSdkStatus(): SDKStatus {
|
|
32
|
-
return _context.status;
|
|
33
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { setSdkClient } from "../contexts";
|
|
2
|
-
import { GraphQLClient } from "graphql-request";
|
|
3
|
-
|
|
4
|
-
interface InitSdkClientArgs {
|
|
5
|
-
base: string;
|
|
6
|
-
realm: string;
|
|
7
|
-
key: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function initSdkClient({ base, realm, key }: InitSdkClientArgs) {
|
|
11
|
-
const client = new GraphQLClient(`${base}`, {
|
|
12
|
-
headers: {
|
|
13
|
-
"x-realm-key": realm,
|
|
14
|
-
"x-api-token": key,
|
|
15
|
-
"x-origin": "sdk",
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
setSdkClient(client);
|
|
19
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getSdkStatus, setSdkStatus } from "../contexts";
|
|
2
|
-
import { initSdkClient } from "./init-sdk-client.function";
|
|
3
|
-
import { GRAPHQL_BASE_URL } from "../constants/graphql-base.constant";
|
|
4
|
-
|
|
5
|
-
interface InitSdkArgs {
|
|
6
|
-
realm: string;
|
|
7
|
-
key: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function initSdk({ realm, key }: InitSdkArgs) {
|
|
11
|
-
try {
|
|
12
|
-
if (getSdkStatus() !== "unknown") return;
|
|
13
|
-
setSdkStatus("initializing");
|
|
14
|
-
|
|
15
|
-
initSdkClient({
|
|
16
|
-
base: GRAPHQL_BASE_URL,
|
|
17
|
-
key,
|
|
18
|
-
realm,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
setSdkStatus("ready");
|
|
22
|
-
|
|
23
|
-
} catch (error) {
|
|
24
|
-
setSdkStatus("fails");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export type SDKError = {
|
|
2
|
-
code: string;
|
|
3
|
-
message: string;
|
|
4
|
-
details?: any;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export async function safeCall<T>({
|
|
8
|
-
fn,
|
|
9
|
-
onError,
|
|
10
|
-
}: {
|
|
11
|
-
fn: () => Promise<T> | T;
|
|
12
|
-
onError?: (error: SDKError) => void;
|
|
13
|
-
}): Promise<T | null> {
|
|
14
|
-
try {
|
|
15
|
-
return await fn();
|
|
16
|
-
} catch (err: unknown) {
|
|
17
|
-
// Normalize the error to SDKError
|
|
18
|
-
const sdkError: SDKError = {
|
|
19
|
-
code: (err as any)?.code || "UNKNOWN_ERROR",
|
|
20
|
-
message: (err as any)?.message || String(err),
|
|
21
|
-
details: (err as any)?.details,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
if (onError) onError(sdkError);
|
|
25
|
-
else console.error("SDK Error:", sdkError);
|
|
26
|
-
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
package/src/index.d.ts
DELETED
|
File without changes
|
package/src/index.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dokamerce SDK Factory
|
|
3
|
-
*
|
|
4
|
-
* TODOs:
|
|
5
|
-
* [ ] Logger: implement structured logging for all SDK operations
|
|
6
|
-
* [ ] Cache Layer: add caching for queries (LRU / Redis / in-memory)
|
|
7
|
-
* [ ] Pagination & Helpers: add helpers for paginated & infinite queries
|
|
8
|
-
* [ ] Batch Requests: support batching multiple requests in a single call
|
|
9
|
-
* [ ] Subscriptions (Realtime): implement realtime updates via WebSockets / GraphQL subscriptions
|
|
10
|
-
* [ ] Docs & Examples: write usage documentation and code examples
|
|
11
|
-
* [ ] Testing & Mocking: add unit tests, integration tests, and mocks for SDK
|
|
12
|
-
* [ ] Rate Limiting / Retry: implement retry with exponential backoff on errors
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { initSdk } from "./functions/init-sdk.function";
|
|
16
|
-
import { safeCall, SDKError } from "./functions/safe-call.function";
|
|
17
|
-
// import { ShopSDK } from "./typings/sdk.typing";
|
|
18
|
-
import { createProductsSdk } from "./services/products";
|
|
19
|
-
import { getSdkClient } from "./contexts";
|
|
20
|
-
import { createSellersSdk, createColorsSdk, createFileUploadSdk, createCategoriesSdk, createBrandsSdk, createAttributesSdk, createCustomersSdk, createOrdersSdk } from "./services";
|
|
21
|
-
import { createMetricsSdk } from "./services/metrics";
|
|
22
|
-
import { DokamerceSDK } from "./typings/sdk.typing";
|
|
23
|
-
|
|
24
|
-
export type SDKOptions = {
|
|
25
|
-
realm: string;
|
|
26
|
-
key: string;
|
|
27
|
-
onError?: (error: SDKError) => void;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates a Dokamerce SDK instance.
|
|
32
|
-
*
|
|
33
|
-
* Current Status:
|
|
34
|
-
* ✅ Initialization with realm/key via initSdk
|
|
35
|
-
* ✅ Safe error handling with safeCall
|
|
36
|
-
* ⚠️ Client retrieval uses getSdkClient (may need refactor for backend safety)
|
|
37
|
-
* ✅ Products SDK attached
|
|
38
|
-
*
|
|
39
|
-
* TODO Improvements:
|
|
40
|
-
* - Ensure backend safety by creating per-instance GraphQLClient instead of relying on global context
|
|
41
|
-
* - Wrap all SDK methods with safeCall automatically
|
|
42
|
-
*/
|
|
43
|
-
export function createInstance(options: SDKOptions): DokamerceSDK {
|
|
44
|
-
// 1️⃣ Initialize SDK safely
|
|
45
|
-
safeCall({
|
|
46
|
-
fn: () =>
|
|
47
|
-
initSdk({
|
|
48
|
-
realm: options.realm,
|
|
49
|
-
key: options.key,
|
|
50
|
-
}),
|
|
51
|
-
onError: options.onError,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// 2️⃣ Retrieve GraphQL client (currently from global context)
|
|
55
|
-
const client = getSdkClient();
|
|
56
|
-
|
|
57
|
-
if (!client) {
|
|
58
|
-
throw new Error("Failed to initialize client");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 3️⃣ Return SDK instance
|
|
62
|
-
return {
|
|
63
|
-
products: createProductsSdk(client),
|
|
64
|
-
sellers: createSellersSdk(client),
|
|
65
|
-
colors: createColorsSdk(client),
|
|
66
|
-
files: createFileUploadSdk(client),
|
|
67
|
-
categories: createCategoriesSdk(client),
|
|
68
|
-
brands: createBrandsSdk(client),
|
|
69
|
-
attributes: createAttributesSdk(client),
|
|
70
|
-
customers: createCustomersSdk(client),
|
|
71
|
-
orders: createOrdersSdk(client),
|
|
72
|
-
metrics: createMetricsSdk(client),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
PaginatedAttributesDocument,
|
|
4
|
-
PaginatedAttributesQuery,
|
|
5
|
-
PaginatedAttributesQueryVariables,
|
|
6
|
-
InfiniteAttributesDocument,
|
|
7
|
-
InfiniteAttributesQuery,
|
|
8
|
-
InfiniteAttributesQueryVariables,
|
|
9
|
-
} from "@dokamerce/graphql";
|
|
10
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface AttributesSdk {
|
|
14
|
-
// Paginated queries
|
|
15
|
-
paginated: (variables?: PaginatedAttributesQueryVariables) => Promise<PaginatedAttributesQuery>;
|
|
16
|
-
// Infinite queries
|
|
17
|
-
infinite: (variables: InfiniteAttributesQueryVariables) => Promise<InfiniteAttributesQuery>;
|
|
18
|
-
all: (variables: InfiniteAttributesQueryVariables) => Promise<InfiniteAttributesQuery["infiniteAttributes"]["edges"][number]["node"][]>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function createAttributesSdk(client: GraphQLClient): AttributesSdk {
|
|
22
|
-
|
|
23
|
-
const paginated = {
|
|
24
|
-
paginated(variables: PaginatedAttributesQueryVariables = {}) {
|
|
25
|
-
return client.request<PaginatedAttributesQuery>(PaginatedAttributesDocument, variables);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const infinite = {
|
|
30
|
-
infinite(variables: InfiniteAttributesQueryVariables) {
|
|
31
|
-
return client.request<InfiniteAttributesQuery>(InfiniteAttributesDocument, variables);
|
|
32
|
-
},
|
|
33
|
-
all(variables: InfiniteAttributesQueryVariables) {
|
|
34
|
-
const sdk: InfiniteListSdk<InfiniteAttributesQuery, InfiniteAttributesQueryVariables> = {
|
|
35
|
-
listInfinite: (v) => client.request<InfiniteAttributesQuery>(InfiniteAttributesDocument, v),
|
|
36
|
-
};
|
|
37
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteAttributes);
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return { ...paginated, ...infinite };
|
|
42
|
-
}
|
package/src/services/brands.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
PaginatedBrandsDocument,
|
|
4
|
-
PaginatedBrandsQuery,
|
|
5
|
-
PaginatedBrandsQueryVariables,
|
|
6
|
-
InfiniteBrandsDocument,
|
|
7
|
-
InfiniteBrandsQuery,
|
|
8
|
-
InfiniteBrandsQueryVariables,
|
|
9
|
-
} from "@dokamerce/graphql";
|
|
10
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
11
|
-
|
|
12
|
-
export interface BrandsSdk {
|
|
13
|
-
// Paginated queries
|
|
14
|
-
paginated: (variables?: PaginatedBrandsQueryVariables) => Promise<PaginatedBrandsQuery>;
|
|
15
|
-
// Infinite queries
|
|
16
|
-
infinite: (variables: InfiniteBrandsQueryVariables) => Promise<InfiniteBrandsQuery>;
|
|
17
|
-
all: (variables: InfiniteBrandsQueryVariables) => Promise<InfiniteBrandsQuery["infiniteBrands"]["edges"][number]["node"][]>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function createBrandsSdk(client: GraphQLClient): BrandsSdk {
|
|
21
|
-
|
|
22
|
-
const paginated = {
|
|
23
|
-
paginated(variables: PaginatedBrandsQueryVariables = {}) {
|
|
24
|
-
return client.request<PaginatedBrandsQuery>(PaginatedBrandsDocument, variables);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const infinite = {
|
|
29
|
-
infinite(variables: InfiniteBrandsQueryVariables) {
|
|
30
|
-
return client.request<InfiniteBrandsQuery>(InfiniteBrandsDocument, variables);
|
|
31
|
-
},
|
|
32
|
-
all(variables: InfiniteBrandsQueryVariables) {
|
|
33
|
-
const sdk: InfiniteListSdk<InfiniteBrandsQuery, InfiniteBrandsQueryVariables> = {
|
|
34
|
-
listInfinite: (v) => client.request<InfiniteBrandsQuery>(InfiniteBrandsDocument, v),
|
|
35
|
-
};
|
|
36
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteBrands);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return { ...paginated, ...infinite };
|
|
41
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
PaginatedCategoriesDocument,
|
|
4
|
-
PaginatedCategoriesQuery,
|
|
5
|
-
PaginatedCategoriesQueryVariables,
|
|
6
|
-
InfiniteCategoriesDocument,
|
|
7
|
-
InfiniteCategoriesQuery,
|
|
8
|
-
InfiniteCategoriesQueryVariables,
|
|
9
|
-
} from "@dokamerce/graphql";
|
|
10
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
11
|
-
|
|
12
|
-
export interface CategoriesSdk {
|
|
13
|
-
// Paginated queries
|
|
14
|
-
paginated: (variables?: PaginatedCategoriesQueryVariables) => Promise<PaginatedCategoriesQuery>;
|
|
15
|
-
// Infinite queries
|
|
16
|
-
infinite: (variables: InfiniteCategoriesQueryVariables) => Promise<InfiniteCategoriesQuery>;
|
|
17
|
-
all: (variables: InfiniteCategoriesQueryVariables) => Promise<InfiniteCategoriesQuery["infiniteCategories"]["edges"][number]["node"][]>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function createCategoriesSdk(client: GraphQLClient): CategoriesSdk {
|
|
21
|
-
|
|
22
|
-
const paginated = {
|
|
23
|
-
paginated(variables: PaginatedCategoriesQueryVariables = {}) {
|
|
24
|
-
return client.request<PaginatedCategoriesQuery>(PaginatedCategoriesDocument, variables);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const infinite = {
|
|
29
|
-
infinite(variables: InfiniteCategoriesQueryVariables) {
|
|
30
|
-
return client.request<InfiniteCategoriesQuery>(InfiniteCategoriesDocument, variables);
|
|
31
|
-
},
|
|
32
|
-
all(variables: InfiniteCategoriesQueryVariables) {
|
|
33
|
-
const sdk: InfiniteListSdk<InfiniteCategoriesQuery, InfiniteCategoriesQueryVariables> = {
|
|
34
|
-
listInfinite: (v) => client.request<InfiniteCategoriesQuery>(InfiniteCategoriesDocument, v),
|
|
35
|
-
};
|
|
36
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteCategories);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return { ...paginated, ...infinite };
|
|
41
|
-
}
|
package/src/services/colors.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
PaginatedColorsDocument,
|
|
4
|
-
PaginatedColorsQuery,
|
|
5
|
-
PaginatedColorsQueryVariables,
|
|
6
|
-
InfiniteColorsDocument,
|
|
7
|
-
InfiniteColorsQuery,
|
|
8
|
-
InfiniteColorsQueryVariables,
|
|
9
|
-
} from "@dokamerce/graphql";
|
|
10
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
11
|
-
|
|
12
|
-
export interface ColorsSdk {
|
|
13
|
-
// Paginated queries
|
|
14
|
-
paginated: (variables?: PaginatedColorsQueryVariables) => Promise<PaginatedColorsQuery>;
|
|
15
|
-
// Infinite queries
|
|
16
|
-
infinite: (variables: InfiniteColorsQueryVariables) => Promise<InfiniteColorsQuery>;
|
|
17
|
-
all: (variables: InfiniteColorsQueryVariables) => Promise<InfiniteColorsQuery["infiniteColors"]["edges"][number]["node"][]>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function createColorsSdk(client: GraphQLClient): ColorsSdk {
|
|
21
|
-
|
|
22
|
-
const paginated = {
|
|
23
|
-
paginated(variables: PaginatedColorsQueryVariables = {}) {
|
|
24
|
-
return client.request<PaginatedColorsQuery>(PaginatedColorsDocument, variables);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const infinite = {
|
|
29
|
-
infinite(variables: InfiniteColorsQueryVariables) {
|
|
30
|
-
return client.request<InfiniteColorsQuery>(InfiniteColorsDocument, variables);
|
|
31
|
-
},
|
|
32
|
-
all(variables: InfiniteColorsQueryVariables) {
|
|
33
|
-
const sdk: InfiniteListSdk<InfiniteColorsQuery, InfiniteColorsQueryVariables> = {
|
|
34
|
-
listInfinite: (v) => client.request<InfiniteColorsQuery>(InfiniteColorsDocument, v),
|
|
35
|
-
};
|
|
36
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteColors);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return { ...paginated, ...infinite };
|
|
41
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
CreateCustomerDocument,
|
|
4
|
-
CreateCustomerMutation,
|
|
5
|
-
CreateCustomerMutationVariables,
|
|
6
|
-
UpdateCustomerDocument,
|
|
7
|
-
UpdateCustomerMutation,
|
|
8
|
-
UpdateCustomerMutationVariables,
|
|
9
|
-
PaginatedCustomersDocument,
|
|
10
|
-
PaginatedCustomersQuery,
|
|
11
|
-
PaginatedCustomersQueryVariables,
|
|
12
|
-
InfiniteCustomersDocument,
|
|
13
|
-
InfiniteCustomersQuery,
|
|
14
|
-
InfiniteCustomersQueryVariables,
|
|
15
|
-
} from "@dokamerce/graphql";
|
|
16
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export interface CustomersSdk {
|
|
20
|
-
// Mutations
|
|
21
|
-
create: (variables: CreateCustomerMutationVariables) => Promise<CreateCustomerMutation>;
|
|
22
|
-
update: (variables: UpdateCustomerMutationVariables) => Promise<UpdateCustomerMutation>;
|
|
23
|
-
// Paginated queries
|
|
24
|
-
paginated: (variables?: PaginatedCustomersQueryVariables) => Promise<PaginatedCustomersQuery>;
|
|
25
|
-
// Infinite queries
|
|
26
|
-
infinite: (variables: InfiniteCustomersQueryVariables) => Promise<InfiniteCustomersQuery>;
|
|
27
|
-
all: (variables: InfiniteCustomersQueryVariables) => Promise<InfiniteCustomersQuery["infiniteCustomers"]["edges"][number]["node"][]>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export function createCustomersSdk(client: GraphQLClient): CustomersSdk {
|
|
32
|
-
const mutations = {
|
|
33
|
-
create(variables: CreateCustomerMutationVariables) {
|
|
34
|
-
return client.request<CreateCustomerMutation>(CreateCustomerDocument, variables);
|
|
35
|
-
},
|
|
36
|
-
update(variables: UpdateCustomerMutationVariables) {
|
|
37
|
-
return client.request<UpdateCustomerMutation>(UpdateCustomerDocument, variables);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const paginated = {
|
|
42
|
-
paginated(variables: PaginatedCustomersQueryVariables = {}) {
|
|
43
|
-
return client.request<PaginatedCustomersQuery>(PaginatedCustomersDocument, variables);
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const infinite = {
|
|
48
|
-
infinite(variables: InfiniteCustomersQueryVariables) {
|
|
49
|
-
return client.request<InfiniteCustomersQuery>(InfiniteCustomersDocument, variables);
|
|
50
|
-
},
|
|
51
|
-
all(variables: InfiniteCustomersQueryVariables) {
|
|
52
|
-
const sdk: InfiniteListSdk<InfiniteCustomersQuery, InfiniteCustomersQueryVariables> = {
|
|
53
|
-
listInfinite: (v) => client.request<InfiniteCustomersQuery>(InfiniteCustomersDocument, v),
|
|
54
|
-
};
|
|
55
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteCustomers);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return { ...mutations, ...paginated, ...infinite };
|
|
60
|
-
}
|
package/src/services/files.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
InitiateFileUploadDocument,
|
|
4
|
-
InitiateFileUploadMutation,
|
|
5
|
-
InitiateFileUploadMutationVariables,
|
|
6
|
-
CompleteFileUploadDocument,
|
|
7
|
-
CompleteFileUploadMutation,
|
|
8
|
-
CompleteFileUploadMutationVariables,
|
|
9
|
-
FileDocument,
|
|
10
|
-
FileQuery,
|
|
11
|
-
FileQueryVariables,
|
|
12
|
-
} from "@dokamerce/graphql";
|
|
13
|
-
|
|
14
|
-
export interface FileUploadSdk {
|
|
15
|
-
// Mutations
|
|
16
|
-
initiate: (
|
|
17
|
-
variables: InitiateFileUploadMutationVariables
|
|
18
|
-
) => Promise<InitiateFileUploadMutation>;
|
|
19
|
-
|
|
20
|
-
complete: (
|
|
21
|
-
variables: CompleteFileUploadMutationVariables
|
|
22
|
-
) => Promise<CompleteFileUploadMutation>;
|
|
23
|
-
|
|
24
|
-
// Queries
|
|
25
|
-
file: (
|
|
26
|
-
variables: FileQueryVariables
|
|
27
|
-
) => Promise<FileQuery>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export function createFileUploadSdk(client: GraphQLClient): FileUploadSdk {
|
|
32
|
-
const mutations = {
|
|
33
|
-
initiate(variables: InitiateFileUploadMutationVariables) {
|
|
34
|
-
return client.request<InitiateFileUploadMutation>(
|
|
35
|
-
InitiateFileUploadDocument,
|
|
36
|
-
variables
|
|
37
|
-
);
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
complete(variables: CompleteFileUploadMutationVariables) {
|
|
41
|
-
return client.request<CompleteFileUploadMutation>(
|
|
42
|
-
CompleteFileUploadDocument,
|
|
43
|
-
variables
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const queries = {
|
|
49
|
-
file(variables: FileQueryVariables) {
|
|
50
|
-
return client.request<FileQuery>(FileDocument, variables);
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
...mutations,
|
|
56
|
-
...queries,
|
|
57
|
-
};
|
|
58
|
-
}
|
package/src/services/index.ts
DELETED
package/src/services/metrics.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
// PaginatedMetricsDocument,
|
|
4
|
-
// PaginatedMetricsQuery,
|
|
5
|
-
// PaginatedMetricsQueryVariables,
|
|
6
|
-
InfiniteMetricsDocument,
|
|
7
|
-
InfiniteMetricsQuery,
|
|
8
|
-
InfiniteMetricsQueryVariables,
|
|
9
|
-
} from "@dokamerce/graphql";
|
|
10
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
11
|
-
|
|
12
|
-
export interface MetricsSdk {
|
|
13
|
-
// Infinite queries
|
|
14
|
-
infinite: (variables: InfiniteMetricsQueryVariables) => Promise<InfiniteMetricsQuery>;
|
|
15
|
-
all: (variables: InfiniteMetricsQueryVariables) => Promise<InfiniteMetricsQuery["infiniteMetrics"]["edges"][number]["node"][]>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function createMetricsSdk(client: GraphQLClient): MetricsSdk {
|
|
19
|
-
|
|
20
|
-
// const paginated = {
|
|
21
|
-
// list(variables: PaginatedMetricsQueryVariables = {}) {
|
|
22
|
-
// return client.request<PaginatedMetricsQuery>(PaginatedMetricsDocument, variables);
|
|
23
|
-
// },
|
|
24
|
-
// };
|
|
25
|
-
|
|
26
|
-
const infinite = {
|
|
27
|
-
infinite(variables: InfiniteMetricsQueryVariables) {
|
|
28
|
-
return client.request<InfiniteMetricsQuery>(InfiniteMetricsDocument, variables);
|
|
29
|
-
},
|
|
30
|
-
all(variables: InfiniteMetricsQueryVariables) {
|
|
31
|
-
const sdk: InfiniteListSdk<InfiniteMetricsQuery, InfiniteMetricsQueryVariables> = {
|
|
32
|
-
listInfinite: (v) => client.request<InfiniteMetricsQuery>(InfiniteMetricsDocument, v),
|
|
33
|
-
};
|
|
34
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteMetrics);
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return { ...infinite };
|
|
39
|
-
}
|
package/src/services/orders.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
CreateOrderDocument,
|
|
4
|
-
CreateOrderMutation,
|
|
5
|
-
CreateOrderMutationVariables,
|
|
6
|
-
UpdateOrderDocument,
|
|
7
|
-
UpdateOrderMutation,
|
|
8
|
-
UpdateOrderMutationVariables,
|
|
9
|
-
PaginatedOrdersDocument,
|
|
10
|
-
PaginatedOrdersQuery,
|
|
11
|
-
PaginatedOrdersQueryVariables,
|
|
12
|
-
InfiniteOrdersDocument,
|
|
13
|
-
InfiniteOrdersQuery,
|
|
14
|
-
InfiniteOrdersQueryVariables,
|
|
15
|
-
} from "@dokamerce/graphql";
|
|
16
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
17
|
-
|
|
18
|
-
export interface OrdersSdk {
|
|
19
|
-
// Mutations
|
|
20
|
-
create: (variables: CreateOrderMutationVariables) => Promise<CreateOrderMutation>;
|
|
21
|
-
update: (variables: UpdateOrderMutationVariables) => Promise<UpdateOrderMutation>;
|
|
22
|
-
// Paginated queries
|
|
23
|
-
paginated: (variables?: PaginatedOrdersQueryVariables) => Promise<PaginatedOrdersQuery>;
|
|
24
|
-
// Infinite queries
|
|
25
|
-
infinite: (variables: InfiniteOrdersQueryVariables) => Promise<InfiniteOrdersQuery>;
|
|
26
|
-
all: (variables: InfiniteOrdersQueryVariables) => Promise<InfiniteOrdersQuery["infiniteOrders"]["edges"][number]["node"][]>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export function createOrdersSdk(client: GraphQLClient): OrdersSdk {
|
|
31
|
-
const mutations = {
|
|
32
|
-
create(variables: CreateOrderMutationVariables) {
|
|
33
|
-
return client.request<CreateOrderMutation>(CreateOrderDocument, variables);
|
|
34
|
-
},
|
|
35
|
-
update(variables: UpdateOrderMutationVariables) {
|
|
36
|
-
return client.request<UpdateOrderMutation>(UpdateOrderDocument, variables);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const paginated = {
|
|
41
|
-
paginated(variables: PaginatedOrdersQueryVariables = {}) {
|
|
42
|
-
return client.request<PaginatedOrdersQuery>(PaginatedOrdersDocument, variables);
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const infinite = {
|
|
47
|
-
infinite(variables: InfiniteOrdersQueryVariables) {
|
|
48
|
-
return client.request<InfiniteOrdersQuery>(InfiniteOrdersDocument, variables);
|
|
49
|
-
},
|
|
50
|
-
all(variables: InfiniteOrdersQueryVariables) {
|
|
51
|
-
const sdk: InfiniteListSdk<InfiniteOrdersQuery, InfiniteOrdersQueryVariables> = {
|
|
52
|
-
listInfinite: (v) => client.request<InfiniteOrdersQuery>(InfiniteOrdersDocument, v),
|
|
53
|
-
};
|
|
54
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteOrders);
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return { ...mutations, ...paginated, ...infinite };
|
|
59
|
-
}
|
package/src/services/products.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
CreateProductDocument,
|
|
4
|
-
CreateProductMutation,
|
|
5
|
-
CreateProductMutationVariables,
|
|
6
|
-
UpdateProductDocument,
|
|
7
|
-
UpdateProductMutation,
|
|
8
|
-
UpdateProductMutationVariables,
|
|
9
|
-
DeleteProductDocument,
|
|
10
|
-
DeleteProductMutation,
|
|
11
|
-
DeleteProductMutationVariables,
|
|
12
|
-
PaginatedProductsDocument,
|
|
13
|
-
PaginatedProductsQuery,
|
|
14
|
-
PaginatedProductsQueryVariables,
|
|
15
|
-
InfiniteProductsDocument,
|
|
16
|
-
InfiniteProductsQuery,
|
|
17
|
-
InfiniteProductsQueryVariables,
|
|
18
|
-
} from "@dokamerce/graphql";
|
|
19
|
-
import { fetchAllInfinite, InfiniteListSdk } from "@/utils/fetch-all-infinite.util";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export interface ProductsSdk {
|
|
23
|
-
// Mutations
|
|
24
|
-
create: (variables: CreateProductMutationVariables) => Promise<CreateProductMutation>; update: (variables: UpdateProductMutationVariables) => Promise<UpdateProductMutation>;
|
|
25
|
-
delete: (variables: DeleteProductMutationVariables) => Promise<DeleteProductMutation>;
|
|
26
|
-
// Paginated queries
|
|
27
|
-
paginated: (variables?: PaginatedProductsQueryVariables) => Promise<PaginatedProductsQuery>;
|
|
28
|
-
// Infinite queries
|
|
29
|
-
infinite: (variables: InfiniteProductsQueryVariables) => Promise<InfiniteProductsQuery>;
|
|
30
|
-
all: (variables: InfiniteProductsQueryVariables) => Promise<InfiniteProductsQuery["infiniteProducts"]["edges"][number]["node"][]>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function createProductsSdk(client: GraphQLClient) : ProductsSdk {
|
|
34
|
-
const mutations = {
|
|
35
|
-
create(variables: CreateProductMutationVariables) {
|
|
36
|
-
return client.request<CreateProductMutation>(CreateProductDocument, variables);
|
|
37
|
-
},
|
|
38
|
-
update(variables: UpdateProductMutationVariables) {
|
|
39
|
-
return client.request<UpdateProductMutation>(UpdateProductDocument, variables);
|
|
40
|
-
},
|
|
41
|
-
delete(variables: DeleteProductMutationVariables) {
|
|
42
|
-
return client.request<DeleteProductMutation>(DeleteProductDocument, variables);
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const paginated = {
|
|
47
|
-
paginated(variables: PaginatedProductsQueryVariables = {}) {
|
|
48
|
-
return client.request<PaginatedProductsQuery>(PaginatedProductsDocument, variables);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const infinite = {
|
|
53
|
-
infinite(variables: InfiniteProductsQueryVariables) {
|
|
54
|
-
return client.request<InfiniteProductsQuery>(InfiniteProductsDocument, variables);
|
|
55
|
-
},
|
|
56
|
-
all(variables: InfiniteProductsQueryVariables) {
|
|
57
|
-
const sdk: InfiniteListSdk<InfiniteProductsQuery, InfiniteProductsQueryVariables> = {
|
|
58
|
-
listInfinite: (v) => client.request<InfiniteProductsQuery>(InfiniteProductsDocument, v),
|
|
59
|
-
};
|
|
60
|
-
return fetchAllInfinite(sdk, variables, (res) => res.infiniteProducts);
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return { ...mutations, ...paginated, ...infinite };
|
|
65
|
-
}
|
package/src/services/sellers.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
import {
|
|
3
|
-
CreateSellerDocument,
|
|
4
|
-
CreateSellerMutation,
|
|
5
|
-
CreateSellerMutationVariables,
|
|
6
|
-
UpdateSellerDocument,
|
|
7
|
-
UpdateSellerMutation,
|
|
8
|
-
UpdateSellerMutationVariables,
|
|
9
|
-
PaginatedSellersDocument,
|
|
10
|
-
PaginatedSellersQuery,
|
|
11
|
-
PaginatedSellersQueryVariables,
|
|
12
|
-
InfiniteSellersDocument,
|
|
13
|
-
InfiniteSellersQuery,
|
|
14
|
-
InfiniteSellersQueryVariables,
|
|
15
|
-
} from "@dokamerce/graphql";
|
|
16
|
-
import {
|
|
17
|
-
fetchAllInfinite,
|
|
18
|
-
InfiniteListSdk,
|
|
19
|
-
} from "@/utils/fetch-all-infinite.util";
|
|
20
|
-
|
|
21
|
-
export interface SellersSdk {
|
|
22
|
-
// Mutations
|
|
23
|
-
create: (
|
|
24
|
-
variables: CreateSellerMutationVariables,
|
|
25
|
-
) => Promise<CreateSellerMutation>;
|
|
26
|
-
update: (
|
|
27
|
-
variables: UpdateSellerMutationVariables,
|
|
28
|
-
) => Promise<UpdateSellerMutation>;
|
|
29
|
-
// Paginated queries
|
|
30
|
-
paginated: (
|
|
31
|
-
variables?: PaginatedSellersQueryVariables,
|
|
32
|
-
) => Promise<PaginatedSellersQuery>;
|
|
33
|
-
// Infinite queries
|
|
34
|
-
infinite: (
|
|
35
|
-
variables: InfiniteSellersQueryVariables,
|
|
36
|
-
) => Promise<InfiniteSellersQuery>;
|
|
37
|
-
all: (
|
|
38
|
-
variables: InfiniteSellersQueryVariables,
|
|
39
|
-
) => Promise<InfiniteSellersQuery["infiniteSellers"]["edges"][number]["node"][]>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function createSellersSdk(client: GraphQLClient): SellersSdk {
|
|
43
|
-
const mutations = {
|
|
44
|
-
create(variables: CreateSellerMutationVariables) {
|
|
45
|
-
return client.request<CreateSellerMutation>(
|
|
46
|
-
CreateSellerDocument,
|
|
47
|
-
variables,
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
update(variables: UpdateSellerMutationVariables) {
|
|
51
|
-
return client.request<UpdateSellerMutation>(
|
|
52
|
-
UpdateSellerDocument,
|
|
53
|
-
variables,
|
|
54
|
-
);
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const paginated = {
|
|
59
|
-
paginated(variables: PaginatedSellersQueryVariables = {}) {
|
|
60
|
-
return client.request<PaginatedSellersQuery>(
|
|
61
|
-
PaginatedSellersDocument,
|
|
62
|
-
variables,
|
|
63
|
-
);
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const infinite = {
|
|
68
|
-
infinite(variables: InfiniteSellersQueryVariables) {
|
|
69
|
-
return client.request<InfiniteSellersQuery>(
|
|
70
|
-
InfiniteSellersDocument,
|
|
71
|
-
variables,
|
|
72
|
-
);
|
|
73
|
-
},
|
|
74
|
-
all(variables: InfiniteSellersQueryVariables) {
|
|
75
|
-
const sdk: InfiniteListSdk<
|
|
76
|
-
InfiniteSellersQuery,
|
|
77
|
-
InfiniteSellersQueryVariables
|
|
78
|
-
> = {
|
|
79
|
-
listInfinite: (v) =>
|
|
80
|
-
client.request<InfiniteSellersQuery>(InfiniteSellersDocument, v),
|
|
81
|
-
};
|
|
82
|
-
return fetchAllInfinite<
|
|
83
|
-
InfiniteSellersQuery["infiniteSellers"]["edges"][number]["node"],
|
|
84
|
-
InfiniteSellersQuery,
|
|
85
|
-
InfiniteSellersQueryVariables
|
|
86
|
-
>(sdk, variables, (res) => res.infiniteSellers);
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return { ...mutations, ...paginated, ...infinite };
|
|
91
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type PageInfo = {
|
|
2
|
-
hasNextPage: boolean;
|
|
3
|
-
endCursor?: string | null;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export type Edge<T> = {
|
|
7
|
-
node: T;
|
|
8
|
-
cursor?: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type Connection<T> = {
|
|
12
|
-
edges?: Edge<T>[] | null;
|
|
13
|
-
pageInfo?: PageInfo | null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type CursorVariables = {
|
|
17
|
-
after?: string | null;
|
|
18
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// import { SDKError } from "./functions/safe-call.function";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AttributesSdk,
|
|
5
|
-
BrandsSdk,
|
|
6
|
-
CategoriesSdk,
|
|
7
|
-
ColorsSdk,
|
|
8
|
-
CustomersSdk,
|
|
9
|
-
FileUploadSdk,
|
|
10
|
-
OrdersSdk,
|
|
11
|
-
ProductsSdk,
|
|
12
|
-
SellersSdk,
|
|
13
|
-
} from "@/services";
|
|
14
|
-
import { MetricsSdk } from "@/services/metrics";
|
|
15
|
-
|
|
16
|
-
export interface DokamerceSDK {
|
|
17
|
-
products: ProductsSdk;
|
|
18
|
-
attributes: AttributesSdk;
|
|
19
|
-
brands: BrandsSdk;
|
|
20
|
-
categories: CategoriesSdk;
|
|
21
|
-
colors: ColorsSdk;
|
|
22
|
-
customers: CustomersSdk;
|
|
23
|
-
metrics: MetricsSdk;
|
|
24
|
-
files: FileUploadSdk;
|
|
25
|
-
orders: OrdersSdk;
|
|
26
|
-
sellers: SellersSdk;
|
|
27
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Connection, CursorVariables } from "../typings/pagination.typing";
|
|
2
|
-
|
|
3
|
-
export interface InfiniteListSdk<TResponse, TVariables> {
|
|
4
|
-
listInfinite(variables: TVariables): Promise<TResponse>;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Generic helper to fetch all nodes from a cursor-based infinite connection
|
|
9
|
-
*/
|
|
10
|
-
export async function fetchAllInfinite<
|
|
11
|
-
TNode,
|
|
12
|
-
TResponse,
|
|
13
|
-
TVariables extends (CursorVariables)
|
|
14
|
-
>(
|
|
15
|
-
sdk: InfiniteListSdk<TResponse, TVariables>,
|
|
16
|
-
variables: TVariables,
|
|
17
|
-
selectConnection: (response: TResponse) => Connection<TNode> | null | undefined
|
|
18
|
-
): Promise<TNode[]> {
|
|
19
|
-
let after = variables.after;
|
|
20
|
-
const items: TNode[] = [];
|
|
21
|
-
|
|
22
|
-
while (true) {
|
|
23
|
-
const res = await sdk.listInfinite({
|
|
24
|
-
...variables,
|
|
25
|
-
after,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const connection = selectConnection(res);
|
|
29
|
-
if (!connection) break;
|
|
30
|
-
|
|
31
|
-
const edges = connection.edges ?? [];
|
|
32
|
-
items.push(...edges.map((e) => e.node));
|
|
33
|
-
|
|
34
|
-
const pageInfo = connection.pageInfo;
|
|
35
|
-
if (!pageInfo?.hasNextPage) break;
|
|
36
|
-
|
|
37
|
-
after = pageInfo.endCursor;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return items;
|
|
41
|
-
}
|
package/tsconfig.dev.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"removeComments": true,
|
|
7
|
-
"emitDecoratorMetadata": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"allowSyntheticDefaultImports": true,
|
|
10
|
-
"target": "ES2023",
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"outDir": "./dist",
|
|
13
|
-
"incremental": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"strict": true,
|
|
16
|
-
"strictFunctionTypes": true,
|
|
17
|
-
"strictNullChecks": true,
|
|
18
|
-
"strictBindCallApply": true,
|
|
19
|
-
"strictPropertyInitialization": true,
|
|
20
|
-
"noImplicitThis": true,
|
|
21
|
-
"noImplicitAny": true,
|
|
22
|
-
"alwaysStrict": true,
|
|
23
|
-
"noUnusedLocals": true,
|
|
24
|
-
"noUnusedParameters": true,
|
|
25
|
-
"noImplicitReturns": true,
|
|
26
|
-
"noFallthroughCasesInSwitch": true,
|
|
27
|
-
"forceConsistentCasingInFileNames": false,
|
|
28
|
-
"resolveJsonModule": true,
|
|
29
|
-
"types": ["expect-more-jest", "jest", "node"],
|
|
30
|
-
"baseUrl": "./"
|
|
31
|
-
}
|
|
32
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"removeComments": true,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"target": "ES2023",
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"incremental": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"strictFunctionTypes": true,
|
|
16
|
-
"strictNullChecks": true,
|
|
17
|
-
"strictBindCallApply": true,
|
|
18
|
-
"strictPropertyInitialization": true,
|
|
19
|
-
"noImplicitThis": true,
|
|
20
|
-
"noImplicitAny": true,
|
|
21
|
-
"alwaysStrict": true,
|
|
22
|
-
"noUnusedLocals": true,
|
|
23
|
-
"noUnusedParameters": true,
|
|
24
|
-
"noImplicitReturns": true,
|
|
25
|
-
"noFallthroughCasesInSwitch": true,
|
|
26
|
-
"forceConsistentCasingInFileNames": false,
|
|
27
|
-
"resolveJsonModule": true,
|
|
28
|
-
"types": ["expect-more-jest", "jest", "node"],
|
|
29
|
-
"baseUrl": "./",
|
|
30
|
-
"paths": {
|
|
31
|
-
"@dokamerce/common": ["../common/src"],
|
|
32
|
-
"@/*": ["./src/*"],
|
|
33
|
-
"@dokamerce/graphql": ["../graphql/src/gateway"],
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"exclude": ["../../packages/graphql/__generated__/**/*.ts"]
|
|
37
|
-
}
|