@onabl/js 0.1.0 → 0.1.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.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicForm, ValidateCodeResponse, Quote, Invoice, PresignResponse, PublicFormField } from '@onabl/contracts/public-api';
2
2
  export { Invoice, PublicForm, PublicFormConfig, PublicFormField, Quote, ValidateCodeResponse } from '@onabl/contracts/public-api';
3
- import { AnswerMap, FormStep } from '@onabl/types/config';
4
- export { GroupedItems, PresentQuoteInput, QuotePresentation, QuoteRow, SeparateSection, groupLineItems, presentQuote } from '@onabl/engine/presentation';
3
+ import { AnswerMap, DisplayGroup, FormStep } from '@onabl/types/config';
4
+ import { LineItem } from '@onabl/types/engine';
5
5
 
6
6
  interface OnablClientConfig {
7
7
  handle: string;
@@ -84,6 +84,46 @@ declare class OnablNetwork extends OnablError {
84
84
  constructor(message?: string, cause?: unknown);
85
85
  }
86
86
 
87
+ interface QuoteRow {
88
+ key: string;
89
+ label: string;
90
+ amount: number;
91
+ isGroup: boolean;
92
+ displayMode?: DisplayGroup["displayMode"];
93
+ children?: QuoteRow[];
94
+ sourceItem?: LineItem;
95
+ groupTag?: string;
96
+ }
97
+ interface SeparateSection {
98
+ group: DisplayGroup;
99
+ rows: QuoteRow[];
100
+ amount: number;
101
+ }
102
+ interface GroupedItems {
103
+ main: QuoteRow[];
104
+ separateSections: SeparateSection[];
105
+ groupTotals: Record<string, number>;
106
+ }
107
+ interface PresentQuoteInput {
108
+ lineItems: LineItem[];
109
+ displayGroups?: DisplayGroup[];
110
+ finalTotal: number;
111
+ totalAfterDiscount: number;
112
+ discountLabel?: string | null;
113
+ }
114
+ interface QuotePresentation {
115
+ rows: QuoteRow[];
116
+ separateSections: SeparateSection[];
117
+ subtotal: number;
118
+ discount: {
119
+ label: string;
120
+ amount: number;
121
+ } | null;
122
+ total: number;
123
+ }
124
+ declare function groupLineItems(lineItems: LineItem[], displayGroups?: DisplayGroup[]): GroupedItems;
125
+ declare function presentQuote(input: PresentQuoteInput): QuotePresentation;
126
+
87
127
  /**
88
128
  * The form state machine, extracted from apps/web/components/form/MultiStepForm.tsx
89
129
  * (§14.5.2, part 2). Pure functions only — no React, no framework of any kind —
@@ -143,4 +183,4 @@ declare function getInitialAnswers(form: PublicForm): AnswerMap;
143
183
  */
144
184
  declare function validateFields(fields: PublicFormField[], answers: AnswerMap): Record<string, string>;
145
185
 
146
- export { type CallOpts, type OnablClient, type OnablClientConfig, OnablError, OnablNetwork, OnablNotFound, OnablUnauthorized, OnablValidation, type TokenOpts, type VisibleStep, createOnablClient, getAllFields, getInitialAnswers, getVisibleSteps, validateFields };
186
+ export { type CallOpts, type GroupedItems, type OnablClient, type OnablClientConfig, OnablError, OnablNetwork, OnablNotFound, OnablUnauthorized, OnablValidation, type PresentQuoteInput, type QuotePresentation, type QuoteRow, type SeparateSection, type TokenOpts, type VisibleStep, createOnablClient, getAllFields, getInitialAnswers, getVisibleSteps, groupLineItems, presentQuote, validateFields };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicForm, ValidateCodeResponse, Quote, Invoice, PresignResponse, PublicFormField } from '@onabl/contracts/public-api';
2
2
  export { Invoice, PublicForm, PublicFormConfig, PublicFormField, Quote, ValidateCodeResponse } from '@onabl/contracts/public-api';
3
- import { AnswerMap, FormStep } from '@onabl/types/config';
4
- export { GroupedItems, PresentQuoteInput, QuotePresentation, QuoteRow, SeparateSection, groupLineItems, presentQuote } from '@onabl/engine/presentation';
3
+ import { AnswerMap, DisplayGroup, FormStep } from '@onabl/types/config';
4
+ import { LineItem } from '@onabl/types/engine';
5
5
 
