@longvansoftware/service-js-client 2.6.9 → 2.7.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.
Files changed (39) hide show
  1. package/dist/src/graphql/campaign/queries.d.ts +13 -11
  2. package/dist/src/graphql/campaign/queries.js +39 -111
  3. package/dist/src/graphql/cloud/mutations.js +6 -6
  4. package/dist/src/graphql/crm_camping/queries.js +16 -59
  5. package/dist/src/graphql/marketplace/mutations.d.ts +3 -0
  6. package/dist/src/graphql/marketplace/mutations.js +54 -0
  7. package/dist/src/graphql/marketplace/queries.d.ts +2 -0
  8. package/dist/src/graphql/marketplace/queries.js +42 -0
  9. package/dist/src/graphql/paymentV2/mutations.d.ts +1 -0
  10. package/dist/src/graphql/paymentV2/mutations.js +15 -1
  11. package/dist/src/graphql/paymentV2/queries.d.ts +2 -0
  12. package/dist/src/graphql/paymentV2/queries.js +58 -1
  13. package/dist/src/graphql/storefont/mutation.d.ts +0 -0
  14. package/dist/src/graphql/storefont/mutation.js +1 -0
  15. package/dist/src/graphql/storefont/queries.d.ts +2 -0
  16. package/dist/src/graphql/storefont/queries.js +46 -0
  17. package/dist/src/graphql/tag/mutations.d.ts +2 -0
  18. package/dist/src/graphql/tag/mutations.js +44 -0
  19. package/dist/src/graphql/tag/queries.d.ts +1 -0
  20. package/dist/src/graphql/tag/queries.js +20 -0
  21. package/dist/src/lib/campaign/index.d.ts +1 -0
  22. package/dist/src/lib/campaign/index.js +69 -12
  23. package/dist/src/lib/cloud/index.d.ts +6 -6
  24. package/dist/src/lib/cloud/index.js +12 -12
  25. package/dist/src/lib/marketplace/index.d.ts +9 -0
  26. package/dist/src/lib/marketplace/index.js +106 -0
  27. package/dist/src/lib/paymentV2/index.d.ts +10 -0
  28. package/dist/src/lib/paymentV2/index.js +39 -0
  29. package/dist/src/lib/portal/index.d.ts +3 -0
  30. package/dist/src/lib/portal/index.js +50 -0
  31. package/dist/src/lib/storefont/index.d.ts +6 -0
  32. package/dist/src/lib/storefont/index.js +51 -0
  33. package/dist/src/lib/tag/index.d.ts +7 -0
  34. package/dist/src/lib/tag/index.js +61 -0
  35. package/package.json +1 -1
  36. package/dist/src/lib/service.d.ts +0 -14
  37. package/dist/src/lib/service.js +0 -101
  38. package/dist/src/utils/build-field-string.d.ts +0 -1
  39. package/dist/src/utils/build-field-string.js +0 -16
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StorefontService = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ const queries_1 = require("../../graphql/storefont/queries");
15
+ class StorefontService extends serviceSDK_1.Service {
16
+ constructor(endpoint, orgId, storeId) {
17
+ super(endpoint, orgId, storeId);
18
+ }
19
+ getRevenueStatisticByGroupOrCategory(dataQuery, groupBy) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const query = queries_1.GET_REVENUE_STATISTIC_BY_GROUP_OR_CATEGORY;
22
+ const variables = {
23
+ input: dataQuery,
24
+ groupBy,
25
+ };
26
+ try {
27
+ const response = yield this.graphqlQuery(query, variables);
28
+ return response.getRevenueStatisticByGroupOrCategory;
29
+ }
30
+ catch (error) {
31
+ throw error;
32
+ }
33
+ });
34
+ }
35
+ getRevenueStatisticByProduct(dataQuery) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const query = queries_1.GET_REVENUE_STATISTIC_BY_PRODUCT;
38
+ const variables = {
39
+ input: dataQuery,
40
+ };
41
+ try {
42
+ const response = yield this.graphqlQuery(query, variables);
43
+ return response.getRevenueStatisticByProduct;
44
+ }
45
+ catch (error) {
46
+ throw error;
47
+ }
48
+ });
49
+ }
50
+ }
51
+ exports.StorefontService = StorefontService;
@@ -0,0 +1,7 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class TagService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ addTagToTagGroup(data: any): Promise<any>;
5
+ removeTagToTagGroup(data: any): Promise<any>;
6
+ getResultTag(resourceId: string, resourceType: string): Promise<any>;
7
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TagService = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ const mutations_1 = require("../../graphql/tag/mutations");
15
+ const queries_1 = require("../../graphql/tag/queries");
16
+ class TagService extends serviceSDK_1.Service {
17
+ constructor(endpoint, orgId, storeId) {
18
+ super(endpoint, orgId, storeId);
19
+ }
20
+ addTagToTagGroup(data) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const mutation = mutations_1.ADD_TAG_TO_TAG_GROUP;
23
+ try {
24
+ const response = yield this.graphqlMutation(mutation, data);
25
+ return response.addTagToTagGroup;
26
+ }
27
+ catch (error) {
28
+ throw error;
29
+ }
30
+ });
31
+ }
32
+ removeTagToTagGroup(data) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const mutation = mutations_1.REMOVE_TAG_TO_TAG_GROUP;
35
+ try {
36
+ const response = yield this.graphqlMutation(mutation, data);
37
+ return response.removeTagToTagGroup;
38
+ }
39
+ catch (error) {
40
+ throw error;
41
+ }
42
+ });
43
+ }
44
+ getResultTag(resourceId, resourceType) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const queries = queries_1.GET_RESULT_TAG;
47
+ const variables = {
48
+ resourceId,
49
+ resourceType,
50
+ };
51
+ try {
52
+ const response = yield this.graphqlMutationV3(queries, variables);
53
+ return response.getResultTag;
54
+ }
55
+ catch (error) {
56
+ throw error;
57
+ }
58
+ });
59
+ }
60
+ }
61
+ exports.TagService = TagService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "2.6.9",
3
+ "version": "2.7.1",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [
@@ -1,14 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from "@apollo/client";
2
- import { DocumentNode } from "graphql";
3
- export declare class Service {
4
- protected token: string | null;
5
- protected client: ApolloClient<NormalizedCacheObject>;
6
- protected orgId: string;
7
- protected storeId: string;
8
- protected endpoint: string;
9
- constructor(endpoint: string, orgId: string, storeId: string);
10
- setToken(token: string): void;
11
- protected graphqlQuery(query: DocumentNode, variables: any): Promise<any>;
12
- protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
13
- protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
14
- }
@@ -1,101 +0,0 @@
1
- "use strict";
2
- // src/service.ts
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.Service = void 0;
17
- const client_1 = require("@apollo/client");
18
- const axios_1 = __importDefault(require("axios"));
19
- class Service {
20
- constructor(endpoint, orgId, storeId) {
21
- this.token = null;
22
- this.client = new client_1.ApolloClient({
23
- uri: endpoint,
24
- cache: new client_1.InMemoryCache(),
25
- defaultOptions: {
26
- query: {
27
- fetchPolicy: "network-only",
28
- },
29
- },
30
- });
31
- this.orgId = orgId;
32
- this.storeId = storeId;
33
- this.endpoint = endpoint;
34
- }
35
- setToken(token) {
36
- this.token = token;
37
- }
38
- // setOrgId(orgId: string) {
39
- // this.orgId = orgId;
40
- // }
41
- graphqlQuery(query, variables) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- try {
44
- const { data, errors } = yield this.client.query({
45
- query: (0, client_1.gql) `
46
- ${query}
47
- `,
48
- variables,
49
- });
50
- if (errors) {
51
- throw new Error(`GraphQL error! errors: ${errors}`);
52
- }
53
- return data;
54
- }
55
- catch (error) {
56
- console.log(`Error in graphqlQuery: ${error}`);
57
- throw error;
58
- }
59
- });
60
- }
61
- graphqlMutation(mutation, variables) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- try {
64
- const { data, errors } = yield this.client.mutate({
65
- mutation: (0, client_1.gql) `
66
- ${mutation}
67
- `,
68
- variables,
69
- });
70
- if (errors) {
71
- throw new Error(`GraphQL error! errors: ${errors}`);
72
- }
73
- return data;
74
- }
75
- catch (error) {
76
- console.log(`Error in graphqlMutation: ${error}`);
77
- throw error;
78
- }
79
- });
80
- }
81
- restApiCallWithToken(path, method, data, headers) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- try {
84
- const modifiedHeaders = Object.assign(Object.assign({}, headers), { "Partner-Id": this.orgId, "X-Ecomos-Access-Token": this.token });
85
- console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
86
- const response = yield (0, axios_1.default)({
87
- url: this.endpoint + path,
88
- method,
89
- data,
90
- headers: modifiedHeaders,
91
- });
92
- return response.data;
93
- }
94
- catch (error) {
95
- console.log(`Error in restApiCallWithToken: ${error}`);
96
- throw error;
97
- }
98
- });
99
- }
100
- }
101
- exports.Service = Service;
@@ -1 +0,0 @@
1
- export declare function buildFieldString(fields: (string | Record<string, any>)[], indent?: number): string;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildFieldString = void 0;
4
- function buildFieldString(fields, indent = 6) {
5
- const space = " ".repeat(indent);
6
- return fields
7
- .map((field) => {
8
- if (typeof field === "string")
9
- return `${space}${field}`;
10
- const [key, value] = Object.entries(field)[0];
11
- const nested = buildFieldString(value, indent + 2);
12
- return `${space}${key} {\n${nested}\n${space}}`;
13
- })
14
- .join("\n");
15
- }
16
- exports.buildFieldString = buildFieldString;