@longvansoftware/service-js-client 1.19.3 → 1.19.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.
@@ -8,3 +8,4 @@ export declare const GET_NUMBER_OF_TICKET_EVALUATION: import("graphql").Document
8
8
  export declare const SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE: import("graphql").DocumentNode;
9
9
  export declare const GET_VOUCHERS_V2: import("graphql").DocumentNode;
10
10
  export declare const SEARCH_CAMPAIGN: import("graphql").DocumentNode;
11
+ export declare const GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SEARCH_CAMPAIGN = exports.GET_VOUCHERS_V2 = exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = exports.GET_NUMBER_OF_TICKET_EVALUATION = exports.GET_URL_EVALUATION = exports.GET_AVERAGE_RATING = exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
3
+ exports.GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS = exports.SEARCH_CAMPAIGN = exports.GET_VOUCHERS_V2 = exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = exports.GET_NUMBER_OF_TICKET_EVALUATION = exports.GET_URL_EVALUATION = exports.GET_AVERAGE_RATING = exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = (0, graphql_tag_1.gql) `
6
6
  query SearchProductQuantityPromotionAction(
@@ -361,3 +361,27 @@ exports.SEARCH_CAMPAIGN = (0, graphql_tag_1.gql) `
361
361
  }
362
362
  }
363
363
  `;
364
+ exports.GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS = (0, graphql_tag_1.gql) `
365
+ query GetConditionByOrgIdCampaignActionIds(
366
+ $orgId: String!
367
+ $campaignActionIds: [String]!
368
+ ) {
369
+ getConditionByOrgIdCampaignActionIds(
370
+ orgId: $orgId
371
+ campaignActionIds: $campaignActionIds
372
+ ) {
373
+ partyId
374
+ campaignActionId
375
+ type
376
+ minimumSpend
377
+ maximumSpend
378
+ description
379
+ newCustomer
380
+ id
381
+ createdStamp
382
+ updatedStamp
383
+ updatedBy
384
+ createdBy
385
+ }
386
+ }
387
+ `;
@@ -11,3 +11,6 @@ export declare const SHARE_LINK_FILE_BY_TIME: DocumentNode;
11
11
  export declare const COPY_FILE: (fields?: string[]) => DocumentNode;
12
12
  export declare const MOVE_FILE: (fields?: string[]) => DocumentNode;
13
13
  export declare const REMOVE_FILE: (fields?: string[]) => DocumentNode;
14
+ export declare const UPDATE_ACL_PERMISSION_BUCKET: (fields?: string[]) => DocumentNode;
15
+ export declare const UPDATE_BUCKET_VERSIONING: (fields?: string[]) => DocumentNode;
16
+ export declare const RESTORE_FILE_TRASH: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REMOVE_FILE = exports.MOVE_FILE = exports.COPY_FILE = exports.SHARE_LINK_FILE_BY_TIME = exports.SHARE_LINK_FILE_BY_TIME_DYNAMIC = exports.RENAME_FILE = exports.UPDATE_ACL_PERMISSION_FILE = exports.UPLOAD_FOLDER = exports.REMOVE_FOLDER = exports.CREATE_FOLDER = exports.DELETE_BUCKET = exports.CREATE_BUCKET = void 0;
3
+ exports.RESTORE_FILE_TRASH = exports.UPDATE_BUCKET_VERSIONING = exports.UPDATE_ACL_PERMISSION_BUCKET = exports.REMOVE_FILE = exports.MOVE_FILE = exports.COPY_FILE = exports.SHARE_LINK_FILE_BY_TIME = exports.SHARE_LINK_FILE_BY_TIME_DYNAMIC = exports.RENAME_FILE = exports.UPDATE_ACL_PERMISSION_FILE = exports.UPLOAD_FOLDER = exports.REMOVE_FOLDER = exports.CREATE_FOLDER = exports.DELETE_BUCKET = exports.CREATE_BUCKET = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  const CREATE_BUCKET = (fields = []) => {
6
6
  const fieldStr = fields.join('\n ');
@@ -239,3 +239,69 @@ const REMOVE_FILE = (fields = []) => {
239
239
  `;
