@updraft-solutions/mcrit-sdk 0.1.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 (79) hide show
  1. package/README.md +240 -0
  2. package/dist/chunk-2DRKSYW4.cjs +99 -0
  3. package/dist/chunk-2M32EOYI.js +145 -0
  4. package/dist/chunk-AN55SAGU.js +1189 -0
  5. package/dist/chunk-D5DUVW34.js +176 -0
  6. package/dist/chunk-HQSF3WGF.cjs +14 -0
  7. package/dist/chunk-JGIAOBZI.js +99 -0
  8. package/dist/chunk-JRVRIKNM.cjs +168 -0
  9. package/dist/chunk-LVTDNDWE.cjs +124 -0
  10. package/dist/chunk-LXNCAKJZ.js +0 -0
  11. package/dist/chunk-MF7G76QS.cjs +176 -0
  12. package/dist/chunk-MI4YBENQ.cjs +145 -0
  13. package/dist/chunk-MOOGM3DW.cjs +1 -0
  14. package/dist/chunk-NQV2D3FJ.js +14 -0
  15. package/dist/chunk-TJXWL42D.js +124 -0
  16. package/dist/chunk-VYT5KQWF.js +168 -0
  17. package/dist/chunk-XKZQ5W7E.cjs +1189 -0
  18. package/dist/courses/index.cjs +7 -0
  19. package/dist/courses/index.d.cts +58 -0
  20. package/dist/courses/index.d.ts +58 -0
  21. package/dist/courses/index.js +7 -0
  22. package/dist/crew/index.cjs +10 -0
  23. package/dist/crew/index.d.cts +102 -0
  24. package/dist/crew/index.d.ts +102 -0
  25. package/dist/crew/index.js +10 -0
  26. package/dist/crew/vue.cjs +34 -0
  27. package/dist/crew/vue.d.cts +31 -0
  28. package/dist/crew/vue.d.ts +31 -0
  29. package/dist/crew/vue.js +34 -0
  30. package/dist/format/index.cjs +44 -0
  31. package/dist/format/index.d.cts +69 -0
  32. package/dist/format/index.d.ts +69 -0
  33. package/dist/format/index.js +44 -0
  34. package/dist/index.cjs +261 -0
  35. package/dist/index.d.cts +11 -0
  36. package/dist/index.d.ts +11 -0
  37. package/dist/index.js +261 -0
  38. package/dist/media/index.cjs +30 -0
  39. package/dist/media/index.d.cts +89 -0
  40. package/dist/media/index.d.ts +89 -0
  41. package/dist/media/index.js +30 -0
  42. package/dist/models-CY3MmvCg.d.cts +33801 -0
  43. package/dist/models-CY3MmvCg.d.ts +33801 -0
  44. package/dist/money/index.cjs +18 -0
  45. package/dist/money/index.d.cts +66 -0
  46. package/dist/money/index.d.ts +66 -0
  47. package/dist/money/index.js +18 -0
  48. package/dist/pagination/index.cjs +6 -0
  49. package/dist/pagination/index.d.cts +16 -0
  50. package/dist/pagination/index.d.ts +16 -0
  51. package/dist/pagination/index.js +6 -0
  52. package/dist/schemas/index.cjs +158 -0
  53. package/dist/schemas/index.d.cts +1019 -0
  54. package/dist/schemas/index.d.ts +1019 -0
  55. package/dist/schemas/index.js +158 -0
  56. package/dist/types/index.cjs +1 -0
  57. package/dist/types/index.d.cts +143 -0
  58. package/dist/types/index.d.ts +143 -0
  59. package/dist/types/index.js +1 -0
  60. package/package.json +171 -0
  61. package/src/courses/index.ts +202 -0
  62. package/src/crew/index.ts +255 -0
  63. package/src/crew/vue.ts +70 -0
  64. package/src/format/index.ts +265 -0
  65. package/src/index.ts +76 -0
  66. package/src/media/index.ts +224 -0
  67. package/src/money/index.ts +168 -0
  68. package/src/pagination/index.ts +27 -0
  69. package/src/schemas/common.ts +73 -0
  70. package/src/schemas/faq.ts +94 -0
  71. package/src/schemas/fee.ts +37 -0
  72. package/src/schemas/index.ts +6 -0
  73. package/src/schemas/models.ts +996 -0
  74. package/src/schemas/report.ts +306 -0
  75. package/src/schemas/safety-report.ts +163 -0
  76. package/src/types/api.ts +37 -0
  77. package/src/types/compliance.ts +44 -0
  78. package/src/types/index.ts +3 -0
  79. package/src/types/models.ts +124 -0
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkLVTDNDWEcjs = require('../chunk-LVTDNDWE.cjs');
4
+ require('../chunk-2DRKSYW4.cjs');
5
+
6
+
7
+ exports.parseCourse = _chunkLVTDNDWEcjs.parseCourse;
@@ -0,0 +1,58 @@
1
+ import { Dinero } from 'dinero.js';
2
+ import { FeeLike, NetGross } from '../money/index.cjs';
3
+ export { ParsedFee, ParsedPrice, PriceLike } from '../money/index.cjs';
4
+
5
+ /**
6
+ * Permissive input shape for {@link parseCourse}. Course fees in
7
+ * different parts of the API are sometimes returned with pivot data
8
+ * nested in `pivot`, sometimes flattened on the fee object itself —
9
+ * this type supports both, and an optional nested `fee` field for the
10
+ * eager-loaded fee resource.
11
+ */
12
+ interface CourseFeeLike extends FeeLike {
13
+ pivot?: {
14
+ count?: number;
15
+ variant?: string | null;
16
+ is_optional?: boolean;
17
+ sort_order?: number;
18
+ };
19
+ count?: number;
20
+ variant?: string | null;
21
+ is_optional?: boolean;
22
+ sort_order?: number;
23
+ fee?: FeeLike;
24
+ }
25
+ /**
26
+ * Permissive input shape for {@link parseCourse}.
27
+ */
28
+ interface CourseLike {
29
+ id?: number;
30
+ fees?: CourseFeeLike[];
31
+ [key: string]: unknown;
32
+ }
33
+ interface ParsedCourseFee {
34
+ fee: CourseFeeLike;
35
+ count: number;
36
+ variant: string;
37
+ isOptional: boolean;
38
+ sortOrder: number;
39
+ unitPrice: Dinero | null;
40
+ lineTotal: Dinero | null;
41
+ title: string;
42
+ hasUpcomingPrice: boolean;
43
+ upcomingPrice: Dinero | null;
44
+ upcomingPriceValidFrom: string | null;
45
+ }
46
+ interface CourseVariant {
47
+ variant: string;
48
+ fees: ParsedCourseFee[];
49
+ totalCost: Dinero;
50
+ }
51
+ interface ParsedCourse {
52
+ totalCost(netGross?: NetGross): Dinero | null;
53
+ feesWithCost(netGross?: NetGross): ParsedCourseFee[];
54
+ variants(netGross?: NetGross): CourseVariant[];
55
+ }
56
+ declare function parseCourse(course: CourseLike | null | undefined): ParsedCourse | null;
57
+
58
+ export { type CourseFeeLike, type CourseLike, type CourseVariant, FeeLike, NetGross, type ParsedCourse, type ParsedCourseFee, parseCourse };
@@ -0,0 +1,58 @@
1
+ import { Dinero } from 'dinero.js';
2
+ import { FeeLike, NetGross } from '../money/index.js';
3
+ export { ParsedFee, ParsedPrice, PriceLike } from '../money/index.js';
4
+
5
+ /**
6
+ * Permissive input shape for {@link parseCourse}. Course fees in
7
+ * different parts of the API are sometimes returned with pivot data
8
+ * nested in `pivot`, sometimes flattened on the fee object itself —
9
+ * this type supports both, and an optional nested `fee` field for the
10
+ * eager-loaded fee resource.
11
+ */
12
+ interface CourseFeeLike extends FeeLike {
13
+ pivot?: {
14
+ count?: number;
15
+ variant?: string | null;
16
+ is_optional?: boolean;
17
+ sort_order?: number;
18
+ };
19
+ count?: number;
20
+ variant?: string | null;
21
+ is_optional?: boolean;
22
+ sort_order?: number;
23
+ fee?: FeeLike;
24
+ }
25
+ /**
26
+ * Permissive input shape for {@link parseCourse}.
27
+ */
28
+ interface CourseLike {
29
+ id?: number;
30
+ fees?: CourseFeeLike[];
31
+ [key: string]: unknown;
32
+ }
33
+ interface ParsedCourseFee {
34
+ fee: CourseFeeLike;
35
+ count: number;
36
+ variant: string;
37
+ isOptional: boolean;
38
+ sortOrder: number;
39
+ unitPrice: Dinero | null;
40
+ lineTotal: Dinero | null;
41
+ title: string;
42
+ hasUpcomingPrice: boolean;
43
+ upcomingPrice: Dinero | null;
44
+ upcomingPriceValidFrom: string | null;
45
+ }
46
+ interface CourseVariant {
47
+ variant: string;
48
+ fees: ParsedCourseFee[];
49
+ totalCost: Dinero;
50
+ }
51
+ interface ParsedCourse {
52
+ totalCost(netGross?: NetGross): Dinero | null;
53
+ feesWithCost(netGross?: NetGross): ParsedCourseFee[];
54
+ variants(netGross?: NetGross): CourseVariant[];
55
+ }
56
+ declare function parseCourse(course: CourseLike | null | undefined): ParsedCourse | null;
57
+
58
+ export { type CourseFeeLike, type CourseLike, type CourseVariant, FeeLike, NetGross, type ParsedCourse, type ParsedCourseFee, parseCourse };
@@ -0,0 +1,7 @@
1
+ import {
2
+ parseCourse
3
+ } from "../chunk-TJXWL42D.js";
4
+ import "../chunk-JGIAOBZI.js";
5
+ export {
6
+ parseCourse
7
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkMI4YBENQcjs = require('../chunk-MI4YBENQ.cjs');
6
+
7
+
8
+
9
+
10
+ exports.createCrewValidator = _chunkMI4YBENQcjs.createCrewValidator; exports.defaultCrewRoleForMembership = _chunkMI4YBENQcjs.defaultCrewRoleForMembership; exports.hasMembershipRole = _chunkMI4YBENQcjs.hasMembershipRole;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Crew configuration consumer for the MCRIT SDK.
3
+ *
4
+ * No crew-role data lives in this module — the canonical source is the
5
+ * backend `App\Crew\CrewConfiguration`, served via `GET /meta/crew`.
6
+ * Apps fetch the config once at boot, hand it to `createCrewValidator`,
7
+ * and use the returned validator to drive UI feedback on a live crew
8
+ * list.
9
+ */
10
+ interface PositionAttributes {
11
+ picPriority: number | null;
12
+ isOnBoard: boolean;
13
+ isInstructorClass: boolean;
14
+ isTrainingRole: boolean;
15
+ }
16
+ interface PositionDefinition extends PositionAttributes {
17
+ name: string;
18
+ }
19
+ type Constraint = {
20
+ kind: "single_pic";
21
+ } | {
22
+ kind: "min_members";
23
+ min: number;
24
+ } | {
25
+ kind: "when_crew_contains_role_requires_one_of";
26
+ when_role: string;
27
+ required_roles: string[];
28
+ message_key: string | null;
29
+ } | {
30
+ kind: "when_any_membership_has_system_role_requires_one_of";
31
+ system_role: string;
32
+ required_roles: string[];
33
+ message_key: string | null;
34
+ };
35
+ type ConstraintKind = Constraint["kind"];
36
+ interface CrewConfig {
37
+ version: number;
38
+ positions: Record<string, PositionDefinition>;
39
+ pic_priority: string[];
40
+ constraints: Constraint[];
41
+ }
42
+ interface MembershipRoleHolder {
43
+ roles?: {
44
+ name: string;
45
+ company_id?: number | null;
46
+ }[] | null;
47
+ }
48
+ /**
49
+ * True iff the membership holds the given *system* (global, company-less)
50
+ * role. Pure helper that operates on the membership payload's `roles`
51
+ * array — unrelated to the per-flight crew validator.
52
+ */
53
+ declare function hasMembershipRole(membership: MembershipRoleHolder | null | undefined, roleName: string): boolean;
54
+ /**
55
+ * UX nicety: smart-default the crew-position dropdown when adding a new
56
+ * crew member, based on the membership's system roles. Returns the crew
57
+ * position string ("student" / "instructor" / "pilot"). Not a validation
58
+ * rule and intentionally divorced from the validator — adding a new
59
+ * default mapping only requires changing this one function.
60
+ */
61
+ declare function defaultCrewRoleForMembership(membership: MembershipRoleHolder | null | undefined): string;
62
+ interface CrewEntry {
63
+ role: string;
64
+ membership_id?: number | null;
65
+ membership?: MembershipRoleHolder | null;
66
+ }
67
+ interface Violation {
68
+ kind: ConstraintKind;
69
+ message_key: string | null;
70
+ details?: Record<string, unknown>;
71
+ }
72
+ type PicResolution = {
73
+ type: "ok";
74
+ index: number;
75
+ role: string;
76
+ } | {
77
+ type: "tie";
78
+ role: string;
79
+ } | {
80
+ type: "none";
81
+ };
82
+ interface CrewValidator {
83
+ /** True iff the named role exists in the config and is `isOnBoard`. */
84
+ isOnBoardRole(role: string): boolean;
85
+ isInstructorClassRole(role: string): boolean;
86
+ isPicEligibleRole(role: string): boolean;
87
+ /** Resolves the single PIC by walking `config.pic_priority`. */
88
+ resolvePic(crew: readonly CrewEntry[]): PicResolution;
89
+ /** Returns every constraint violation found in the composition. */
90
+ evaluate(crew: readonly CrewEntry[]): {
91
+ ok: boolean;
92
+ violations: Violation[];
93
+ };
94
+ }
95
+ /**
96
+ * Build a validator over a specific crew configuration. The validator is
97
+ * pure and stateless beyond the config it closed over; safe to share
98
+ * across components.
99
+ */
100
+ declare function createCrewValidator(config: CrewConfig): CrewValidator;
101
+
102
+ export { type Constraint, type ConstraintKind, type CrewConfig, type CrewEntry, type CrewValidator, type MembershipRoleHolder, type PicResolution, type PositionAttributes, type PositionDefinition, type Violation, createCrewValidator, defaultCrewRoleForMembership, hasMembershipRole };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Crew configuration consumer for the MCRIT SDK.
3
+ *
4
+ * No crew-role data lives in this module — the canonical source is the
5
+ * backend `App\Crew\CrewConfiguration`, served via `GET /meta/crew`.
6
+ * Apps fetch the config once at boot, hand it to `createCrewValidator`,
7
+ * and use the returned validator to drive UI feedback on a live crew
8
+ * list.
9
+ */
10
+ interface PositionAttributes {
11
+ picPriority: number | null;
12
+ isOnBoard: boolean;
13
+ isInstructorClass: boolean;
14
+ isTrainingRole: boolean;
15
+ }
16
+ interface PositionDefinition extends PositionAttributes {
17
+ name: string;
18
+ }
19
+ type Constraint = {
20
+ kind: "single_pic";
21
+ } | {
22
+ kind: "min_members";
23
+ min: number;
24
+ } | {
25
+ kind: "when_crew_contains_role_requires_one_of";
26
+ when_role: string;
27
+ required_roles: string[];
28
+ message_key: string | null;
29
+ } | {
30
+ kind: "when_any_membership_has_system_role_requires_one_of";
31
+ system_role: string;
32
+ required_roles: string[];
33
+ message_key: string | null;
34
+ };
35
+ type ConstraintKind = Constraint["kind"];
36
+ interface CrewConfig {
37
+ version: number;
38
+ positions: Record<string, PositionDefinition>;
39
+ pic_priority: string[];
40
+ constraints: Constraint[];
41
+ }
42
+ interface MembershipRoleHolder {
43
+ roles?: {
44
+ name: string;
45
+ company_id?: number | null;
46
+ }[] | null;
47
+ }
48
+ /**
49
+ * True iff the membership holds the given *system* (global, company-less)
50
+ * role. Pure helper that operates on the membership payload's `roles`
51
+ * array — unrelated to the per-flight crew validator.
52
+ */
53
+ declare function hasMembershipRole(membership: MembershipRoleHolder | null | undefined, roleName: string): boolean;
54
+ /**
55
+ * UX nicety: smart-default the crew-position dropdown when adding a new
56
+ * crew member, based on the membership's system roles. Returns the crew
57
+ * position string ("student" / "instructor" / "pilot"). Not a validation
58
+ * rule and intentionally divorced from the validator — adding a new
59
+ * default mapping only requires changing this one function.
60
+ */
61
+ declare function defaultCrewRoleForMembership(membership: MembershipRoleHolder | null | undefined): string;
62
+ interface CrewEntry {
63
+ role: string;
64
+ membership_id?: number | null;
65
+ membership?: MembershipRoleHolder | null;
66
+ }
67
+ interface Violation {
68
+ kind: ConstraintKind;
69
+ message_key: string | null;
70
+ details?: Record<string, unknown>;
71
+ }
72
+ type PicResolution = {
73
+ type: "ok";
74
+ index: number;
75
+ role: string;
76
+ } | {
77
+ type: "tie";
78
+ role: string;
79
+ } | {
80
+ type: "none";
81
+ };
82
+ interface CrewValidator {
83
+ /** True iff the named role exists in the config and is `isOnBoard`. */
84
+ isOnBoardRole(role: string): boolean;
85
+ isInstructorClassRole(role: string): boolean;
86
+ isPicEligibleRole(role: string): boolean;
87
+ /** Resolves the single PIC by walking `config.pic_priority`. */
88
+ resolvePic(crew: readonly CrewEntry[]): PicResolution;
89
+ /** Returns every constraint violation found in the composition. */
90
+ evaluate(crew: readonly CrewEntry[]): {
91
+ ok: boolean;
92
+ violations: Violation[];
93
+ };
94
+ }
95
+ /**
96
+ * Build a validator over a specific crew configuration. The validator is
97
+ * pure and stateless beyond the config it closed over; safe to share
98
+ * across components.
99
+ */
100
+ declare function createCrewValidator(config: CrewConfig): CrewValidator;
101
+
102
+ export { type Constraint, type ConstraintKind, type CrewConfig, type CrewEntry, type CrewValidator, type MembershipRoleHolder, type PicResolution, type PositionAttributes, type PositionDefinition, type Violation, createCrewValidator, defaultCrewRoleForMembership, hasMembershipRole };
@@ -0,0 +1,10 @@
1
+ import {
2
+ createCrewValidator,
3
+ defaultCrewRoleForMembership,
4
+ hasMembershipRole
5
+ } from "../chunk-2M32EOYI.js";
6
+ export {
7
+ createCrewValidator,
8
+ defaultCrewRoleForMembership,
9
+ hasMembershipRole
10
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkMI4YBENQcjs = require('../chunk-MI4YBENQ.cjs');
4
+
5
+ // src/crew/vue.ts
6
+ var _vue = require('vue');
7
+ function useCrewValidator(crewRef, configRef) {
8
+ const validator = _vue.computed.call(void 0, () => {
9
+ const cfg = _vue.toValue.call(void 0, configRef);
10
+ return cfg ? _chunkMI4YBENQcjs.createCrewValidator.call(void 0, cfg) : null;
11
+ });
12
+ const crew = _vue.computed.call(void 0, () => _nullishCoalesce(_vue.toValue.call(void 0, crewRef), () => ( [])));
13
+ const pic = _vue.computed.call(void 0,
14
+ () => validator.value ? validator.value.resolvePic(crew.value) : { type: "none" }
15
+ );
16
+ const violations = _vue.computed.call(void 0,
17
+ () => validator.value ? validator.value.evaluate(crew.value).violations : []
18
+ );
19
+ const isValid = _vue.computed.call(void 0,
20
+ () => violations.value.length === 0 && pic.value.type === "ok"
21
+ );
22
+ return {
23
+ validator,
24
+ pic,
25
+ violations,
26
+ isValid,
27
+ isOnBoardRole: (role) => _nullishCoalesce(_optionalChain([validator, 'access', _ => _.value, 'optionalAccess', _2 => _2.isOnBoardRole, 'call', _3 => _3(role)]), () => ( false)),
28
+ isInstructorClassRole: (role) => _nullishCoalesce(_optionalChain([validator, 'access', _4 => _4.value, 'optionalAccess', _5 => _5.isInstructorClassRole, 'call', _6 => _6(role)]), () => ( false)),
29
+ isPicEligibleRole: (role) => _nullishCoalesce(_optionalChain([validator, 'access', _7 => _7.value, 'optionalAccess', _8 => _8.isPicEligibleRole, 'call', _9 => _9(role)]), () => ( false))
30
+ };
31
+ }
32
+
33
+
34
+ exports.useCrewValidator = useCrewValidator;
@@ -0,0 +1,31 @@
1
+ import { ComputedRef, MaybeRefOrGetter } from 'vue';
2
+ import { CrewValidator, PicResolution, Violation, CrewEntry, CrewConfig } from './index.cjs';
3
+
4
+ interface UseCrewValidatorResult {
5
+ /** The validator instance (null while config hasn't loaded yet). */
6
+ validator: ComputedRef<CrewValidator | null>;
7
+ /** PIC walk result over the current crew. */
8
+ pic: ComputedRef<PicResolution>;
9
+ /** Every constraint violation in the current crew. */
10
+ violations: ComputedRef<Violation[]>;
11
+ /** True iff PIC resolves cleanly AND no violations are present. */
12
+ isValid: ComputedRef<boolean>;
13
+ /** True iff the role exists in the config and is on-board. */
14
+ isOnBoardRole: (role: string) => boolean;
15
+ /** True iff the role is an instructor variant. */
16
+ isInstructorClassRole: (role: string) => boolean;
17
+ /** True iff the role can hold PIC. */
18
+ isPicEligibleRole: (role: string) => boolean;
19
+ }
20
+ /**
21
+ * Reactive Vue composable over an SDK `CrewValidator`. Pass the live
22
+ * crew array and the (possibly-loading) crew config; outputs update as
23
+ * either reference changes.
24
+ *
25
+ * `configRef` may be null while the app is fetching `/meta/crew`; the
26
+ * computed properties cleanly degrade to a `none` PIC and empty
27
+ * violations during that window.
28
+ */
29
+ declare function useCrewValidator(crewRef: MaybeRefOrGetter<readonly CrewEntry[] | null | undefined>, configRef: MaybeRefOrGetter<CrewConfig | null | undefined>): UseCrewValidatorResult;
30
+
31
+ export { type UseCrewValidatorResult, useCrewValidator };
@@ -0,0 +1,31 @@
1
+ import { ComputedRef, MaybeRefOrGetter } from 'vue';
2
+ import { CrewValidator, PicResolution, Violation, CrewEntry, CrewConfig } from './index.js';
3
+
4
+ interface UseCrewValidatorResult {
5
+ /** The validator instance (null while config hasn't loaded yet). */
6
+ validator: ComputedRef<CrewValidator | null>;
7
+ /** PIC walk result over the current crew. */
8
+ pic: ComputedRef<PicResolution>;
9
+ /** Every constraint violation in the current crew. */
10
+ violations: ComputedRef<Violation[]>;
11
+ /** True iff PIC resolves cleanly AND no violations are present. */
12
+ isValid: ComputedRef<boolean>;
13
+ /** True iff the role exists in the config and is on-board. */
14
+ isOnBoardRole: (role: string) => boolean;
15
+ /** True iff the role is an instructor variant. */
16
+ isInstructorClassRole: (role: string) => boolean;
17
+ /** True iff the role can hold PIC. */
18
+ isPicEligibleRole: (role: string) => boolean;
19
+ }
20
+ /**
21
+ * Reactive Vue composable over an SDK `CrewValidator`. Pass the live
22
+ * crew array and the (possibly-loading) crew config; outputs update as
23
+ * either reference changes.
24
+ *
25
+ * `configRef` may be null while the app is fetching `/meta/crew`; the
26
+ * computed properties cleanly degrade to a `none` PIC and empty
27
+ * violations during that window.
28
+ */
29
+ declare function useCrewValidator(crewRef: MaybeRefOrGetter<readonly CrewEntry[] | null | undefined>, configRef: MaybeRefOrGetter<CrewConfig | null | undefined>): UseCrewValidatorResult;
30
+
31
+ export { type UseCrewValidatorResult, useCrewValidator };
@@ -0,0 +1,34 @@
1
+ import {
2
+ createCrewValidator
3
+ } from "../chunk-2M32EOYI.js";
4
+
5
+ // src/crew/vue.ts
6
+ import { computed, toValue } from "vue";
7
+ function useCrewValidator(crewRef, configRef) {
8
+ const validator = computed(() => {
9
+ const cfg = toValue(configRef);
10
+ return cfg ? createCrewValidator(cfg) : null;
11
+ });
12
+ const crew = computed(() => toValue(crewRef) ?? []);
13
+ const pic = computed(
14
+ () => validator.value ? validator.value.resolvePic(crew.value) : { type: "none" }
15
+ );
16
+ const violations = computed(
17
+ () => validator.value ? validator.value.evaluate(crew.value).violations : []
18
+ );
19
+ const isValid = computed(
20
+ () => violations.value.length === 0 && pic.value.type === "ok"
21
+ );
22
+ return {
23
+ validator,
24
+ pic,
25
+ violations,
26
+ isValid,
27
+ isOnBoardRole: (role) => validator.value?.isOnBoardRole(role) ?? false,
28
+ isInstructorClassRole: (role) => validator.value?.isInstructorClassRole(role) ?? false,
29
+ isPicEligibleRole: (role) => validator.value?.isPicEligibleRole(role) ?? false
30
+ };
31
+ }
32
+ export {
33
+ useCrewValidator
34
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ var _chunkMF7G76QScjs = require('../chunk-MF7G76QS.cjs');
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+ exports.DATE_FORMATS = _chunkMF7G76QScjs.DATE_FORMATS; exports.TIME_FORMATS = _chunkMF7G76QScjs.TIME_FORMATS; exports.bookingDuration = _chunkMF7G76QScjs.bookingDuration; exports.bytesToHuman = _chunkMF7G76QScjs.bytesToHuman; exports.crewObjectToString = _chunkMF7G76QScjs.crewObjectToString; exports.dateString = _chunkMF7G76QScjs.dateString; exports.dateTimeString = _chunkMF7G76QScjs.dateTimeString; exports.dayString = _chunkMF7G76QScjs.dayString; exports.formatDate = _chunkMF7G76QScjs.formatDate; exports.formatDateTime = _chunkMF7G76QScjs.formatDateTime; exports.formatTime = _chunkMF7G76QScjs.formatTime; exports.getMonthFromDate = _chunkMF7G76QScjs.getMonthFromDate; exports.membershipStatus = _chunkMF7G76QScjs.membershipStatus; exports.minutesFormatted = _chunkMF7G76QScjs.minutesFormatted; exports.monthString = _chunkMF7G76QScjs.monthString; exports.percentage = _chunkMF7G76QScjs.percentage; exports.timeDiffInDays = _chunkMF7G76QScjs.timeDiffInDays; exports.timeString = _chunkMF7G76QScjs.timeString; exports.timeUntil = _chunkMF7G76QScjs.timeUntil; exports.yearString = _chunkMF7G76QScjs.yearString;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Note on German locale: the SDK does not eagerly load `moment/locale/de`.
3
+ * Consumers that want German formatting should import it once at their
4
+ * app entry: `import "moment/locale/de"`. Otherwise `timeUntil` and other
5
+ * locale-dependent functions will fall back to English.
6
+ */
7
+ /** Predefined moment format strings, frozen so callers can reference them safely. */
8
+ declare const DATE_FORMATS: Readonly<{
9
+ readonly DATE: "DD.MM.YYYY";
10
+ readonly TIME: "HH:mm";
11
+ readonly TIME_TZ: "HH:mm z";
12
+ readonly DATETIME: "DD.MM.YYYY HH:mm";
13
+ readonly DATETIME_TZ: "DD.MM.YYYY HH:mm z";
14
+ readonly YEAR: "YYYY";
15
+ readonly DAY: "DD";
16
+ readonly MONTH_SHORT: "MMM";
17
+ }>;
18
+ declare const TIME_FORMATS: Readonly<{
19
+ readonly TIME: "HH:mm";
20
+ readonly TIME_WITH_SECONDS: "HH:mm:ss";
21
+ }>;
22
+ type DateFormat = (typeof DATE_FORMATS)[keyof typeof DATE_FORMATS];
23
+ type TimeFormat = (typeof TIME_FORMATS)[keyof typeof TIME_FORMATS];
24
+ /**
25
+ * Format a strict `YYYY-MM-DD` date string with the given moment format.
26
+ * Returns `""` for invalid input.
27
+ */
28
+ declare function formatDate(date: string | null | undefined, format?: string, locale?: string): string;
29
+ /**
30
+ * Normalize an `HH:mm[:ss]`-ish string into a chosen format. Pads
31
+ * components and clamps each to its valid range.
32
+ */
33
+ declare function formatTime(time: string | null | undefined, format?: string): string;
34
+ /**
35
+ * Format an ISO date-time string or Date in a specific timezone+locale.
36
+ * Returns `""` for invalid input.
37
+ */
38
+ declare function formatDateTime(dateTime: string | Date | null | undefined, timezone?: string, format?: string, locale?: string): string;
39
+ declare function bytesToHuman(bytes: number | null | undefined): string;
40
+ declare function monthString(date: string | Date | null | undefined): string;
41
+ declare function getMonthFromDate(date: string | Date | null | undefined): string;
42
+ declare function yearString(date: string | Date | null | undefined, timezone?: string): string;
43
+ declare function percentage(value: number | string | null | undefined): string;
44
+ interface MembershipStatusBadge {
45
+ text: string;
46
+ color: string;
47
+ }
48
+ declare function membershipStatus(value: string | null | undefined): MembershipStatusBadge;
49
+ declare function dayString(date: string | Date | null | undefined, timezone?: string): string;
50
+ declare function dateString(date: string | Date | null | undefined, timezone?: string): string;
51
+ declare function dateTimeString(date: string | Date | null | undefined, timezone?: string, includeTimezone?: boolean): string | null;
52
+ declare function timeString(date: string | Date | null | undefined, timezone?: string, includeTimezone?: boolean): string;
53
+ declare function timeUntil(dateTime: string | Date | null | undefined, locale?: string): string;
54
+ declare function minutesFormatted(minutes: number | null | undefined): string;
55
+ interface CrewMember {
56
+ name?: string;
57
+ role?: string;
58
+ }
59
+ declare function crewObjectToString(crew: CrewMember[] | string | null | undefined, { includeRoles }?: {
60
+ includeRoles?: boolean;
61
+ }): string;
62
+ declare function timeDiffInDays(startDateTime: string | Date | null | undefined, endDateTime: string | Date | null | undefined): string | null;
63
+ interface BookingTimespan {
64
+ etdZ: string | Date;
65
+ etaZ: string | Date;
66
+ }
67
+ declare function bookingDuration(booking: BookingTimespan): string;
68
+
69
+ export { type BookingTimespan, type CrewMember, DATE_FORMATS, type DateFormat, type MembershipStatusBadge, TIME_FORMATS, type TimeFormat, bookingDuration, bytesToHuman, crewObjectToString, dateString, dateTimeString, dayString, formatDate, formatDateTime, formatTime, getMonthFromDate, membershipStatus, minutesFormatted, monthString, percentage, timeDiffInDays, timeString, timeUntil, yearString };