@accounter/server 0.0.8-alpha-20251105181339-4ce756e457f7145a4035565e526bc02285ab2675 → 0.0.8-alpha-20251105183654-b3147b83bfda6ce62d09073ce81342ceadf5160c
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/CHANGELOG.md +25 -5
- package/dist/server/src/__generated__/types.d.ts +39 -10
- package/dist/server/src/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/financial-entities/__generated__/clients.types.d.ts +11 -4
- package/dist/server/src/modules/financial-entities/__generated__/types.d.ts +19 -7
- package/dist/server/src/modules/financial-entities/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/financial-entities/helpers/clients.helper.d.ts +11 -0
- package/dist/server/src/modules/financial-entities/helpers/clients.helper.js +26 -0
- package/dist/server/src/modules/financial-entities/helpers/clients.helper.js.map +1 -0
- package/dist/server/src/modules/financial-entities/providers/businesses.provider.js +1 -1
- package/dist/server/src/modules/financial-entities/providers/clients.provider.js +18 -16
- package/dist/server/src/modules/financial-entities/providers/clients.provider.js.map +1 -1
- package/dist/server/src/modules/financial-entities/resolvers/clients.resolvers.js +26 -24
- package/dist/server/src/modules/financial-entities/resolvers/clients.resolvers.js.map +1 -1
- package/dist/server/src/modules/financial-entities/typeDefs/clients.graphql.js +24 -8
- package/dist/server/src/modules/financial-entities/typeDefs/clients.graphql.js.map +1 -1
- package/dist/server/src/modules/green-invoice/__generated__/types.d.ts +8 -0
- package/dist/server/src/modules/green-invoice/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.d.ts +3 -1
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js +5 -12
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js.map +1 -1
- package/dist/server/src/modules/green-invoice/helpers/green-invoice-clients.helper.d.ts +1 -2
- package/dist/server/src/modules/green-invoice/helpers/green-invoice-clients.helper.js +17 -31
- package/dist/server/src/modules/green-invoice/helpers/green-invoice-clients.helper.js.map +1 -1
- package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.d.ts +2 -2
- package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.js +16 -14
- package/dist/server/src/modules/green-invoice/helpers/green-invoice.helper.js.map +1 -1
- package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js +91 -29
- package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js.map +1 -1
- package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js +4 -0
- package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js.map +1 -1
- package/package.json +3 -4
- package/src/__generated__/types.ts +42 -10
- package/src/modules/financial-entities/__generated__/clients.types.ts +10 -4
- package/src/modules/financial-entities/__generated__/types.ts +19 -7
- package/src/modules/financial-entities/helpers/clients.helper.ts +28 -0
- package/src/modules/financial-entities/providers/businesses.provider.ts +1 -1
- package/src/modules/financial-entities/providers/clients.provider.ts +19 -16
- package/src/modules/financial-entities/resolvers/clients.resolvers.ts +30 -27
- package/src/modules/financial-entities/typeDefs/clients.graphql.ts +24 -8
- package/src/modules/green-invoice/__generated__/types.ts +8 -0
- package/src/modules/green-invoice/helpers/contract-to-draft.helper.ts +7 -13
- package/src/modules/green-invoice/helpers/green-invoice-clients.helper.ts +19 -40
- package/src/modules/green-invoice/helpers/green-invoice.helper.ts +17 -18
- package/src/modules/green-invoice/resolvers/green-invoice.resolvers.ts +101 -35
- package/src/modules/green-invoice/typeDefs/green-invoice.graphql.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @accounter/server
|
|
2
2
|
|
|
3
|
-
## 0.0.8-alpha-
|
|
3
|
+
## 0.0.8-alpha-20251105183654-b3147b83bfda6ce62d09073ce81342ceadf5160c
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -264,6 +264,16 @@
|
|
|
264
264
|
- Updated dependency [`graphql@16.12.0` ↗︎](https://www.npmjs.com/package/graphql/v/16.12.0)
|
|
265
265
|
(from `16.11.0`, in `dependencies`)
|
|
266
266
|
|
|
267
|
+
- [#2655](https://github.com/Urigo/accounter-fullstack/pull/2655)
|
|
268
|
+
[`dd02669`](https://github.com/Urigo/accounter-fullstack/commit/dd02669a794e4debd032cd4a2c418795cba38563)
|
|
269
|
+
Thanks [@gilgardosh](https://github.com/gilgardosh)! - dependencies updates:
|
|
270
|
+
- Updated dependency
|
|
271
|
+
[`@graphql-yoga/plugin-defer-stream@3.16.1` ↗︎](https://www.npmjs.com/package/@graphql-yoga/plugin-defer-stream/v/3.16.1)
|
|
272
|
+
(from `3.16.0`, in `dependencies`)
|
|
273
|
+
- Updated dependency
|
|
274
|
+
[`graphql-yoga@5.16.1` ↗︎](https://www.npmjs.com/package/graphql-yoga/v/5.16.1) (from `5.16.0`,
|
|
275
|
+
in `dependencies`)
|
|
276
|
+
|
|
267
277
|
- [#2662](https://github.com/Urigo/accounter-fullstack/pull/2662)
|
|
268
278
|
[`fa15c75`](https://github.com/Urigo/accounter-fullstack/commit/fa15c754be3cf82893a3573b4ebe60776c96a296)
|
|
269
279
|
Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
|
|
@@ -650,6 +660,16 @@
|
|
|
650
660
|
`packages/server/src/modules/app-providers/green-invoice-client.ts`, the access patterns for these
|
|
651
661
|
environment variables have been updated to use optional chaining (`?.`) to safely handle cases
|
|
652
662
|
where the configuration might be `undefined`.
|
|
663
|
+
|
|
664
|
+
- [#2655](https://github.com/Urigo/accounter-fullstack/pull/2655)
|
|
665
|
+
[`eee0a0e`](https://github.com/Urigo/accounter-fullstack/commit/eee0a0e586d6c5b49caa3a7ac308b8bd79f11b8a)
|
|
666
|
+
Thanks [@gilgardosh](https://github.com/gilgardosh)! - - Introduced a new `ClientIntegrations`
|
|
667
|
+
GraphQL type with a JSONB-backed structure
|
|
668
|
+
- Migrated `green_invoice_id` and `hive_id` columns to a unified `integrations` JSONB field
|
|
669
|
+
- Added validation helper using Zod schema for client integrations
|
|
670
|
+
- Updated GraphQL resolvers to use the new structure, with `GreenInvoiceClient` now resolving as a
|
|
671
|
+
string ID
|
|
672
|
+
- Activate integrations section in the client management UI to reflect backend changes
|
|
653
673
|
- Updated dependencies
|
|
654
674
|
[[`1ae19c6`](https://github.com/Urigo/accounter-fullstack/commit/1ae19c6f8dabd995120862795284dab6e363dc79),
|
|
655
675
|
[`7fef068`](https://github.com/Urigo/accounter-fullstack/commit/7fef0682c7316153ae5ffde42f97ce7284dd4c9a),
|
|
@@ -658,10 +678,10 @@
|
|
|
658
678
|
[`65e3c7f`](https://github.com/Urigo/accounter-fullstack/commit/65e3c7f01993eb4f41244a40feefefa08b31a4e6),
|
|
659
679
|
[`7a898a0`](https://github.com/Urigo/accounter-fullstack/commit/7a898a0ff1ee15420ab2532370a1d2f618cc86ab),
|
|
660
680
|
[`15ed6f9`](https://github.com/Urigo/accounter-fullstack/commit/15ed6f982a5d288a1159ccd069fca14b35801a18)]:
|
|
661
|
-
- @accounter/green-invoice-graphql@0.8.2-alpha-
|
|
662
|
-
- @accounter/pcn874-generator@0.6.3-alpha-
|
|
663
|
-
- @accounter/shaam-uniform-format-generator@0.2.2-alpha-
|
|
664
|
-
- @accounter/shaam6111-generator@0.1.4-alpha-
|
|
681
|
+
- @accounter/green-invoice-graphql@0.8.2-alpha-20251105183654-b3147b83bfda6ce62d09073ce81342ceadf5160c
|
|
682
|
+
- @accounter/pcn874-generator@0.6.3-alpha-20251105183654-b3147b83bfda6ce62d09073ce81342ceadf5160c
|
|
683
|
+
- @accounter/shaam-uniform-format-generator@0.2.2-alpha-20251105183654-b3147b83bfda6ce62d09073ce81342ceadf5160c
|
|
684
|
+
- @accounter/shaam6111-generator@0.1.4-alpha-20251105183654-b3147b83bfda6ce62d09073ce81342ceadf5160c
|
|
665
685
|
|
|
666
686
|
## 0.0.7
|
|
667
687
|
|
|
@@ -916,10 +916,8 @@ export type Client = {
|
|
|
916
916
|
readonly __typename?: 'Client';
|
|
917
917
|
readonly emails: ReadonlyArray<Scalars['String']['output']>;
|
|
918
918
|
readonly generatedDocumentType: DocumentType;
|
|
919
|
-
readonly greenInvoiceId?: Maybe<Scalars['UUID']['output']>;
|
|
920
|
-
readonly greenInvoiceInfo?: Maybe<GreenInvoiceClient>;
|
|
921
|
-
readonly hiveId?: Maybe<Scalars['String']['output']>;
|
|
922
919
|
readonly id: Scalars['UUID']['output'];
|
|
920
|
+
readonly integrations: ClientIntegrations;
|
|
923
921
|
readonly originalBusiness: LtdFinancialEntity;
|
|
924
922
|
};
|
|
925
923
|
/** fields for inserting a new client */
|
|
@@ -927,15 +925,33 @@ export type ClientInsertInput = {
|
|
|
927
925
|
readonly businessId: Scalars['UUID']['input'];
|
|
928
926
|
readonly emails?: InputMaybe<ReadonlyArray<Scalars['String']['input']>>;
|
|
929
927
|
readonly generatedDocumentType: DocumentType;
|
|
928
|
+
readonly integrations?: InputMaybe<ClientIntegrationsInput>;
|
|
929
|
+
};
|
|
930
|
+
/** integrations associated with a client */
|
|
931
|
+
export type ClientIntegrations = {
|
|
932
|
+
readonly __typename?: 'ClientIntegrations';
|
|
933
|
+
readonly greenInvoiceInfo?: Maybe<GreenInvoiceClient>;
|
|
934
|
+
readonly hiveId?: Maybe<Scalars['String']['output']>;
|
|
935
|
+
readonly id: Scalars['ID']['output'];
|
|
936
|
+
readonly linearId?: Maybe<Scalars['String']['output']>;
|
|
937
|
+
readonly notionId?: Maybe<Scalars['String']['output']>;
|
|
938
|
+
readonly slackChannelKey?: Maybe<Scalars['String']['output']>;
|
|
939
|
+
readonly workflowyUrl?: Maybe<Scalars['String']['output']>;
|
|
940
|
+
};
|
|
941
|
+
/** integrations input for client insert/update */
|
|
942
|
+
export type ClientIntegrationsInput = {
|
|
930
943
|
readonly greenInvoiceId?: InputMaybe<Scalars['UUID']['input']>;
|
|
931
944
|
readonly hiveId?: InputMaybe<Scalars['String']['input']>;
|
|
945
|
+
readonly linearId?: InputMaybe<Scalars['String']['input']>;
|
|
946
|
+
readonly notionId?: InputMaybe<Scalars['String']['input']>;
|
|
947
|
+
readonly slackChannelKey?: InputMaybe<Scalars['String']['input']>;
|
|
948
|
+
readonly workflowyUrl?: InputMaybe<Scalars['String']['input']>;
|
|
932
949
|
};
|
|
933
950
|
/** fields for updating an existing client */
|
|
934
951
|
export type ClientUpdateInput = {
|
|
935
952
|
readonly emails?: InputMaybe<ReadonlyArray<Scalars['String']['input']>>;
|
|
936
953
|
readonly generatedDocumentType?: InputMaybe<DocumentType>;
|
|
937
|
-
readonly
|
|
938
|
-
readonly hiveId?: InputMaybe<Scalars['String']['input']>;
|
|
954
|
+
readonly integrations?: InputMaybe<ClientIntegrationsInput>;
|
|
939
955
|
readonly newBusinessId?: InputMaybe<Scalars['UUID']['input']>;
|
|
940
956
|
};
|
|
941
957
|
/** common charge */
|
|
@@ -4257,6 +4273,8 @@ export type ResolversTypes = {
|
|
|
4257
4273
|
}>;
|
|
4258
4274
|
Client: ResolverTypeWrapper<IGetAllClientsResult>;
|
|
4259
4275
|
ClientInsertInput: ClientInsertInput;
|
|
4276
|
+
ClientIntegrations: ResolverTypeWrapper<IGetAllClientsResult>;
|
|
4277
|
+
ClientIntegrationsInput: ClientIntegrationsInput;
|
|
4260
4278
|
ClientUpdateInput: ClientUpdateInput;
|
|
4261
4279
|
CommonCharge: ResolverTypeWrapper<IGetChargesByIdsResult>;
|
|
4262
4280
|
CommonError: ResolverTypeWrapper<CommonError>;
|
|
@@ -4329,7 +4347,7 @@ export type ResolversTypes = {
|
|
|
4329
4347
|
Fund: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Fund']>;
|
|
4330
4348
|
GenerateMonthlyClientDocumentsResult: ResolverTypeWrapper<GenerateMonthlyClientDocumentsResult>;
|
|
4331
4349
|
GeneratedLedgerRecords: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['GeneratedLedgerRecords']>;
|
|
4332
|
-
GreenInvoiceClient: ResolverTypeWrapper<
|
|
4350
|
+
GreenInvoiceClient: ResolverTypeWrapper<string>;
|
|
4333
4351
|
GreenInvoiceClientInput: GreenInvoiceClientInput;
|
|
4334
4352
|
GreenInvoiceCountry: GreenInvoiceCountry;
|
|
4335
4353
|
GreenInvoiceDiscount: ResolverTypeWrapper<GreenInvoiceDiscount>;
|
|
@@ -4628,6 +4646,8 @@ export type ResolversParentTypes = {
|
|
|
4628
4646
|
};
|
|
4629
4647
|
Client: IGetAllClientsResult;
|
|
4630
4648
|
ClientInsertInput: ClientInsertInput;
|
|
4649
|
+
ClientIntegrations: IGetAllClientsResult;
|
|
4650
|
+
ClientIntegrationsInput: ClientIntegrationsInput;
|
|
4631
4651
|
ClientUpdateInput: ClientUpdateInput;
|
|
4632
4652
|
CommonCharge: IGetChargesByIdsResult;
|
|
4633
4653
|
CommonError: CommonError;
|
|
@@ -4691,7 +4711,7 @@ export type ResolversParentTypes = {
|
|
|
4691
4711
|
Fund: ResolversInterfaceTypes<ResolversParentTypes>['Fund'];
|
|
4692
4712
|
GenerateMonthlyClientDocumentsResult: GenerateMonthlyClientDocumentsResult;
|
|
4693
4713
|
GeneratedLedgerRecords: ResolversUnionTypes<ResolversParentTypes>['GeneratedLedgerRecords'];
|
|
4694
|
-
GreenInvoiceClient:
|
|
4714
|
+
GreenInvoiceClient: string;
|
|
4695
4715
|
GreenInvoiceClientInput: GreenInvoiceClientInput;
|
|
4696
4716
|
GreenInvoiceDiscount: GreenInvoiceDiscount;
|
|
4697
4717
|
GreenInvoiceDiscountInput: GreenInvoiceDiscountInput;
|
|
@@ -5368,13 +5388,21 @@ export type ChargesWithLedgerChangesResultResolvers<ContextType = GraphQLModules
|
|
|
5368
5388
|
export type ClientResolvers<ContextType = GraphQLModules.Context, ParentType extends ResolversParentTypes['Client'] = ResolversParentTypes['Client']> = {
|
|
5369
5389
|
emails?: Resolver<ReadonlyArray<ResolversTypes['String']>, ParentType, ContextType>;
|
|
5370
5390
|
generatedDocumentType?: Resolver<ResolversTypes['DocumentType'], ParentType, ContextType>;
|
|
5371
|
-
greenInvoiceId?: Resolver<Maybe<ResolversTypes['UUID']>, ParentType, ContextType>;
|
|
5372
|
-
greenInvoiceInfo?: Resolver<Maybe<ResolversTypes['GreenInvoiceClient']>, ParentType, ContextType>;
|
|
5373
|
-
hiveId?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
5374
5391
|
id?: Resolver<ResolversTypes['UUID'], ParentType, ContextType>;
|
|
5392
|
+
integrations?: Resolver<ResolversTypes['ClientIntegrations'], ParentType, ContextType>;
|
|
5375
5393
|
originalBusiness?: Resolver<ResolversTypes['LtdFinancialEntity'], ParentType, ContextType>;
|
|
5376
5394
|
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
5377
5395
|
};
|
|
5396
|
+
export type ClientIntegrationsResolvers<ContextType = GraphQLModules.Context, ParentType extends ResolversParentTypes['ClientIntegrations'] = ResolversParentTypes['ClientIntegrations']> = {
|
|
5397
|
+
greenInvoiceInfo?: Resolver<Maybe<ResolversTypes['GreenInvoiceClient']>, ParentType, ContextType>;
|
|
5398
|
+
hiveId?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
5399
|
+
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
|
|
5400
|
+
linearId?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
5401
|
+
notionId?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
5402
|
+
slackChannelKey?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
5403
|
+
workflowyUrl?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
5404
|
+
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
5405
|
+
};
|
|
5378
5406
|
export type CommonChargeResolvers<ContextType = GraphQLModules.Context, ParentType extends ResolversParentTypes['CommonCharge'] = ResolversParentTypes['CommonCharge']> = {
|
|
5379
5407
|
accountantApproval?: Resolver<ResolversTypes['AccountantStatus'], ParentType, ContextType>;
|
|
5380
5408
|
additionalDocuments?: Resolver<ReadonlyArray<ResolversTypes['Document']>, ParentType, ContextType>;
|
|
@@ -7089,6 +7117,7 @@ export type Resolvers<ContextType = GraphQLModules.Context> = {
|
|
|
7089
7117
|
ChargeSuggestions?: ChargeSuggestionsResolvers<ContextType>;
|
|
7090
7118
|
ChargesWithLedgerChangesResult?: ChargesWithLedgerChangesResultResolvers<ContextType>;
|
|
7091
7119
|
Client?: ClientResolvers<ContextType>;
|
|
7120
|
+
ClientIntegrations?: ClientIntegrationsResolvers<ContextType>;
|
|
7092
7121
|
CommonCharge?: CommonChargeResolvers<ContextType>;
|
|
7093
7122
|
CommonError?: CommonErrorResolvers<ContextType>;
|
|
7094
7123
|
CommonTransaction?: CommonTransactionResolvers<ContextType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/__generated__/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAu5BrD,OAAO,EAAE,iBAAiB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/__generated__/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAu5BrD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AA2Y7B,OAAO,EAAE,QAAQ,EAAE,CAAC;AAuLpB,OAAO,EAAE,YAAY,EAAE,CAAC;AAomCxB,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAw6D7B,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/** Types generated for queries found in "src/modules/financial-entities/providers/clients.provider.ts" */
|
|
2
2
|
export type document_type = 'CREDIT_INVOICE' | 'INVOICE' | 'INVOICE_RECEIPT' | 'OTHER' | 'PROFORMA' | 'RECEIPT' | 'UNPROCESSED';
|
|
3
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
4
|
+
[key: string]: Json;
|
|
5
|
+
};
|
|
3
6
|
export type stringArray = (string)[];
|
|
4
7
|
/** 'GetAllClients' parameters type */
|
|
5
8
|
export type IGetAllClientsParams = void;
|
|
@@ -10,6 +13,7 @@ export interface IGetAllClientsResult {
|
|
|
10
13
|
emails: stringArray | null;
|
|
11
14
|
green_invoice_id: string;
|
|
12
15
|
hive_id: string | null;
|
|
16
|
+
integrations: Json | null;
|
|
13
17
|
remark: string | null;
|
|
14
18
|
}
|
|
15
19
|
/** 'GetAllClients' query type */
|
|
@@ -28,6 +32,7 @@ export interface IGetClientsByIdsResult {
|
|
|
28
32
|
emails: stringArray | null;
|
|
29
33
|
green_invoice_id: string;
|
|
30
34
|
hive_id: string | null;
|
|
35
|
+
integrations: Json | null;
|
|
31
36
|
remark: string | null;
|
|
32
37
|
}
|
|
33
38
|
/** 'GetClientsByIds' query type */
|
|
@@ -44,8 +49,10 @@ export interface IGetClientsByGreenInvoiceIdsResult {
|
|
|
44
49
|
business_id: string;
|
|
45
50
|
document_type: document_type;
|
|
46
51
|
emails: stringArray | null;
|
|
52
|
+
green_invoice_business_id: string | null;
|
|
47
53
|
green_invoice_id: string;
|
|
48
54
|
hive_id: string | null;
|
|
55
|
+
integrations: Json | null;
|
|
49
56
|
remark: string | null;
|
|
50
57
|
}
|
|
51
58
|
/** 'GetClientsByGreenInvoiceIds' query type */
|
|
@@ -57,8 +64,7 @@ export interface IGetClientsByGreenInvoiceIdsQuery {
|
|
|
57
64
|
export interface IUpdateClientParams {
|
|
58
65
|
businessId?: string | null | void;
|
|
59
66
|
emails?: stringArray | null | void;
|
|
60
|
-
|
|
61
|
-
hiveId?: string | null | void;
|
|
67
|
+
integrations?: Json | null | void;
|
|
62
68
|
newBusinessId?: string | null | void;
|
|
63
69
|
}
|
|
64
70
|
/** 'UpdateClient' return type */
|
|
@@ -68,6 +74,7 @@ export interface IUpdateClientResult {
|
|
|
68
74
|
emails: stringArray | null;
|
|
69
75
|
green_invoice_id: string;
|
|
70
76
|
hive_id: string | null;
|
|
77
|
+
integrations: Json | null;
|
|
71
78
|
remark: string | null;
|
|
72
79
|
}
|
|
73
80
|
/** 'UpdateClient' query type */
|
|
@@ -92,8 +99,7 @@ export interface IDeleteClientQuery {
|
|
|
92
99
|
export interface IInsertClientParams {
|
|
93
100
|
businessId?: string | null | void;
|
|
94
101
|
emails?: stringArray | null | void;
|
|
95
|
-
|
|
96
|
-
hiveId?: string | null | void;
|
|
102
|
+
integrations?: Json | null | void;
|
|
97
103
|
}
|
|
98
104
|
/** 'InsertClient' return type */
|
|
99
105
|
export interface IInsertClientResult {
|
|
@@ -102,6 +108,7 @@ export interface IInsertClientResult {
|
|
|
102
108
|
emails: stringArray | null;
|
|
103
109
|
green_invoice_id: string;
|
|
104
110
|
hive_id: string | null;
|
|
111
|
+
integrations: Json | null;
|
|
105
112
|
remark: string | null;
|
|
106
113
|
}
|
|
107
114
|
/** 'InsertClient' query type */
|
|
@@ -17,7 +17,8 @@ export declare namespace FinancialEntitiesModule {
|
|
|
17
17
|
Suggestions: 'phrases' | 'tags' | 'description' | 'emails' | 'emailListener' | 'priority';
|
|
18
18
|
SuggestionsEmailListenerConfig: 'internalEmailLinks' | 'emailBody' | 'attachments';
|
|
19
19
|
PersonalFinancialEntity: 'id' | 'name' | 'email' | 'pcn874RecordType' | 'irsCode' | 'isActive' | 'createdAt' | 'updatedAt';
|
|
20
|
-
Client: 'id' | 'originalBusiness' | '
|
|
20
|
+
Client: 'id' | 'originalBusiness' | 'emails' | 'generatedDocumentType' | 'integrations';
|
|
21
|
+
ClientIntegrations: 'id' | 'hiveId' | 'linearId' | 'slackChannelKey' | 'notionId' | 'workflowyUrl';
|
|
21
22
|
PaginatedFinancialEntities: 'nodes' | 'pageInfo';
|
|
22
23
|
TaxCategory: 'id' | 'name' | 'irsCode' | 'createdAt' | 'updatedAt' | 'isActive';
|
|
23
24
|
CommonCharge: 'owner' | 'counterparty' | 'taxCategory';
|
|
@@ -59,8 +60,9 @@ export declare namespace FinancialEntitiesModule {
|
|
|
59
60
|
InsertNewBusinessInput: 'name' | 'sortCode' | 'country' | 'hebrewName' | 'address' | 'email' | 'website' | 'phoneNumber' | 'governmentId' | 'taxCategory' | 'exemptDealer' | 'suggestions' | 'optionalVAT' | 'isReceiptEnough' | 'isDocumentsOptional' | 'pcn874RecordType' | 'irsCode' | 'isActive';
|
|
60
61
|
SuggestionsInput: 'phrases' | 'tags' | 'description' | 'emails' | 'emailListener' | 'priority';
|
|
61
62
|
SuggestionsEmailListenerConfigInput: 'internalEmailLinks' | 'emailBody' | 'attachments';
|
|
62
|
-
ClientInsertInput: 'businessId' | '
|
|
63
|
-
ClientUpdateInput: '
|
|
63
|
+
ClientInsertInput: 'businessId' | 'emails' | 'generatedDocumentType' | 'integrations';
|
|
64
|
+
ClientUpdateInput: 'newBusinessId' | 'emails' | 'generatedDocumentType' | 'integrations';
|
|
65
|
+
ClientIntegrationsInput: 'greenInvoiceId' | 'hiveId' | 'linearId' | 'slackChannelKey' | 'notionId' | 'workflowyUrl';
|
|
64
66
|
UpdateTaxCategoryInput: 'name' | 'sortCode' | 'irsCode' | 'isActive' | 'hashavshevetName' | 'taxExcluded';
|
|
65
67
|
InsertTaxCategoryInput: 'name' | 'sortCode' | 'irsCode' | 'hashavshevetName' | 'taxExcluded' | 'isActive';
|
|
66
68
|
UpdateChargeInput: 'counterpartyId' | 'ownerId';
|
|
@@ -123,7 +125,8 @@ export declare namespace FinancialEntitiesModule {
|
|
|
123
125
|
export type ClientUpdateInput = Pick<Types.ClientUpdateInput, DefinedInputFields['ClientUpdateInput']>;
|
|
124
126
|
export type ClientInsertInput = Pick<Types.ClientInsertInput, DefinedInputFields['ClientInsertInput']>;
|
|
125
127
|
export type DocumentType = Types.DocumentType;
|
|
126
|
-
export type
|
|
128
|
+
export type ClientIntegrations = Pick<Types.ClientIntegrations, DefinedFields['ClientIntegrations']>;
|
|
129
|
+
export type ClientIntegrationsInput = Pick<Types.ClientIntegrationsInput, DefinedInputFields['ClientIntegrationsInput']>;
|
|
127
130
|
export type PaginatedFinancialEntities = Pick<Types.PaginatedFinancialEntities, DefinedFields['PaginatedFinancialEntities']>;
|
|
128
131
|
export type UpdateChargeInput = Types.UpdateChargeInput;
|
|
129
132
|
export type Transaction = Types.Transaction;
|
|
@@ -156,6 +159,7 @@ export declare namespace FinancialEntitiesModule {
|
|
|
156
159
|
export type SuggestionsEmailListenerConfigResolvers = Pick<Types.SuggestionsEmailListenerConfigResolvers, DefinedFields['SuggestionsEmailListenerConfig']>;
|
|
157
160
|
export type PersonalFinancialEntityResolvers = Pick<Types.PersonalFinancialEntityResolvers, DefinedFields['PersonalFinancialEntity'] | '__isTypeOf'>;
|
|
158
161
|
export type ClientResolvers = Pick<Types.ClientResolvers, DefinedFields['Client'] | '__isTypeOf'>;
|
|
162
|
+
export type ClientIntegrationsResolvers = Pick<Types.ClientIntegrationsResolvers, DefinedFields['ClientIntegrations']>;
|
|
159
163
|
export type PaginatedFinancialEntitiesResolvers = Pick<Types.PaginatedFinancialEntitiesResolvers, DefinedFields['PaginatedFinancialEntities']>;
|
|
160
164
|
export type TaxCategoryResolvers = Pick<Types.TaxCategoryResolvers, DefinedFields['TaxCategory'] | '__isTypeOf'>;
|
|
161
165
|
export type CommonChargeResolvers = Pick<Types.CommonChargeResolvers, DefinedFields['CommonCharge']>;
|
|
@@ -199,6 +203,7 @@ export declare namespace FinancialEntitiesModule {
|
|
|
199
203
|
SuggestionsEmailListenerConfig?: SuggestionsEmailListenerConfigResolvers;
|
|
200
204
|
PersonalFinancialEntity?: PersonalFinancialEntityResolvers;
|
|
201
205
|
Client?: ClientResolvers;
|
|
206
|
+
ClientIntegrations?: ClientIntegrationsResolvers;
|
|
202
207
|
PaginatedFinancialEntities?: PaginatedFinancialEntitiesResolvers;
|
|
203
208
|
TaxCategory?: TaxCategoryResolvers;
|
|
204
209
|
CommonCharge?: CommonChargeResolvers;
|
|
@@ -440,11 +445,18 @@ export declare namespace FinancialEntitiesModule {
|
|
|
440
445
|
'*'?: gm.Middleware[];
|
|
441
446
|
id?: gm.Middleware[];
|
|
442
447
|
originalBusiness?: gm.Middleware[];
|
|
443
|
-
greenInvoiceId?: gm.Middleware[];
|
|
444
|
-
hiveId?: gm.Middleware[];
|
|
445
448
|
emails?: gm.Middleware[];
|
|
446
449
|
generatedDocumentType?: gm.Middleware[];
|
|
447
|
-
|
|
450
|
+
integrations?: gm.Middleware[];
|
|
451
|
+
};
|
|
452
|
+
ClientIntegrations?: {
|
|
453
|
+
'*'?: gm.Middleware[];
|
|
454
|
+
id?: gm.Middleware[];
|
|
455
|
+
hiveId?: gm.Middleware[];
|
|
456
|
+
linearId?: gm.Middleware[];
|
|
457
|
+
slackChannelKey?: gm.Middleware[];
|
|
458
|
+
notionId?: gm.Middleware[];
|
|
459
|
+
workflowyUrl?: gm.Middleware[];
|
|
448
460
|
};
|
|
449
461
|
PaginatedFinancialEntities?: {
|
|
450
462
|
'*'?: gm.Middleware[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,uBAAuB,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,uBAAuB,CAugBvC;AAvgBD,WAAiB,uBAAuB;IA6CrC,CAAC;IAKD,CAAC;IAkBD,CAAC;IAkKD,CAAC;IAgSD,CAAC;AACJ,CAAC,EAvgBgB,uBAAuB,KAAvB,uBAAuB,QAugBvC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ClientIntegrationsSchema: z.ZodObject<{
|
|
3
|
+
greenInvoiceId: z.ZodNullable<z.ZodOptional<z.ZodUUID>>;
|
|
4
|
+
hiveId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
5
|
+
linearId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
6
|
+
slackChannelKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
notionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
workflowyUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export type ClientIntegrations = z.infer<typeof ClientIntegrationsSchema>;
|
|
11
|
+
export declare function validateClientIntegrations(input: unknown): ClientIntegrations;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// Zod schema matching the GraphQL `ClientIntegrations` type
|
|
4
|
+
export const ClientIntegrationsSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
greenInvoiceId: z.uuid().optional().nullable(),
|
|
7
|
+
hiveId: z.string().optional().nullable(),
|
|
8
|
+
linearId: z.string().optional().nullable(),
|
|
9
|
+
slackChannelKey: z.string().optional().nullable(),
|
|
10
|
+
notionId: z.string().optional().nullable(),
|
|
11
|
+
workflowyUrl: z.string().optional().nullable(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
export function validateClientIntegrations(input) {
|
|
15
|
+
try {
|
|
16
|
+
const { data, success, error } = ClientIntegrationsSchema.safeParse(input);
|
|
17
|
+
if (!success) {
|
|
18
|
+
throw new Error(`Parsing error: ${error}`);
|
|
19
|
+
}
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new GraphQLError(`Failed to validate client integrations: ${error}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=clients.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.helper.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/helpers/clients.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4DAA4D;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC;IACN,cAAc,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC9C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC1C,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACjD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC1C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC/C,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACvD,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,wBAAwB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3E,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,YAAY,CAAC,2CAA2C,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
|
@@ -264,7 +264,7 @@ const replaceBusinesses = sql `
|
|
|
264
264
|
UPDATE accounter_schema.clients
|
|
265
265
|
SET business_id = $targetBusinessId
|
|
266
266
|
WHERE business_id = $businessIdToReplace
|
|
267
|
-
RETURNING
|
|
267
|
+
RETURNING (integrations->>'greenInvoiceId')::uuid
|
|
268
268
|
)
|
|
269
269
|
UPDATE accounter_schema.transactions
|
|
270
270
|
SET business_id = $targetBusinessId
|
|
@@ -4,6 +4,7 @@ import { Injectable, Scope } from 'graphql-modules';
|
|
|
4
4
|
import { DBProvider } from '../../app-providers/db.provider.js';
|
|
5
5
|
import { sql } from '@pgtyped/runtime';
|
|
6
6
|
import { getCacheInstance } from '../../../shared/helpers/index.js';
|
|
7
|
+
import { validateClientIntegrations } from '../helpers/clients.helper.js';
|
|
7
8
|
const getAllClients = sql `
|
|
8
9
|
SELECT *
|
|
9
10
|
FROM accounter_schema.clients;
|
|
@@ -14,23 +15,13 @@ const getClientsByIds = sql `
|
|
|
14
15
|
WHERE business_id IN $$businessIds;
|
|
15
16
|
`;
|
|
16
17
|
const getClientsByGreenInvoiceIds = sql `
|
|
17
|
-
SELECT
|
|
18
|
+
SELECT *, (integrations->>'greenInvoiceId')::uuid as green_invoice_business_id
|
|
18
19
|
FROM accounter_schema.clients
|
|
19
|
-
WHERE
|
|
20
|
+
WHERE (integrations->>'greenInvoiceId')::uuid in $$greenInvoiceBusinessIds;
|
|
20
21
|
`;
|
|
21
22
|
const updateClient = sql `
|
|
22
23
|
UPDATE accounter_schema.clients
|
|
23
24
|
SET
|
|
24
|
-
green_invoice_id = COALESCE(
|
|
25
|
-
$greenInvoiceId,
|
|
26
|
-
green_invoice_id,
|
|
27
|
-
NULL
|
|
28
|
-
),
|
|
29
|
-
hive_id = COALESCE(
|
|
30
|
-
$hiveId,
|
|
31
|
-
hive_id,
|
|
32
|
-
NULL
|
|
33
|
-
),
|
|
34
25
|
emails = COALESCE(
|
|
35
26
|
$emails,
|
|
36
27
|
emails,
|
|
@@ -40,6 +31,11 @@ const updateClient = sql `
|
|
|
40
31
|
$newBusinessId,
|
|
41
32
|
business_id,
|
|
42
33
|
NULL
|
|
34
|
+
),
|
|
35
|
+
integrations = COALESCE(
|
|
36
|
+
$integrations,
|
|
37
|
+
integrations,
|
|
38
|
+
NULL
|
|
43
39
|
)
|
|
44
40
|
WHERE
|
|
45
41
|
business_id = $businessId
|
|
@@ -51,8 +47,8 @@ const deleteClient = sql `
|
|
|
51
47
|
RETURNING business_id;
|
|
52
48
|
`;
|
|
53
49
|
const insertClient = sql `
|
|
54
|
-
INSERT INTO accounter_schema.clients (business_id,
|
|
55
|
-
VALUES ($businessId, $
|
|
50
|
+
INSERT INTO accounter_schema.clients (business_id, emails, integrations)
|
|
51
|
+
VALUES ($businessId, $emails, $integrations)
|
|
56
52
|
RETURNING *;`;
|
|
57
53
|
let ClientsProvider = class ClientsProvider {
|
|
58
54
|
dbProvider;
|
|
@@ -71,7 +67,13 @@ let ClientsProvider = class ClientsProvider {
|
|
|
71
67
|
this.cache.set('all-clients', data);
|
|
72
68
|
data.map(client => {
|
|
73
69
|
this.cache.set(`client-id-${client.business_id}`, client);
|
|
74
|
-
|
|
70
|
+
try {
|
|
71
|
+
const { greenInvoiceId } = validateClientIntegrations(client.integrations ?? {});
|
|
72
|
+
this.cache.set(`client-green-invoice-id-${greenInvoiceId}`, client);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// swallow errors
|
|
76
|
+
}
|
|
75
77
|
});
|
|
76
78
|
return data;
|
|
77
79
|
});
|
|
@@ -93,7 +95,7 @@ let ClientsProvider = class ClientsProvider {
|
|
|
93
95
|
async batchClientsByGreenInvoiceIds(greenInvoiceIds) {
|
|
94
96
|
try {
|
|
95
97
|
const matches = await getClientsByGreenInvoiceIds.run({ greenInvoiceBusinessIds: greenInvoiceIds }, this.dbProvider);
|
|
96
|
-
return greenInvoiceIds.map(id => matches.find(match => match.
|
|
98
|
+
return greenInvoiceIds.map(id => matches.find(match => match.green_invoice_business_id === id));
|
|
97
99
|
}
|
|
98
100
|
catch (e) {
|
|
99
101
|
console.error(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.provider.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/providers/clients.provider.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"clients.provider.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/providers/clients.provider.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAa1E,MAAM,aAAa,GA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from 'graphql';
|
|
2
|
-
import { GreenInvoiceClientProvider } from '../../app-providers/green-invoice-client.js';
|
|
3
2
|
import { BusinessesProvider } from '../../financial-entities/providers/businesses.provider.js';
|
|
4
3
|
import { addGreenInvoiceClient, updateGreenInvoiceClient, } from '../../green-invoice/helpers/green-invoice-clients.helper.js';
|
|
4
|
+
import { validateClientIntegrations } from '../helpers/clients.helper.js';
|
|
5
5
|
import { ClientsProvider } from '../providers/clients.provider.js';
|
|
6
6
|
export const clientsResolvers = {
|
|
7
7
|
Query: {
|
|
@@ -33,12 +33,25 @@ export const clientsResolvers = {
|
|
|
33
33
|
},
|
|
34
34
|
Mutation: {
|
|
35
35
|
updateClient: async (_, { businessId, fields }, { injector }) => {
|
|
36
|
+
let updatedIntegrations = fields.integrations ?? undefined;
|
|
37
|
+
if (updatedIntegrations) {
|
|
38
|
+
const currentClient = await injector
|
|
39
|
+
.get(ClientsProvider)
|
|
40
|
+
.getClientByIdLoader.load(businessId);
|
|
41
|
+
if (!currentClient) {
|
|
42
|
+
throw new GraphQLError(`Client with ID="${businessId}" not found`);
|
|
43
|
+
}
|
|
44
|
+
const currentIntegrations = validateClientIntegrations(currentClient.integrations);
|
|
45
|
+
updatedIntegrations = {
|
|
46
|
+
...currentIntegrations,
|
|
47
|
+
...updatedIntegrations,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
36
50
|
const adjustedFields = {
|
|
37
51
|
businessId,
|
|
38
52
|
emails: fields.emails ? [...fields.emails] : undefined,
|
|
39
|
-
greenInvoiceId: fields.greenInvoiceId,
|
|
40
|
-
hiveId: fields.hiveId,
|
|
41
53
|
newBusinessId: fields.newBusinessId,
|
|
54
|
+
integrations: updatedIntegrations,
|
|
42
55
|
};
|
|
43
56
|
try {
|
|
44
57
|
const [updatedClient] = await injector
|
|
@@ -68,8 +81,7 @@ export const clientsResolvers = {
|
|
|
68
81
|
const newClient = {
|
|
69
82
|
businessId: fields.businessId,
|
|
70
83
|
emails: fields.emails ? [...fields.emails] : [],
|
|
71
|
-
|
|
72
|
-
hiveId: fields.hiveId,
|
|
84
|
+
integrations: fields.integrations,
|
|
73
85
|
};
|
|
74
86
|
const [insertClient] = await injector.get(ClientsProvider).insertClient(newClient);
|
|
75
87
|
if (!insertClient) {
|
|
@@ -99,26 +111,16 @@ export const clientsResolvers = {
|
|
|
99
111
|
}
|
|
100
112
|
return businessMatch;
|
|
101
113
|
},
|
|
102
|
-
greenInvoiceId: business => business.green_invoice_id,
|
|
103
|
-
hiveId: business => business.hive_id,
|
|
104
114
|
emails: business => business.emails ?? [],
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
const emails = client.emails ? client.emails.filter(Boolean) : [];
|
|
116
|
-
return {
|
|
117
|
-
...client,
|
|
118
|
-
emails,
|
|
119
|
-
id: business.green_invoice_id,
|
|
120
|
-
};
|
|
121
|
-
},
|
|
115
|
+
integrations: business => business,
|
|
116
|
+
},
|
|
117
|
+
ClientIntegrations: {
|
|
118
|
+
id: business => `${business.business_id}-integrations`,
|
|
119
|
+
hiveId: business => validateClientIntegrations(business.integrations).hiveId ?? null,
|
|
120
|
+
linearId: business => validateClientIntegrations(business.integrations).linearId ?? null,
|
|
121
|
+
slackChannelKey: business => validateClientIntegrations(business.integrations).slackChannelKey ?? null,
|
|
122
|
+
notionId: business => validateClientIntegrations(business.integrations).notionId ?? null,
|
|
123
|
+
workflowyUrl: business => validateClientIntegrations(business.integrations).workflowyUrl ?? null,
|
|
122
124
|
},
|
|
123
125
|
LtdFinancialEntity: {
|
|
124
126
|
clientInfo: async (business, _, { injector }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.resolvers.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/resolvers/clients.resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"clients.resolvers.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/resolvers/clients.resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,EACL,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,gEAAgE,CAAC;AAExE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAOnE,MAAM,CAAC,MAAM,gBAAgB,GACe;IAC1C,KAAK,EAAE;QACL,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAChD,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAExF,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,IAAI,YAAY,CAAC,mBAAmB,UAAU,aAAa,CAAC,CAAC;gBACrE,CAAC;gBAED,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,wBAAwB,CAAC;gBACzC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC9B,MAAM,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YACxC,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,aAAa,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