@updraft-solutions/mcrit-sdk 0.8.0 → 0.9.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.
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { aB as activitySchema, aC as addressSchema, aD as aircraftPositionSchema, aE as aircraftRatingSchema, aJ as airplaneSchema, aI as airplanePermissionSchema, aK as airplaneShareInviteSchema, aL as airportSchema, aM as alertSchema, aN as allowedDocumentTypeSchema, aO as approachTypeSchema, aP as availSchema, aQ as baseMembershipSchema, aR as bookingSchema, aT as commentSchema, aU as companySchema, a_ as courseSchema, aY as courseEnrollmentSchema, aZ as courseFeeSchema, aG as airplaneIssueSeverityEnum, b4 as documentSchema, b0 as documentComplianceStatus, b1 as documentRequirement, b2 as documentRequirementGroup, b3 as documentRequirementGroupAssignment, b5 as documentShareSchema, b6 as documentType, b8 as eventSchema, ba as expenseSchema, b9 as expenseItemSchema, bb as extendedAirplaneSchema, bd as feeSchema, bc as feeCategoryOptionsSchema, be as flightLogSchema, bl as invoiceSchema, bn as landingSchema, bm as landingFeeSchema, bp as maintenanceEventSchema, bo as maintenanceEventEstimationSchema, bq as maintenanceStatusSchema, br as mediaCollection, bt as membershipSchema, bu as membershipSignupSchema, bv as postSchema, bw as prePaidPackageSchema, bx as priceSchema, by as qualificationSchema, bz as recurringFlightSchema, bA as roleSchema, bB as runwaySchema, bC as scheduledFlightSchema, bD as settingSchema, bE as specialFlightSchema, bL as tagSchema, bM as ticketSchema, bW as userSchema, bU as userAircraftRatingSchema, bV as userQualificationSchema, bX as waypointSchema, aF as airplaneIssueSchema, aH as airplaneIssueStatusEnum, B as BaseModel$1, aW as courseCheckSyllabusSchema, aX as courseEnrollmentMetricsSchema, bs as mediaSchema, l as FormSubmission } from '../training-BibD4HsC.cjs';
2
+ import { aB as activitySchema, aC as addressSchema, aD as aircraftPositionSchema, aE as aircraftRatingSchema, aJ as airplaneSchema, aI as airplanePermissionSchema, aK as airplaneShareInviteSchema, aL as airportSchema, aM as alertSchema, aN as allowedDocumentTypeSchema, aO as approachTypeSchema, aP as availSchema, aQ as baseMembershipSchema, aS as bookingSchema, aU as commentSchema, aV as companySchema, a$ as courseSchema, aZ as courseEnrollmentSchema, a_ as courseFeeSchema, aG as airplaneIssueSeverityEnum, b5 as documentSchema, b1 as documentComplianceStatus, b2 as documentRequirement, b3 as documentRequirementGroup, b4 as documentRequirementGroupAssignment, b6 as documentShareSchema, b7 as documentType, b9 as eventSchema, bb as expenseSchema, ba as expenseItemSchema, bc as extendedAirplaneSchema, be as feeSchema, bd as feeCategoryOptionsSchema, bf as flightLogSchema, bm as invoiceSchema, bo as landingSchema, bn as landingFeeSchema, bq as maintenanceEventSchema, bp as maintenanceEventEstimationSchema, br as maintenanceStatusSchema, bs as mediaCollection, bu as membershipSchema, bv as membershipSignupSchema, bw as postSchema, by as prePaidPackageSchema, bz as priceSchema, bA as qualificationSchema, bB as recurringFlightSchema, bC as roleSchema, bD as runwaySchema, bE as scheduledFlightSchema, bF as settingSchema, bG as specialFlightSchema, bN as tagSchema, bO as ticketSchema, bY as userSchema, bW as userAircraftRatingSchema, bX as userQualificationSchema, bZ as waypointSchema, aF as airplaneIssueSchema, aH as airplaneIssueStatusEnum, B as BaseModel$1, aX as courseCheckSyllabusSchema, aY as courseEnrollmentMetricsSchema, bt as mediaSchema, l as FormSubmission } from '../training-nljZCLW5.cjs';
3
3
 
4
4
  type BaseModel = z.infer<typeof BaseModel$1>;
5
5
  type User = z.infer<typeof userSchema>;
@@ -277,6 +277,7 @@ interface LogbookFlightLogPayload {
277
277
  role: string;
278
278
  }[];
279
279
  membership_id: number | null;
280
+ billing_profile_id?: number | null;
280
281
  }