6
6
  interface OnablClientConfig {
7
7
  handle: string;
@@ -84,6 +84,46 @@ declare class OnablNetwork extends OnablError {
84
84
  constructor(message?: string, cause?: unknown);
85
85
  }
86
86
 
87
+ interface QuoteRow {
88
+ key: string;
89
+ label: string;
90
+ amount: number;
91
+ isGroup: boolean;
92
+ displayMode?: DisplayGroup["displayMode"];
93
+ children?: QuoteRow[];
94
+ sourceItem?: LineItem;
95
+ groupTag?: string;
96
+ }
97
+ interface SeparateSection {
98
+ group: DisplayGroup;
99
+ rows: QuoteRow[];
100
+ amount: number;
101
+ }
102
+ interface GroupedItems {
103
+ main: QuoteRow[];
104
+ separateSections: SeparateSection[];
105
+ groupTotals: Record<string, number>;
106
+ }
107
+ interface PresentQuoteInput {
108
+ lineItems: LineItem[];
109
+ displayGroups?: DisplayGroup[];
110
+ finalTotal: number;
111
+ totalAfterDiscount: number;
112
+ discountLabel?: string | null;
113
+ }
114
+ interface QuotePresentation {
115
+ rows: QuoteRow[];
116
+ separateSections: SeparateSection[];
117
+ subtotal: number;
118
+ discount: {
119
+ label: string;
120
+ amount: number;
121
+ } | null;
122
+ total: number;
123
+ }
124
+ declare function groupLineItems(lineItems: LineItem[], displayGroups?: DisplayGroup[]): GroupedItems;
125
+ declare function presentQuote(input: PresentQuoteInput): QuotePresentation;
126
+
87
127
  /**
88
128
  * The form state machine, extracted from apps/web/components/form/MultiStepForm.tsx
89
129
  * (§14.5.2, part 2). Pure functions only — no React, no framework of any kind —
@@ -143,4 +183,4 @@ declare function getInitialAnswers(form: PublicForm): AnswerMap;
143
183
  */
144
184
  declare function validateFields(fields: PublicFormField[], answers: AnswerMap): Record<string, string>;
145
185
 
146
- export { type CallOpts, type OnablClient, type OnablClientConfig, OnablError, OnablNetwork, OnablNotFound, OnablUnauthorized, OnablValidation, type TokenOpts, type VisibleStep, createOnablClient, getAllFields, getInitialAnswers, getVisibleSteps, validateFields };
186
+ export { type CallOpts, type GroupedItems, type OnablClient, type OnablClientConfig, OnablError, OnablNetwork, OnablNotFound, OnablUnauthorized, OnablValidation, type PresentQuoteInput, type QuotePresentation, type QuoteRow, type SeparateSection, type TokenOpts, type VisibleStep, createOnablClient, getAllFields, getInitialAnswers, getVisibleSteps, groupLineItems, presentQuote, validateFields };
package/dist/index.js CHANGED
@@ -1004,8 +1004,8 @@ __export(index_exports, {
1004
1004
  getAllFields: () => getAllFields,
1005
1005
  getInitialAnswers: () => getInitialAnswers,
1006
1006
  getVisibleSteps: () => getVisibleSteps,
1007
- groupLineItems: () => import_presentation.groupLineItems,
1008
- presentQuote: () => import_presentation.presentQuote,
1007
+ groupLineItems: () => groupLineItems,
1008
+ presentQuote: () => presentQuote,
1009
1009
  validateFields: () => validateFields
1010
1010
  });
1011
1011
  module.exports = __toCommonJS(index_exports);
@@ -1156,6 +1156,12 @@ function createOnablClient(config) {
1156
1156
 
1157
1157
  // src/presentation.ts
1158
1158
  var import_presentation = __toESM(require_presentation());
1159
+ function groupLineItems(lineItems, displayGroups) {
1160
+ return (0, import_presentation.groupLineItems)(lineItems, displayGroups);
1161
+ }
1162
+ function presentQuote(input) {
1163
+ return (0, import_presentation.presentQuote)(input);
1164
+ }
1159
1165
 
1160
1166
  // src/form-state.ts
1161
1167
  var import_engine = __toESM(require_engine());