@ngbplatform/ui 1.3.0

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 (217) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +44 -0
  3. package/package.json +61 -0
  4. package/public/favicon.svg +6 -0
  5. package/public/silent-check-sso.html +8 -0
  6. package/src/assets/ngb_logo.svg +17 -0
  7. package/src/assets/ngb_logo_color.svg +17 -0
  8. package/src/index.ts +1023 -0
  9. package/src/ngb/README.md +27 -0
  10. package/src/ngb/accounting/NgbAccountingPeriodClosingPage.vue +1157 -0
  11. package/src/ngb/accounting/NgbChartOfAccountEditor.vue +590 -0
  12. package/src/ngb/accounting/NgbChartOfAccountsPage.vue +420 -0
  13. package/src/ngb/accounting/NgbGeneralJournalEntryEditPage.vue +796 -0
  14. package/src/ngb/accounting/NgbGeneralJournalEntryLinesEditor.vue +454 -0
  15. package/src/ngb/accounting/NgbGeneralJournalEntryListPage.vue +186 -0
  16. package/src/ngb/accounting/api.ts +79 -0
  17. package/src/ngb/accounting/generalJournalEntry.ts +127 -0
  18. package/src/ngb/accounting/generalJournalEntryApi.ts +112 -0
  19. package/src/ngb/accounting/generalJournalEntryTypes.ts +155 -0
  20. package/src/ngb/accounting/navigation.ts +83 -0
  21. package/src/ngb/accounting/periodClosing.ts +75 -0
  22. package/src/ngb/accounting/periodClosingApi.ts +60 -0
  23. package/src/ngb/accounting/periodClosingTypes.ts +73 -0
  24. package/src/ngb/accounting/types.ts +57 -0
  25. package/src/ngb/api/audit.ts +23 -0
  26. package/src/ngb/api/catalogs.ts +50 -0
  27. package/src/ngb/api/contracts.ts +285 -0
  28. package/src/ngb/api/documents.ts +170 -0
  29. package/src/ngb/api/http.ts +446 -0
  30. package/src/ngb/api/lookups.ts +14 -0
  31. package/src/ngb/api/types.ts +6 -0
  32. package/src/ngb/auth/index.ts +13 -0
  33. package/src/ngb/auth/keycloak.ts +374 -0
  34. package/src/ngb/auth/router.ts +35 -0
  35. package/src/ngb/auth/types.ts +12 -0
  36. package/src/ngb/auth/useAuthStore.ts +209 -0
  37. package/src/ngb/command-palette/NgbCommandPaletteDialog.vue +342 -0
  38. package/src/ngb/command-palette/NgbCommandPaletteEmptyState.vue +55 -0
  39. package/src/ngb/command-palette/NgbCommandPaletteFooterHints.vue +29 -0
  40. package/src/ngb/command-palette/api.ts +10 -0
  41. package/src/ngb/command-palette/config.ts +16 -0
  42. package/src/ngb/command-palette/presentation.ts +85 -0
  43. package/src/ngb/command-palette/search.ts +130 -0
  44. package/src/ngb/command-palette/staticItems.ts +243 -0
  45. package/src/ngb/command-palette/storage.ts +45 -0
  46. package/src/ngb/command-palette/store.ts +716 -0
  47. package/src/ngb/command-palette/types.ts +120 -0
  48. package/src/ngb/command-palette/useCommandPaletteHotkeys.ts +27 -0
  49. package/src/ngb/command-palette/useCommandPalettePageContext.ts +18 -0
  50. package/src/ngb/components/NgbConfirmDialog.vue +63 -0
  51. package/src/ngb/components/NgbDialog.vue +44 -0
  52. package/src/ngb/components/NgbDrawer.vue +156 -0
  53. package/src/ngb/components/NgbHeaderActionCluster.vue +140 -0
  54. package/src/ngb/components/NgbModalShell.vue +99 -0
  55. package/src/ngb/components/NgbToolbar.vue +14 -0
  56. package/src/ngb/components/forms/NgbFormLayout.vue +13 -0
  57. package/src/ngb/components/forms/NgbFormRow.vue +21 -0
  58. package/src/ngb/components/forms/NgbFormSection.vue +16 -0
  59. package/src/ngb/components/forms/NgbValidationSummary.vue +18 -0
  60. package/src/ngb/components/navigation/NgbNavigationTree.vue +68 -0
  61. package/src/ngb/components/navigation/NgbTreeNode.vue +94 -0
  62. package/src/ngb/components/register/NgbColumnChooser.vue +101 -0
  63. package/src/ngb/components/register/NgbRegisterGrid.vue +473 -0
  64. package/src/ngb/components/register/registerTypes.ts +51 -0
  65. package/src/ngb/components/register/useRegisterColumnResize.ts +99 -0
  66. package/src/ngb/components/register/useRegisterColumnState.ts +220 -0
  67. package/src/ngb/components/register/useRegisterRows.ts +209 -0
  68. package/src/ngb/components/register/useRegisterViewport.ts +56 -0
  69. package/src/ngb/editor/NgbDocumentEffectsPage.vue +512 -0
  70. package/src/ngb/editor/NgbDocumentFlowPage.vue +409 -0
  71. package/src/ngb/editor/NgbDocumentPrintPage.vue +712 -0
  72. package/src/ngb/editor/NgbEditorDiscardDialog.vue +40 -0
  73. package/src/ngb/editor/NgbEntityAuditSidebar.vue +288 -0
  74. package/src/ngb/editor/NgbEntityEditor.vue +250 -0
  75. package/src/ngb/editor/NgbEntityEditorDrawerActions.vue +88 -0
  76. package/src/ngb/editor/NgbEntityEditorHeader.vue +114 -0
  77. package/src/ngb/editor/catalogNavigation.ts +13 -0
  78. package/src/ngb/editor/config.ts +252 -0
  79. package/src/ngb/editor/documentCopyDraft.ts +245 -0
  80. package/src/ngb/editor/documentEffects.ts +43 -0
  81. package/src/ngb/editor/documentEffectsDateFormatting.ts +18 -0
  82. package/src/ngb/editor/documentNavigation.ts +115 -0
  83. package/src/ngb/editor/documentStatus.ts +45 -0
  84. package/src/ngb/editor/entityEditorErrors.ts +162 -0
  85. package/src/ngb/editor/entityEditorPersistence.ts +241 -0
  86. package/src/ngb/editor/extensions.ts +40 -0
  87. package/src/ngb/editor/types.ts +295 -0
  88. package/src/ngb/editor/useConfiguredEntityEditorDocumentActions.ts +183 -0
  89. package/src/ngb/editor/useDocumentEditorDrawerState.ts +152 -0
  90. package/src/ngb/editor/useEditorDrawerState.ts +88 -0
  91. package/src/ngb/editor/useEntityEditorBusinessContext.ts +97 -0
  92. package/src/ngb/editor/useEntityEditorCapabilities.ts +190 -0
  93. package/src/ngb/editor/useEntityEditorCommandPalette.ts +154 -0
  94. package/src/ngb/editor/useEntityEditorCommitHandlers.ts +102 -0
  95. package/src/ngb/editor/useEntityEditorHeaderActions.ts +253 -0
  96. package/src/ngb/editor/useEntityEditorLeaveGuard.ts +66 -0
  97. package/src/ngb/editor/useEntityEditorNavigationActions.ts +235 -0
  98. package/src/ngb/editor/useEntityEditorOutputs.ts +59 -0
  99. package/src/ngb/editor/useEntityEditorPageActions.ts +57 -0
  100. package/src/ngb/editor/useRouteQueryEditorDrawer.ts +173 -0
  101. package/src/ngb/env/runtimeConfig.ts +25 -0
  102. package/src/ngb/lookup/config.ts +42 -0
  103. package/src/ngb/lookup/defaultConfig.ts +136 -0
  104. package/src/ngb/lookup/navigation.ts +76 -0
  105. package/src/ngb/lookup/prefetch.ts +40 -0
  106. package/src/ngb/lookup/store.ts +261 -0
  107. package/src/ngb/metadata/NgbDocumentListFiltersDrawer.vue +78 -0
  108. package/src/ngb/metadata/NgbDocumentPeriodFilter.vue +53 -0
  109. package/src/ngb/metadata/NgbEntityForm.vue +84 -0
  110. package/src/ngb/metadata/NgbEntityFormFieldsBlock.vue +110 -0
  111. package/src/ngb/metadata/NgbEntityListPageHeader.vue +80 -0
  112. package/src/ngb/metadata/NgbFilterFieldControl.vue +104 -0
  113. package/src/ngb/metadata/NgbMetadataCatalogEditPage.vue +42 -0
  114. package/src/ngb/metadata/NgbMetadataCatalogListPage.vue +269 -0
  115. package/src/ngb/metadata/NgbMetadataDocumentEditPage.vue +68 -0
  116. package/src/ngb/metadata/NgbMetadataDocumentListPage.vue +353 -0
  117. package/src/ngb/metadata/NgbMetadataFieldRenderer.vue +124 -0
  118. package/src/ngb/metadata/NgbMetadataLookupControl.vue +92 -0
  119. package/src/ngb/metadata/NgbRecycleBinFilter.vue +53 -0
  120. package/src/ngb/metadata/NgbRegisterPageLayout.vue +143 -0
  121. package/src/ngb/metadata/config.ts +28 -0
  122. package/src/ngb/metadata/dataTypes.ts +27 -0
  123. package/src/ngb/metadata/entityForm.ts +114 -0
  124. package/src/ngb/metadata/entityModel.ts +34 -0
  125. package/src/ngb/metadata/entityValueFormatting.ts +83 -0
  126. package/src/ngb/metadata/fieldRendererState.ts +84 -0
  127. package/src/ngb/metadata/filtering.ts +153 -0
  128. package/src/ngb/metadata/lookup.ts +25 -0
  129. package/src/ngb/metadata/monthPagedListQuery.ts +108 -0
  130. package/src/ngb/metadata/normalization.ts +100 -0
  131. package/src/ngb/metadata/referenceHydration.ts +99 -0
  132. package/src/ngb/metadata/register.ts +135 -0
  133. package/src/ngb/metadata/routePages.ts +86 -0
  134. package/src/ngb/metadata/store.ts +35 -0
  135. package/src/ngb/metadata/types.ts +276 -0
  136. package/src/ngb/metadata/useMetadataListFilters.ts +306 -0
  137. package/src/ngb/metadata/useMetadataRegisterPageData.ts +246 -0
  138. package/src/ngb/metadata/useValidationFocus.ts +49 -0
  139. package/src/ngb/primitives/NgbBadge.vue +31 -0
  140. package/src/ngb/primitives/NgbButton.vue +53 -0
  141. package/src/ngb/primitives/NgbCheckbox.vue +33 -0
  142. package/src/ngb/primitives/NgbDatePicker.vue +141 -0
  143. package/src/ngb/primitives/NgbIcon.vue +545 -0
  144. package/src/ngb/primitives/NgbInput.vue +57 -0
  145. package/src/ngb/primitives/NgbLookup.vue +264 -0
  146. package/src/ngb/primitives/NgbMonthPicker.vue +132 -0
  147. package/src/ngb/primitives/NgbMultiSelect.vue +179 -0
  148. package/src/ngb/primitives/NgbPeriodPicker.vue +125 -0
  149. package/src/ngb/primitives/NgbPickerNavButton.vue +31 -0
  150. package/src/ngb/primitives/NgbPickerPopover.vue +79 -0
  151. package/src/ngb/primitives/NgbRadioGroup.vue +53 -0
  152. package/src/ngb/primitives/NgbSelect.vue +108 -0
  153. package/src/ngb/primitives/NgbStatusIcon.vue +63 -0
  154. package/src/ngb/primitives/NgbSwitch.vue +42 -0
  155. package/src/ngb/primitives/NgbTabs.vue +116 -0
  156. package/src/ngb/primitives/NgbToastHost.vue +49 -0
  157. package/src/ngb/primitives/NgbTooltip.vue +27 -0
  158. package/src/ngb/primitives/iconNames.ts +83 -0
  159. package/src/ngb/primitives/toast.ts +66 -0
  160. package/src/ngb/primitives/useAsyncComboboxQuery.ts +85 -0
  161. package/src/ngb/primitives/useFloatingDropdownPosition.ts +129 -0
  162. package/src/ngb/reporting/NgbReportComposerCollectionSection.vue +106 -0
  163. package/src/ngb/reporting/NgbReportComposerPanel.vue +1187 -0
  164. package/src/ngb/reporting/NgbReportDateRangeFilter.vue +54 -0
  165. package/src/ngb/reporting/NgbReportPage.vue +1124 -0
  166. package/src/ngb/reporting/NgbReportSheet.vue +467 -0
  167. package/src/ngb/reporting/api.ts +35 -0
  168. package/src/ngb/reporting/composer.ts +904 -0
  169. package/src/ngb/reporting/config.ts +120 -0
  170. package/src/ngb/reporting/defaultConfig.ts +15 -0
  171. package/src/ngb/reporting/lookupFilters.ts +43 -0
  172. package/src/ngb/reporting/navigation.ts +181 -0
  173. package/src/ngb/reporting/pageHelpers.ts +73 -0
  174. package/src/ngb/reporting/pageSession.ts +92 -0
  175. package/src/ngb/reporting/paging.ts +66 -0
  176. package/src/ngb/reporting/types.ts +333 -0
  177. package/src/ngb/router/backNavigation.ts +122 -0
  178. package/src/ngb/router/queryParams.ts +129 -0
  179. package/src/ngb/router/queryState.ts +121 -0
  180. package/src/ngb/router/routeAliases.ts +66 -0
  181. package/src/ngb/router/routeParams.ts +15 -0
  182. package/src/ngb/router/shareLink.ts +39 -0
  183. package/src/ngb/security/NgbAccessAuditPanel.vue +32 -0
  184. package/src/ngb/security/NgbAccessDeniedState.vue +27 -0
  185. package/src/ngb/security/NgbEffectiveAccessPanel.vue +60 -0
  186. package/src/ngb/security/NgbPermissionMatrix.vue +160 -0
  187. package/src/ngb/security/NgbRoleEditorPage.vue +319 -0
  188. package/src/ngb/security/NgbRolesPage.vue +125 -0
  189. package/src/ngb/security/NgbUserEditorPage.vue +615 -0
  190. package/src/ngb/security/NgbUsersPage.vue +125 -0
  191. package/src/ngb/security/api.ts +91 -0
  192. package/src/ngb/security/audit.ts +21 -0
  193. package/src/ngb/security/permissions.ts +65 -0
  194. package/src/ngb/security/types.ts +157 -0
  195. package/src/ngb/security/useAccessStore.ts +69 -0
  196. package/src/ngb/site/NgbDashboardAsOfToolbar.vue +100 -0
  197. package/src/ngb/site/NgbDashboardStatusBanner.vue +91 -0
  198. package/src/ngb/site/NgbLogo.vue +44 -0
  199. package/src/ngb/site/NgbPageHeader.vue +49 -0
  200. package/src/ngb/site/NgbSiteShell.vue +286 -0
  201. package/src/ngb/site/NgbSiteSidebar.vue +270 -0
  202. package/src/ngb/site/NgbTopBar.vue +425 -0
  203. package/src/ngb/site/NgbTrendChart.vue +224 -0
  204. package/src/ngb/site/dashboardData.ts +324 -0
  205. package/src/ngb/site/mainMenuStore.ts +49 -0
  206. package/src/ngb/site/types.ts +31 -0
  207. package/src/ngb/site/useDashboardPageState.ts +98 -0
  208. package/src/ngb/site/useTheme.ts +95 -0
  209. package/src/ngb/utils/clone.ts +43 -0
  210. package/src/ngb/utils/dateValues.ts +107 -0
  211. package/src/ngb/utils/errorMessage.ts +14 -0
  212. package/src/ngb/utils/guid.ts +21 -0
  213. package/src/ngb/utils/stableValue.ts +21 -0
  214. package/src/ngb/utils/storage.ts +135 -0
  215. package/src/styles/tailwind.css +165 -0
  216. package/src/vite/publicAssets.ts +104 -0
  217. package/vite-public-assets.js +68 -0