240
240
  };
241
241
  exports.REMOVE_FILE = REMOVE_FILE;
242
+ const UPDATE_ACL_PERMISSION_BUCKET = (fields = []) => {
243
+ const fieldStr = fields.join('\n ');
244
+ const hasFields = fields.length > 0;
245
+ return (0, graphql_tag_1.gql) `
246
+ mutation UpdateAclPermissionBucket(
247
+ $s3UserId: String!,
248
+ $bucketId: String!,
249
+ $isPublic: Boolean!
250
+ $updateBy: String!,
251
+ ) {
252
+ updateAclPermissionBucket(
253
+ s3UserId: $s3UserId,
254
+ bucketId: $bucketId,
255
+ isPublic: $isPublic
256
+ updateBy: $updateBy,
257
+ ) {
258
+ ${hasFields ? `${fieldStr}` : ''}
259
+ }
260
+ }
261
+ `;
262
+ };
263
+ exports.UPDATE_ACL_PERMISSION_BUCKET = UPDATE_ACL_PERMISSION_BUCKET;
264
+ const UPDATE_BUCKET_VERSIONING = (fields = []) => {
265
+ const fieldStr = fields.join('\n ');
266
+ const hasFields = fields.length > 0;
267
+ return (0, graphql_tag_1.gql) `
268
+ mutation UpdateBucketVersioning(
269
+ $s3UserId: String!,
270
+ $bucketId: String!,
271
+ $isOn: Boolean!
272
+ $updateBy: String!,
273
+ ) {
274
+ updateBucketVersioning(
275
+ s3UserId: $s3UserId,
276
+ bucketId: $bucketId,
277
+ isOn: $isOn
278
+ updateBy: $updateBy,
279
+ ) {
280
+ ${hasFields ? `${fieldStr}` : ''}
281
+ }
282
+ }
283
+ `;
284
+ };
285
+ exports.UPDATE_BUCKET_VERSIONING = UPDATE_BUCKET_VERSIONING;
286
+ const RESTORE_FILE_TRASH = (fields = []) => {
287
+ const fieldStr = fields.join('\n ');
288
+ const hasFields = fields.length > 0;
289
+ return (0, graphql_tag_1.gql) `
290
+ mutation RestoreFileTrash(
291
+ $s3UserId: String!,
292
+ $bucketId: String!,
293
+ $key: String!
294
+ $versionId: String!,
295
+ ) {
296
+ restoreFileTrash(
297
+ s3UserId: $s3UserId,
298
+ bucketId: $bucketId,
299
+ key: $key
300
+ versionId: $versionId,
301
+ ) {
302
+ ${hasFields ? `${fieldStr}` : ''}
303
+ }
304
+ }
305
+ `;
306
+ };
307
+ exports.RESTORE_FILE_TRASH = RESTORE_FILE_TRASH;
@@ -2,3 +2,4 @@ import { DocumentNode } from 'graphql';
2
2
  export declare const GET_LIST_S3_USER_BY_SERVICE_ID: (fields?: string[]) => DocumentNode;
3
3
  export declare const GET_LIST_BUCKET_BY_S3_USER_ID: (fields?: string[]) => DocumentNode;
4
4
  export declare const GET_LIST_OBJECT: (fields?: string[]) => DocumentNode;
