@powerhousedao/contributor-billing 0.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.
- package/LICENSE +661 -0
- package/README.md +22 -0
- package/dist/document-models/index.d.ts +2 -0
- package/dist/document-models/index.d.ts.map +1 -0
- package/dist/document-models/index.js +1 -0
- package/dist/document-models/invoice/gen/actions.d.ts +8 -0
- package/dist/document-models/invoice/gen/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/actions.js +3 -0
- package/dist/document-models/invoice/gen/creators.d.ts +4 -0
- package/dist/document-models/invoice/gen/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/creators.js +3 -0
- package/dist/document-models/invoice/gen/document-model.d.ts +3 -0
- package/dist/document-models/invoice/gen/document-model.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/document-model.js +227 -0
- package/dist/document-models/invoice/gen/general/actions.d.ts +10 -0
- package/dist/document-models/invoice/gen/general/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/actions.js +1 -0
- package/dist/document-models/invoice/gen/general/creators.d.ts +9 -0
- package/dist/document-models/invoice/gen/general/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/creators.js +8 -0
- package/dist/document-models/invoice/gen/general/error.d.ts +2 -0
- package/dist/document-models/invoice/gen/general/error.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/error.js +1 -0
- package/dist/document-models/invoice/gen/general/object.d.ts +12 -0
- package/dist/document-models/invoice/gen/general/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/object.js +22 -0
- package/dist/document-models/invoice/gen/general/operations.d.ts +12 -0
- package/dist/document-models/invoice/gen/general/operations.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/general/operations.js +1 -0
- package/dist/document-models/invoice/gen/index.d.ts +6 -0
- package/dist/document-models/invoice/gen/index.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/index.js +5 -0
- package/dist/document-models/invoice/gen/items/actions.d.ts +8 -0
- package/dist/document-models/invoice/gen/items/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/actions.js +1 -0
- package/dist/document-models/invoice/gen/items/creators.d.ts +7 -0
- package/dist/document-models/invoice/gen/items/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/creators.js +6 -0
- package/dist/document-models/invoice/gen/items/error.d.ts +2 -0
- package/dist/document-models/invoice/gen/items/error.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/error.js +1 -0
- package/dist/document-models/invoice/gen/items/object.d.ts +10 -0
- package/dist/document-models/invoice/gen/items/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/object.js +16 -0
- package/dist/document-models/invoice/gen/items/operations.d.ts +10 -0
- package/dist/document-models/invoice/gen/items/operations.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/items/operations.js +1 -0
- package/dist/document-models/invoice/gen/object.d.ts +20 -0
- package/dist/document-models/invoice/gen/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/object.js +29 -0
- package/dist/document-models/invoice/gen/parties/actions.d.ts +10 -0
- package/dist/document-models/invoice/gen/parties/actions.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/actions.js +1 -0
- package/dist/document-models/invoice/gen/parties/creators.d.ts +9 -0
- package/dist/document-models/invoice/gen/parties/creators.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/creators.js +8 -0
- package/dist/document-models/invoice/gen/parties/error.d.ts +2 -0
- package/dist/document-models/invoice/gen/parties/error.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/error.js +1 -0
- package/dist/document-models/invoice/gen/parties/object.d.ts +12 -0
- package/dist/document-models/invoice/gen/parties/object.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/object.js +22 -0
- package/dist/document-models/invoice/gen/parties/operations.d.ts +12 -0
- package/dist/document-models/invoice/gen/parties/operations.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/parties/operations.js +1 -0
- package/dist/document-models/invoice/gen/reducer.d.ts +3 -0
- package/dist/document-models/invoice/gen/reducer.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/reducer.js +79 -0
- package/dist/document-models/invoice/gen/schema/index.d.ts +3 -0
- package/dist/document-models/invoice/gen/schema/index.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/schema/index.js +2 -0
- package/dist/document-models/invoice/gen/schema/types.d.ts +390 -0
- package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/schema/types.js +1 -0
- package/dist/document-models/invoice/gen/schema/zod.d.ts +56 -0
- package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/schema/zod.js +362 -0
- package/dist/document-models/invoice/gen/types.d.ts +10 -0
- package/dist/document-models/invoice/gen/types.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/types.js +1 -0
- package/dist/document-models/invoice/gen/utils.d.ts +7 -0
- package/dist/document-models/invoice/gen/utils.d.ts.map +1 -0
- package/dist/document-models/invoice/gen/utils.js +166 -0
- package/dist/document-models/invoice/index.d.ts +41 -0
- package/dist/document-models/invoice/index.d.ts.map +1 -0
- package/dist/document-models/invoice/index.js +21 -0
- package/dist/document-models/invoice/src/reducers/general.d.ts +8 -0
- package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -0
- package/dist/document-models/invoice/src/reducers/general.js +79 -0
- package/dist/document-models/invoice/src/reducers/items.d.ts +8 -0
- package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -0
- package/dist/document-models/invoice/src/reducers/items.js +108 -0
- package/dist/document-models/invoice/src/reducers/parties.d.ts +8 -0
- package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -0
- package/dist/document-models/invoice/src/reducers/parties.js +266 -0
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/document-model.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/document-model.test.js +17 -0
- package/dist/document-models/invoice/src/tests/general.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/general.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/general.test.js +75 -0
- package/dist/document-models/invoice/src/tests/items.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/items.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/items.test.js +45 -0
- package/dist/document-models/invoice/src/tests/parties.test.d.ts +6 -0
- package/dist/document-models/invoice/src/tests/parties.test.d.ts.map +1 -0
- package/dist/document-models/invoice/src/tests/parties.test.js +75 -0
- package/dist/document-models/invoice/src/utils.d.ts +2 -0
- package/dist/document-models/invoice/src/utils.d.ts.map +1 -0
- package/dist/document-models/invoice/src/utils.js +1 -0
- package/dist/editors/contributor-billing/components/CreateDocument.d.ts +8 -0
- package/dist/editors/contributor-billing/components/CreateDocument.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/CreateDocument.js +14 -0
- package/dist/editors/contributor-billing/components/DocumentDispatch.d.ts +12 -0
- package/dist/editors/contributor-billing/components/DocumentDispatch.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/DocumentDispatch.js +20 -0
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +17 -0
- package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/DriveExplorer.js +112 -0
- package/dist/editors/contributor-billing/components/EditorContainer.d.ts +14 -0
- package/dist/editors/contributor-billing/components/EditorContainer.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/EditorContainer.js +28 -0
- package/dist/editors/contributor-billing/components/FileItemsGrid.d.ts +12 -0
- package/dist/editors/contributor-billing/components/FileItemsGrid.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/FileItemsGrid.js +7 -0
- package/dist/editors/contributor-billing/components/FolderItemsGrid.d.ts +17 -0
- package/dist/editors/contributor-billing/components/FolderItemsGrid.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/FolderItemsGrid.js +14 -0
- package/dist/editors/contributor-billing/components/FolderTree.d.ts +9 -0
- package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/FolderTree.js +31 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +16 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +16 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +21 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +45 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts +12 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +12 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts +7 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableSection.js +7 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts +8 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.d.ts.map +1 -0
- package/dist/editors/contributor-billing/components/InvoiceTable/RowActionMenu.js +2 -0
- package/dist/editors/contributor-billing/editor.d.ts +6 -0
- package/dist/editors/contributor-billing/editor.d.ts.map +1 -0
- package/dist/editors/contributor-billing/editor.js +48 -0
- package/dist/editors/contributor-billing/hooks/useDispatchMap.d.ts +9 -0
- package/dist/editors/contributor-billing/hooks/useDispatchMap.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useDispatchMap.js +21 -0
- package/dist/editors/contributor-billing/hooks/useDrop.d.ts +22 -0
- package/dist/editors/contributor-billing/hooks/useDrop.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useDrop.js +57 -0
- package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.d.ts +8 -0
- package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useSelectedFolderChildren.js +19 -0
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +4 -0
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -0
- package/dist/editors/contributor-billing/hooks/useTransformedNodes.js +32 -0
- package/dist/editors/contributor-billing/index.d.ts +5 -0
- package/dist/editors/contributor-billing/index.d.ts.map +1 -0
- package/dist/editors/contributor-billing/index.js +12 -0
- package/dist/editors/index.d.ts +3 -0
- package/dist/editors/index.d.ts.map +1 -0
- package/dist/editors/index.js +2 -0
- package/dist/editors/invoice/InvoicePDF.d.ts +8 -0
- package/dist/editors/invoice/InvoicePDF.d.ts.map +1 -0
- package/dist/editors/invoice/InvoicePDF.js +359 -0
- package/dist/editors/invoice/assets/custom.d.ts +4 -0
- package/dist/editors/invoice/assets/powerhouseLogo.png +0 -0
- package/dist/editors/invoice/components/countryForm.d.ts +12 -0
- package/dist/editors/invoice/components/countryForm.d.ts.map +1 -0
- package/dist/editors/invoice/components/countryForm.js +28 -0
- package/dist/editors/invoice/components/currencyForm.d.ts +13 -0
- package/dist/editors/invoice/components/currencyForm.d.ts.map +1 -0
- package/dist/editors/invoice/components/currencyForm.js +26 -0
- package/dist/editors/invoice/components/datePicker.d.ts +11 -0
- package/dist/editors/invoice/components/datePicker.d.ts.map +1 -0
- package/dist/editors/invoice/components/datePicker.js +8 -0
- package/dist/editors/invoice/components/inputField.d.ts +14 -0
- package/dist/editors/invoice/components/inputField.d.ts.map +1 -0
- package/dist/editors/invoice/components/inputField.js +25 -0
- package/dist/editors/invoice/components/numberForm.d.ts +11 -0
- package/dist/editors/invoice/components/numberForm.d.ts.map +1 -0
- package/dist/editors/invoice/components/numberForm.js +7 -0
- package/dist/editors/invoice/components/selectField.d.ts +8 -0
- package/dist/editors/invoice/components/selectField.d.ts.map +1 -0
- package/dist/editors/invoice/components/selectField.js +323 -0
- package/dist/editors/invoice/editor.d.ts +5 -0
- package/dist/editors/invoice/editor.d.ts.map +1 -0
- package/dist/editors/invoice/editor.js +377 -0
- package/dist/editors/invoice/exportUBL.d.ts +85 -0
- package/dist/editors/invoice/exportUBL.d.ts.map +1 -0
- package/dist/editors/invoice/exportUBL.js +382 -0
- package/dist/editors/invoice/index.d.ts +5 -0
- package/dist/editors/invoice/index.d.ts.map +1 -0
- package/dist/editors/invoice/index.js +12 -0
- package/dist/editors/invoice/ingestPDF.d.ts +12 -0
- package/dist/editors/invoice/ingestPDF.d.ts.map +1 -0
- package/dist/editors/invoice/ingestPDF.js +193 -0
- package/dist/editors/invoice/ingestUBL.d.ts +21 -0
- package/dist/editors/invoice/ingestUBL.d.ts.map +1 -0
- package/dist/editors/invoice/ingestUBL.js +169 -0
- package/dist/editors/invoice/invoiceToGnosis.d.ts +7 -0
- package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -0
- package/dist/editors/invoice/invoiceToGnosis.js +139 -0
- package/dist/editors/invoice/legalEntity/bankSection.d.ts +14 -0
- package/dist/editors/invoice/legalEntity/bankSection.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/bankSection.js +156 -0
- package/dist/editors/invoice/legalEntity/common.d.ts +6 -0
- package/dist/editors/invoice/legalEntity/common.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/common.js +6 -0
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts +40 -0
- package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/legalEntity.js +63 -0
- package/dist/editors/invoice/legalEntity/walletSection.d.ts +13 -0
- package/dist/editors/invoice/legalEntity/walletSection.d.ts.map +1 -0
- package/dist/editors/invoice/legalEntity/walletSection.js +55 -0
- package/dist/editors/invoice/lineItems.d.ts +23 -0
- package/dist/editors/invoice/lineItems.d.ts.map +1 -0
- package/dist/editors/invoice/lineItems.js +157 -0
- package/dist/editors/invoice/requestFinance.d.ts +7 -0
- package/dist/editors/invoice/requestFinance.d.ts.map +1 -0
- package/dist/editors/invoice/requestFinance.js +155 -0
- package/dist/editors/invoice/uploadPdfChunked.d.ts +10 -0
- package/dist/editors/invoice/uploadPdfChunked.d.ts.map +1 -0
- package/dist/editors/invoice/uploadPdfChunked.js +79 -0
- package/dist/editors/invoice/utils/utils.d.ts +2 -0
- package/dist/editors/invoice/utils/utils.d.ts.map +1 -0
- package/dist/editors/invoice/utils/utils.js +54 -0
- package/dist/editors/invoice/validation/validationManager.d.ts +28 -0
- package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -0
- package/dist/editors/invoice/validation/validationManager.js +65 -0
- package/dist/editors/invoice/validation/validationRules.d.ts +14 -0
- package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -0
- package/dist/editors/invoice/validation/validationRules.js +334 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/powerhouse.manifest.json +31 -0
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.d.ts.map +1 -0
- package/dist/processors/index.js +1 -0
- package/dist/scripts/invoice/exampleBatchTxn.d.ts +2 -0
- package/dist/scripts/invoice/exampleBatchTxn.d.ts.map +1 -0
- package/dist/scripts/invoice/exampleBatchTxn.js +44 -0
- package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts +28 -0
- package/dist/scripts/invoice/gnosisTransactionBuilder.d.ts.map +1 -0
- package/dist/scripts/invoice/gnosisTransactionBuilder.js +74 -0
- package/dist/scripts/invoice/pdfToDocumentAi.d.ts +5 -0
- package/dist/scripts/invoice/pdfToDocumentAi.d.ts.map +1 -0
- package/dist/scripts/invoice/pdfToDocumentAi.js +659 -0
- package/dist/scripts/invoice/requestFinance.d.ts +2 -0
- package/dist/scripts/invoice/requestFinance.d.ts.map +1 -0
- package/dist/scripts/invoice/requestFinance.js +38 -0
- package/dist/style.css +6463 -0
- package/dist/subgraphs/index.d.ts +2 -0
- package/dist/subgraphs/index.d.ts.map +1 -0
- package/dist/subgraphs/index.js +1 -0
- package/dist/subgraphs/invoice/customResolvers.d.ts +50 -0
- package/dist/subgraphs/invoice/customResolvers.d.ts.map +1 -0
- package/dist/subgraphs/invoice/customResolvers.js +327 -0
- package/dist/subgraphs/invoice/index.d.ts +10 -0
- package/dist/subgraphs/invoice/index.d.ts.map +1 -0
- package/dist/subgraphs/invoice/index.js +30 -0
- package/dist/subgraphs/invoice/resolvers.d.ts +3 -0
- package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/invoice/resolvers.js +184 -0
- package/dist/subgraphs/invoice/schema.d.ts +3 -0
- package/dist/subgraphs/invoice/schema.d.ts.map +1 -0
- package/dist/subgraphs/invoice/schema.js +460 -0
- package/dist/tailwind.config.d.ts +13 -0
- package/dist/tailwind.config.d.ts.map +1 -0
- package/dist/tailwind.config.js +15 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +8 -0
- package/editors/invoice/assets/custom.d.ts +4 -0
- package/editors/invoice/assets/powerhouseLogo.png +0 -0
- package/package.json +117 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../subgraphs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as InvoiceSubgraph from "./invoice/index.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare let pendingTransactions: Record<string, {
|
|
2
|
+
invoiceNo: string;
|
|
3
|
+
payerWallet: any;
|
|
4
|
+
paymentDetails: any;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const Invoice_processGnosisPayment: (_: any, args: any) => Promise<{
|
|
8
|
+
success: boolean;
|
|
9
|
+
data: import("../../scripts/invoice/gnosisTransactionBuilder.js").TransferResult;
|
|
10
|
+
error?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
success: boolean;
|
|
13
|
+
error: string;
|
|
14
|
+
data?: undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const Invoice_createRequestFinancePayment: (_: any, args: any) => Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
error: any;
|
|
19
|
+
data?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
success: boolean;
|
|
22
|
+
data: {
|
|
23
|
+
message: string;
|
|
24
|
+
response: any;
|
|
25
|
+
};
|
|
26
|
+
error?: undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const Invoice_uploadInvoicePdfChunk: (_: any, args: any) => Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
data: {
|
|
31
|
+
invoiceData: Partial<import("../../document-models/invoice/index.js").InvoiceState>;
|
|
32
|
+
};
|
|
33
|
+
error?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
success: boolean;
|
|
36
|
+
data: {
|
|
37
|
+
message: string;
|
|
38
|
+
progress: number;
|
|
39
|
+
};
|
|
40
|
+
error?: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
success: boolean;
|
|
43
|
+
error: string;
|
|
44
|
+
data?: undefined;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const setReactor: (reactorInstance: any) => void;
|
|
47
|
+
export { pendingTransactions };
|
|
48
|
+
export declare const cleanupOldPendingTransactions: () => void;
|
|
49
|
+
export declare const handleWebhook: (req: any, res: any) => Promise<any>;
|
|
50
|
+
//# sourceMappingURL=customResolvers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customResolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/invoice/customResolvers.ts"],"names":[],"mappings":"AAOA,QAAA,IAAI,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,GAAG,CAAC;IACjB,cAAc,EAAE,GAAG,CAAC;IACpB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAM,CAAC;AAyBR,eAAO,MAAM,4BAA4B,GAAU,GAAG,GAAG,EAAE,MAAM,GAAG;;;;;;;;EA8CnE,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAAU,GAAG,GAAG,EAAE,MAAM,GAAG;;;;;;;;;;;EAkC1E,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAU,GAAG,GAAG,EAAE,MAAM,GAAG;;;;;;;;;;;;;;;;;EAsDpE,CAAA;AAGD,eAAO,MAAM,UAAU,GAAI,iBAAiB,GAAG,SAE9C,CAAC;AAGF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAG/B,eAAO,MAAM,6BAA6B,YAyBzC,CAAA;AAwCD,eAAO,MAAM,aAAa,GAAU,KAAK,GAAG,EAAE,KAAK,GAAG,iBAkJrD,CAAA"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { executeTransferProposal } from "../../scripts/invoice/gnosisTransactionBuilder.js";
|
|
2
|
+
import { requestDirectPayment } from "../../scripts/invoice/requestFinance.js";
|
|
3
|
+
import { actions } from "../../document-models/invoice/index.js";
|
|
4
|
+
import { uploadPdfAndGetJson } from "../../scripts/invoice/pdfToDocumentAi.js";
|
|
5
|
+
import * as crypto from "crypto";
|
|
6
|
+
// Store pending transactions for webhook matching
|
|
7
|
+
let pendingTransactions = {};
|
|
8
|
+
// Add a set to track processed transaction hashes to avoid duplicate processing
|
|
9
|
+
let processedTransactions = new Set();
|
|
10
|
+
// Create a Map to store file chunks data
|
|
11
|
+
const fileChunksMap = new Map();
|
|
12
|
+
let reactor;
|
|
13
|
+
export const Invoice_processGnosisPayment = async (_, args) => {
|
|
14
|
+
try {
|
|
15
|
+
const { payerWallet, paymentDetails, invoiceNo } = args;
|
|
16
|
+
// Cast payerWallet to any to access its properties
|
|
17
|
+
const typedPayerWallet = payerWallet;
|
|
18
|
+
console.log("Processing gnosis payment:", {
|
|
19
|
+
payerWallet,
|
|
20
|
+
invoiceNo,
|
|
21
|
+
paymentDetails
|
|
22
|
+
});
|
|
23
|
+
// Import and call the executeTransferProposal function
|
|
24
|
+
const result = await executeTransferProposal(payerWallet, paymentDetails);
|
|
25
|
+
console.log("Token transfer result:", result);
|
|
26
|
+
// Store the transaction information for later matching with webhook
|
|
27
|
+
if (result.success && result.txHash) {
|
|
28
|
+
// Generate a unique ID for this transaction
|
|
29
|
+
const transactionId = `gnosis-${invoiceNo}-${Date.now()}`;
|
|
30
|
+
// Store the transaction with all the details needed for matching
|
|
31
|
+
pendingTransactions[transactionId] = {
|
|
32
|
+
invoiceNo,
|
|
33
|
+
payerWallet,
|
|
34
|
+
paymentDetails,
|
|
35
|
+
timestamp: Date.now()
|
|
36
|
+
};
|
|
37
|
+
console.log(`Stored pending transaction ${transactionId} for invoice ${invoiceNo}`);
|
|
38
|
+
}
|
|
39
|
+
// Return the result without updating the document status yet
|
|
40
|
+
// The status will be updated when the webhook confirms the transaction
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
data: result,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error("Error processing gnosis payment:", error);
|
|
48
|
+
return {
|
|
49
|
+
success: false,
|
|
50
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export const Invoice_createRequestFinancePayment = async (_, args) => {
|
|
55
|
+
try {
|
|
56
|
+
const { paymentData } = args;
|
|
57
|
+
if (!paymentData) {
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: "No payment data provided"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
console.log("Creating direct payment with data:", paymentData.invoiceNumber);
|
|
64
|
+
const response = await requestDirectPayment(paymentData);
|
|
65
|
+
if (response.errors && response.errors.length > 0) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: response.errors[0]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
success: true,
|
|
73
|
+
data: {
|
|
74
|
+
message: "Direct payment request received successfully",
|
|
75
|
+
response
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error("Error creating direct payment:", error);
|
|
81
|
+
return {
|
|
82
|
+
success: false,
|
|
83
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export const Invoice_uploadInvoicePdfChunk = async (_, args) => {
|
|
88
|
+
try {
|
|
89
|
+
const { chunk, chunkIndex, totalChunks, fileName, sessionId } = args;
|
|
90
|
+
const fileKey = `${sessionId}_${fileName}`;
|
|
91
|
+
// Initialize array for this file if it doesn't exist
|
|
92
|
+
if (!fileChunksMap.has(fileKey)) {
|
|
93
|
+
fileChunksMap.set(fileKey, {
|
|
94
|
+
chunks: new Array(totalChunks).fill(''),
|
|
95
|
+
receivedChunks: 0
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// Get the file chunks data
|
|
99
|
+
const fileData = fileChunksMap.get(fileKey);
|
|
100
|
+
// Add the chunk at the correct position
|
|
101
|
+
fileData.chunks[chunkIndex] = chunk;
|
|
102
|
+
fileData.receivedChunks += 1;
|
|
103
|
+
console.log(`Received chunk ${chunkIndex + 1}/${totalChunks} for ${fileName}`);
|
|
104
|
+
// If we've received all chunks, process the complete file
|
|
105
|
+
if (fileData.receivedChunks === totalChunks) {
|
|
106
|
+
// Combine all chunks
|
|
107
|
+
const completeFile = fileData.chunks.join('');
|
|
108
|
+
// Process the file
|
|
109
|
+
const result = await uploadPdfAndGetJson(completeFile);
|
|
110
|
+
// Clean up
|
|
111
|
+
fileChunksMap.delete(fileKey);
|
|
112
|
+
return {
|
|
113
|
+
success: true,
|
|
114
|
+
data: result
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// If not all chunks received yet, just acknowledge receipt
|
|
118
|
+
return {
|
|
119
|
+
success: true,
|
|
120
|
+
data: {
|
|
121
|
+
message: `Chunk ${chunkIndex + 1}/${totalChunks} received`,
|
|
122
|
+
progress: (fileData.receivedChunks / totalChunks) * 100
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
console.error("Error processing PDF chunk:", error);
|
|
128
|
+
return {
|
|
129
|
+
success: false,
|
|
130
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
// Function to set the reactor instance
|
|
135
|
+
export const setReactor = (reactorInstance) => {
|
|
136
|
+
reactor = reactorInstance;
|
|
137
|
+
};
|
|
138
|
+
// Export the pendingTransactions for use in webhook handling
|
|
139
|
+
export { pendingTransactions };
|
|
140
|
+
// Add a method to clean up old pending transactions
|
|
141
|
+
export const cleanupOldPendingTransactions = () => {
|
|
142
|
+
const now = Date.now();
|
|
143
|
+
const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds
|
|
144
|
+
const MAX_PROCESSED_TRANSACTIONS = 1000; // Limit the size of the processed transactions set
|
|
145
|
+
let cleanupCount = 0;
|
|
146
|
+
for (const [txHash, txInfo] of Object.entries(pendingTransactions)) {
|
|
147
|
+
if (now - txInfo.timestamp > MAX_AGE_MS) {
|
|
148
|
+
delete pendingTransactions[txHash];
|
|
149
|
+
cleanupCount++;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Also clean up the processed transactions set if it gets too large
|
|
153
|
+
if (processedTransactions.size > MAX_PROCESSED_TRANSACTIONS) {
|
|
154
|
+
// Convert to array, keep only the most recent transactions
|
|
155
|
+
const txArray = Array.from(processedTransactions);
|
|
156
|
+
const toKeep = txArray.slice(-MAX_PROCESSED_TRANSACTIONS / 2); // Keep the most recent half
|
|
157
|
+
processedTransactions = new Set(toKeep);
|
|
158
|
+
console.log(`Cleaned up processed transactions set from ${txArray.length} to ${toKeep.length} items`);
|
|
159
|
+
}
|
|
160
|
+
if (cleanupCount > 0) {
|
|
161
|
+
console.log(`Cleaned up ${cleanupCount} old pending transactions`);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
// Function to validate Alchemy signature
|
|
165
|
+
function isValidSignatureForStringBody(body, signature, signingKey) {
|
|
166
|
+
const hmac = crypto.createHmac("sha256", signingKey);
|
|
167
|
+
hmac.update(body, "utf8");
|
|
168
|
+
const digest = hmac.digest("hex");
|
|
169
|
+
return signature === digest;
|
|
170
|
+
}
|
|
171
|
+
const updateDocumentStatus = async (invoiceNo) => {
|
|
172
|
+
try {
|
|
173
|
+
const drive = await reactor.getDrive('powerhouse');
|
|
174
|
+
const documents = drive.state.global.nodes.filter((node) => node.documentType === 'powerhouse/invoice');
|
|
175
|
+
if (documents.length === 0) {
|
|
176
|
+
console.log(`No documents found for invoice ${invoiceNo}`);
|
|
177
|
+
return Promise.reject(new Error(`No documents found for invoice ${invoiceNo}`));
|
|
178
|
+
}
|
|
179
|
+
for (const document of documents) {
|
|
180
|
+
const invoiceDocument = await reactor.getDocument('powerhouse', document.id);
|
|
181
|
+
const reactorInvoiceNo = invoiceDocument.state.global.invoiceNo;
|
|
182
|
+
if (reactorInvoiceNo === invoiceNo) {
|
|
183
|
+
console.log(`Changing status of Invoice No: ${invoiceNo} to PAID`);
|
|
184
|
+
await reactor.addAction('powerhouse', document.id, actions.editStatus({
|
|
185
|
+
status: "PAYMENTRECEIVED",
|
|
186
|
+
}));
|
|
187
|
+
return Promise.resolve();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.error(`Error finding document for invoice ${invoiceNo}:`, error);
|
|
193
|
+
return Promise.reject(error);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
// Webhook handler method
|
|
197
|
+
export const handleWebhook = async (req, res) => {
|
|
198
|
+
try {
|
|
199
|
+
console.log('Webhook received');
|
|
200
|
+
// Log all headers to debug
|
|
201
|
+
// console.log('Webhook request headers:', req.headers);
|
|
202
|
+
// console.log('Webhook request body:', req.body);
|
|
203
|
+
// Get the request body and signature
|
|
204
|
+
let payload = req.body;
|
|
205
|
+
let rawBody = JSON.stringify(payload);
|
|
206
|
+
const signature = req.headers['x-alchemy-signature'];
|
|
207
|
+
if (!signature) {
|
|
208
|
+
console.warn('Missing signature header');
|
|
209
|
+
// For testing, continue anyway
|
|
210
|
+
// return res.status(400).json({ error: 'Missing signature header' });
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
// Validate the signature
|
|
214
|
+
const signingKey = process.env.ALCHEMY_SIGNING_KEY || 'whsec_test';
|
|
215
|
+
const isValid = isValidSignatureForStringBody(rawBody, signature, signingKey);
|
|
216
|
+
if (!isValid) {
|
|
217
|
+
console.warn('Invalid signature');
|
|
218
|
+
// For testing, continue anyway
|
|
219
|
+
// return res.status(401).json({ error: 'Invalid signature' });
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Process the webhook
|
|
223
|
+
// console.log('Processing webhook test button:', payload.event);
|
|
224
|
+
// console.log('Processing webhook payload:', payload.event.activity);
|
|
225
|
+
// Check if this is a transaction confirmation webhook
|
|
226
|
+
if (payload.event && payload.event.activity) {
|
|
227
|
+
const activities = Array.isArray(payload.event.activity)
|
|
228
|
+
? payload.event.activity
|
|
229
|
+
: [payload.event.activity];
|
|
230
|
+
for (const activity of activities) {
|
|
231
|
+
// Check if this is a transaction with relevant details
|
|
232
|
+
if (activity.category === 'token' && activity.fromAddress && activity.toAddress && activity.rawContract) {
|
|
233
|
+
console.log(`Processing token transfer from ${activity.fromAddress} to ${activity.toAddress}`);
|
|
234
|
+
// Check if we've already processed this transaction
|
|
235
|
+
if (activity.hash && processedTransactions.has(activity.hash)) {
|
|
236
|
+
console.log(`Transaction ${activity.hash} has already been processed, skipping`);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
// Extract transaction details from the activity
|
|
240
|
+
const fromAddress = activity.fromAddress.toLowerCase();
|
|
241
|
+
const toAddress = activity.toAddress.toLowerCase();
|
|
242
|
+
const tokenAddress = activity.rawContract.address.toLowerCase();
|
|
243
|
+
const tokenValue = activity.value || 0;
|
|
244
|
+
const tokenDecimals = activity.rawContract.decimals || 18;
|
|
245
|
+
console.log(`Token transfer details: ${tokenValue} of token ${tokenAddress} from ${fromAddress} to ${toAddress}`);
|
|
246
|
+
// Look for matching pending transactions based on transaction details
|
|
247
|
+
let matchedInvoiceNo = null;
|
|
248
|
+
let matchedTxHash = null;
|
|
249
|
+
for (const [txHash, txInfo] of Object.entries(pendingTransactions)) {
|
|
250
|
+
const paymentDetails = Array.isArray(txInfo.paymentDetails)
|
|
251
|
+
? txInfo.paymentDetails
|
|
252
|
+
: [txInfo.paymentDetails];
|
|
253
|
+
// Safe transactions may be sent from a different address than the Safe itself
|
|
254
|
+
// So we'll focus on recipient, token, and amount
|
|
255
|
+
for (const payment of paymentDetails) {
|
|
256
|
+
// Cast payment to any to access its properties
|
|
257
|
+
const typedPayment = payment;
|
|
258
|
+
// Check if recipient address matches
|
|
259
|
+
if (typedPayment.payeeWallet &&
|
|
260
|
+
typedPayment.payeeWallet.address.toLowerCase() === toAddress) {
|
|
261
|
+
// Check if token address matches
|
|
262
|
+
if (typedPayment.token &&
|
|
263
|
+
typedPayment.token.evmAddress.toLowerCase() === tokenAddress) {
|
|
264
|
+
// Check if amount is similar (allowing for some precision loss)
|
|
265
|
+
// Convert both to a common format for comparison
|
|
266
|
+
const expectedAmount = parseFloat(typedPayment.amount);
|
|
267
|
+
const actualAmount = parseFloat(tokenValue);
|
|
268
|
+
// Allow for a small difference due to precision issues
|
|
269
|
+
const amountDifference = Math.abs(expectedAmount - actualAmount);
|
|
270
|
+
const isAmountSimilar = amountDifference < 0.0001 ||
|
|
271
|
+
(expectedAmount > 0 && amountDifference / expectedAmount < 0.01); // 1% tolerance
|
|
272
|
+
if (isAmountSimilar) {
|
|
273
|
+
console.log(`Found matching transaction for invoice ${txInfo.invoiceNo}`);
|
|
274
|
+
console.log(`Expected: ${expectedAmount}, Actual: ${actualAmount}`);
|
|
275
|
+
matchedInvoiceNo = txInfo.invoiceNo;
|
|
276
|
+
matchedTxHash = txHash;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
console.log(`Token amounts don't match. Expected: ${expectedAmount}, Actual: ${actualAmount}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
console.log(`Token addresses don't match. Expected: ${typedPayment.token?.evmAddress}, Actual: ${tokenAddress}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
console.log(`Recipient addresses don't match. Expected: ${typedPayment.payeeWallet?.address}, Actual: ${toAddress}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (matchedInvoiceNo)
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
// If we found a matching transaction, update the invoice status
|
|
295
|
+
if (matchedInvoiceNo) {
|
|
296
|
+
await updateDocumentStatus(matchedInvoiceNo);
|
|
297
|
+
// Remove all related transactions from pending
|
|
298
|
+
for (const [txHash, txInfo] of Object.entries(pendingTransactions)) {
|
|
299
|
+
if (txInfo.invoiceNo === matchedInvoiceNo) {
|
|
300
|
+
delete pendingTransactions[txHash];
|
|
301
|
+
console.log(`Removed pending transaction ${txHash} for invoice ${matchedInvoiceNo}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Add to processed transactions to avoid duplicate processing
|
|
305
|
+
if (activity.hash) {
|
|
306
|
+
processedTransactions.add(activity.hash);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
console.log('No matching pending transaction found for this activity');
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// For testing, just acknowledge receipt
|
|
316
|
+
return res.status(200).json({
|
|
317
|
+
success: true,
|
|
318
|
+
message: 'Webhook received successfully'
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
console.error('Error processing webhook:', error);
|
|
323
|
+
return res.status(500).json({
|
|
324
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Subgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
export declare class InvoiceSubgraph extends Subgraph {
|
|
3
|
+
name: string;
|
|
4
|
+
typeDefs: import("graphql").DocumentNode;
|
|
5
|
+
resolvers: Record<string, any>;
|
|
6
|
+
additionalContextFields: {};
|
|
7
|
+
onSetup(): Promise<void>;
|
|
8
|
+
onDisconnect(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../subgraphs/invoice/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAOtD,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,IAAI,SAAa;IAEjB,QAAQ,iCAAU;IAClB,SAAS,sBAAsB;IAC/B,uBAAuB,KAAM;IACvB,OAAO;IAsBP,YAAY;CACnB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Subgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import { schema } from "./schema.js";
|
|
3
|
+
import { getResolvers } from "./resolvers.js";
|
|
4
|
+
import { handleWebhook, cleanupOldPendingTransactions, setReactor } from "./customResolvers.js";
|
|
5
|
+
import express from "express";
|
|
6
|
+
import cors from "cors";
|
|
7
|
+
export class InvoiceSubgraph extends Subgraph {
|
|
8
|
+
name = "invoice";
|
|
9
|
+
typeDefs = schema;
|
|
10
|
+
resolvers = getResolvers(this);
|
|
11
|
+
additionalContextFields = {};
|
|
12
|
+
async onSetup() {
|
|
13
|
+
try {
|
|
14
|
+
// Set the reactor instance for custom resolvers
|
|
15
|
+
setReactor(this.reactor);
|
|
16
|
+
if (this.graphqlManager && this.graphqlManager['app']) {
|
|
17
|
+
console.log('Registering webhook handler at /webhook');
|
|
18
|
+
// Add CORS middleware for the webhook route
|
|
19
|
+
this.graphqlManager['app'].post('/webhook', cors(), // Add CORS middleware
|
|
20
|
+
express.json({ limit: '3mb' }), handleWebhook.bind(this));
|
|
21
|
+
}
|
|
22
|
+
// Set up a periodic cleanup of old pending transactions
|
|
23
|
+
setInterval(() => cleanupOldPendingTransactions(), 3600000); // Run every hour
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error('Error in invoice subgraph setup:', error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async onDisconnect() { }
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/invoice/resolvers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAQ3D,eAAO,MAAM,YAAY,GAAI,UAAU,QAAQ,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CA6SnE,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { addFile } from "document-drive";
|
|
2
|
+
import { actions } from "../../document-models/invoice/index.js";
|
|
3
|
+
import { generateId, hashKey } from "document-model";
|
|
4
|
+
import { Invoice_processGnosisPayment, Invoice_createRequestFinancePayment, Invoice_uploadInvoicePdfChunk } from "./customResolvers.js";
|
|
5
|
+
const DEFAULT_DRIVE_ID = "powerhouse";
|
|
6
|
+
export const getResolvers = (subgraph) => {
|
|
7
|
+
const reactor = subgraph.reactor;
|
|
8
|
+
return {
|
|
9
|
+
Query: {
|
|
10
|
+
Invoice: async (_, args, ctx) => {
|
|
11
|
+
return {
|
|
12
|
+
getDocument: async (args) => {
|
|
13
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
14
|
+
const docId = args.docId || "";
|
|
15
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
16
|
+
return {
|
|
17
|
+
id: docId,
|
|
18
|
+
driveId: driveId,
|
|
19
|
+
...doc,
|
|
20
|
+
state: doc.state.global,
|
|
21
|
+
stateJSON: doc.state.global,
|
|
22
|
+
revision: doc.revision.global,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
getDocuments: async (args) => {
|
|
26
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
27
|
+
const docsIds = await reactor.getDocuments(driveId);
|
|
28
|
+
const docs = await Promise.all(docsIds.map(async (docId) => {
|
|
29
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
30
|
+
return {
|
|
31
|
+
id: docId,
|
|
32
|
+
driveId: driveId,
|
|
33
|
+
...doc,
|
|
34
|
+
state: doc.state.global,
|
|
35
|
+
stateJSON: doc.state.global,
|
|
36
|
+
revision: doc.revision.global,
|
|
37
|
+
};
|
|
38
|
+
}));
|
|
39
|
+
return docs.filter((doc) => doc.documentType === "powerhouse/invoice");
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
Mutation: {
|
|
45
|
+
Invoice_createDocument: async (_, args) => {
|
|
46
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
47
|
+
const docId = generateId();
|
|
48
|
+
await reactor.addDriveAction(driveId, addFile({
|
|
49
|
+
id: docId,
|
|
50
|
+
name: args.name,
|
|
51
|
+
documentType: "powerhouse/invoice",
|
|
52
|
+
synchronizationUnits: [
|
|
53
|
+
{
|
|
54
|
+
branch: "main",
|
|
55
|
+
scope: "global",
|
|
56
|
+
syncId: hashKey(),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
branch: "main",
|
|
60
|
+
scope: "local",
|
|
61
|
+
syncId: hashKey(),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
}));
|
|
65
|
+
return docId;
|
|
66
|
+
},
|
|
67
|
+
Invoice_editInvoice: async (_, args) => {
|
|
68
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
69
|
+
const docId = args.docId || "";
|
|
70
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
71
|
+
await reactor.addAction(driveId, docId, actions.editInvoice({ ...args.input }));
|
|
72
|
+
return doc.revision.global + 1;
|
|
73
|
+
},
|
|
74
|
+
Invoice_editStatus: async (_, args) => {
|
|
75
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
76
|
+
const docId = args.docId || "";
|
|
77
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
78
|
+
await reactor.addAction(driveId, docId, actions.editStatus({ ...args.input }));
|
|
79
|
+
return doc.revision.global + 1;
|
|
80
|
+
},
|
|
81
|
+
Invoice_addRef: async (_, args) => {
|
|
82
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
83
|
+
const docId = args.docId || "";
|
|
84
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
85
|
+
await reactor.addAction(driveId, docId, actions.addRef({ ...args.input }));
|
|
86
|
+
return doc.revision.global + 1;
|
|
87
|
+
},
|
|
88
|
+
Invoice_editRef: async (_, args) => {
|
|
89
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
90
|
+
const docId = args.docId || "";
|
|
91
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
92
|
+
await reactor.addAction(driveId, docId, actions.editRef({ ...args.input }));
|
|
93
|
+
return doc.revision.global + 1;
|
|
94
|
+
},
|
|
95
|
+
Invoice_deleteRef: async (_, args) => {
|
|
96
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
97
|
+
const docId = args.docId || "";
|
|
98
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
99
|
+
await reactor.addAction(driveId, docId, actions.deleteRef({ ...args.input }));
|
|
100
|
+
return doc.revision.global + 1;
|
|
101
|
+
},
|
|
102
|
+
Invoice_setPaymentAccount: async (_, args) => {
|
|
103
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
104
|
+
const docId = args.docId || "";
|
|
105
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
106
|
+
await reactor.addAction(driveId, docId, actions.setPaymentAccount({ ...args.input }));
|
|
107
|
+
return doc.revision.global + 1;
|
|
108
|
+
},
|
|
109
|
+
Invoice_editIssuer: async (_, args) => {
|
|
110
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
111
|
+
const docId = args.docId || "";
|
|
112
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
113
|
+
await reactor.addAction(driveId, docId, actions.editIssuer({ ...args.input }));
|
|
114
|
+
return doc.revision.global + 1;
|
|
115
|
+
},
|
|
116
|
+
Invoice_editIssuerBank: async (_, args) => {
|
|
117
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
118
|
+
const docId = args.docId || "";
|
|
119
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
120
|
+
await reactor.addAction(driveId, docId, actions.editIssuerBank({ ...args.input }));
|
|
121
|
+
return doc.revision.global + 1;
|
|
122
|
+
},
|
|
123
|
+
Invoice_editIssuerWallet: async (_, args) => {
|
|
124
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
125
|
+
const docId = args.docId || "";
|
|
126
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
127
|
+
await reactor.addAction(driveId, docId, actions.editIssuerWallet({ ...args.input }));
|
|
128
|
+
return doc.revision.global + 1;
|
|
129
|
+
},
|
|
130
|
+
Invoice_editPayer: async (_, args) => {
|
|
131
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
132
|
+
const docId = args.docId || "";
|
|
133
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
134
|
+
await reactor.addAction(driveId, docId, actions.editPayer({ ...args.input }));
|
|
135
|
+
return doc.revision.global + 1;
|
|
136
|
+
},
|
|
137
|
+
Invoice_editPayerBank: async (_, args) => {
|
|
138
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
139
|
+
const docId = args.docId || "";
|
|
140
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
141
|
+
await reactor.addAction(driveId, docId, actions.editPayerBank({ ...args.input }));
|
|
142
|
+
return doc.revision.global + 1;
|
|
143
|
+
},
|
|
144
|
+
Invoice_editPayerWallet: async (_, args) => {
|
|
145
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
146
|
+
const docId = args.docId || "";
|
|
147
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
148
|
+
await reactor.addAction(driveId, docId, actions.editPayerWallet({ ...args.input }));
|
|
149
|
+
return doc.revision.global + 1;
|
|
150
|
+
},
|
|
151
|
+
Invoice_addLineItem: async (_, args) => {
|
|
152
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
153
|
+
const docId = args.docId || "";
|
|
154
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
155
|
+
await reactor.addAction(driveId, docId, actions.addLineItem({ ...args.input }));
|
|
156
|
+
return doc.revision.global + 1;
|
|
157
|
+
},
|
|
158
|
+
Invoice_editLineItem: async (_, args) => {
|
|
159
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
160
|
+
const docId = args.docId || "";
|
|
161
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
162
|
+
await reactor.addAction(driveId, docId, actions.editLineItem({ ...args.input }));
|
|
163
|
+
return doc.revision.global + 1;
|
|
164
|
+
},
|
|
165
|
+
Invoice_deleteLineItem: async (_, args) => {
|
|
166
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
167
|
+
const docId = args.docId || "";
|
|
168
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
169
|
+
await reactor.addAction(driveId, docId, actions.deleteLineItem({ ...args.input }));
|
|
170
|
+
return doc.revision.global + 1;
|
|
171
|
+
},
|
|
172
|
+
Invoice_setLineItemTag: async (_, args) => {
|
|
173
|
+
const driveId = args.driveId || DEFAULT_DRIVE_ID;
|
|
174
|
+
const docId = args.docId || "";
|
|
175
|
+
const doc = await reactor.getDocument(driveId, docId);
|
|
176
|
+
await reactor.addAction(driveId, docId, actions.setLineItemTag({ ...args.input }));
|
|
177
|
+
return doc.revision.global + 1;
|
|
178
|
+
},
|
|
179
|
+
Invoice_uploadInvoicePdfChunk,
|
|
180
|
+
Invoice_createRequestFinancePayment,
|
|
181
|
+
Invoice_processGnosisPayment,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/invoice/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YA0cpB,CAAC"}
|