281
282
  interface LogbookSuggestionMeta {
282
283
  flags?: string[];
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { aB as activitySchema, aC as addressSchema, aD as aircraftPositionSchema, aE as aircraftRatingSchema, aJ as airplaneSchema, aI as airplanePermissionSchema, aK as airplaneShareInviteSchema, aL as airportSchema, aM as alertSchema, aN as allowedDocumentTypeSchema, aO as approachTypeSchema, aP as availSchema, aQ as baseMembershipSchema, aR as bookingSchema, aT as commentSchema, aU as companySchema, a_ as courseSchema, aY as courseEnrollmentSchema, aZ as courseFeeSchema, aG as airplaneIssueSeverityEnum, b4 as documentSchema, b0 as documentComplianceStatus, b1 as documentRequirement, b2 as documentRequirementGroup, b3 as documentRequirementGroupAssignment, b5 as documentShareSchema, b6 as documentType, b8 as eventSchema, ba as expenseSchema, b9 as expenseItemSchema, bb as extendedAirplaneSchema, bd as feeSchema, bc as feeCategoryOptionsSchema, be as flightLogSchema, bl as invoiceSchema, bn as landingSchema, bm as landingFeeSchema, bp as maintenanceEventSchema, bo as maintenanceEventEstimationSchema, bq as maintenanceStatusSchema, br as mediaCollection, bt as membershipSchema, bu as membershipSignupSchema, bv as postSchema, bw as prePaidPackageSchema, bx as priceSchema, by as qualificationSchema, bz as recurringFlightSchema, bA as roleSchema, bB as runwaySchema, bC as scheduledFlightSchema, bD as settingSchema, bE as specialFlightSchema, bL as tagSchema, bM as ticketSchema, bW as userSchema, bU as userAircraftRatingSchema, bV as userQualificationSchema, bX as waypointSchema, aF as airplaneIssueSchema, aH as airplaneIssueStatusEnum, B as BaseModel$1, aW as courseCheckSyllabusSchema, aX as courseEnrollmentMetricsSchema, bs as mediaSchema, l as FormSubmission } from '../training-BibD4HsC.js';
2
+ import { aB as activitySchema, aC as addressSchema, aD as aircraftPositionSchema, aE as aircraftRatingSchema, aJ as airplaneSchema, aI as airplanePermissionSchema, aK as airplaneShareInviteSchema, aL as airportSchema, aM as alertSchema, aN as allowedDocumentTypeSchema, aO as approachTypeSchema, aP as availSchema, aQ as baseMembershipSchema, aS as bookingSchema, aU as commentSchema, aV as companySchema, a$ as courseSchema, aZ as courseEnrollmentSchema, a_ as courseFeeSchema, aG as airplaneIssueSeverityEnum, b5 as documentSchema, b1 as documentComplianceStatus, b2 as documentRequirement, b3 as documentRequirementGroup, b4 as documentRequirementGroupAssignment, b6 as documentShareSchema, b7 as documentType, b9 as eventSchema, bb as expenseSchema, ba as expenseItemSchema, bc as extendedAirplaneSchema, be as feeSchema, bd as feeCategoryOptionsSchema, bf as flightLogSchema, bm as invoiceSchema, bo as landingSchema, bn as landingFeeSchema, bq as maintenanceEventSchema, bp as maintenanceEventEstimationSchema, br as maintenanceStatusSchema, bs as mediaCollection, bu as membershipSchema, bv as membershipSignupSchema, bw as postSchema, by as prePaidPackageSchema, bz as priceSchema, bA as qualificationSchema, bB as recurringFlightSchema, bC as roleSchema, bD as runwaySchema, bE as scheduledFlightSchema, bF as settingSchema, bG as specialFlightSchema, bN as tagSchema, bO as ticketSchema, bY as userSchema, bW as userAircraftRatingSchema, bX as userQualificationSchema, bZ as waypointSchema, aF as airplaneIssueSchema, aH as airplaneIssueStatusEnum, B as BaseModel$1, aX as courseCheckSyllabusSchema, aY as courseEnrollmentMetricsSchema, bt as mediaSchema, l as FormSubmission } from '../training-nljZCLW5.js';
3
3
 
4
4
  type BaseModel = z.infer<typeof BaseModel$1>;
5
5
  type User = z.infer<typeof userSchema>;
@@ -277,6 +277,7 @@ interface LogbookFlightLogPayload {
277
277
  role: string;
278
278
  }[];
279
279
  membership_id: number | null;
280
+ billing_profile_id?: number | null;
280
281
  }