5
+ export declare const GET_LIST_FILE_TRASH: (fields?: string[]) => DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_LIST_OBJECT = exports.GET_LIST_BUCKET_BY_S3_USER_ID = exports.GET_LIST_S3_USER_BY_SERVICE_ID = void 0;
3
+ exports.GET_LIST_FILE_TRASH = exports.GET_LIST_OBJECT = exports.GET_LIST_BUCKET_BY_S3_USER_ID = exports.GET_LIST_S3_USER_BY_SERVICE_ID = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  const GET_LIST_S3_USER_BY_SERVICE_ID = (fields = []) => {
6
6
  const fieldStr = fields.join('\n ');
@@ -38,3 +38,15 @@ const GET_LIST_OBJECT = (fields = []) => {
38
38
  `;
39
39
  };
40
40
  exports.GET_LIST_OBJECT = GET_LIST_OBJECT;
41
+ const GET_LIST_FILE_TRASH = (fields = []) => {
42
+ const fieldStr = fields.join('\n ');
43
+ const hasFields = fields.length > 0;
44
+ return (0, graphql_tag_1.gql) `
45
+ query GetListFileTrash($s3UserId: String!, $bucketId: String!) {
46
+ getListFileTrash(s3UserId: $s3UserId, bucketId: $bucketId) {
47
+ ${hasFields ? `${fieldStr}` : ''}
48
+ }
49
+ }
50
+ `;
51
+ };
52
+ exports.GET_LIST_FILE_TRASH = GET_LIST_FILE_TRASH;
@@ -15,4 +15,5 @@ export declare class CrmCampingService extends Service {
15
15
  addProductGiftPromotion(orderId: string, updatedBy: string, addData: any): Promise<any>;
16
16
  searchVouchersV2(searchVoucherRequest: any): Promise<any>;
17
17
  searchCampaign(searchCampaignRequest: any): Promise<any>;
18
+ getConditionByOrgIdCampaignActionIds(campaignActionIds: [string]): Promise<any>;
18
19
  }
@@ -258,5 +258,22 @@ class CrmCampingService extends serviceSDK_1.Service {
258
258
  }
259
259
  });
260
260
  }
261
+ getConditionByOrgIdCampaignActionIds(campaignActionIds) {
262
+ return __awaiter(this, void 0, void 0, function* () {
263
+ const query = queries_1.GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS;
264
+ const variables = {
265
+ orgId: this.orgId,
266
+ campaignActionIds,
267
+ };
268
+ try {
269
+ const response = yield this.graphqlQuery(query, variables);
270
+ return response.getConditionByOrgIdCampaignActionIds;
271
+ }
272
+ catch (error) {
273
+ console.log(`Error fetching getConditionByOrgIdCampaignActionIds: ${error}`);
274
+ throw error;
275
+ }
276
+ });
277
+ }
261
278
  }
262
279
  exports.CrmCampingService = CrmCampingService;
@@ -0,0 +1,14 @@
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
+ }
@@ -0,0 +1,101 @@
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;
@@ -15,4 +15,9 @@ export declare class StorageS3Service extends Service {
15
15
  removeFile(s3UserId: string, bucketId: string, keys: string[], fields: string[]): Promise<any>;
16
16
  createFolder(s3UserId: string, bucketId: string, folderName: string, key: string, fields: string[]): Promise<any>;
17
17
  removeFolder(s3UserId: string, bucketId: string, key: string, fields: string[]): Promise<any>;
18
+ createBucket(s3UserId: string, bucketName: string, enableObjectLock: boolean, enableBucketVersioning: boolean, fields: string[]): Promise<any>;
19
+ deleteBucket(bucketId: string, updateBy: string, fields: string[]): Promise<any>;
20
+ updateAclPermissionBucket(s3UserId: string, bucketId: string, isPublic: boolean, updateBy: string, fields: string[]): Promise<any>;
21
+ updateBucketVersioning(s3UserId: string, bucketId: string, isOn: boolean, updateBy: string, fields: string[]): Promise<any>;
22
+ getListFileTrash(s3UserId: string, bucketId: string, fields: string[]): Promise<any>;
18
23
  }
@@ -107,7 +107,7 @@ class StorageS3Service extends serviceSDK_1.Service {
107
107
  }
108
108
  updateAclPermissionFile(s3UserId, bucketId, key, isPublic, fields) {
109
109
  return __awaiter(this, void 0, void 0, function* () {
110
- const query = (0, mutations_1.UPDATE_ACL_PERMISSION_FILE)(fields);
110
+ const mutation = (0, mutations_1.UPDATE_ACL_PERMISSION_FILE)(fields);
111
111
  const variables = {
112
112
  s3UserId,
113
113
  bucketId,
@@ -115,7 +115,7 @@ class StorageS3Service extends serviceSDK_1.Service {
115
115
  isPublic,
116
116
  };
117
117
  try {
118
- const response = yield this.graphqlQueryV2(query, variables);
118
+ const response = yield this.graphqlMutationV2(mutation, variables);
119
119
  return response.updateAclPermissionFile;
120
120
  }
121
121
  catch (error) {
@@ -255,5 +255,96 @@ class StorageS3Service extends serviceSDK_1.Service {
255
255
  }
256
256
  });
257
257
  }
258
+ createBucket(s3UserId, bucketName, enableObjectLock, enableBucketVersioning, fields) {
259
+ return __awaiter(this, void 0, void 0, function* () {
260
+ const mutation = (0, mutations_1.CREATE_BUCKET)(fields);
261
+ const variables = {
262
+ s3UserId,
263
+ bucketName,
264
+ enableObjectLock,
265
+ enableBucketVersioning
266
+ };
267
+ try {
268
+ const response = yield this.graphqlMutationV2(mutation, variables);
269
+ return response.createBucket;
270
+ }
271
+ catch (error) {
272
+ console.log(`Error in createBucket: ${error}`);
273
+ throw error;
274
+ }
275
+ });
276
+ }
277
+ deleteBucket(bucketId, updateBy, fields) {
278
+ return __awaiter(this, void 0, void 0, function* () {
279
+ const mutation = (0, mutations_1.DELETE_BUCKET)(fields);
280
+ const variables = {
281
+ bucketId,
282
+ updateBy
283
+ };
284
+ try {
285
+ const response = yield this.graphqlMutationV2(mutation, variables);
286
+ return response.deleteBucket;
287
+ }
288
+ catch (error) {
289
+ console.log(`Error in deleteBucket: ${error}`);
290
+ throw error;
291
+ }
292
+ });
293
+ }
294
+ updateAclPermissionBucket(s3UserId, bucketId, isPublic, updateBy, fields) {
295
+ return __awaiter(this, void 0, void 0, function* () {
296
+ const mutation = (0, mutations_1.UPDATE_ACL_PERMISSION_BUCKET)(fields);
297
+ const variables = {
298
+ s3UserId,
299
+ bucketId,
300
+ isPublic,
301
+ updateBy
302
+ };
303
+ try {
304
+ const response = yield this.graphqlMutationV2(mutation, variables);
305
+ return response.updateAclPermissionBucket;
306
+ }
307
+ catch (error) {
308
+ console.log(`Error in updateAclPermissionBucket: ${error}`);
309
+ throw error;
310
+ }
311
+ });
312
+ }
313
+ updateBucketVersioning(s3UserId, bucketId, isOn, updateBy, fields) {
314
+ return __awaiter(this, void 0, void 0, function* () {
315
+ const mutation = (0, mutations_1.UPDATE_BUCKET_VERSIONING)(fields);
316
+ const variables = {
317
+ s3UserId,
318
+ bucketId,
319
+ isOn,
320
+ updateBy
321
+ };
322
+ try {
323
+ const response = yield this.graphqlMutationV2(mutation, variables);
324
+ return response.updateBucketVersioning;
325
+ }
326
+ catch (error) {
327
+ console.log(`Error in updateBucketVersioning: ${error}`);
328
+ throw error;
329
+ }
330
+ });
331
+ }
332
+ getListFileTrash(s3UserId, bucketId, fields) {
333
+ return __awaiter(this, void 0, void 0, function* () {
334
+ const query = (0, queries_1.GET_LIST_FILE_TRASH)(fields);
335
+ const variables = {
336
+ s3UserId,
337
+ bucketId
338
+ };
339
+ try {
340
+ const response = yield this.graphqlQueryV2(query, variables);
341
+ return response.getListFileTrash;
342
+ }
343
+ catch (error) {
344
+ console.log(`Error in getListFileTrash: ${error}`);
345
+ throw error;
346
+ }
347
+ });
348
+ }
258
349
  }
259
350
  exports.StorageS3Service = StorageS3Service;
@@ -0,0 +1 @@
1
+ export declare function buildFieldString(fields: (string | Record<string, any>)[], indent?: number): string;
@@ -0,0 +1,16 @@
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "1.19.3",
3
+ "version": "1.19.5",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [