@chift/chift-nodejs 1.0.17 → 1.0.19

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 (48) hide show
  1. package/dist/src/types/public-api/schema.d.ts +15294 -0
  2. package/package.json +6 -2
  3. package/.eslintignore +0 -1
  4. package/.eslintrc.json +0 -25
  5. package/.github/workflows/ci.yml +0 -75
  6. package/.husky/pre-commit +0 -4
  7. package/.prettierignore +0 -1
  8. package/.prettierrc.json +0 -7
  9. package/CHANGELOG.md +0 -108
  10. package/jest.config.ts +0 -195
  11. package/src/helpers/openapi.ts +0 -22
  12. package/src/helpers/settings.ts +0 -3
  13. package/src/index.ts +0 -1
  14. package/src/modules/accounting.ts +0 -510
  15. package/src/modules/api.ts +0 -35
  16. package/src/modules/consumer.ts +0 -216
  17. package/src/modules/consumers.ts +0 -82
  18. package/src/modules/custom.ts +0 -36
  19. package/src/modules/datastores.ts +0 -19
  20. package/src/modules/ecommerce.ts +0 -129
  21. package/src/modules/flow.ts +0 -168
  22. package/src/modules/integrations.ts +0 -24
  23. package/src/modules/internalApi.ts +0 -182
  24. package/src/modules/invoicing.ts +0 -118
  25. package/src/modules/payment.ts +0 -59
  26. package/src/modules/pms.ts +0 -67
  27. package/src/modules/pos.ts +0 -144
  28. package/src/modules/sync.ts +0 -77
  29. package/src/modules/syncs.ts +0 -59
  30. package/src/modules/webhooks.ts +0 -86
  31. package/src/types/api.ts +0 -37
  32. package/src/types/consumers.ts +0 -9
  33. package/src/types/public-api/mappings.ts +0 -21
  34. package/src/types/sync.ts +0 -38
  35. package/test/data/accounting_invoice.pdf +0 -0
  36. package/test/modules/accounting.test.ts +0 -647
  37. package/test/modules/consumer.test.ts +0 -68
  38. package/test/modules/consumers.test.ts +0 -85
  39. package/test/modules/ecommerce.test.ts +0 -213
  40. package/test/modules/integrations.test.ts +0 -22
  41. package/test/modules/invoicing.test.ts +0 -98
  42. package/test/modules/payment.test.ts +0 -65
  43. package/test/modules/pms.test.ts +0 -69
  44. package/test/modules/pos.test.ts +0 -164
  45. package/test/modules/sync.test.ts +0 -74
  46. package/test/modules/syncs.test.ts +0 -23
  47. package/test/modules/webhooks.test.ts +0 -92
  48. package/tsconfig.json +0 -107
@@ -1,59 +0,0 @@
1
- import { components } from '../types/public-api/schema';
2
- import { InternalAPI } from './internalApi';
3
- import { Sync } from './sync';
4
-
5
- export type SyncsAPI = {
6
- createSync: (
7
- body?: components['schemas']['CreateSyncItem']
8
- ) => Promise<ReturnType<typeof Sync>>;
9
- getSyncs: () => Promise<ReturnType<typeof Sync>[]>;
10
- getSyncById: (syncid: string) => Promise<ReturnType<typeof Sync>>;
11
- updateSync: (
12
- body?: components['schemas']['CreateSyncItem']
13
- ) => Promise<ReturnType<typeof Sync>>;
14
- };
15
-
16
- const Syncs = (internalApi: InternalAPI): SyncsAPI => {
17
- const _internalApi: InternalAPI = internalApi;
18
-
19
- const getSyncs = async () => {
20
- const { data }: { data: components['schemas']['ReadSyncItem'][] } = await _internalApi.get(
21
- '/syncs'
22
- );
23
- return data.map((sync) => Sync(_internalApi, sync));
24
- };
25
-
26
- const getSyncById = async (syncid: string) => {
27
- const { data }: { data: components['schemas']['ReadSyncItem'] } = await _internalApi.get(
28
- `/syncs/${syncid}`
29
- );
30
- return Sync(_internalApi, data);
31
- };
32
-
33
- const createSync = async (body?: components['schemas']['CreateSyncItem']) => {
34
- const {
35
- data,
36
- }: {
37
- data: components['schemas']['ReadSyncItem'];
38
- } = await _internalApi.post('/syncs', body);
39
- return Sync(_internalApi, data);
40
- };
41
-
42
- const updateSync = async (body?: components['schemas']['CreateSyncItem']) => {
43
- const {
44
- data,
45
- }: {
46
- data: components['schemas']['ReadSyncItem'];
47
- } = await _internalApi.patch('/syncs', body);
48
- return Sync(_internalApi, data);
49
- };
50
-
51
- return {
52
- createSync,
53
- getSyncs,
54
- getSyncById,
55
- updateSync,
56
- };
57
- };
58
-
59
- export { Syncs };
@@ -1,86 +0,0 @@
1
- import { operations } from '../types/public-api/schema';
2
- import { InternalAPI } from './internalApi';
3
- import { chiftOperations } from '../types/public-api/mappings';
4
-
5
- const Webhooks = (internalApi: InternalAPI) => {
6
- const _internalApi: InternalAPI = internalApi;
7
-
8
- const getWebhookTypes = async () => {
9
- const {
10
- data,
11
- }: {
12
- data: operations[chiftOperations['getWebhookTypes']]['responses'][200]['content']['application/json'];
13
- } = await _internalApi.get('/webhooks/list');
14
- return data;
15
- };
16
-
17
- const getWebhooks = async () => {
18
- const {
19
- data,
20
- }: {
21
- data: operations[chiftOperations['getWebhooks']]['responses'][200]['content']['application/json'];
22
- } = await _internalApi.get('/webhooks');
23
- return data;
24
- };
25
-
26
- const registerWebhook = async (
27
- body: operations[chiftOperations['registerWebhook']]['requestBody']['content']['application/json']
28
- ) => {
29
- const {
30
- data,
31
- }: {
32
- data: operations[chiftOperations['createConsumer']]['responses'][200]['content']['application/json'];
33
- } = await _internalApi.post('/webhooks', body);
34
- return data;
35
- };
36
-
37
- const getWebhookById = async (webhookId: string) => {
38
- const {
39
- data,
40
- }: {
41
- data: operations[chiftOperations['getWebhookById']]['responses'][200]['content']['application/json'];
42
- } = await _internalApi.get(`/webhooks/${webhookId}`);
43
- return data;
44
- };
45
-
46
- const updateWebhookById = async (
47
- webhookId: string,
48
- body: operations[chiftOperations['updateWebhookById']]['requestBody']['content']['application/json']
49
- ) => {
50
- const {
51
- data,
52
- }: {
53
- data: operations[chiftOperations['updateConsumer']]['responses'][200]['content']['application/json'];
54
- } = await _internalApi.patch(`/webhooks/${webhookId}`, body);
55
- return data;
56
- };
57
-
58
- const unRegisterWebhook = async (webhookId: string) => {
59
- const {
60
- data,
61
- }: { data: operations[chiftOperations['unRegisterWebhook']]['responses'][204] } =
62
- await _internalApi.delete(`/webhooks/${webhookId}`);
63
- return data;
64
- };
65
-
66
- const getWebhookLogsByWebhookId = async (webhookId: string) => {
67
- const {
68
- data,
69
- }: {
70
- data: operations[chiftOperations['getWebhookLogsByWebhookId']]['responses'][200]['content']['application/json'];
71
- } = await _internalApi.get(`/webhooks/${webhookId}/logs`);
72
- return data;
73
- };
74
-
75
- return {
76
- getWebhookTypes,
77
- registerWebhook,
78
- getWebhookById,
79
- updateWebhookById,
80
- unRegisterWebhook,
81
- getWebhookLogsByWebhookId,
82
- getWebhooks,
83
- };
84
- };
85
-
86
- export { Webhooks };
package/src/types/api.ts DELETED
@@ -1,37 +0,0 @@
1
- export interface AuthType {
2
- clientId: string;
3
- clientSecret: string;
4
- accountId: string;
5
- envId?: string;
6
- baseUrl?: string;
7
- }
8
-
9
- export interface TokenType {
10
- access_token: string;
11
- token_type: string;
12
- expires_in: number;
13
- expires_on: number;
14
- }
15
-
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- export type RequestData<TResponse> = {
18
- method: string;
19
- property?: string;
20
- consumerName?: string;
21
- consumerId?: string;
22
- url: string;
23
- params?: unknown;
24
- body?: unknown;
25
- };
26
-
27
- export type RequestFactory = { [key: string]: (...args: any) => RequestData<any> };
28
-
29
- export type ApiFor<TFactory extends RequestFactory> = {
30
- [key in keyof TFactory]: TFactory[key] extends (
31
- ...args: infer TArgs
32
- ) => RequestData<infer TResponse>
33
- ? (...args: TArgs) => Promise<TResponse>
34
- : never;
35
- };
36
-
37
- export type AutoPaginatedParams<T> = Omit<Exclude<T, undefined>, 'page' | 'size'>;
@@ -1,9 +0,0 @@
1
- export interface Consumers {
2
- method: void;
3
- }
4
-
5
- export interface ConsumerLog {
6
- type: string;
7
- message: string;
8
- context: any;
9
- }
@@ -1,21 +0,0 @@
1
- export type chiftOperations = {
2
- getConsumers: 'consumers_get_consumers';
3
- createConsumer: 'consumers_create_consumer';
4
- getConsumerById: 'consumers_get_consumer';
5
- updateConsumer: 'consumers_update_consumer';
6
- deleteConsumerById: 'consumers_delete_consumer';
7
- getConnectionsByConsumerId: 'connections_get_connections';
8
- createConnection: 'connections_create_connection';
9
- deleteConnectionById: 'connections_delete_connection';
10
- updateConnection: 'connections_update_connection';
11
- getSyncs: 'syncs_get_syncs';
12
- getIntegrations: 'integrations_get_integrations';
13
- getWebhookTypes: 'webhooks_get_webhook_types';
14
- getWebhooks: 'webhooks_get_webhooks';
15
- registerWebhook: 'webhooks_create_webhook';
16
- unRegisterWebhook: 'webhooks_delete_webhook';
17
- getWebhookById: 'webhooks_get_webhook';
18
- updateWebhookById: 'webhooks_update_webhook';
19
- getWebhookLogsByWebhookId: 'webhooks_get_webhook_logs';
20
- getSync: 'syncs_get_sync';
21
- };
package/src/types/sync.ts DELETED
@@ -1,38 +0,0 @@
1
- interface FlowTriggerOptions {
2
- autostart?: boolean;
3
- }
4
-
5
- export interface FlowTrigger {
6
- id: string;
7
- type: 'event' | 'timer';
8
- cronschedules?: string[];
9
- definitionFields?: any[];
10
- visible?: boolean;
11
- label?: string;
12
- options?: FlowTriggerOptions;
13
- }
14
-
15
- interface FlowConfig {
16
- datastores?: { id: string; name: string }[];
17
- definitionFields?: Record<string, unknown>[];
18
- doorkeyFields?: Record<string, unknown>[];
19
- }
20
-
21
- export interface ExecutionType {
22
- type: 'code' | 'module';
23
- data?: any;
24
- }
25
-
26
- export interface ContextType {
27
- name: string;
28
- description?: string;
29
- triggers: FlowTrigger[];
30
- execution: ExecutionType;
31
- config?: FlowConfig;
32
- }
33
-
34
- export interface SimpleResponseModel {
35
- status: string;
36
- message: string;
37
- data?: any;
38
- }
Binary file