281
282
  interface LogbookSuggestionMeta {
282
283
  flags?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@updraft-solutions/mcrit-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Shared TypeScript types, Zod schemas, and pure helpers for the MCRIT aviation fleet management platform",
5
5
  "homepage": "https://github.com/updraft-solutions/mcrit-sdk#readme",
6
6
  "bugs": {
@@ -735,6 +735,47 @@ export const allowedDocumentTypeSchema = z.object({
735
735
  .optional(),
736
736
  });
737
737
 
738
+ // Billing recipient (formerly "Address"; the `addresses` table was renamed
739
+ // to `billing_profiles` — see BillingProfileResource.php). A membership/user
740
+ // can own several profiles (e.g. private vs. "Firma"); invoices, flight logs
741
+ // and expense items each point at one via `billing_profile_id`.
742
+ export const billingProfileSchema = z.object({
743
+ // BillingProfileResource never actually emits a `type` key today; kept
744
+ // optional for forward-compat / discriminated-union consistency with
745
+ // sibling schemas in this file.
746
+ type: z.literal("billing_profile").optional(),
747
+ id: z.number(),
748
+ owner_type: z.string(),
749
+ owner_id: z.number(),
750
+ label: z.string().nullable(),
751
+ is_default: z.boolean(),
752
+ name: z.string().nullable(),
753
+ company: z.string().nullable(),
754
+ address_street_1: z.string().nullable(),
755
+ address_street_2: z.string().nullable(),
756
+ city: z.string().nullable(),
757
+ state: z.string().nullable(),
758
+ zip: z.string().nullable(),
759
+ phone: z.string().nullable(),
760
+ fax: z.string().nullable(),
761
+ iso_country: z.string().nullable(),
762
+ vat_id: z.string().nullable(),
763
+ email: z.string().nullable(),
764
+ archived_at: z.string().nullable(),
765
+ source_billing_profile_id: z.number().nullable(),
766
+ is_synced: z.boolean(),
767
+ frozen_at: z.string().nullable(),
768
+ // Present only when the profile is frozen (frozen_by_user_id !== null).
769
+ frozen_by: z
770
+ .object({
771
+ id: z.number(),
772
+ name: z.string().nullable().optional(),
773
+ })
774
+ .optional(),
775
+ created_at: z.string(),
776
+ updated_at: z.string(),
777
+ });
778
+
738
779
  export const flightLogSchema = z.object({
739
780
  type: z.literal("flightLog"),
740
781
  id: z.number(),
@@ -749,6 +790,7 @@ export const flightLogSchema = z.object({
749
790
  booking_id: z.number().nullable().optional(),
750
791
  membership_id: z.number().nullable().optional(),
751
792
  membership: baseMembershipSchema.optional(),
793
+ billing_profile_id: z.number().nullable().optional(),
752
794
  author_id: z.number(),
753
795
  author: userSchema.optional(),
754
796
  invoice_id: z.number().nullable().optional(),
@@ -798,6 +840,14 @@ export const invoiceSchema = z.object({
798
840
  title: z.string(),
799
841
  membership_id: z.number(),
800
842
  membership: baseMembershipSchema.optional(),
843
+ // InvoiceResource.php always emits `billing_profile_id` (non-optional key,
844
+ // nullable FK value). `billingProfile` is a `whenLoaded('billingProfile')`
845
+ // relation, so it stays optional. (Fix round 1: as of the original Task 16
846
+ // commit, InvoiceResource hadn't gained `billing_profile_id` yet — it was
847
+ // added ~4 minutes later in the same session; tightened here now that the
848
+ // key is always present.)
849
+ billing_profile_id: z.number().nullable(),
850
+ billingProfile: billingProfileSchema.optional(),
801
851
  company_id: z.number().optional(),
802
852
  company: companySchema.optional(),
803
853
  sequence_number: z.string().nullable().optional(),
@@ -825,6 +875,9 @@ export const invoiceSchema = z.object({
825
875
  recipient_state: z.string().nullable().optional(),
826
876
  recipient_country: z.string().nullable().optional(),
827
877
  recipient_vat_id: z.string().nullable().optional(),
878
+ // Always computed by InvoiceResource (billingProfile email, else the
879
+ // membership's user email) — used by InvoiceDialog today but was missing.
880
+ recipient_email: z.string().nullable().optional(),
828
881
  issuer_name: z.string().nullable().optional(),
829
882
  issuer_address_street_1: z.string().nullable().optional(),
830
883
  issuer_address_street_2: z.string().nullable().optional(),
@@ -1283,17 +1336,90 @@ export const prePaidPackageSchema = z.object({
1283
1336
  .optional(),
1284
1337
  });
1285
1338
 
1339
+ // A billing line-item (flight charge, landing fee, membership fee, refund,
1340
+ // …) attached to a flight log / booking / membership via the polymorphic
1341
+ // (model_type, model_id) pair, and to an invoice once released. NOT a
1342
+ // catalog entry — rebuilt field-by-field against ExpenseItemResource.php;
1343
+ // the previous shape (name/category/active) modeled a company catalog row,
1344
+ // which ExpenseItem has never had.
1345
+ export const prePaidPackageAssignmentSchema = z.object({
1346
+ id: z.number(),
1347
+ flight_log_id: z.number().nullable().optional(),
1348
+ expense_item_id: z.number().nullable().optional(),
1349
+ pre_paid_package_id: z.number().nullable().optional(),
1350
+ gross_total: zPhpMoneyObject.nullable().optional(),
1351
+ created_at: z.string().nullable().optional(),
1352
+ updated_at: z.string().nullable().optional(),
1353
+ });
1354
+
1286
1355
  export const expenseItemSchema = z.object({
1287
- type: z.literal("expenseItem"),
1356
+ // ExpenseItemResource never emits a `type` key; kept optional for
1357
+ // consistency with sibling schemas' discriminated-union literal.
1358
+ type: z.literal("expenseItem").optional(),
1288
1359
  id: z.number(),
1360
+ date: z.string(),
1361
+ model_id: z.number(),
1362
+ model_type: z.string(),
1363
+ identifier: z.string().nullable(),
1364
+ // Provenance: the `prices` row this item was generated from. `price_id` is
1365
+ // always present (nullable FK); `price` only when the relation is
1366
+ // eager-loaded.
1367
+ price_id: z.number().nullable(),
1368
+ price: priceSchema.optional(),
1369
+ description: z.string(),
1370
+ description_lines: z.array(z.any()).nullable(),
1371
+ // Resource emits a trimmed decimal string (trailing zeros/dot stripped),
1372
+ // not a number.
1373
+ quantity: z.string(),
1374
+ discount: z.number(),
1375
+ applied_discounts: z.array(z.any()).nullable(),
1376
+ status: z.string(),
1377
+ is_system_controlled: z.boolean(),
1378
+ deferred: z.boolean(),
1379
+
1380
+ invoice_id: z.number().nullable(),
1289
1381
  company_id: z.number(),
1290
- company: companySchema.optional(),
1291
- name: z.string(),
1292
- description: z.string().nullable().optional(),
1293
- category: z.string().nullable().optional(),
1294
- active: z.boolean().default(true),
1382
+ membership_id: z.number(),
1383
+ billing_profile_id: z.number().nullable(),
1384
+
1385
+ gross_total_before_vouchers: zPhpMoneyObject,
1386
+ gross_total: zPhpMoneyObject,
1387
+ net_total: zPhpMoneyObject,
1388
+ tax_total: zPhpMoneyObject,
1389
+ // number_format(…, 2) string, not a number.
1390
+ tax_percentage: z.string(),
1391
+ billable: z.boolean(),
1392
+ meta: z.record(z.string(), z.any()).nullable(),
1393
+ input_value: z.number().nullable(),
1394
+ net_gross: zNetGross,
1395
+
1396
+ refunds_expense_item_id: z.number().nullable(),
1397
+
1295
1398
  created_at: z.string(),
1296
1399
  updated_at: z.string(),
1400
+
1401
+ // Lazy + explicitly typed as ZodTypeAny (so `invoice` infers as `any`
1402
+ // rather than the full Invoice shape): invoiceSchema is large (60+ fields
1403
+ // incl. media/activities), and this field is additionally reached from
1404
+ // courseEnrollmentSchema/bookingSchema/flightLogSchema via their own lazy
1405
+ // expenseItems refs — inlining the full inferred type here blows past TS's
1406
+ // type-serialization size limit (TS7056: "inferred type … exceeds the
1407
+ // maximum length"). No true cycle: invoiceSchema does not reference
1408
+ // expenseItemSchema back.
1409
+ invoice: z.lazy((): z.ZodTypeAny => invoiceSchema).optional(),
1410
+ membership: baseMembershipSchema.optional(),
1411
+ prePaidPackageAssignments: z
1412
+ .array(prePaidPackageAssignmentSchema)
1413
+ .optional(),
1414
+ // Loose record on purpose: gates are policy-reflected server-side and grow
1415
+ // over time — same convention as companySchema/invoiceSchema.
1416
+ can: z.record(z.string(), z.boolean().nullable()).optional(),
1417
+
1418
+ // Set true only by InvoiceItemSnapshotResource — the immutable,
1419
+ // frozen-at-release line-item shape reused for released/cancelled
1420
+ // invoices (same JSON shape as ExpenseItemResource by design). Absent on
1421
+ // a live ExpenseItemResource payload.
1422
+ is_snapshot: z.boolean().optional(),
1297
1423
  });
1298
1424
 
1299
1425
  export const waypointSchema = z.object({
package/src/types/ai.ts CHANGED
@@ -58,6 +58,7 @@ export interface LogbookFlightLogPayload {
58
58
  low_approaches: number;
59
59
  crew_assignments: { membership_id: number; role: string }[];
60
60
  membership_id: number | null;
61
+ billing_profile_id?: number | null;
61
62
  }
62
63
 
63
64
  export interface LogbookSuggestionMeta {