repzo-sap-absjo 1.0.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 (157) hide show
  1. package/README.md +3 -0
  2. package/changelog.md +17 -0
  3. package/lib/actions/create_invoice.d.ts +26 -0
  4. package/lib/actions/create_invoice.js +311 -0
  5. package/lib/actions/create_payment.d.ts +5 -0
  6. package/lib/actions/create_payment.js +177 -0
  7. package/lib/actions/create_proforma.d.ts +5 -0
  8. package/lib/actions/create_proforma.js +241 -0
  9. package/lib/actions/create_return_invoice.d.ts +5 -0
  10. package/lib/actions/create_return_invoice.js +268 -0
  11. package/lib/actions/create_transfer.d.ts +5 -0
  12. package/lib/actions/create_transfer.js +171 -0
  13. package/lib/actions/index.d.ts +3 -0
  14. package/lib/actions/index.js +31 -0
  15. package/lib/commands/adjust_inventory.d.ts +6 -0
  16. package/lib/commands/adjust_inventory.js +303 -0
  17. package/lib/commands/bank.d.ts +7 -0
  18. package/lib/commands/bank.js +301 -0
  19. package/lib/commands/basic.d.ts +2 -0
  20. package/lib/commands/basic.js +73 -0
  21. package/lib/commands/category.d.ts +4 -0
  22. package/lib/commands/category.js +193 -0
  23. package/lib/commands/channel.d.ts +4 -0
  24. package/lib/commands/channel.js +213 -0
  25. package/lib/commands/client.d.ts +39 -0
  26. package/lib/commands/client.js +410 -0
  27. package/lib/commands/client_disabled.d.ts +4 -0
  28. package/lib/commands/client_disabled.js +183 -0
  29. package/lib/commands/index.d.ts +23 -0
  30. package/lib/commands/index.js +82 -0
  31. package/lib/commands/join.d.ts +2 -0
  32. package/lib/commands/join.js +134 -0
  33. package/lib/commands/measureunit.d.ts +23 -0
  34. package/lib/commands/measureunit.js +314 -0
  35. package/lib/commands/measureunit_family.d.ts +12 -0
  36. package/lib/commands/measureunit_family.js +263 -0
  37. package/lib/commands/payment_term.d.ts +4 -0
  38. package/lib/commands/payment_term.js +217 -0
  39. package/lib/commands/price_list.d.ts +18 -0
  40. package/lib/commands/price_list.js +608 -0
  41. package/lib/commands/product.d.ts +39 -0
  42. package/lib/commands/product.js +454 -0
  43. package/lib/commands/product_disabled.d.ts +4 -0
  44. package/lib/commands/product_disabled.js +178 -0
  45. package/lib/commands/rep.d.ts +2 -0
  46. package/lib/commands/rep.js +246 -0
  47. package/lib/commands/tag.d.ts +2 -0
  48. package/lib/commands/tag.js +195 -0
  49. package/lib/commands/tax.d.ts +2 -0
  50. package/lib/commands/tax.js +198 -0
  51. package/lib/commands/warehouse.d.ts +4 -0
  52. package/lib/commands/warehouse.js +221 -0
  53. package/lib/index.d.ts +29 -0
  54. package/lib/index.js +6 -0
  55. package/lib/test/actions/create_invoice.d.ts +1 -0
  56. package/lib/test/actions/create_invoice.js +214 -0
  57. package/lib/test/actions/create_payment.d.ts +1 -0
  58. package/lib/test/actions/create_payment.js +131 -0
  59. package/lib/test/actions/create_proforma.d.ts +1 -0
  60. package/lib/test/actions/create_proforma.js +242 -0
  61. package/lib/test/actions/create_return_invoice.d.ts +1 -0
  62. package/lib/test/actions/create_return_invoice.js +226 -0
  63. package/lib/test/actions/create_transfer.d.ts +1 -0
  64. package/lib/test/actions/create_transfer.js +142 -0
  65. package/lib/test/commands/adjust_inventory.d.ts +1 -0
  66. package/lib/test/commands/adjust_inventory.js +97 -0
  67. package/lib/test/commands/bank.d.ts +1 -0
  68. package/lib/test/commands/bank.js +97 -0
  69. package/lib/test/commands/basic.d.ts +1 -0
  70. package/lib/test/commands/basic.js +339 -0
  71. package/lib/test/commands/category.d.ts +1 -0
  72. package/lib/test/commands/category.js +97 -0
  73. package/lib/test/commands/channel.d.ts +1 -0
  74. package/lib/test/commands/channel.js +97 -0
  75. package/lib/test/commands/client.d.ts +1 -0
  76. package/lib/test/commands/client.js +97 -0
  77. package/lib/test/commands/client_disabled.d.ts +1 -0
  78. package/lib/test/commands/client_disabled.js +97 -0
  79. package/lib/test/commands/join.d.ts +1 -0
  80. package/lib/test/commands/join.js +339 -0
  81. package/lib/test/commands/measureunit.d.ts +1 -0
  82. package/lib/test/commands/measureunit.js +97 -0
  83. package/lib/test/commands/measureunit_family.d.ts +1 -0
  84. package/lib/test/commands/measureunit_family.js +97 -0
  85. package/lib/test/commands/payment_term.d.ts +1 -0
  86. package/lib/test/commands/payment_term.js +97 -0
  87. package/lib/test/commands/price_list.d.ts +1 -0
  88. package/lib/test/commands/price_list.js +97 -0
  89. package/lib/test/commands/product.d.ts +1 -0
  90. package/lib/test/commands/product.js +97 -0
  91. package/lib/test/commands/product_disabled.d.ts +1 -0
  92. package/lib/test/commands/product_disabled.js +97 -0
  93. package/lib/test/commands/rep.d.ts +1 -0
  94. package/lib/test/commands/rep.js +97 -0
  95. package/lib/test/commands/tag.d.ts +1 -0
  96. package/lib/test/commands/tag.js +97 -0
  97. package/lib/test/commands/tax.d.ts +1 -0
  98. package/lib/test/commands/tax.js +97 -0
  99. package/lib/test/commands/warehouse.d.ts +1 -0
  100. package/lib/test/commands/warehouse.js +97 -0
  101. package/lib/types.d.ts +77 -0
  102. package/lib/types.js +1 -0
  103. package/lib/util.d.ts +70 -0
  104. package/lib/util.js +164 -0
  105. package/package.json +51 -0
  106. package/src/actions/create_invoice.ts +275 -0
  107. package/src/actions/create_payment.ts +138 -0
  108. package/src/actions/create_proforma.ts +187 -0
  109. package/src/actions/create_return_invoice.ts +217 -0
  110. package/src/actions/create_transfer.ts +160 -0
  111. package/src/actions/index.ts +27 -0
  112. package/src/commands/adjust_inventory.ts +250 -0
  113. package/src/commands/bank.ts +243 -0
  114. package/src/commands/basic.ts +64 -0
  115. package/src/commands/category.ts +176 -0
  116. package/src/commands/channel.ts +219 -0
  117. package/src/commands/client.ts +368 -0
  118. package/src/commands/client_disabled.ts +158 -0
  119. package/src/commands/index.ts +87 -0
  120. package/src/commands/join.ts +80 -0
  121. package/src/commands/measureunit.ts +276 -0
  122. package/src/commands/measureunit_family.ts +209 -0
  123. package/src/commands/payment_term.ts +224 -0
  124. package/src/commands/price_list.ts +434 -0
  125. package/src/commands/product.ts +359 -0
  126. package/src/commands/product_disabled.ts +152 -0
  127. package/src/commands/rep.ts +209 -0
  128. package/src/commands/tag.ts +173 -0
  129. package/src/commands/tax.ts +178 -0
  130. package/src/commands/warehouse.ts +204 -0
  131. package/src/index.ts +7 -0
  132. package/src/test/actions/create_invoice.ts +214 -0
  133. package/src/test/actions/create_payment.ts +131 -0
  134. package/src/test/actions/create_proforma.ts +242 -0
  135. package/src/test/actions/create_return_invoice.ts +226 -0
  136. package/src/test/actions/create_transfer.ts +142 -0
  137. package/src/test/commands/adjust_inventory.ts +100 -0
  138. package/src/test/commands/bank.ts +100 -0
  139. package/src/test/commands/basic.ts +342 -0
  140. package/src/test/commands/category.ts +100 -0
  141. package/src/test/commands/channel.ts +100 -0
  142. package/src/test/commands/client.ts +100 -0
  143. package/src/test/commands/client_disabled.ts +100 -0
  144. package/src/test/commands/join.ts +342 -0
  145. package/src/test/commands/measureunit.ts +100 -0
  146. package/src/test/commands/measureunit_family.ts +100 -0
  147. package/src/test/commands/payment_term.ts +100 -0
  148. package/src/test/commands/price_list.ts +100 -0
  149. package/src/test/commands/product.ts +100 -0
  150. package/src/test/commands/product_disabled.ts +100 -0
  151. package/src/test/commands/rep.ts +100 -0
  152. package/src/test/commands/tag.ts +100 -0
  153. package/src/test/commands/tax.ts +100 -0
  154. package/src/test/commands/warehouse.ts +100 -0
  155. package/src/types.ts +76 -0
  156. package/src/util.ts +205 -0
  157. package/tsconfig.json +15 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ import { Commands } from "../../index.js";
