@spaceinvoices/react-ui 0.4.0 → 0.4.2

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 (200) hide show
  1. package/cli/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/registry.json +23 -27
  4. package/src/components/advance-invoices/advance-invoices.hooks.ts +32 -2
  5. package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +109 -4
  6. package/src/components/advance-invoices/create/locales/de.ts +2 -0
  7. package/src/components/advance-invoices/create/locales/es.ts +2 -0
  8. package/src/components/advance-invoices/create/locales/fr.ts +2 -0
  9. package/src/components/advance-invoices/create/locales/hr.ts +2 -0
  10. package/src/components/advance-invoices/create/locales/it.ts +2 -0
  11. package/src/components/advance-invoices/create/locales/nl.ts +2 -0
  12. package/src/components/advance-invoices/create/locales/pl.ts +2 -0
  13. package/src/components/advance-invoices/create/locales/pt.ts +2 -0
  14. package/src/components/advance-invoices/create/locales/sl.ts +2 -0
  15. package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +17 -0
  16. package/src/components/advance-invoices/list/list-row-actions.tsx +3 -6
  17. package/src/components/advance-invoices/list/list-table.tsx +45 -2
  18. package/src/components/advance-invoices/list/locales/de.ts +3 -0
  19. package/src/components/advance-invoices/list/locales/en.ts +3 -0
  20. package/src/components/advance-invoices/list/locales/es.ts +3 -0
  21. package/src/components/advance-invoices/list/locales/fr.ts +3 -0
  22. package/src/components/advance-invoices/list/locales/hr.ts +3 -0
  23. package/src/components/advance-invoices/list/locales/it.ts +3 -0
  24. package/src/components/advance-invoices/list/locales/nl.ts +3 -0
  25. package/src/components/advance-invoices/list/locales/pl.ts +3 -0
  26. package/src/components/advance-invoices/list/locales/pt.ts +3 -0
  27. package/src/components/advance-invoices/list/locales/sl.ts +3 -0
  28. package/src/components/credit-notes/create/create-credit-note-form.tsx +177 -6
  29. package/src/components/credit-notes/create/locales/de.ts +8 -0
  30. package/src/components/credit-notes/create/locales/es.ts +8 -0
  31. package/src/components/credit-notes/create/locales/fr.ts +7 -0
  32. package/src/components/credit-notes/create/locales/hr.ts +7 -0
  33. package/src/components/credit-notes/create/locales/it.ts +9 -0
  34. package/src/components/credit-notes/create/locales/nl.ts +7 -0
  35. package/src/components/credit-notes/create/locales/pl.ts +7 -0
  36. package/src/components/credit-notes/create/locales/pt.ts +7 -0
  37. package/src/components/credit-notes/create/locales/sl.ts +7 -0
  38. package/src/components/credit-notes/credit-notes.hooks.ts +30 -0
  39. package/src/components/credit-notes/list/list-row-actions.tsx +3 -6
  40. package/src/components/credit-notes/list/list-table.tsx +45 -2
  41. package/src/components/credit-notes/list/locales/de.ts +3 -0
  42. package/src/components/credit-notes/list/locales/en.ts +3 -0
  43. package/src/components/credit-notes/list/locales/es.ts +3 -0
  44. package/src/components/credit-notes/list/locales/fr.ts +3 -0
  45. package/src/components/credit-notes/list/locales/hr.ts +3 -0
  46. package/src/components/credit-notes/list/locales/it.ts +3 -0
  47. package/src/components/credit-notes/list/locales/nl.ts +3 -0
  48. package/src/components/credit-notes/list/locales/pl.ts +3 -0
  49. package/src/components/credit-notes/list/locales/pt.ts +3 -0
  50. package/src/components/credit-notes/list/locales/sl.ts +3 -0
  51. package/src/components/customers/create-customer-form/create-customer-form.tsx +0 -1
  52. package/src/components/documents/create/document-details-section.tsx +67 -1
  53. package/src/components/documents/create/mark-as-paid-section.tsx +11 -2
  54. package/src/components/documents/view/document-actions-bar.tsx +30 -0
  55. package/src/components/documents/view/locales/de.ts +5 -0
  56. package/src/components/documents/view/locales/es.ts +5 -0
  57. package/src/components/documents/view/locales/fr.ts +5 -0
  58. package/src/components/documents/view/locales/hr.ts +5 -0
  59. package/src/components/documents/view/locales/it.ts +5 -0
  60. package/src/components/documents/view/locales/nl.ts +5 -0
  61. package/src/components/documents/view/locales/pl.ts +5 -0
  62. package/src/components/documents/view/locales/pt.ts +5 -0
  63. package/src/components/documents/view/locales/sl.ts +5 -0
  64. package/src/components/entities/create-entity-form.tsx +1 -1
  65. package/src/components/entities/entity-settings-form/entity-settings-form.tsx +2 -3
  66. package/src/components/entities/entity-settings-form/locales/es.ts +2 -0
  67. package/src/components/entities/entity-settings-form/locales/fr.ts +2 -0
  68. package/src/components/entities/entity-settings-form/locales/hr.ts +2 -0
  69. package/src/components/entities/entity-settings-form/locales/it.ts +2 -0
  70. package/src/components/entities/entity-settings-form/locales/nl.ts +2 -0
  71. package/src/components/entities/entity-settings-form/locales/pl.ts +2 -0
  72. package/src/components/entities/entity-settings-form/locales/pt.ts +2 -0
  73. package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +109 -0
  74. package/src/components/entities/fina-settings-form/fina-settings-form.tsx +365 -35
  75. package/src/components/entities/fina-settings-form/fina-settings.hooks.ts +101 -20
  76. package/src/components/entities/fina-settings-form/index.ts +1 -0
  77. package/src/components/entities/fina-settings-form/locales/de.ts +54 -34
  78. package/src/components/entities/fina-settings-form/locales/en.ts +51 -34
  79. package/src/components/entities/fina-settings-form/locales/es.ts +50 -34
  80. package/src/components/entities/fina-settings-form/locales/fr.ts +50 -34
  81. package/src/components/entities/fina-settings-form/locales/hr.ts +50 -34
  82. package/src/components/entities/fina-settings-form/locales/it.ts +50 -34
  83. package/src/components/entities/fina-settings-form/locales/nl.ts +50 -34
  84. package/src/components/entities/fina-settings-form/locales/pl.ts +50 -34
  85. package/src/components/entities/fina-settings-form/locales/pt.ts +50 -34
  86. package/src/components/entities/fina-settings-form/locales/sl.ts +50 -34
  87. package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +18 -0
  88. package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +64 -89
  89. package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +51 -323
  90. package/src/components/entities/furs-settings-form/furs-operator-required-dialog.tsx +106 -0
  91. package/src/components/entities/furs-settings-form/furs-settings-form.tsx +24 -10
  92. package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +5 -9
  93. package/src/components/entities/furs-settings-form/index.ts +1 -0
  94. package/src/components/entities/furs-settings-form/locales/de.ts +27 -3
  95. package/src/components/entities/furs-settings-form/locales/en.ts +17 -3
  96. package/src/components/entities/furs-settings-form/locales/es.ts +26 -3
  97. package/src/components/entities/furs-settings-form/locales/fr.ts +26 -3
  98. package/src/components/entities/furs-settings-form/locales/hr.ts +26 -3
  99. package/src/components/entities/furs-settings-form/locales/it.ts +26 -3
  100. package/src/components/entities/furs-settings-form/locales/nl.ts +26 -3
  101. package/src/components/entities/furs-settings-form/locales/pl.ts +26 -3
  102. package/src/components/entities/furs-settings-form/locales/pt.ts +26 -3
  103. package/src/components/entities/furs-settings-form/locales/sl.ts +16 -3
  104. package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +22 -0
  105. package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +15 -2
  106. package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +1 -0
  107. package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +58 -34
  108. package/src/components/entities/settings/tax-rules-settings-form.tsx +4 -4
  109. package/src/components/estimates/list/list-row-actions.tsx +3 -7
  110. package/src/components/estimates/list/list-table.tsx +35 -2
  111. package/src/components/estimates/list/locales/de.ts +3 -0
  112. package/src/components/estimates/list/locales/en.ts +3 -0
  113. package/src/components/estimates/list/locales/es.ts +3 -0
  114. package/src/components/estimates/list/locales/fr.ts +3 -0
  115. package/src/components/estimates/list/locales/hr.ts +3 -0
  116. package/src/components/estimates/list/locales/it.ts +3 -0
  117. package/src/components/estimates/list/locales/nl.ts +3 -0
  118. package/src/components/estimates/list/locales/pl.ts +3 -0
  119. package/src/components/estimates/list/locales/pt.ts +3 -0
  120. package/src/components/estimates/list/locales/sl.ts +3 -0
  121. package/src/components/export/document-export-form.tsx +34 -34
  122. package/src/components/invoices/create/create-invoice-form.tsx +107 -5
  123. package/src/components/invoices/create/prepare-invoice-submission.ts +17 -0
  124. package/src/components/invoices/invoices.hooks.ts +32 -2
  125. package/src/components/invoices/list/list-row-actions.tsx +23 -8
  126. package/src/components/invoices/list/list-table.tsx +53 -2
  127. package/src/components/invoices/list/locales/de.ts +4 -0
  128. package/src/components/invoices/list/locales/en.ts +4 -0
  129. package/src/components/invoices/list/locales/es.ts +4 -0
  130. package/src/components/invoices/list/locales/fr.ts +4 -0
  131. package/src/components/invoices/list/locales/hr.ts +4 -0
  132. package/src/components/invoices/list/locales/it.ts +4 -0
  133. package/src/components/invoices/list/locales/nl.ts +4 -0
  134. package/src/components/invoices/list/locales/pl.ts +4 -0
  135. package/src/components/invoices/list/locales/pt.ts +4 -0
  136. package/src/components/invoices/list/locales/sl.ts +4 -0
  137. package/src/components/invoices/view/fiscalization-status-card.tsx +4 -1
  138. package/src/components/items/item-list-table/item-list-row-actions.tsx +3 -7
  139. package/src/components/items/item-list-table/item-list-row.tsx +3 -2
  140. package/src/components/items/item-list-table/item-list-table.tsx +5 -1
  141. package/src/components/recurring-invoices/create-recurring-invoice-form/create-recurring-invoice-form.tsx +418 -0
  142. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/de.ts +45 -0
  143. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/es.ts +44 -0
  144. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/fr.ts +44 -0
  145. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/hr.ts +44 -0
  146. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/it.ts +44 -0
  147. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/nl.ts +44 -0
  148. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/pl.ts +44 -0
  149. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/pt.ts +44 -0
  150. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sl.ts +44 -0
  151. package/src/components/recurring-invoices/index.ts +3 -0
  152. package/src/components/recurring-invoices/list/index.ts +2 -0
  153. package/src/components/recurring-invoices/list/list-row-actions.tsx +139 -0
  154. package/src/components/recurring-invoices/list/list-table.tsx +179 -0
  155. package/src/components/recurring-invoices/list/locales/de.ts +27 -0
  156. package/src/components/recurring-invoices/list/locales/en.ts +5 -0
  157. package/src/components/recurring-invoices/list/locales/es.ts +27 -0
  158. package/src/components/recurring-invoices/list/locales/fr.ts +27 -0
  159. package/src/components/recurring-invoices/list/locales/hr.ts +27 -0
  160. package/src/components/recurring-invoices/list/locales/it.ts +27 -0
  161. package/src/components/recurring-invoices/list/locales/nl.ts +27 -0
  162. package/src/components/recurring-invoices/list/locales/pl.ts +27 -0
  163. package/src/components/recurring-invoices/list/locales/pt.ts +27 -0
  164. package/src/components/recurring-invoices/list/locales/sl.ts +27 -0
  165. package/src/components/recurring-invoices/recurring-invoices.hooks.ts +28 -0
  166. package/src/components/table/data-table.tsx +122 -5
  167. package/src/components/table/selection-toolbar.tsx +36 -0
  168. package/src/components/tax-reports/kir-export-form.tsx +75 -55
  169. package/src/components/taxes/tax-list-table/tax-list-row-actions.tsx +3 -6
  170. package/src/components/taxes/tax-list-table/tax-list-row.tsx +3 -2
  171. package/src/components/taxes/tax-list-table/tax-list-table.tsx +5 -1
  172. package/src/components/ui/checkbox.tsx +5 -5
  173. package/src/generate-schemas.ts +46 -7
  174. package/src/generated/schemas/advanceinvoice.ts +79 -187
  175. package/src/generated/schemas/authorizeshopify_body.ts +22 -0
  176. package/src/generated/schemas/creditnote.ts +60 -88
  177. package/src/generated/schemas/customadvanceinvoice.ts +70 -97
  178. package/src/generated/schemas/customcreditnote.ts +70 -97
  179. package/src/generated/schemas/customestimate.ts +68 -97
  180. package/src/generated/schemas/custominvoice.ts +70 -97
  181. package/src/generated/schemas/entity.ts +1 -1
  182. package/src/generated/schemas/estimate.ts +67 -172
  183. package/src/generated/schemas/index.ts +39 -28
  184. package/src/generated/schemas/invoice.ts +79 -187
  185. package/src/generated/schemas/order.ts +127 -0
  186. package/src/generated/schemas/orderintegration.ts +51 -0
  187. package/src/generated/schemas/payment.ts +2 -0
  188. package/src/generated/schemas/recurringinvoice.ts +61 -0
  189. package/src/generated/schemas/registerfursrealestatepremise_body.ts +11 -7
  190. package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +140 -269
  191. package/src/generated/schemas/rendercreditnotepreview_body.ts +141 -270
  192. package/src/generated/schemas/renderestimatepreview_body.ts +112 -212
  193. package/src/generated/schemas/renderinvoicepreview_body.ts +141 -270
  194. package/src/generated/schemas/webhook.ts +42 -0
  195. package/src/lib/furs-error-utils.ts +36 -0
  196. package/src/lib/schemas/advance-invoice.ts +3 -3
  197. package/src/lib/schemas/credit-note.ts +3 -3
  198. package/src/lib/schemas/estimate.ts +3 -3
  199. package/src/lib/schemas/invoice.ts +3 -3
  200. package/src/providers/white-label-provider.tsx +3 -0