@@ -0,0 +1,73 @@
1
+ export type CloseMonthRequestDto = {
2
+ period: string;
3
+ };
4
+
5
+ export type ReopenMonthRequestDto = {
6
+ period: string;
7
+ reason: string;
8
+ };
9
+
10
+ export type PeriodCloseStatusDto = {
11
+ period: string;
12
+ state: string;
13
+ isClosed: boolean;
14
+ hasActivity: boolean;
15
+ closedBy?: string | null;
16
+ closedAtUtc?: string | null;
17
+ canClose: boolean;
18
+ canReopen: boolean;
19
+ blockingPeriod?: string | null;
20
+ blockingReason?: string | null;
21
+ };
22
+
23
+ export type PeriodClosingCalendarDto = {
24
+ year: number;
25
+ yearStartPeriod: string;
26
+ yearEndPeriod: string;
27
+ earliestActivityPeriod?: string | null;
28
+ latestContiguousClosedPeriod?: string | null;
29
+ latestClosedPeriod?: string | null;
30
+ nextClosablePeriod?: string | null;
31
+ canCloseAnyMonth: boolean;
32
+ hasBrokenChain: boolean;
33
+ firstGapPeriod?: string | null;
34
+ months: PeriodCloseStatusDto[];
35
+ };
36
+
37
+ export type CloseFiscalYearRequestDto = {
38
+ fiscalYearEndPeriod: string;
39
+ retainedEarningsAccountId: string;
40
+ };
41
+
42
+ export type ReopenFiscalYearRequestDto = {
43
+ fiscalYearEndPeriod: string;
44
+ reason: string;
45
+ };
46
+
47
+ export type RetainedEarningsAccountOptionDto = {
48
+ accountId: string;
49
+ code: string;
50
+ name: string;
51
+ display: string;
52
+ };
53
+
54
+ export type FiscalYearCloseStatusDto = {
55
+ fiscalYearEndPeriod: string;
56
+ fiscalYearStartPeriod: string;
57
+ state: string;
58
+ documentId: string;
59
+ startedAtUtc?: string | null;
60
+ completedAtUtc?: string | null;
61
+ endPeriodClosed: boolean;
62
+ endPeriodClosedBy?: string | null;
63
+ endPeriodClosedAtUtc?: string | null;
64
+ canClose: boolean;
65
+ canReopen: boolean;
66
+ reopenWillOpenEndPeriod: boolean;
67
+ closedRetainedEarningsAccount?: RetainedEarningsAccountOptionDto | null;
68
+ blockingPeriod?: string | null;
69
+ blockingReason?: string | null;
70
+ reopenBlockingPeriod?: string | null;
71
+ reopenBlockingReason?: string | null;
72
+ priorMonths: PeriodCloseStatusDto[];
73
+ };
@@ -0,0 +1,57 @@
1
+ export type ChartOfAccountsAccountDto = {
2
+ accountId: string;
3
+ code: string;
4
+ name: string;
5
+ accountType: string;
6
+ cashFlowRole?: string | null;
7
+ cashFlowLineCode?: string | null;
8
+ isActive: boolean;
9
+ isDeleted: boolean;
10
+ isMarkedForDeletion: boolean;
11
+ };
12
+
13
+ export type ChartOfAccountsOptionDto = {
14
+ value: string;
15
+ label: string;
16
+ };
17
+
18
+ export type ChartOfAccountsCashFlowRoleOptionDto = {
19
+ value: string;
20
+ label: string;
21
+ supportsLineCode: boolean;
22
+ requiresLineCode: boolean;
23
+ };
24
+
25
+ export type ChartOfAccountsCashFlowLineOptionDto = {
26
+ value: string;
27
+ label: string;
28
+ section: string;
29
+ allowedRoles: string[];
30
+ };
31
+
32
+ export type ChartOfAccountsMetadataDto = {
33
+ accountTypeOptions: ChartOfAccountsOptionDto[];
34
+ cashFlowRoleOptions: ChartOfAccountsCashFlowRoleOptionDto[];
35
+ cashFlowLineOptions: ChartOfAccountsCashFlowLineOptionDto[];
36
+ };
37
+
38
+ export type ChartOfAccountsPageDto = {
39
+ items: ChartOfAccountsAccountDto[];
40
+ offset: number;
41
+ limit: number;
42
+ total?: number | null;
43
+ };
44
+
45
+ export type ChartOfAccountsUpsertRequestDto = {
46
+ code: string;
47
+ name: string;
48
+ accountType: string;
49
+ isActive: boolean;
50
+ cashFlowRole?: string | null;
51
+ cashFlowLineCode?: string | null;
52
+ };
53
+
54
+ export type ChartOfAccountEditorShellState = {
55
+ hideHeader: boolean;
56
+ flushBody: boolean;
57
+ };
@@ -0,0 +1,23 @@
1
+ import { httpGet } from './http'
2
+ import type { AuditLogPageDto } from './contracts'
3
+
4
+ export type GetEntityAuditLogOptions = {
5
+ afterOccurredAtUtc?: string | null
6
+ afterAuditEventId?: string | null
7
+ limit?: number
8
+ }
9
+
10
+ export async function getEntityAuditLog(
11
+ entityKind: number,
12
+ entityId: string,
13
+ opts?: GetEntityAuditLogOptions,
14
+ ): Promise<AuditLogPageDto> {
15
+ return await httpGet<AuditLogPageDto>(
16
+ `/api/audit/entities/${encodeURIComponent(String(entityKind))}/${encodeURIComponent(entityId)}`,
17
+ {
18
+ afterOccurredAtUtc: opts?.afterOccurredAtUtc,
19
+ afterAuditEventId: opts?.afterAuditEventId,
20
+ limit: opts?.limit,
21
+ },
22
+ )
23
+ }
@@ -0,0 +1,50 @@
1
+ import { httpDelete, httpGet, httpPost, httpPut } from './http'
2
+ import type { CatalogItemDto, CatalogTypeMetadataDto, PageRequest, PageResponseDto, RecordPayload } from './contracts'
3
+
4
+ function toPageQuery(req: PageRequest | null | undefined) {
5
+ if (!req) return undefined
6
+ return {
7
+ offset: req.offset,
8
+ limit: req.limit,
9
+ search: req.search,
10
+ ...(req.filters ?? {}),
11
+ }
12
+ }
13
+
14
+ export async function getCatalogTypeMetadata(catalogType: string): Promise<CatalogTypeMetadataDto> {
15
+ return await httpGet<CatalogTypeMetadataDto>(`/api/catalogs/${encodeURIComponent(catalogType)}/metadata`)
16
+ }
17
+
18
+ export async function getCatalogPage(
19
+ catalogType: string,
20
+ req: PageRequest,
21
+ ): Promise<PageResponseDto<CatalogItemDto>> {
22
+ return await httpGet<PageResponseDto<CatalogItemDto>>(
23
+ `/api/catalogs/${encodeURIComponent(catalogType)}`,
24
+ toPageQuery(req),
25
+ )
26
+ }
27
+
28
+ export async function getCatalogById(catalogType: string, id: string): Promise<CatalogItemDto> {
29
+ return await httpGet<CatalogItemDto>(`/api/catalogs/${encodeURIComponent(catalogType)}/${encodeURIComponent(id)}`)
30
+ }
31
+
32
+ export async function createCatalog(catalogType: string, payload: RecordPayload): Promise<CatalogItemDto> {
33
+ return await httpPost<CatalogItemDto>(`/api/catalogs/${encodeURIComponent(catalogType)}`, payload)
34
+ }
35
+
36
+ export async function updateCatalog(catalogType: string, id: string, payload: RecordPayload): Promise<CatalogItemDto> {
37
+ return await httpPut<CatalogItemDto>(`/api/catalogs/${encodeURIComponent(catalogType)}/${encodeURIComponent(id)}`, payload)
38
+ }
39
+
40
+ export async function deleteCatalog(catalogType: string, id: string): Promise<void> {
41
+ await httpDelete<void>(`/api/catalogs/${encodeURIComponent(catalogType)}/${encodeURIComponent(id)}`)
42
+ }
43
+
44
+ export async function markCatalogForDeletion(catalogType: string, id: string): Promise<void> {
45
+ await httpPost<void>(`/api/catalogs/${encodeURIComponent(catalogType)}/${encodeURIComponent(id)}/mark-for-deletion`)
46
+ }
47
+
48
+ export async function unmarkCatalogForDeletion(catalogType: string, id: string): Promise<void> {
49
+ await httpPost<void>(`/api/catalogs/${encodeURIComponent(catalogType)}/${encodeURIComponent(id)}/unmark-for-deletion`)
50
+ }
@@ -0,0 +1,285 @@
1
+ import type { ReferenceValue } from '../metadata/entityModel'
2
+ import type {
3
+ ActionKind,
4
+ CatalogTypeMetadata,
5
+ ColumnAlign,
6
+ ColumnMetadata,
7
+ DataType,
8
+ DocumentCapabilities,
9
+ DocumentPresentation,
10
+ DocumentStatusValue,
11
+ DocumentTypeMetadata,
12
+ EntityKind,
13
+ FieldMetadata,
14
+ FieldValidation,
15
+ FormMetadata,
16
+ FormRow,
17
+ FormSection,
18
+ FieldOption,
19
+ ListFilterField,
20
+ ListFilterOption,
21
+ ListMetadata,
22
+ LookupSource,
23
+ PartMetadata,
24
+ RecordFields,
25
+ RecordPart,
26
+ RecordPartRow,
27
+ RecordParts,
28
+ RecordPayload,
29
+ } from '../metadata/types'
30
+
31
+ export type DocumentStatus = DocumentStatusValue
32
+ export type NgbActionKind = ActionKind
33
+
34
+ export type CatalogLookupSourceDto = Extract<LookupSource, { kind: 'catalog' }>
35
+ export type DocumentLookupSourceDto = Extract<LookupSource, { kind: 'document' }>
36
+ export type ChartOfAccountsLookupSourceDto = Extract<LookupSource, { kind: 'coa' }>
37
+ export type LookupSourceDto = LookupSource
38
+
39
+ export type ColumnMetadataDto = ColumnMetadata
40
+ export type MetadataOptionDto = FieldOption
41
+ export type ListFilterOptionDto = ListFilterOption
42
+ export type ListFilterFieldDto = ListFilterField
43
+ export type ListMetadataDto = ListMetadata
44
+ export type FieldValidationDto = FieldValidation
45
+ export type FieldMetadataDto = FieldMetadata
46
+ export type FormRowDto = FormRow
47
+ export type FormSectionDto = FormSection
48
+ export type FormMetadataDto = FormMetadata
49
+ export type ActionMetadataDto = {
50
+ code: string
51
+ label: string
52
+ kind?: NgbActionKind
53
+ requiresConfirm?: boolean
54
+ visibleWhenStatusIn?: DocumentStatus[] | null
55
+ }
56
+ export type CatalogTypeMetadataDto = CatalogTypeMetadata
57
+ export type PartMetadataDto = PartMetadata
58
+ export type DocumentCapabilitiesDto = DocumentCapabilities
59
+ export type DocumentPresentationDto = DocumentPresentation
60
+ export type DocumentTypeMetadataDto = DocumentTypeMetadata
61
+ export type RefValueDto = ReferenceValue
62
+
63
+ export type CatalogItemDto = {
64
+ id: string
65
+ display?: string | null
66
+ payload: RecordPayload
67
+ isMarkedForDeletion: boolean
68
+ isDeleted: boolean
69
+ }
70
+
71
+ export type DocumentDto = {
72
+ id: string
73
+ number?: string | null
74
+ display?: string | null
75
+ payload: RecordPayload
76
+ status: DocumentStatus
77
+ isMarkedForDeletion: boolean
78
+ }
79
+
80
+ export type GraphNodeDto = {
81
+ nodeId: string
82
+ kind: EntityKind
83
+ typeCode: string
84
+ entityId: string
85
+ title: string
86
+ subtitle?: string | null
87
+ documentStatus?: DocumentStatus | null
88
+ depth?: number | null
89
+ amount?: number | null
90
+ }
91
+
92
+ export type GraphEdgeDto = {
93
+ fromNodeId: string
94
+ toNodeId: string
95
+ relationshipType: string
96
+ label?: string | null
97
+ }
98
+
99
+ export type RelationshipGraphDto = {
100
+ nodes: GraphNodeDto[]
101
+ edges: GraphEdgeDto[]
102
+ }
103
+
104
+ export type DocumentUiActionReasonDto = {
105
+ errorCode: string
106
+ message: string
107
+ }
108
+
109
+ export type DocumentUiEffectsDto = {
110
+ isPosted: boolean
111
+ canEdit: boolean
112
+ canPost: boolean
113
+ canUnpost: boolean
114
+ canRepost: boolean
115
+ canApply: boolean
116
+ disabledReasons?: Record<string, DocumentUiActionReasonDto[]> | null
117
+ }
118
+
119
+ export type EffectAccountDto = {
120
+ accountId: string
121
+ code: string
122
+ name: string
123
+ }
124
+
125
+ export type EffectDimensionValueDto = {
126
+ dimensionId: string
127
+ valueId: string
128
+ display: string
129
+ }
130
+
131
+ export type EffectResourceValueDto = {
132
+ code: string
133
+ value: number
134
+ }
135
+
136
+ export type AccountingEntryEffectDto = {
137
+ entryId: string | number
138
+ documentId?: string | null
139
+ occurredAtUtc: string
140
+ debitAccount?: EffectAccountDto | null
141
+ creditAccount?: EffectAccountDto | null
142
+ debitAccountId?: string | null
143
+ creditAccountId?: string | null
144
+ amount: number
145
+ isStorno?: boolean
146
+ debitDimensionSetId?: string | null
147
+ creditDimensionSetId?: string | null
148
+ debitDimensions?: EffectDimensionValueDto[] | null
149
+ creditDimensions?: EffectDimensionValueDto[] | null
150
+ }
151
+
152
+ export type OperationalRegisterMovementEffectDto = {
153
+ registerId?: string | null
154
+ registerCode: string
155
+ registerName?: string | null
156
+ movementId: string | number
157
+ documentId?: string | null
158
+ occurredAtUtc: string
159
+ periodMonth?: string | null
160
+ isStorno?: boolean
161
+ dimensionSetId?: string | null
162
+ dimensions?: EffectDimensionValueDto[] | null
163
+ resources: EffectResourceValueDto[] | Record<string, unknown>
164
+ }
165
+
166
+ export type ReferenceRegisterWriteEffectDto = {
167
+ registerId?: string | null
168
+ registerCode: string
169
+ registerName?: string | null
170
+ recordId: string | number
171
+ documentId?: string | null
172
+ periodUtc?: string | null
173
+ periodBucketUtc?: string | null
174
+ recordedAtUtc: string
175
+ dimensionSetId?: string | null
176
+ dimensions?: EffectDimensionValueDto[] | null
177
+ fields: Record<string, unknown>
178
+ isTombstone: boolean
179
+ }
180
+
181
+ export type DocumentEffectsDto = {
182
+ accountingEntries: AccountingEntryEffectDto[]
183
+ operationalRegisterMovements: OperationalRegisterMovementEffectDto[]
184
+ referenceRegisterWrites: ReferenceRegisterWriteEffectDto[]
185
+ ui?: DocumentUiEffectsDto | null
186
+ }
187
+
188
+ export type PageResponseDto<T> = {
189
+ items: T[]
190
+ offset: number
191
+ limit: number
192
+ total?: number | null
193
+ }
194
+
195
+ export type PageRequest = {
196
+ offset?: number
197
+ limit?: number
198
+ search?: string
199
+ filters?: Record<string, string>
200
+ }
201
+
202
+ export type LookupItemDto = {
203
+ id: string
204
+ label: string
205
+ meta?: Record<string, string> | null
206
+ }
207
+
208
+ export type DocumentLookupDto = {
209
+ id: string
210
+ documentType: string
211
+ display?: string | null
212
+ status: DocumentStatus
213
+ isMarkedForDeletion: boolean
214
+ number?: string | null
215
+ }
216
+
217
+ export type DocumentDerivationActionDto = {
218
+ code: string
219
+ name: string
220
+ fromTypeCode: string
221
+ toTypeCode: string
222
+ relationshipCodes: string[]
223
+ }
224
+
225
+ export type DocumentLookupAcrossTypesRequestDto = {
226
+ documentTypes: string[]
227
+ query?: string | null
228
+ perTypeLimit?: number | null
229
+ activeOnly?: boolean | null
230
+ }
231
+
232
+ export type DocumentLookupByIdsRequestDto = {
233
+ documentTypes: string[]
234
+ ids: string[]
235
+ }
236
+
237
+ export type ByIdsRequestDto = {
238
+ ids: string[]
239
+ }
240
+
241
+ export type AuditFieldChangeDto = {
242
+ fieldPath: string
243
+ oldValueJson?: string | null
244
+ newValueJson?: string | null
245
+ }
246
+
247
+ export type AuditActorDto = {
248
+ userId?: string | null
249
+ displayName?: string | null
250
+ email?: string | null
251
+ }
252
+
253
+ export type AuditEventDto = {
254
+ auditEventId: string
255
+ entityKind: EntityKind
256
+ entityId: string
257
+ actionCode: string
258
+ actor?: AuditActorDto | null
259
+ occurredAtUtc: string
260
+ correlationId?: string | null
261
+ metadataJson?: string | null
262
+ changes: AuditFieldChangeDto[]
263
+ }
264
+
265
+ export type AuditCursorDto = {
266
+ occurredAtUtc: string
267
+ auditEventId: string
268
+ }
269
+
270
+ export type AuditLogPageDto = {
271
+ items: AuditEventDto[]
272
+ nextCursor?: AuditCursorDto | null
273
+ limit: number
274
+ }
275
+
276
+ export type {
277
+ ColumnAlign,
278
+ DataType,
279
+ EntityKind,
280
+ RecordFields,
281
+ RecordPart,
282
+ RecordPartRow,
283
+ RecordParts,
284
+ RecordPayload,
285
+ }
@@ -0,0 +1,170 @@
1
+ import { normalizeDocumentStatusValue } from '../editor/documentStatus'
2
+ import { httpDelete, httpGet, httpPost, httpPut } from './http'
3
+ import type {
4
+ DocumentDerivationActionDto,
5
+ DocumentDto,
6
+ DocumentEffectsDto,
7
+ DocumentLookupAcrossTypesRequestDto,
8
+ DocumentLookupByIdsRequestDto,
9
+ DocumentLookupDto,
10
+ DocumentTypeMetadataDto,
11
+ PageRequest,
12
+ PageResponseDto,
13
+ RecordPayload,
14
+ RelationshipGraphDto,
15
+ } from './contracts'
16
+
17
+ function toPageQuery(req: PageRequest | null | undefined) {
18
+ if (!req) return undefined
19
+ return {
20
+ offset: req.offset,
21
+ limit: req.limit,
22
+ search: req.search,
23
+ ...(req.filters ?? {}),
24
+ }
25
+ }
26
+
27
+ function normalizeDocumentDto(document: DocumentDto): DocumentDto {
28
+ const status = normalizeDocumentStatusValue(document.status)
29
+ if (document.status === status) return document
30
+ return { ...document, status }
31
+ }
32
+
33
+ function normalizeDocumentLookup(document: DocumentLookupDto): DocumentLookupDto {
34
+ const status = normalizeDocumentStatusValue(document.status)
35
+ if (document.status === status) return document
36
+ return { ...document, status }
37
+ }
38
+
39
+ function normalizeDocumentPage(page: PageResponseDto<DocumentDto>): PageResponseDto<DocumentDto> {
40
+ return {
41
+ ...page,
42
+ items: (page.items ?? []).map(normalizeDocumentDto),
43
+ }
44
+ }
45
+
46
+ export async function getDocumentTypeMetadata(documentType: string): Promise<DocumentTypeMetadataDto> {
47
+ return await httpGet<DocumentTypeMetadataDto>(`/api/documents/${encodeURIComponent(documentType)}/metadata`)
48
+ }
49
+
50
+ export async function getDocumentPage(
51
+ documentType: string,
52
+ req: PageRequest,
53
+ ): Promise<PageResponseDto<DocumentDto>> {
54
+ const page = await httpGet<PageResponseDto<DocumentDto>>(
55
+ `/api/documents/${encodeURIComponent(documentType)}`,
56
+ toPageQuery(req),
57
+ )
58
+ return normalizeDocumentPage(page)
59
+ }
60
+
61
+ export async function getDocumentById(documentType: string, id: string): Promise<DocumentDto> {
62
+ const document = await httpGet<DocumentDto>(
63
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}`,
64
+ )
65
+ return normalizeDocumentDto(document)
66
+ }
67
+
68
+ export async function getDocumentDerivationActions(
69
+ documentType: string,
70
+ id: string,
71
+ ): Promise<DocumentDerivationActionDto[]> {
72
+ return await httpGet<DocumentDerivationActionDto[]>(
73
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}/derive-actions`,
74
+ )
75
+ }
76
+
77
+ export async function lookupDocumentsAcrossTypes(
78
+ request: DocumentLookupAcrossTypesRequestDto,
79
+ ): Promise<DocumentLookupDto[]> {
80
+ return (await httpPost<DocumentLookupDto[]>('/api/documents/lookup', request)).map(normalizeDocumentLookup)
81
+ }
82
+
83
+ export async function getDocumentLookupByIds(
84
+ request: DocumentLookupByIdsRequestDto,
85
+ ): Promise<DocumentLookupDto[]> {
86
+ return (await httpPost<DocumentLookupDto[]>('/api/documents/lookup/by-ids', request)).map(normalizeDocumentLookup)
87
+ }
88
+
89
+ export async function createDraft(documentType: string, payload: RecordPayload): Promise<DocumentDto> {
90
+ const document = await httpPost<DocumentDto>(`/api/documents/${encodeURIComponent(documentType)}`, payload)
91
+ return normalizeDocumentDto(document)
92
+ }
93
+
94
+ export async function deriveDocument(
95
+ targetDocumentType: string,
96
+ request: {
97
+ sourceDocumentId: string
98
+ relationshipType: string
99
+ initialPayload?: RecordPayload | null
100
+ },
101
+ ): Promise<DocumentDto> {
102
+ const document = await httpPost<DocumentDto>(
103
+ `/api/documents/${encodeURIComponent(targetDocumentType)}/derive`,
104
+ {
105
+ sourceDocumentId: request.sourceDocumentId,
106
+ relationshipType: request.relationshipType,
107
+ initialPayload: request.initialPayload ?? null,
108
+ },
109
+ )
110
+ return normalizeDocumentDto(document)
111
+ }
112
+
113
+ export async function updateDraft(documentType: string, id: string, payload: RecordPayload): Promise<DocumentDto> {
114
+ const document = await httpPut<DocumentDto>(
115
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}`,
116
+ payload,
117
+ )
118
+ return normalizeDocumentDto(document)
119
+ }
120
+
121
+ export async function deleteDraft(documentType: string, id: string): Promise<void> {
122
+ await httpDelete<void>(`/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}`)
123
+ }
124
+
125
+ export async function postDocument(documentType: string, id: string): Promise<DocumentDto> {
126
+ const document = await httpPost<DocumentDto>(
127
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}/post`,
128
+ )
129
+ return normalizeDocumentDto(document)
130
+ }
131
+
132
+ export async function unpostDocument(documentType: string, id: string): Promise<DocumentDto> {
133
+ const document = await httpPost<DocumentDto>(
134
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}/unpost`,
135
+ )
136
+ return normalizeDocumentDto(document)
137
+ }
138
+
139
+ export async function markDocumentForDeletion(documentType: string, id: string): Promise<DocumentDto> {
140
+ const document = await httpPost<DocumentDto>(
141
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}/mark-for-deletion`,
142
+ )
143
+ return normalizeDocumentDto(document)
144
+ }
145
+
146
+ export async function unmarkDocumentForDeletion(documentType: string, id: string): Promise<DocumentDto> {
147
+ const document = await httpPost<DocumentDto>(
148
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}/unmark-for-deletion`,
149
+ )
150
+ return normalizeDocumentDto(document)
151
+ }
152
+
153
+ export async function getDocumentEffects(documentType: string, id: string, limit = 500): Promise<DocumentEffectsDto> {
154
+ return await httpGet<DocumentEffectsDto>(
155
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}/effects`,
156
+ { limit },
157
+ )
158
+ }
159
+
160
+ export async function getDocumentGraph(
161
+ documentType: string,
162
+ id: string,
163
+ depth = 5,
164
+ maxNodes = 100,
165
+ ): Promise<RelationshipGraphDto> {
166
+ return await httpGet<RelationshipGraphDto>(
167
+ `/api/documents/${encodeURIComponent(documentType)}/${encodeURIComponent(id)}/graph`,
168
+ { depth, maxNodes },
169
+ )
170
+ }