2
+ let commandEvent = {
3
+ app: {
4
+ _id: "6391a53edb71ef6435719794",
5
+ name: "SAP",
6
+ disabled: false,
7
+ available_app: {
8
+ _id: "6391a268db71ef64357195da",
9
+ name: "repzo-sap-absjo",
10
+ title: "SAP ABS JO",
11
+ logo: "https://www.e2abs.com/wp-content/uploads/2021/03/Website-Main-Logo-1.svg",
12
+ description: "",
13
+ disabled: false,
14
+ JSONSchema: {
15
+ title: "SAP Integration Settings",
16
+ type: "object",
17
+ required: ["repzoApiKey", "sapHostUrl"],
18
+ properties: {
19
+ repzoApiKey: {
20
+ type: "string",
21
+ title: "Repzo API KEY",
22
+ },
23
+ sapHostUrl: {
24
+ type: "string",
25
+ title: "SAP Host Url",
26
+ },
27
+ errorEmail: {
28
+ type: "string",
29
+ format: "email",
30
+ title: "Email in case of error",
31
+ },
32
+ warehouseDefaultUpdateDate: {
33
+ type: "string",
34
+ format: "date",
35
+ title: "Warehouse: Default Update Date",
36
+ },
37
+ },
38
+ },
39
+ options_JSONSchema: {
40
+ title: "SAP Integration Optional Settings",
41
+ type: "object",
42
+ required: [],
43
+ properties: {
44
+ bench_time_warehouse: {
45
+ title: "Bench Time: Warehouse",
46
+ type: "string",
47
+ format: "date",
48
+ },
49
+ },
50
+ },
51
+ app_settings: {
52
+ repo: "",
53
+ serviceEndPoint: "",
54
+ _id: "6391a268db71ef64357195db",
55
+ },
56
+ app_category: "6249fa8466312f76e595634a",
57
+ commands: [
58
+ {
59
+ command: "basic",
60
+ name: "Full Sync",
61
+ description: "",
62
+ _id: "6391a268db71ef64357195dc",
63
+ },
64
+ {
65
+ command: "join",
66
+ name: "Join",
67
+ description: "",
68
+ _id: "6391a268db71ef64357195dd",
69
+ },
70
+ ],
71
+ actions: [],
72
+ createdAt: "2022-12-08T08:38:00.915Z",
73
+ updatedAt: "2022-12-08T09:42:49.236Z",
74
+ __v: 0,
75
+ },
76
+ company_namespace: ["unisap"],
77
+ formData: {
78
+ repzoApiKey: "L98_Pc8qZG2R5hZIIMjxLQNUgUzT3_0aX2BuLvkyh74",
79
+ sapHostUrl: "http://unipal.b1pro.com:8083/api",
80
+ errorEmail: "maram.alshen@repzoapp.com",
81
+ serviceApiKey: "awdas",
82
+ warehouseDefaultUpdateDate: "2015-01-01",
83
+ },
84
+ options_formData: {},
85
+ createdAt: "2022-12-08T08:50:06.903Z",
86
+ updatedAt: "2022-12-08T09:43:21.620Z",
87
+ __v: 0,
88
+ },
89
+ end_of_day: "04:00",
90
+ nameSpace: ["unisap"],
91
+ timezone: "Asia/Amman",
92
+ meta: "",
93
+ env: "staging",
94
+ sync_id: "47c9c804-e136-4d54-928a-000003",
95
+ command: "tag",
96
+ };
97
+ Commands(commandEvent);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ import { Commands } from "../../index.js";
2
+ let commandEvent = {
3
+ app: {
4
+ _id: "6391a53edb71ef6435719794",
5
+ name: "SAP",
6
+ disabled: false,
7
+ available_app: {
8
+ _id: "6391a268db71ef64357195da",
9
+ name: "repzo-sap-absjo",
10
+ title: "SAP ABS JO",
11
+ logo: "https://www.e2abs.com/wp-content/uploads/2021/03/Website-Main-Logo-1.svg",
12
+ description: "",
13
+ disabled: false,
14
+ JSONSchema: {
15
+ title: "SAP Integration Settings",
16
+ type: "object",
17
+ required: ["repzoApiKey", "sapHostUrl"],
18
+ properties: {
19
+ repzoApiKey: {
20
+ type: "string",
21
+ title: "Repzo API KEY",
22
+ },
23
+ sapHostUrl: {
24
+ type: "string",
25
+ title: "SAP Host Url",
26
+ },
27
+ errorEmail: {
28
+ type: "string",
29
+ format: "email",
30
+ title: "Email in case of error",
31
+ },
32
+ warehouseDefaultUpdateDate: {
33
+ type: "string",
34
+ format: "date",
35
+ title: "Warehouse: Default Update Date",
36
+ },
37
+ },
38
+ },
39
+ options_JSONSchema: {
40
+ title: "SAP Integration Optional Settings",
41
+ type: "object",
42
+ required: [],
43
+ properties: {
44
+ bench_time_warehouse: {
45
+ title: "Bench Time: Warehouse",
46
+ type: "string",
47
+ format: "date",
48
+ },
49
+ },
50
+ },
51
+ app_settings: {
52
+ repo: "",
53
+ serviceEndPoint: "",
54
+ _id: "6391a268db71ef64357195db",
55
+ },
56
+ app_category: "6249fa8466312f76e595634a",
57
+ commands: [
58
+ {
59
+ command: "basic",
60
+ name: "Full Sync",
61
+ description: "",
62
+ _id: "6391a268db71ef64357195dc",
63
+ },
64
+ {
65
+ command: "join",
66
+ name: "Join",
67
+ description: "",
68
+ _id: "6391a268db71ef64357195dd",
69
+ },
70
+ ],
71
+ actions: [],
72
+ createdAt: "2022-12-08T08:38:00.915Z",
73
+ updatedAt: "2022-12-08T09:42:49.236Z",
74
+ __v: 0,
75
+ },
76
+ company_namespace: ["unisap"],
77
+ formData: {
78
+ repzoApiKey: "L98_Pc8qZG2R5hZIIMjxLQNUgUzT3_0aX2BuLvkyh74",
79
+ sapHostUrl: "http://unipal.b1pro.com:8083/api",
80
+ errorEmail: "maram.alshen@repzoapp.com",
81
+ serviceApiKey: "awdas",
82
+ warehouseDefaultUpdateDate: "2015-01-01",
83
+ },
84
+ options_formData: {},
85
+ createdAt: "2022-12-08T08:50:06.903Z",
86
+ updatedAt: "2022-12-08T09:43:21.620Z",
87
+ __v: 0,
88
+ },
89
+ end_of_day: "04:00",
90
+ nameSpace: ["unisap"],
91
+ timezone: "Asia/Amman",
92
+ meta: "",
93
+ env: "staging",
94
+ sync_id: "47c9c804-e136-4d54-928a-000002",
95
+ command: "tax",
96
+ };
97
+ Commands(commandEvent);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ import { Commands } from "../../index.js";
2
+ let commandEvent = {
3
+ app: {
4
+ _id: "6391a53edb71ef6435719794",
5
+ name: "SAP",
6
+ disabled: false,
7
+ available_app: {
8
+ _id: "6391a268db71ef64357195da",
9
+ name: "repzo-sap-absjo",
10
+ title: "SAP ABS JO",
11
+ logo: "https://www.e2abs.com/wp-content/uploads/2021/03/Website-Main-Logo-1.svg",
12
+ description: "",
13
+ disabled: false,
14
+ JSONSchema: {
15
+ title: "SAP Integration Settings",
16
+ type: "object",
17
+ required: ["repzoApiKey", "sapHostUrl"],
18
+ properties: {
19
+ repzoApiKey: {
20
+ type: "string",
21
+ title: "Repzo API KEY",
22
+ },
23
+ sapHostUrl: {
24
+ type: "string",
25
+ title: "SAP Host Url",
26
+ },
27
+ errorEmail: {
28
+ type: "string",
29
+ format: "email",
30
+ title: "Email in case of error",
31
+ },
32
+ warehouseDefaultUpdateDate: {
33
+ type: "string",
34
+ format: "date",
35
+ title: "Warehouse: Default Update Date",
36
+ },
37
+ },
38
+ },
39
+ options_JSONSchema: {
40
+ title: "SAP Integration Optional Settings",
41
+ type: "object",
42
+ required: [],
43
+ properties: {
44
+ bench_time_warehouse: {
45
+ title: "Bench Time: Warehouse",
46
+ type: "string",
47
+ format: "date",
48
+ },
49
+ },
50
+ },
51
+ app_settings: {
52
+ repo: "",
53
+ serviceEndPoint: "",
54
+ _id: "6391a268db71ef64357195db",
55
+ },
56
+ app_category: "6249fa8466312f76e595634a",
57
+ commands: [
58
+ {
59
+ command: "basic",
60
+ name: "Full Sync",
61
+ description: "",
62
+ _id: "6391a268db71ef64357195dc",
63
+ },
64
+ {
65
+ command: "join",
66
+ name: "Join",
67
+ description: "",
68
+ _id: "6391a268db71ef64357195dd",
69
+ },
70
+ ],
71
+ actions: [],
72
+ createdAt: "2022-12-08T08:38:00.915Z",
73
+ updatedAt: "2022-12-08T09:42:49.236Z",
74
+ __v: 0,
75
+ },
76
+ company_namespace: ["unisap"],
77
+ formData: {
78
+ repzoApiKey: "L98_Pc8qZG2R5hZIIMjxLQNUgUzT3_0aX2BuLvkyh74",
79
+ sapHostUrl: "http://unipal.b1pro.com:8083/api",
80
+ errorEmail: "maram.alshen@repzoapp.com",
81
+ serviceApiKey: "awdas",
82
+ warehouseDefaultUpdateDate: "2015-01-01",
83
+ },
84
+ options_formData: {},
85
+ createdAt: "2022-12-08T08:50:06.903Z",
86
+ updatedAt: "2022-12-08T09:43:21.620Z",
87
+ __v: 0,
88
+ },
89
+ end_of_day: "04:00",
90
+ nameSpace: ["unisap"],
91
+ timezone: "Asia/Amman",
92
+ meta: "",
93
+ env: "staging",
94
+ sync_id: "47c9c804-e136-4d54-928a-000000",
95
+ command: "warehouse",
96
+ };
97
+ Commands(commandEvent);
package/lib/types.d.ts ADDED
@@ -0,0 +1,77 @@
1
+ import jwt from "jsonwebtoken";
2
+ import { Service } from "repzo/src/types";
3
+ export interface Config {
4
+ data?: any;
5
+ repzoEndPoint: string;
6
+ serviceEndPoint: string;
7
+ env: "staging" | "local" | "production";
8
+ }
9
+ type DecodedScope = "admin" | "client" | "rep";
10
+ type StringId = string;
11
+ type Email = string;
12
+ type NameSpaces = string[];
13
+ export type Decoded = jwt.JwtPayload & {
14
+ id?: StringId;
15
+ email?: Email;
16
+ name?: string;
17
+ team?: StringId[];
18
+ scope?: DecodedScope;
19
+ nameSpace?: NameSpaces;
20
+ permaString?: string;
21
+ timezone?: string;
22
+ };
23
+ interface Params {
24
+ nameSpace: NameSpaces;
25
+ decoded: Decoded;
26
+ }
27
+ export type EVENT = AWSLambda.APIGatewayEvent & {
28
+ params: Params;
29
+ };
30
+ export interface Action {
31
+ name: string;
32
+ action: string;
33
+ description: string;
34
+ }
35
+ export interface Command {
36
+ command: string;
37
+ description: string;
38
+ name: string;
39
+ }
40
+ export interface AvailableApp {
41
+ _id: StringId;
42
+ name: string;
43
+ disabled: boolean;
44
+ JSONSchema: any;
45
+ UISchema: any;
46
+ app_settings: {
47
+ repo: string;
48
+ serviceEndPoint: string;
49
+ meta: {};
50
+ };
51
+ app_category: string;
52
+ }
53
+ export interface CommandEvent {
54
+ app: Service.App.Schema_with_populated_AvailableApp;
55
+ command: string;
56
+ nameSpace: NameSpaces;
57
+ meta?: any;
58
+ sync_id?: string;
59
+ end_of_day: string;
60
+ timezone: string;
61
+ data?: any;
62
+ env: "staging" | "production" | "local";
63
+ }
64
+ export interface Result {
65
+ sap_total: number;
66
+ repzo_total: number;
67
+ created: number;
68
+ updated: number;
69
+ failed: number;
70
+ }
71
+ export type FailedDocsReport = {
72
+ method: "create" | "update" | "delete" | "fetchingData";
73
+ doc_id?: string;
74
+ doc?: any;
75
+ error_message: any;
76
+ }[];
77
+ export {};
package/lib/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/lib/util.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ import Repzo from "repzo";
2
+ interface Params {
3
+ [key: string]: any;
4
+ }
5
+ interface Data {
6
+ [key: string]: any;
7
+ }
8
+ interface Headers {
9
+ "API-KEY": string;
10
+ [key: string]: string;
11
+ }
12
+ export declare const _fetch: (
13
+ baseUrl: string,
14
+ path: string,
15
+ headers?: Headers,
16
+ params?: Params
17
+ ) => Promise<any>;
18
+ export declare const _create: (
19
+ baseUrl: string,
20
+ path: string,
21
+ body: Data,
22
+ headers?: Headers,
23
+ params?: Params
24
+ ) => Promise<any>;
25
+ export declare const _update: (
26
+ baseUrl: string,
27
+ path: string,
28
+ body: Data,
29
+ headers?: Headers,
30
+ params?: Params
31
+ ) => Promise<any>;
32
+ export declare const _delete: (
33
+ baseUrl: string,
34
+ path: string,
35
+ headers?: Headers,
36
+ params?: Params
37
+ ) => Promise<any>;
38
+ export declare const update_bench_time: (
39
+ repzo: Repzo,
40
+ app_id: string,
41
+ key: string,
42
+ value: string,
43
+ format?: string
44
+ ) => Promise<void>;
45
+ export declare const updateAt_query: (
46
+ QUERY: string,
47
+ options_formData: any,
48
+ bench_time_key: string
49
+ ) => string;
50
+ export declare const get_data_from_sap: (
51
+ _path: string,
52
+ default_res: any,
53
+ serviceEndPoint: string,
54
+ serviceApiKey: string,
55
+ query?: string
56
+ ) => Promise<any>;
57
+ export declare const set_error: (error_res: any) => any;
58
+ export declare const date_formatting: (
59
+ date: string | number | undefined,
60
+ format: string
61
+ ) => string | number | undefined;
62
+ export declare const get_data: (
63
+ service: any,
64
+ key: string,
65
+ query_array: any[],
66
+ extra_query?: {
67
+ [key: string]: any;
68
+ }
69
+ ) => Promise<any[]>;
70
+ export {};
package/lib/util.js ADDED
@@ -0,0 +1,164 @@
1
+ import axios from "axios";
2
+ import moment from "moment-timezone";
3
+ export const _fetch = async (baseUrl, path, headers, params) => {
4
+ try {
5
+ const res = await axios.get(baseUrl + path, { params, headers });
6
+ return res.data;
7
+ } catch (e) {
8
+ throw e;
9
+ }
10
+ };
11
+ export const _create = async (baseUrl, path, body, headers, params) => {
12
+ try {
13
+ const res = await axios.post(baseUrl + path, body, {
14
+ params,
15
+ headers: {
16
+ ...(headers ? headers : {}),
17
+ "Content-Type": "application/json",
18
+ Accept: "application/json",
19
+ },
20
+ });
21
+ return res.data;
22
+ } catch (e) {
23
+ throw e;
24
+ }
25
+ };
26
+ export const _update = async (baseUrl, path, body, headers, params) => {
27
+ try {
28
+ const res = await axios.put(baseUrl + path, body, {
29
+ params,
30
+ headers,
31
+ });
32
+ return res.data;
33
+ } catch (e) {
34
+ throw e;
35
+ }
36
+ };
37
+ export const _delete = async (baseUrl, path, headers, params) => {
38
+ try {
39
+ const res = await axios.delete(baseUrl + path, {
40
+ params,
41
+ headers,
42
+ });
43
+ return res.data;
44
+ } catch (e) {
45
+ throw e;
46
+ }
47
+ };
48
+ export const update_bench_time = async (repzo, app_id, key, value, format) => {
49
+ try {
50
+ if (format) {
51
+ value = moment(value).format(format);
52
+ }
53
+ const res = await repzo.integrationApp.update(app_id, {
54
+ // options_formData: { [key]: value },
55
+ [`options_formData.${key}`]: value,
56
+ });
57
+ } catch (e) {
58
+ throw e;
59
+ }
60
+ };
61
+ export const updateAt_query = (QUERY, options_formData, bench_time_key) => {
62
+ try {
63
+ QUERY = QUERY || "";
64
+ if (options_formData && options_formData[bench_time_key]) {
65
+ QUERY += `${QUERY ? "&" : "?"}q[updated_at_gteq]=${
66
+ options_formData[bench_time_key]
67
+ }`;
68
+ }
69
+ return QUERY;
70
+ } catch (e) {
71
+ throw e;
72
+ }
73
+ };
74
+ export const get_data_from_sap = async (
75
+ _path,
76
+ default_res, // if no data was found
77
+ serviceEndPoint,
78
+ serviceApiKey,
79
+ query
80
+ ) => {
81
+ try {
82
+ const result = await _fetch(
83
+ serviceEndPoint,
84
+ `/${_path}${query ? query : ""}`,
85
+ { "API-KEY": serviceApiKey }
86
+ );
87
+ return result;
88
+ } catch (e) {
89
+ if (e.response.status == 404) return default_res;
90
+ throw e;
91
+ }
92
+ };
93
+ export const set_error = (error_res) => {
94
+ var _a, _b, _c, _d;
95
+ try {
96
+ if (error_res) {
97
+ if (typeof error_res == "string") {
98
+ return { message: error_res };
99
+ } else if (
100
+ error_res.message ||
101
+ ((_a = error_res.response) === null || _a === void 0 ? void 0 : _a.data)
102
+ ) {
103
+ return {
104
+ code:
105
+ (_c =
106
+ (_b = error_res.response) === null || _b === void 0
107
+ ? void 0
108
+ : _b.data) === null || _c === void 0
109
+ ? void 0
110
+ : _c.code,
111
+ message:
112
+ ((_d = error_res.response) === null || _d === void 0
113
+ ? void 0
114
+ : _d.data.message) || error_res.message,
115
+ // responseData: error_res.response?.data,
116
+ };
117
+ } else {
118
+ return error_res;
119
+ }
120
+ }
121
+ return error_res;
122
+ } catch (e) {
123
+ throw e;
124
+ }
125
+ };
126
+ export const date_formatting = (date, format) => {
127
+ try {
128
+ if (!date && date !== 0) return date;
129
+ const result = moment(date).format(format);
130
+ if (result == "Invalid date") return date;
131
+ return result;
132
+ } catch (e) {
133
+ console.error(e);
134
+ return date;
135
+ throw e;
136
+ }
137
+ };
138
+ export const get_data = async (service, key, query_array, extra_query = {}) => {
139
+ var _a;
140
+ try {
141
+ const all_data = [];
142
+ const per_page = 200;
143
+ const pages = Math.ceil(query_array.length / per_page);
144
+ for (let i = 0; i < pages; i += per_page) {
145
+ const repzo_data = await service.find({
146
+ per_page: 50000,
147
+ [key]: query_array.slice(i, i + per_page),
148
+ ...extra_query,
149
+ });
150
+ if (
151
+ (_a =
152
+ repzo_data === null || repzo_data === void 0
153
+ ? void 0
154
+ : repzo_data.data) === null || _a === void 0
155
+ ? void 0
156
+ : _a.length
157
+ )
158
+ all_data.push(...repzo_data.data);
159
+ }
160
+ return all_data;
161
+ } catch (e) {
162
+ throw e;
163
+ }
164
+ };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "repzo-sap-absjo",
3
+ "description": "repzo SAP ABS jo integration",
4
+ "version": "1.0.1",
5
+ "homepage": "",
6
+ "keywords": [],
7
+ "author": {
8
+ "name": "Maram-Alshen",
9
+ "email": "maram.alshen@repzoapp.com"
10
+ },
11
+ "mocha": {
12
+ "spec": "./lib/test/index.spec.js"
13
+ },
14
+ "contributors": [],
15
+ "main": "./lib/index.js",
16
+ "type": "module",
17
+ "bugs": {},
18
+ "directories": {},
19
+ "engines": {},
20
+ "scripts": {
21
+ "lint": "npx prettier --write .",
22
+ "build": "tsc && npm run lint",
23
+ "test": "mocha",
24
+ "mac": "tsc && node ./lib/test/commands/basic.js"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": ""
29
+ },
30
+ "build": "tsc",
31
+ "devDependencies": {
32
+ "@babel/parser": "^7.16.6",
33
+ "@types/lodash": "^4.14.191",
34
+ "@types/mocha": "^9.0.0",
35
+ "@types/uuid": "^8.3.4",
36
+ "mocha": "^9.1.3",
37
+ "prettier": "^2.5.1",
38
+ "typescript": "^4.8.4"
39
+ },
40
+ "dependencies": {
41
+ "@types/aws-lambda": "^8.10.93",
42
+ "@types/jsonwebtoken": "^8.5.8",
43
+ "axios": "^0.26.1",
44
+ "data-set-query": "0.0.12",
45
+ "jsonwebtoken": "^8.5.1",
46
+ "lodash": "^4.17.21",
47
+ "moment-timezone": "^0.5.34",
48
+ "repzo": "^1.0.21",
49
+ "uuid": "^8.3.2"
50
+ }
51
+ }