@@ -12,14 +12,11 @@ import {
12
12
 
13
13
  type TaxListRowActionsProps = {
14
14
  tax: Tax;
15
+ onView?: (tax: Tax) => void;
15
16
  t: (key: string) => string;
16
17
  };
17
18
 
18
- export default function TaxListRowActions({ tax, t }: TaxListRowActionsProps) {
19
- const handleViewTax = () => {
20
- window.location.href = `/app/taxes/${tax.id}`;
21
- };
22
-
19
+ export default function TaxListRowActions({ tax, onView, t }: TaxListRowActionsProps) {
23
20
  return (
24
21
  <DropdownMenu>
25
22
  <DropdownMenuTrigger asChild>
@@ -34,7 +31,7 @@ export default function TaxListRowActions({ tax, t }: TaxListRowActionsProps) {
34
31
  {t("Copy tax ID")}
35
32
  </DropdownMenuItem>
36
33
  <DropdownMenuSeparator />
37
- <DropdownMenuItem className="cursor-pointer" onClick={handleViewTax}>
34
+ <DropdownMenuItem className="cursor-pointer" onClick={() => onView?.(tax)}>
38
35
  {t("View tax")}
39
36
  </DropdownMenuItem>
40
37
  </DropdownMenuContent>
@@ -8,10 +8,11 @@ import TaxListRowActions from "./tax-list-row-actions";
8
8
  type TaxListRowProps = {
9
9
  tax: Tax;
10
10
  onRowClick?: (tax: Tax) => void;
11
+ onView?: (tax: Tax) => void;
11
12
  t: (key: string) => string;
12
13
  };
13
14
 
14
- export default function TaxListRow({ tax, onRowClick, t }: TaxListRowProps) {
15
+ export default function TaxListRow({ tax, onRowClick, onView, t }: TaxListRowProps) {
15
16
  const formatTaxRates = (taxRates: Tax["tax_rates"]) => {
16
17
  if (!taxRates || taxRates.length === 0) return "-";
17
18
  return taxRates.map((rate) => `${rate.rate}%`).join(", ");
@@ -39,7 +40,7 @@ export default function TaxListRow({ tax, onRowClick, t }: TaxListRowProps) {
39
40
  <TableCell>{formatTaxRates(tax.tax_rates)}</TableCell>
40
41
  <TableCell>{formatDate(tax.created_at)}</TableCell>
41
42
  <TableCell className="text-right">
42
- <TaxListRowActions tax={tax} t={t} />
43
+ <TaxListRowActions tax={tax} onView={onView} t={t} />
43
44
  </TableCell>
44
45
  </TableRow>
45
46
  );
@@ -34,6 +34,7 @@ const translations = {
34
34
 
35
35
  type TaxListTableProps = {
36
36
  entityId?: string;
37
+ onView?: (tax: Tax) => void;
37
38
  } & ListTableProps<Tax> &
38
39
  ComponentTranslationProps;
39
40
 
@@ -41,6 +42,7 @@ export default function TaxListTable({
41
42
  queryParams,
42
43
  createNewTrigger,
43
44
  onRowClick,
45
+ onView,
44
46
  onChangeParams,
45
47
  entityId,
46
48
  ...i18nProps
@@ -61,7 +63,9 @@ export default function TaxListTable({
61
63
  { id: "created_at", header: t("Created"), sortable: true },
62
64
  { id: "actions", header: "", align: "right" },
63
65
  ]}
64
- renderRow={(tax) => <TaxListRow tax={tax} key={tax.id} onRowClick={(tax) => onRowClick?.(tax)} t={t} />}
66
+ renderRow={(tax) => (
67
+ <TaxListRow tax={tax} key={tax.id} onRowClick={(tax) => onRowClick?.(tax)} onView={onView} t={t} />
68
+ )}
65
69
  renderHeader={(headerProps) => <TaxListHeader orderBy={headerProps.orderBy} onSort={headerProps.onSort} t={t} />}
66
70
  queryParams={queryParams}
67
71
  resourceName="tax"
@@ -1,14 +1,15 @@
1
1
  import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox"
2
2
 
3
3
  import { cn } from "@/ui/lib/utils"
4
- import { CheckIcon } from "lucide-react"
4
+ import { CheckIcon, MinusIcon } from "lucide-react"
5
5
 
6
- function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
6
+ function Checkbox({ className, indeterminate, ...props }: CheckboxPrimitive.Root.Props & { indeterminate?: boolean }) {
7
7
  return (
8
8
  <CheckboxPrimitive.Root
9
9
  data-slot="checkbox"
10
+ indeterminate={indeterminate}
10
11
  className={cn(
11
- "border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex size-4 items-center justify-center rounded-[4px] border shadow-xs transition-shadow group-has-disabled/field:opacity-50 focus-visible:ring-[3px] aria-invalid:ring-[3px] peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
12
+ "border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex size-4 items-center justify-center rounded-[4px] border shadow-xs transition-shadow group-has-disabled/field:opacity-50 focus-visible:ring-[3px] aria-invalid:ring-[3px] peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[indeterminate]:bg-primary data-[indeterminate]:text-primary-foreground data-[indeterminate]:border-primary",
12
13
  className
13
14
  )}
14
15
  {...props}
@@ -17,8 +18,7 @@ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
17
18
  data-slot="checkbox-indicator"
18
19
  className="[&>svg]:size-3.5 grid place-content-center text-current transition-none"
19
20
  >
20
- <CheckIcon
21
- />
21
+ {indeterminate ? <MinusIcon /> : <CheckIcon />}
22
22
  </CheckboxPrimitive.Indicator>
23
23
  </CheckboxPrimitive.Root>
24
24
  )
@@ -86,7 +86,12 @@ async function main() {
86
86
  for (const ref of constRefs) {
87
87
  const cleanRef = ref.replace(/\.(optional|nullable)\(\)/, "");
88
88
  // Check if it's actually a schema definition in the file
89
- if (fullContent.includes(`const ${cleanRef} = z.`)) {
89
+ // Handle `const Foo = z.object(...)`, `const Foo = z\n .object(...)`,
90
+ // and `const Foo = OtherSchema.and(...)` (schema composition)
91
+ const isZodSchema =
92
+ fullContent.includes(`const ${cleanRef} = z.`) || fullContent.includes(`const ${cleanRef} = z\n`);
93
+ const isComposedSchema = new RegExp(`const ${cleanRef} = [A-Z][a-zA-Z0-9]+\\.`).test(fullContent);
94
+ if (isZodSchema || isComposedSchema) {
90
95
  dependencies.push(cleanRef);
91
96
  }
92
97
  }
@@ -133,14 +138,41 @@ async function main() {
133
138
  return groups;
134
139
  }, {});
135
140
 
141
+ // Topological sort: ensures each schema is defined after all schemas it depends on
142
+ function topologicalSort(names: string[], fullContent: string): string[] {
143
+ const visited = new Set<string>();
144
+ const result: string[] = [];
145
+
146
+ function visit(name: string) {
147
+ if (visited.has(name)) return;
148
+ visited.add(name);
149
+ // Visit dependencies first so they appear earlier in the output
150
+ const deps = findSchemaDependencies(name, fullContent);
151
+ for (const dep of deps) {
152
+ if (names.includes(dep)) {
153
+ visit(dep);
154
+ }
155
+ }
156
+ result.push(name);
157
+ }
158
+
159
+ for (const name of names) {
160
+ visit(name);
161
+ }
162
+ return result;
163
+ }
164
+
136
165
  // Create files for each group
137
166
  for (const [groupName, schemaNames] of Object.entries(schemasByGroup)) {
138
167
  // Separate dependencies from operation schemas
139
- const dependencies = schemaNames.filter((name) => !name.includes("_Body")).reverse();
168
+ const dependencies = schemaNames.filter((name) => !name.includes("_Body"));
140
169
  const operations = schemaNames.filter((name) => name.includes("_Body"));
141
170
 
171
+ // Topologically sort dependencies so each schema is defined after its own dependencies
172
+ const sortedDependencies = topologicalSort(dependencies, content);
173
+
142
174
  // Process dependencies first, then operations
143
- const orderedNames = [...dependencies, ...operations];
175
+ const orderedNames = [...sortedDependencies, ...operations];
144
176
 
145
177
  const schemas = orderedNames
146
178
  .map((schemaName) => {
@@ -244,16 +276,23 @@ ${exports}
244
276
  await fs.writeFile(path.join(SCHEMAS_DIR, `${groupName}.ts`), schemaContent);
245
277
  }
246
278
 
247
- // Create index file
279
+ // Create index file - export ALL schema files (not just schemasByGroup)
280
+ const allSchemaFiles = (await fs.readdir(SCHEMAS_DIR))
281
+ .filter((f) => f.endsWith(".ts") && f !== "index.ts")
282
+ .map((f) => f.replace(".ts", ""))
283
+ .sort();
284
+
248
285
  const indexContent = `/**
249
286
  * This file was automatically generated using 'bun generate-schemas'.
250
287
  * Do not edit this file manually. To update, run the generator again.
251
288
  * @generated
252
289
  */
253
290
 
254
- ${Object.keys(schemasByGroup)
255
- .map((groupName) => `export * from './${groupName}';`)
256
- .join("\n")}
291
+ ${allSchemaFiles.map((name) => `export * from './${name}';`).join("\n")}
292
+
293
+ // Re-export invoice create schema as credit note create schema (same body structure)
294
+ // Placed here (after invoice is exported) to avoid circular dependency issues
295
+ export { createInvoiceSchema as createCreditNoteSchema, type CreateInvoiceSchema as CreateCreditNoteSchema } from './invoice';
257
296
  `;
258
297
 
259
298
  await fs.writeFile(path.join(SCHEMAS_DIR, "index.ts"), indexContent);
@@ -8,6 +8,17 @@ import { z } from 'zod';
8
8
 
9
9
  // Schemas for advanceinvoice endpoints
10
10
 
11
+ // Dependency schema for advanceinvoice
12
+ const CreateDocumentPayment = z.object({
13
+ amount: z.number().gt(0).optional(),
14
+ type: z.string().max(20),
15
+ date: z.string().optional(),
16
+ reference: z.union([z.string(), z.null()]).optional(),
17
+ note: z.union([z.string(), z.null()]).optional(),
18
+ metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
19
+ });
20
+
21
+
11
22
  // Dependency schema for advanceinvoice
12
23
  const LineDiscount = z.object({
13
24
  value: z.number().gte(0),
@@ -15,6 +26,56 @@ const LineDiscount = z.object({
15
26
  });
16
27
 
17
28
 
29
+ // Dependency schema for advanceinvoice
30
+ const DocumentItemTax = z
31
+ .object({
32
+ rate: z.number(),
33
+ tax_id: z.string(),
34
+ classification: z.string(),
35
+ reverse_charge: z.boolean(),
36
+ amount: z.number(),
37
+ })
38
+ .partial();
39
+
40
+
41
+ // Dependency schema for advanceinvoice
42
+ const DocumentEntity = z
43
+ .object({
44
+ name: z.union([z.string(), z.null()]),
45
+ email: z.union([z.string(), z.null()]),
46
+ address: z.union([z.string(), z.null()]),
47
+ address_2: z.union([z.string(), z.null()]),
48
+ post_code: z.union([z.string(), z.null()]),
49
+ city: z.union([z.string(), z.null()]),
50
+ state: z.union([z.string(), z.null()]),
51
+ country: z.union([z.string(), z.null()]),
52
+ country_code: z.union([z.string(), z.null()]),
53
+ tax_number: z.union([z.string(), z.null()]),
54
+ tax_number_2: z.union([z.string(), z.null()]),
55
+ company_number: z.union([z.string(), z.null()]),
56
+ bank_account: z.union([
57
+ z
58
+ .object({
59
+ type: z
60
+ .enum(["iban", "us_domestic", "uk_domestic", "other"])
61
+ .default("iban"),
62
+ name: z.string(),
63
+ bank_name: z.string(),
64
+ iban: z.string(),
65
+ account_number: z.string(),
66
+ bic: z.string(),
67
+ routing_number: z.string(),
68
+ sort_code: z.string(),
69
+ })
70
+ .partial()
71
+ .passthrough(),
72
+ z.null(),
73
+ ]),
74
+ })
75
+ .partial()
76
+ .passthrough();
77
+
78
+
18
79
  // Schema for create advanceinvoice operation
19
80
  const createAdvanceInvoiceSchemaDefinition = z.object({
20
81
  is_draft: z.boolean().optional(),
@@ -22,84 +83,17 @@ const createAdvanceInvoiceSchemaDefinition = z.object({
22
83
  .string()
23
84
  .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/)
24
85
  .optional(),
25
- issuer: z
26
- .object({
27
- name: z.union([z.string(), z.null()]),
28
- email: z.union([z.string(), z.null()]),
29
- address: z.union([z.string(), z.null()]),
30
- address_2: z.union([z.string(), z.null()]),
31
- post_code: z.union([z.string(), z.null()]),
32
- city: z.union([z.string(), z.null()]),
33
- state: z.union([z.string(), z.null()]),
34
- country: z.union([z.string(), z.null()]),
35
- country_code: z.union([z.string(), z.null()]),
36
- tax_number: z.union([z.string(), z.null()]),
37
- tax_number_2: z.union([z.string(), z.null()]),
38
- company_number: z.union([z.string(), z.null()]),
39
- bank_account: z.union([
40
- z
41
- .object({
42
- type: z
43
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
44
- .default("iban"),
45
- name: z.string(),
46
- bank_name: z.string(),
47
- iban: z.string(),
48
- account_number: z.string(),
49
- bic: z.string(),
50
- routing_number: z.string(),
51
- sort_code: z.string(),
52
- })
53
- .partial()
54
- .passthrough(),
55
- z.null(),
56
- ]),
57
- })
58
- .partial()
59
- .passthrough()
60
- .optional(),
86
+ issuer: DocumentEntity.optional(),
61
87
  customer_id: z.union([z.string(), z.null()]).optional(),
62
- customer: z
63
- .union([
88
+ customer: DocumentEntity.and(
89
+ z.union([
64
90
  z
65
- .object({
66
- name: z.union([z.string(), z.null()]),
67
- email: z.union([z.string(), z.null()]),
68
- address: z.union([z.string(), z.null()]),
69
- address_2: z.union([z.string(), z.null()]),
70
- post_code: z.union([z.string(), z.null()]),
71
- city: z.union([z.string(), z.null()]),
72
- state: z.union([z.string(), z.null()]),
73
- country: z.union([z.string(), z.null()]),
74
- country_code: z.union([z.string(), z.null()]),
75
- tax_number: z.union([z.string(), z.null()]),
76
- tax_number_2: z.union([z.string(), z.null()]),
77
- company_number: z.union([z.string(), z.null()]),
78
- bank_account: z.union([
79
- z
80
- .object({
81
- type: z
82
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
83
- .default("iban"),
84
- name: z.string(),
85
- bank_name: z.string(),
86
- iban: z.string(),
87
- account_number: z.string(),
88
- bic: z.string(),
89
- routing_number: z.string(),
90
- sort_code: z.string(),
91
- })
92
- .partial()
93
- .passthrough(),
94
- z.null(),
95
- ]),
96
- save_customer: z.boolean().default(true),
97
- })
91
+ .object({ save_customer: z.boolean().default(true) })
98
92
  .partial()
99
93
  .passthrough(),
100
94
  z.null(),
101
95
  ])
102
- .optional(),
96
+ ).optional(),
103
97
  note: z.union([z.string(), z.null()]).optional(),
104
98
  tax_clause: z.union([z.string(), z.null()]).optional(),
105
99
  currency_code: z.string().max(3).optional(),
@@ -116,19 +110,7 @@ const createAdvanceInvoiceSchemaDefinition = z.object({
116
110
  gross_price: z.number().optional(),
117
111
  quantity: z.number().gte(-140737488355328).lte(140737488355327),
118
112
  unit: z.union([z.string(), z.null()]).optional(),
119
- taxes: z
120
- .array(
121
- z
122
- .object({
123
- rate: z.number(),
124
- tax_id: z.string(),
125
- classification: z.string(),
126
- reverse_charge: z.boolean(),
127
- amount: z.number(),
128
- })
129
- .partial()
130
- )
131
- .optional(),
113
+ taxes: z.array(DocumentItemTax).optional(),
132
114
  discounts: z.array(LineDiscount).max(5).optional(),
133
115
  metadata: z
134
116
  .union([
@@ -146,21 +128,7 @@ const createAdvanceInvoiceSchemaDefinition = z.object({
146
128
  )
147
129
  .min(1),
148
130
  linked_documents: z.array(z.string().min(1)).optional(),
149
- payments: z
150
- .union([
151
- z.array(
152
- z.object({
153
- amount: z.number().gt(0).optional(),
154
- type: z.string().max(20),
155
- date: z.string().optional(),
156
- reference: z.union([z.string(), z.null()]).optional(),
157
- note: z.union([z.string(), z.null()]).optional(),
158
- metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
159
- })
160
- ),
161
- z.null(),
162
- ])
163
- .optional(),
131
+ payments: z.union([z.array(CreateDocumentPayment), z.null()]).optional(),
164
132
  furs: z
165
133
  .union([
166
134
  z
@@ -220,81 +188,17 @@ const updateAdvanceInvoiceSchemaDefinition = z
220
188
  date: z
221
189
  .string()
222
190
  .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/),
223
- issuer: z
224
- .object({
225
- name: z.union([z.string(), z.null()]),
226
- email: z.union([z.string(), z.null()]),
227
- address: z.union([z.string(), z.null()]),
228
- address_2: z.union([z.string(), z.null()]),
229
- post_code: z.union([z.string(), z.null()]),
230
- city: z.union([z.string(), z.null()]),
231
- state: z.union([z.string(), z.null()]),
232
- country: z.union([z.string(), z.null()]),
233
- country_code: z.union([z.string(), z.null()]),
234
- tax_number: z.union([z.string(), z.null()]),
235
- tax_number_2: z.union([z.string(), z.null()]),
236
- company_number: z.union([z.string(), z.null()]),
237
- bank_account: z.union([
238
- z
239
- .object({
240
- type: z
241
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
242
- .default("iban"),
243
- name: z.string(),
244
- bank_name: z.string(),
245
- iban: z.string(),
246
- account_number: z.string(),
247
- bic: z.string(),
248
- routing_number: z.string(),
249
- sort_code: z.string(),
250
- })
251
- .partial()
252
- .passthrough(),
253
- z.null(),
254
- ]),
255
- })
256
- .partial()
257
- .passthrough(),
191
+ issuer: DocumentEntity.and(z.unknown()),
258
192
  customer_id: z.union([z.string(), z.null()]),
259
- customer: z.union([
260
- z
261
- .object({
262
- name: z.union([z.string(), z.null()]),
263
- email: z.union([z.string(), z.null()]),
264
- address: z.union([z.string(), z.null()]),
265
- address_2: z.union([z.string(), z.null()]),
266
- post_code: z.union([z.string(), z.null()]),
267
- city: z.union([z.string(), z.null()]),
268
- state: z.union([z.string(), z.null()]),
269
- country: z.union([z.string(), z.null()]),
270
- country_code: z.union([z.string(), z.null()]),
271
- tax_number: z.union([z.string(), z.null()]),
272
- tax_number_2: z.union([z.string(), z.null()]),
273
- company_number: z.union([z.string(), z.null()]),
274
- bank_account: z.union([
275
- z
276
- .object({
277
- type: z
278
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
279
- .default("iban"),
280
- name: z.string(),
281
- bank_name: z.string(),
282
- iban: z.string(),
283
- account_number: z.string(),
284
- bic: z.string(),
285
- routing_number: z.string(),
286
- sort_code: z.string(),
287
- })
288
- .partial()
289
- .passthrough(),
290
- z.null(),
291
- ]),
292
- save_customer: z.boolean().default(true),
293
- })
294
- .partial()
295
- .passthrough(),
296
- z.null(),
297
- ]),
193
+ customer: DocumentEntity.and(
194
+ z.union([
195
+ z
196
+ .object({ save_customer: z.boolean().default(true) })
197
+ .partial()
198
+ .passthrough(),
199
+ z.null(),
200
+ ])
201
+ ),
298
202
  items: z
299
203
  .array(
300
204
  z.object({
@@ -304,19 +208,7 @@ const updateAdvanceInvoiceSchemaDefinition = z
304
208
  gross_price: z.number().optional(),
305
209
  quantity: z.number().gte(-140737488355328).lte(140737488355327),
306
210
  unit: z.union([z.string(), z.null()]).optional(),
307
- taxes: z
308
- .array(
309
- z
310
- .object({
311
- rate: z.number(),
312
- tax_id: z.string(),
313
- classification: z.string(),
314
- reverse_charge: z.boolean(),
315
- amount: z.number(),
316
- })
317
- .partial()
318
- )
319
- .optional(),
211
+ taxes: z.array(DocumentItemTax).optional(),
320
212
  discounts: z.array(LineDiscount).max(5).optional(),
321
213
  metadata: z
322
214
  .union([
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This file was automatically generated using 'bun generate-schemas'.
3
+ * Do not edit this file manually. To update, run the generator again.
4
+ * @generated
5
+ */
6
+
7
+ import { z } from 'zod';
8
+
9
+ // Schemas for authorizeshopify_body endpoints
10
+
11
+ // Dependency schema for authorizeshopify_body
12
+ const authorizeShopify_Body = z.object({
13
+ shop_domain: z.string().min(1),
14
+ name: z.string().optional(),
15
+ auto_process: z.boolean().optional(),
16
+ send_invoice_email: z.boolean().optional(),
17
+ issue_invoice_for_bank: z.boolean().optional(),
18
+ issue_invoice_on_complete: z.boolean().optional(),
19
+ auto_process_delay_seconds: z.number().int().gte(0).optional(),
20
+ });
21
+
22
+