@dataverse-kit/calendar-kit 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.
- package/README.md +103 -0
- package/dist/CalendarView-CShiWFsR.d.ts +104 -0
- package/dist/CalendarView-Dd8BHOLE.d.cts +104 -0
- package/dist/core.cjs +192 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +64 -0
- package/dist/core.d.ts +64 -0
- package/dist/core.mjs +151 -0
- package/dist/core.mjs.map +1 -0
- package/dist/dataverse.cjs +300 -0
- package/dist/dataverse.cjs.map +1 -0
- package/dist/dataverse.d.cts +121 -0
- package/dist/dataverse.d.ts +121 -0
- package/dist/dataverse.mjs +263 -0
- package/dist/dataverse.mjs.map +1 -0
- package/dist/fake.cjs +199 -0
- package/dist/fake.cjs.map +1 -0
- package/dist/fake.d.cts +29 -0
- package/dist/fake.d.ts +29 -0
- package/dist/fake.mjs +171 -0
- package/dist/fake.mjs.map +1 -0
- package/dist/index.cjs +568 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +515 -0
- package/dist/index.mjs.map +1 -0
- package/dist/pcf-dataset.cjs +328 -0
- package/dist/pcf-dataset.cjs.map +1 -0
- package/dist/pcf-dataset.d.cts +98 -0
- package/dist/pcf-dataset.d.ts +98 -0
- package/dist/pcf-dataset.mjs +296 -0
- package/dist/pcf-dataset.mjs.map +1 -0
- package/dist/types-u3Gpxk53.d.cts +108 -0
- package/dist/types-u3Gpxk53.d.ts +108 -0
- package/dist/v9.cjs +555 -0
- package/dist/v9.cjs.map +1 -0
- package/dist/v9.d.cts +18 -0
- package/dist/v9.d.ts +18 -0
- package/dist/v9.mjs +517 -0
- package/dist/v9.mjs.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { c as CalendarValue, Z as ZoneOffset, a as CalendarEvent, S as SlotSelection, b as CalendarEventChange } from './types-u3Gpxk53.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dataverse's three DateTime behaviours, and the FOUR different shapes one value takes on its
|
|
5
|
+
* way through a model-driven app. Every rule below was MEASURED on a live org (2026-09-26,
|
|
6
|
+
* `spikes/calendar-view-fc7/FINDINGS.md` in the parent workspace); none is from documentation.
|
|
7
|
+
*
|
|
8
|
+
* ★★★ The two write paths are DIFFERENT CONTRACTS. The same text means different things to
|
|
9
|
+
* `webAPI.updateRecord` and to `navigation.openForm` parameters:
|
|
10
|
+
*
|
|
11
|
+
* | behaviour | read (dataset getValue) | Web API write | form parameter (quick create) |
|
|
12
|
+
* |------------|-----------------------------|------------------------|-------------------------------|
|
|
13
|
+
* | UserLocal | `…T06:30:00.000Z` instant | instant `…Z` | wall clock, NO `Z` |
|
|
14
|
+
* | DateOnly | `…T00:00:00.000Z` UTC-midn. | `YYYY-MM-DD` | `YYYY-MM-DDT00:00:00`, NO `Z` |
|
|
15
|
+
* | TZI | `…T23:30:00.000Z` face+`Z` | wall clock WITH `Z` | wall clock, NO `Z` |
|
|
16
|
+
*
|
|
17
|
+
* Measured failures of the obvious choice, each of which a unit test here pins:
|
|
18
|
+
* - a DateOnly read through `new Date()` lands on the PREVIOUS day anywhere west of UTC;
|
|
19
|
+
* - a bare `YYYY-MM-DD` form parameter was stored as the previous day (Pacific user);
|
|
20
|
+
* - a TZI form parameter WITH `Z` was treated as UTC and shifted −7 h.
|
|
21
|
+
* The first two are why a well-known client control had a "+1 day" hack in its click handler.
|
|
22
|
+
*/
|
|
23
|
+
declare const DateTimeBehavior: {
|
|
24
|
+
readonly UserLocal: 1;
|
|
25
|
+
readonly DateOnly: 2;
|
|
26
|
+
readonly TimeZoneIndependent: 3;
|
|
27
|
+
};
|
|
28
|
+
type DateTimeBehavior = (typeof DateTimeBehavior)[keyof typeof DateTimeBehavior];
|
|
29
|
+
/**
|
|
30
|
+
* The behaviour of a column, from whatever metadata shape the host produced.
|
|
31
|
+
*
|
|
32
|
+
* ★ `getEntityMetadata` in a PCF host answers `Behavior: 1|2|3` (MEASURED). The Web API's
|
|
33
|
+
* `EntityDefinitions` answers `DateTimeBehavior: { Value: 'UserLocal' }`. Both are accepted.
|
|
34
|
+
* ★ A DateOnly column is also recognisable from its PCF `dataType` alone
|
|
35
|
+
* (`DateAndTime.DateOnly`). TZI and UserLocal are NOT — both report `DateAndTime.DateAndTime` —
|
|
36
|
+
* so without metadata a TZI column is indistinguishable and is treated as UserLocal. Callers
|
|
37
|
+
* that can see that ambiguity should surface it (see `adapters/pcf-dataset`).
|
|
38
|
+
*/
|
|
39
|
+
declare function behaviorOf(meta: unknown, dataType?: string): DateTimeBehavior;
|
|
40
|
+
/**
|
|
41
|
+
* A raw column value (dataset `getValue()`, or a Web API property) → a calendar value.
|
|
42
|
+
*
|
|
43
|
+
* ★★★ `getValue()` returns an ISO STRING for all three behaviours, despite
|
|
44
|
+
* `@types/powerapps-component-framework` declaring `Date`. A `Date` is still accepted, because a
|
|
45
|
+
* test double or another host may produce one — and it is read through its UTC fields, which is
|
|
46
|
+
* what the platform's strings encode.
|
|
47
|
+
*/
|
|
48
|
+
declare function readDataverseDate(raw: unknown, behavior: DateTimeBehavior): CalendarValue | null;
|
|
49
|
+
/**
|
|
50
|
+
* A calendar value → the text `webAPI.updateRecord` / `createRecord` wants for this behaviour.
|
|
51
|
+
* `zone` is needed only to turn a value of a different kind into this one (e.g. an all-day drop
|
|
52
|
+
* onto a UserLocal column); same-kind values pass straight through.
|
|
53
|
+
*/
|
|
54
|
+
declare function toWebApiDate(value: CalendarValue, behavior: DateTimeBehavior, zone: ZoneOffset): string;
|
|
55
|
+
/**
|
|
56
|
+
* A calendar value → the text a `navigation.openForm` form PARAMETER wants (quick create
|
|
57
|
+
* prefill). Wall clock in the user's zone, never with `Z`.
|
|
58
|
+
*
|
|
59
|
+
* ★ UNMEASURED: whether "wall clock" here means the Dynamics USER's zone or the BROWSER's when
|
|
60
|
+
* they differ. Measured only with both in Pacific. Pass the user zone; if the org proof shows
|
|
61
|
+
* the browser's is used, this is the one function to change.
|
|
62
|
+
*/
|
|
63
|
+
declare function toFormParameterDate(value: CalendarValue, behavior: DateTimeBehavior, zone: ZoneOffset): string;
|
|
64
|
+
/** Dataverse stores an all-day END inclusive; the calendar's is exclusive. */
|
|
65
|
+
declare const inclusiveEndToExclusive: (lastDay: CalendarValue) => CalendarValue;
|
|
66
|
+
declare const exclusiveEndToInclusive: (dayAfter: CalendarValue) => CalendarValue;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Which columns hold what. Logical names. Only `start` is required — that is the whole
|
|
70
|
+
* genericity story: the same calendar shows Appointments for one client and Orders for another,
|
|
71
|
+
* because a maker names the columns rather than a developer.
|
|
72
|
+
*/
|
|
73
|
+
interface ColumnMap {
|
|
74
|
+
start: string;
|
|
75
|
+
end?: string;
|
|
76
|
+
title?: string;
|
|
77
|
+
/** A hex colour column, or a choice column whose option colours `colorOf` resolves. */
|
|
78
|
+
color?: string;
|
|
79
|
+
/** Location / staff / queue. Drives `resourceId` and, failing `color`, a group colour. */
|
|
80
|
+
group?: string;
|
|
81
|
+
/** A Yes/No column that forces all-day. */
|
|
82
|
+
allDay?: string;
|
|
83
|
+
}
|
|
84
|
+
/** The minimum a record source must answer — a dataset record, a Web API row, a fixture. */
|
|
85
|
+
interface RecordAccessor {
|
|
86
|
+
id: string;
|
|
87
|
+
value(column: string): unknown;
|
|
88
|
+
formatted(column: string): string;
|
|
89
|
+
}
|
|
90
|
+
interface MapOptions {
|
|
91
|
+
/** Behaviour per DATE column (logical name). Missing ⇒ UserLocal. */
|
|
92
|
+
behaviors: Readonly<Record<string, DateTimeBehavior>>;
|
|
93
|
+
zone: ZoneOffset;
|
|
94
|
+
/** Resolve a colour column's value (e.g. choice option colours). Return undefined to fall back. */
|
|
95
|
+
colorOf?: (column: string, raw: unknown, formatted: string) => string | undefined;
|
|
96
|
+
/** Per-record read-only, e.g. a status that forbids rescheduling. */
|
|
97
|
+
isReadOnly?: (record: RecordAccessor) => boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* ★★ A Yes/No column's raw value in a PCF dataset is the STRING `"0"` / `"1"` — and
|
|
101
|
+
* `Boolean("0")` is `true`. MEASURED on a sibling gallery control, where every `false` row
|
|
102
|
+
* rendered ON. Read the digits, never truthiness.
|
|
103
|
+
*/
|
|
104
|
+
declare function readYesNo(raw: unknown): boolean;
|
|
105
|
+
/** One record → one event, or null when it has no usable start. */
|
|
106
|
+
declare function mapRecordToEvent(record: RecordAccessor, map: ColumnMap, opts: MapOptions): CalendarEvent | null;
|
|
107
|
+
/**
|
|
108
|
+
* A move/resize → the column values to PATCH through the Web API.
|
|
109
|
+
* Columns the map does not name are never written.
|
|
110
|
+
*/
|
|
111
|
+
declare function toWebApiPatch(change: CalendarEventChange, map: ColumnMap, opts: Pick<MapOptions, 'behaviors' | 'zone'>): Record<string, string>;
|
|
112
|
+
/**
|
|
113
|
+
* A selected empty range → quick-create form parameters. `extra` is merged underneath, so a
|
|
114
|
+
* host can prefill a lookup (the parent record) without it being overwritten by dates.
|
|
115
|
+
*
|
|
116
|
+
* ★ The all-day column is set to boolean `true` for an all-day selection. The accepted shape of
|
|
117
|
+
* a Yes/No FORM PARAMETER is UNMEASURED; the date shapes are measured.
|
|
118
|
+
*/
|
|
119
|
+
declare function toQuickCreateParameters(selection: SlotSelection, map: ColumnMap, opts: Pick<MapOptions, 'behaviors' | 'zone'>, extra?: Record<string, unknown>): Record<string, unknown>;
|
|
120
|
+
|
|
121
|
+
export { type ColumnMap, DateTimeBehavior, type MapOptions, type RecordAccessor, behaviorOf, exclusiveEndToInclusive, inclusiveEndToExclusive, mapRecordToEvent, readDataverseDate, readYesNo, toFormParameterDate, toQuickCreateParameters, toWebApiDate, toWebApiPatch };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { c as CalendarValue, Z as ZoneOffset, a as CalendarEvent, S as SlotSelection, b as CalendarEventChange } from './types-u3Gpxk53.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dataverse's three DateTime behaviours, and the FOUR different shapes one value takes on its
|
|
5
|
+
* way through a model-driven app. Every rule below was MEASURED on a live org (2026-09-26,
|
|
6
|
+
* `spikes/calendar-view-fc7/FINDINGS.md` in the parent workspace); none is from documentation.
|
|
7
|
+
*
|
|
8
|
+
* ★★★ The two write paths are DIFFERENT CONTRACTS. The same text means different things to
|
|
9
|
+
* `webAPI.updateRecord` and to `navigation.openForm` parameters:
|
|
10
|
+
*
|
|
11
|
+
* | behaviour | read (dataset getValue) | Web API write | form parameter (quick create) |
|
|
12
|
+
* |------------|-----------------------------|------------------------|-------------------------------|
|
|
13
|
+
* | UserLocal | `…T06:30:00.000Z` instant | instant `…Z` | wall clock, NO `Z` |
|
|
14
|
+
* | DateOnly | `…T00:00:00.000Z` UTC-midn. | `YYYY-MM-DD` | `YYYY-MM-DDT00:00:00`, NO `Z` |
|
|
15
|
+
* | TZI | `…T23:30:00.000Z` face+`Z` | wall clock WITH `Z` | wall clock, NO `Z` |
|
|
16
|
+
*
|
|
17
|
+
* Measured failures of the obvious choice, each of which a unit test here pins:
|
|
18
|
+
* - a DateOnly read through `new Date()` lands on the PREVIOUS day anywhere west of UTC;
|
|
19
|
+
* - a bare `YYYY-MM-DD` form parameter was stored as the previous day (Pacific user);
|
|
20
|
+
* - a TZI form parameter WITH `Z` was treated as UTC and shifted −7 h.
|
|
21
|
+
* The first two are why a well-known client control had a "+1 day" hack in its click handler.
|
|
22
|
+
*/
|
|
23
|
+
declare const DateTimeBehavior: {
|
|
24
|
+
readonly UserLocal: 1;
|
|
25
|
+
readonly DateOnly: 2;
|
|
26
|
+
readonly TimeZoneIndependent: 3;
|
|
27
|
+
};
|
|
28
|
+
type DateTimeBehavior = (typeof DateTimeBehavior)[keyof typeof DateTimeBehavior];
|
|
29
|
+
/**
|
|
30
|
+
* The behaviour of a column, from whatever metadata shape the host produced.
|
|
31
|
+
*
|
|
32
|
+
* ★ `getEntityMetadata` in a PCF host answers `Behavior: 1|2|3` (MEASURED). The Web API's
|
|
33
|
+
* `EntityDefinitions` answers `DateTimeBehavior: { Value: 'UserLocal' }`. Both are accepted.
|
|
34
|
+
* ★ A DateOnly column is also recognisable from its PCF `dataType` alone
|
|
35
|
+
* (`DateAndTime.DateOnly`). TZI and UserLocal are NOT — both report `DateAndTime.DateAndTime` —
|
|
36
|
+
* so without metadata a TZI column is indistinguishable and is treated as UserLocal. Callers
|
|
37
|
+
* that can see that ambiguity should surface it (see `adapters/pcf-dataset`).
|
|
38
|
+
*/
|
|
39
|
+
declare function behaviorOf(meta: unknown, dataType?: string): DateTimeBehavior;
|
|
40
|
+
/**
|
|
41
|
+
* A raw column value (dataset `getValue()`, or a Web API property) → a calendar value.
|
|
42
|
+
*
|
|
43
|
+
* ★★★ `getValue()` returns an ISO STRING for all three behaviours, despite
|
|
44
|
+
* `@types/powerapps-component-framework` declaring `Date`. A `Date` is still accepted, because a
|
|
45
|
+
* test double or another host may produce one — and it is read through its UTC fields, which is
|
|
46
|
+
* what the platform's strings encode.
|
|
47
|
+
*/
|
|
48
|
+
declare function readDataverseDate(raw: unknown, behavior: DateTimeBehavior): CalendarValue | null;
|
|
49
|
+
/**
|
|
50
|
+
* A calendar value → the text `webAPI.updateRecord` / `createRecord` wants for this behaviour.
|
|
51
|
+
* `zone` is needed only to turn a value of a different kind into this one (e.g. an all-day drop
|
|
52
|
+
* onto a UserLocal column); same-kind values pass straight through.
|
|
53
|
+
*/
|
|
54
|
+
declare function toWebApiDate(value: CalendarValue, behavior: DateTimeBehavior, zone: ZoneOffset): string;
|
|
55
|
+
/**
|
|
56
|
+
* A calendar value → the text a `navigation.openForm` form PARAMETER wants (quick create
|
|
57
|
+
* prefill). Wall clock in the user's zone, never with `Z`.
|
|
58
|
+
*
|
|
59
|
+
* ★ UNMEASURED: whether "wall clock" here means the Dynamics USER's zone or the BROWSER's when
|
|
60
|
+
* they differ. Measured only with both in Pacific. Pass the user zone; if the org proof shows
|
|
61
|
+
* the browser's is used, this is the one function to change.
|
|
62
|
+
*/
|
|
63
|
+
declare function toFormParameterDate(value: CalendarValue, behavior: DateTimeBehavior, zone: ZoneOffset): string;
|
|
64
|
+
/** Dataverse stores an all-day END inclusive; the calendar's is exclusive. */
|
|
65
|
+
declare const inclusiveEndToExclusive: (lastDay: CalendarValue) => CalendarValue;
|
|
66
|
+
declare const exclusiveEndToInclusive: (dayAfter: CalendarValue) => CalendarValue;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Which columns hold what. Logical names. Only `start` is required — that is the whole
|
|
70
|
+
* genericity story: the same calendar shows Appointments for one client and Orders for another,
|
|
71
|
+
* because a maker names the columns rather than a developer.
|
|
72
|
+
*/
|
|
73
|
+
interface ColumnMap {
|
|
74
|
+
start: string;
|
|
75
|
+
end?: string;
|
|
76
|
+
title?: string;
|
|
77
|
+
/** A hex colour column, or a choice column whose option colours `colorOf` resolves. */
|
|
78
|
+
color?: string;
|
|
79
|
+
/** Location / staff / queue. Drives `resourceId` and, failing `color`, a group colour. */
|
|
80
|
+
group?: string;
|
|
81
|
+
/** A Yes/No column that forces all-day. */
|
|
82
|
+
allDay?: string;
|
|
83
|
+
}
|
|
84
|
+
/** The minimum a record source must answer — a dataset record, a Web API row, a fixture. */
|
|
85
|
+
interface RecordAccessor {
|
|
86
|
+
id: string;
|
|
87
|
+
value(column: string): unknown;
|
|
88
|
+
formatted(column: string): string;
|
|
89
|
+
}
|
|
90
|
+
interface MapOptions {
|
|
91
|
+
/** Behaviour per DATE column (logical name). Missing ⇒ UserLocal. */
|
|
92
|
+
behaviors: Readonly<Record<string, DateTimeBehavior>>;
|
|
93
|
+
zone: ZoneOffset;
|
|
94
|
+
/** Resolve a colour column's value (e.g. choice option colours). Return undefined to fall back. */
|
|
95
|
+
colorOf?: (column: string, raw: unknown, formatted: string) => string | undefined;
|
|
96
|
+
/** Per-record read-only, e.g. a status that forbids rescheduling. */
|
|
97
|
+
isReadOnly?: (record: RecordAccessor) => boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* ★★ A Yes/No column's raw value in a PCF dataset is the STRING `"0"` / `"1"` — and
|
|
101
|
+
* `Boolean("0")` is `true`. MEASURED on a sibling gallery control, where every `false` row
|
|
102
|
+
* rendered ON. Read the digits, never truthiness.
|
|
103
|
+
*/
|
|
104
|
+
declare function readYesNo(raw: unknown): boolean;
|
|
105
|
+
/** One record → one event, or null when it has no usable start. */
|
|
106
|
+
declare function mapRecordToEvent(record: RecordAccessor, map: ColumnMap, opts: MapOptions): CalendarEvent | null;
|
|
107
|
+
/**
|
|
108
|
+
* A move/resize → the column values to PATCH through the Web API.
|
|
109
|
+
* Columns the map does not name are never written.
|
|
110
|
+
*/
|
|
111
|
+
declare function toWebApiPatch(change: CalendarEventChange, map: ColumnMap, opts: Pick<MapOptions, 'behaviors' | 'zone'>): Record<string, string>;
|
|
112
|
+
/**
|
|
113
|
+
* A selected empty range → quick-create form parameters. `extra` is merged underneath, so a
|
|
114
|
+
* host can prefill a lookup (the parent record) without it being overwritten by dates.
|
|
115
|
+
*
|
|
116
|
+
* ★ The all-day column is set to boolean `true` for an all-day selection. The accepted shape of
|
|
117
|
+
* a Yes/No FORM PARAMETER is UNMEASURED; the date shapes are measured.
|
|
118
|
+
*/
|
|
119
|
+
declare function toQuickCreateParameters(selection: SlotSelection, map: ColumnMap, opts: Pick<MapOptions, 'behaviors' | 'zone'>, extra?: Record<string, unknown>): Record<string, unknown>;
|
|
120
|
+
|
|
121
|
+
export { type ColumnMap, DateTimeBehavior, type MapOptions, type RecordAccessor, behaviorOf, exclusiveEndToInclusive, inclusiveEndToExclusive, mapRecordToEvent, readDataverseDate, readYesNo, toFormParameterDate, toQuickCreateParameters, toWebApiDate, toWebApiPatch };
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// src/core/datetime.ts
|
|
2
|
+
var DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
3
|
+
var FLOATING_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,9})?)?$/;
|
|
4
|
+
var INSTANT_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
5
|
+
var pad = (n, w = 2) => String(n).padStart(w, "0");
|
|
6
|
+
function kindOf(value) {
|
|
7
|
+
if (value instanceof Date) {
|
|
8
|
+
if (Number.isNaN(value.getTime())) throw new RangeError("Invalid Date");
|
|
9
|
+
return "instant";
|
|
10
|
+
}
|
|
11
|
+
const local = DATE_RE.test(value) ? "date" : FLOATING_RE.test(value) ? "floating" : null;
|
|
12
|
+
if (local) {
|
|
13
|
+
const m = FLOATING_RE.exec(value) ?? DATE_RE.exec(value);
|
|
14
|
+
const [, y, mo, d, h = "0", mi = "0", sec = "0"] = m;
|
|
15
|
+
const t = new Date(Date.UTC(+y, +mo - 1, +d, +h, +mi, +sec));
|
|
16
|
+
if (t.getUTCFullYear() !== +y || t.getUTCMonth() !== +mo - 1 || t.getUTCDate() !== +d || +h > 23 || +mi > 59 || +sec > 59) {
|
|
17
|
+
throw new RangeError(`Not a real calendar date or time: ${JSON.stringify(value)}`);
|
|
18
|
+
}
|
|
19
|
+
return local;
|
|
20
|
+
}
|
|
21
|
+
if (INSTANT_RE.test(value) && !Number.isNaN(new Date(value).getTime())) return "instant";
|
|
22
|
+
throw new RangeError(`Not an ISO-8601 date, wall-clock time or instant: ${JSON.stringify(value)}`);
|
|
23
|
+
}
|
|
24
|
+
function toInstant(value) {
|
|
25
|
+
if (value instanceof Date) return value.toISOString();
|
|
26
|
+
if (kindOf(value) !== "instant") throw new RangeError(`Not an instant: ${value}`);
|
|
27
|
+
return new Date(value).toISOString();
|
|
28
|
+
}
|
|
29
|
+
function wallMillis(wall) {
|
|
30
|
+
const m = FLOATING_RE.exec(wall) ?? DATE_RE.exec(wall);
|
|
31
|
+
if (!m) throw new RangeError(`Not a date or wall-clock time: ${wall}`);
|
|
32
|
+
const [, y, mo, d, h = "0", mi = "0", s = "0"] = m;
|
|
33
|
+
return Date.UTC(+y, +mo - 1, +d, +h, +mi, +s);
|
|
34
|
+
}
|
|
35
|
+
function formatWall(ms) {
|
|
36
|
+
const d = new Date(ms);
|
|
37
|
+
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`;
|
|
38
|
+
}
|
|
39
|
+
function toWall(instant, zone) {
|
|
40
|
+
const at = instant instanceof Date ? instant : new Date(toInstant(instant));
|
|
41
|
+
return formatWall(at.getTime() + zone(at) * 6e4);
|
|
42
|
+
}
|
|
43
|
+
function fromWall(wall, zone) {
|
|
44
|
+
const w = wallMillis(wall);
|
|
45
|
+
const before = zone(new Date(w - 864e5));
|
|
46
|
+
const after = zone(new Date(w + 864e5));
|
|
47
|
+
const fits = (offset) => {
|
|
48
|
+
const t2 = w - offset * 6e4;
|
|
49
|
+
return zone(new Date(t2)) === offset ? t2 : null;
|
|
50
|
+
};
|
|
51
|
+
const candidates = [fits(before), fits(after)].filter((t2) => t2 !== null);
|
|
52
|
+
const t = candidates.length > 0 ? Math.min(...candidates) : w - before * 6e4;
|
|
53
|
+
return new Date(t).toISOString();
|
|
54
|
+
}
|
|
55
|
+
function toDate(value, zone) {
|
|
56
|
+
const k = kindOf(value);
|
|
57
|
+
if (k === "date") return value;
|
|
58
|
+
if (k === "floating") return value.slice(0, 10);
|
|
59
|
+
return toWall(value, zone).slice(0, 10);
|
|
60
|
+
}
|
|
61
|
+
function addDays(date, days) {
|
|
62
|
+
if (kindOf(date) !== "date") throw new RangeError(`addDays needs a date, got ${date}`);
|
|
63
|
+
return formatWall(wallMillis(date) + days * 864e5).slice(0, 10);
|
|
64
|
+
}
|
|
65
|
+
function normaliseFloating(value) {
|
|
66
|
+
return formatWall(wallMillis(value));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/dataverse/dates.ts
|
|
70
|
+
var DateTimeBehavior = {
|
|
71
|
+
UserLocal: 1,
|
|
72
|
+
DateOnly: 2,
|
|
73
|
+
TimeZoneIndependent: 3
|
|
74
|
+
};
|
|
75
|
+
function behaviorOf(meta, dataType) {
|
|
76
|
+
const m = meta ?? {};
|
|
77
|
+
if (m.Behavior === 1 || m.Behavior === 2 || m.Behavior === 3) return m.Behavior;
|
|
78
|
+
const named = typeof m.DateTimeBehavior === "string" ? m.DateTimeBehavior : m.DateTimeBehavior?.Value;
|
|
79
|
+
if (named === "DateOnly") return DateTimeBehavior.DateOnly;
|
|
80
|
+
if (named === "TimeZoneIndependent") return DateTimeBehavior.TimeZoneIndependent;
|
|
81
|
+
if (named === "UserLocal") return DateTimeBehavior.UserLocal;
|
|
82
|
+
if (dataType === "DateAndTime.DateOnly") return DateTimeBehavior.DateOnly;
|
|
83
|
+
return DateTimeBehavior.UserLocal;
|
|
84
|
+
}
|
|
85
|
+
function rawText(raw) {
|
|
86
|
+
if (raw === null || raw === void 0 || raw === "") return null;
|
|
87
|
+
if (raw instanceof Date) return Number.isNaN(raw.getTime()) ? null : raw.toISOString();
|
|
88
|
+
if (typeof raw === "string") return raw;
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function readDataverseDate(raw, behavior) {
|
|
92
|
+
const s = rawText(raw);
|
|
93
|
+
if (s === null) return null;
|
|
94
|
+
switch (behavior) {
|
|
95
|
+
case DateTimeBehavior.DateOnly:
|
|
96
|
+
return s.slice(0, 10);
|
|
97
|
+
case DateTimeBehavior.TimeZoneIndependent:
|
|
98
|
+
return normaliseFloating(s.replace(/(\.\d+)?(Z|[+-]\d{2}:?\d{2})$/i, ""));
|
|
99
|
+
default:
|
|
100
|
+
return toInstant(s);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function toWebApiDate(value, behavior, zone) {
|
|
104
|
+
const k = kindOf(value);
|
|
105
|
+
switch (behavior) {
|
|
106
|
+
case DateTimeBehavior.DateOnly:
|
|
107
|
+
return toDate(value, zone);
|
|
108
|
+
case DateTimeBehavior.TimeZoneIndependent:
|
|
109
|
+
return `${k === "instant" ? toWall(value, zone) : k === "date" ? `${value}T00:00:00` : normaliseFloating(value)}Z`;
|
|
110
|
+
default:
|
|
111
|
+
return k === "instant" ? toInstant(value) : fromWall(k === "date" ? `${value}T00:00:00` : value, zone);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function toFormParameterDate(value, behavior, zone) {
|
|
115
|
+
const k = kindOf(value);
|
|
116
|
+
if (behavior === DateTimeBehavior.DateOnly) return `${toDate(value, zone)}T00:00:00`;
|
|
117
|
+
if (k === "instant") return toWall(value, zone);
|
|
118
|
+
if (k === "date") return `${value}T00:00:00`;
|
|
119
|
+
return normaliseFloating(value);
|
|
120
|
+
}
|
|
121
|
+
var inclusiveEndToExclusive = (lastDay) => addDays(lastDay, 1);
|
|
122
|
+
var exclusiveEndToInclusive = (dayAfter) => addDays(dayAfter, -1);
|
|
123
|
+
|
|
124
|
+
// src/core/colors.ts
|
|
125
|
+
var GROUP_PALETTE = [
|
|
126
|
+
"#0f6cbd",
|
|
127
|
+
// blue
|
|
128
|
+
"#107c10",
|
|
129
|
+
// green
|
|
130
|
+
"#c50f1f",
|
|
131
|
+
// red
|
|
132
|
+
"#8764b8",
|
|
133
|
+
// lavender
|
|
134
|
+
"#ae4b00",
|
|
135
|
+
// dark orange
|
|
136
|
+
"#03787c",
|
|
137
|
+
// teal
|
|
138
|
+
"#4f52b2",
|
|
139
|
+
// indigo
|
|
140
|
+
"#8a5b00",
|
|
141
|
+
// dark gold
|
|
142
|
+
"#c0077d",
|
|
143
|
+
// magenta
|
|
144
|
+
"#5c2e91"
|
|
145
|
+
// purple
|
|
146
|
+
];
|
|
147
|
+
function hash(key) {
|
|
148
|
+
let h = 2166136261;
|
|
149
|
+
for (let i = 0; i < key.length; i++) {
|
|
150
|
+
h ^= key.charCodeAt(i);
|
|
151
|
+
h = Math.imul(h, 16777619);
|
|
152
|
+
}
|
|
153
|
+
return h >>> 0;
|
|
154
|
+
}
|
|
155
|
+
function groupColor(key, palette = GROUP_PALETTE) {
|
|
156
|
+
return palette[hash(key) % palette.length];
|
|
157
|
+
}
|
|
158
|
+
function parseHex(color) {
|
|
159
|
+
const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim());
|
|
160
|
+
if (!m) return null;
|
|
161
|
+
const h = m[1].length === 3 ? m[1].replace(/./g, (c) => c + c) : m[1];
|
|
162
|
+
return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/dataverse/mapping.ts
|
|
166
|
+
var behaviorFor = (opts, column) => opts.behaviors[column] ?? DateTimeBehavior.UserLocal;
|
|
167
|
+
function readYesNo(raw) {
|
|
168
|
+
if (typeof raw === "boolean") return raw;
|
|
169
|
+
if (typeof raw === "number") return raw === 1;
|
|
170
|
+
if (typeof raw === "string") return raw === "1" || raw.toLowerCase() === "true";
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
function utcDayOf(value) {
|
|
174
|
+
return kindOf(value) === "instant" ? toInstant(value).slice(0, 10) : value.slice(0, 10);
|
|
175
|
+
}
|
|
176
|
+
function utcExclusiveDayOf(end) {
|
|
177
|
+
const text = kindOf(end) === "instant" ? toInstant(end) : end;
|
|
178
|
+
return text.length > 10 && text.slice(11, 19) !== "00:00:00" ? addDays(text.slice(0, 10), 1) : text.slice(0, 10);
|
|
179
|
+
}
|
|
180
|
+
function exclusiveDayOf(end, zone) {
|
|
181
|
+
const day = toDate(end, zone);
|
|
182
|
+
const wall = kindOf(end) === "instant" ? toWall(end, zone) : end;
|
|
183
|
+
return wall.length > 10 && wall.slice(11, 19) === "00:00:00" ? day : addDays(day, 1);
|
|
184
|
+
}
|
|
185
|
+
function mapRecordToEvent(record, map, opts) {
|
|
186
|
+
const startBehavior = behaviorFor(opts, map.start);
|
|
187
|
+
let start = readDataverseDate(record.value(map.start), startBehavior);
|
|
188
|
+
if (start === null) return null;
|
|
189
|
+
const endBehavior = map.end ? behaviorFor(opts, map.end) : startBehavior;
|
|
190
|
+
let end = map.end ? readDataverseDate(record.value(map.end), endBehavior) : null;
|
|
191
|
+
const forcedAllDay = map.allDay ? readYesNo(record.value(map.allDay)) : false;
|
|
192
|
+
const allDay = forcedAllDay || kindOf(start) === "date";
|
|
193
|
+
if (allDay) {
|
|
194
|
+
const flagged = forcedAllDay && startBehavior !== DateTimeBehavior.DateOnly;
|
|
195
|
+
start = flagged ? utcDayOf(start) : toDate(start, opts.zone);
|
|
196
|
+
if (end !== null) {
|
|
197
|
+
end = endBehavior === DateTimeBehavior.DateOnly ? inclusiveEndToExclusive(end) : flagged ? utcExclusiveDayOf(end) : exclusiveDayOf(end, opts.zone);
|
|
198
|
+
}
|
|
199
|
+
if (end !== null && end <= start) end = addDays(start, 1);
|
|
200
|
+
} else if (end !== null && kindOf(end) !== kindOf(start)) {
|
|
201
|
+
end = null;
|
|
202
|
+
} else if (end !== null && end <= start) {
|
|
203
|
+
end = null;
|
|
204
|
+
}
|
|
205
|
+
const title = (map.title ? record.formatted(map.title) : "") || "(untitled)";
|
|
206
|
+
const groupKey = map.group ? record.formatted(map.group) || void 0 : void 0;
|
|
207
|
+
let color;
|
|
208
|
+
if (map.color) {
|
|
209
|
+
const raw = record.value(map.color);
|
|
210
|
+
const formatted = record.formatted(map.color);
|
|
211
|
+
color = opts.colorOf?.(map.color, raw, formatted);
|
|
212
|
+
if (!color && typeof raw === "string" && parseHex(raw)) color = raw;
|
|
213
|
+
}
|
|
214
|
+
if (!color && groupKey) color = groupColor(groupKey);
|
|
215
|
+
return {
|
|
216
|
+
id: record.id,
|
|
217
|
+
start,
|
|
218
|
+
end: end ?? void 0,
|
|
219
|
+
title,
|
|
220
|
+
color,
|
|
221
|
+
resourceId: groupKey,
|
|
222
|
+
allDay,
|
|
223
|
+
readOnly: opts.isReadOnly?.(record) ?? false
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function toWebApiPatch(change, map, opts) {
|
|
227
|
+
const patch = {};
|
|
228
|
+
const write = (value, behavior) => change.allDay && behavior !== DateTimeBehavior.DateOnly && kindOf(value) === "date" ? `${value}T00:00:00Z` : toWebApiDate(value, behavior, opts.zone);
|
|
229
|
+
const sb = behaviorFor(opts, map.start);
|
|
230
|
+
patch[map.start] = write(change.start, sb);
|
|
231
|
+
if (map.end && change.end !== void 0) {
|
|
232
|
+
const eb = behaviorFor(opts, map.end);
|
|
233
|
+
const end = change.allDay && eb === DateTimeBehavior.DateOnly ? exclusiveEndToInclusive(change.end) : change.end;
|
|
234
|
+
patch[map.end] = write(end, eb);
|
|
235
|
+
}
|
|
236
|
+
return patch;
|
|
237
|
+
}
|
|
238
|
+
function toQuickCreateParameters(selection, map, opts, extra = {}) {
|
|
239
|
+
const params = { ...extra };
|
|
240
|
+
const sb = behaviorFor(opts, map.start);
|
|
241
|
+
params[map.start] = toFormParameterDate(selection.start, sb, opts.zone);
|
|
242
|
+
if (map.end) {
|
|
243
|
+
const eb = behaviorFor(opts, map.end);
|
|
244
|
+
const end = selection.allDay && eb === DateTimeBehavior.DateOnly ? exclusiveEndToInclusive(selection.end) : selection.end;
|
|
245
|
+
params[map.end] = toFormParameterDate(end, eb, opts.zone);
|
|
246
|
+
}
|
|
247
|
+
if (map.allDay && selection.allDay) params[map.allDay] = true;
|
|
248
|
+
return params;
|
|
249
|
+
}
|
|
250
|
+
export {
|
|
251
|
+
DateTimeBehavior,
|
|
252
|
+
behaviorOf,
|
|
253
|
+
exclusiveEndToInclusive,
|
|
254
|
+
inclusiveEndToExclusive,
|
|
255
|
+
mapRecordToEvent,
|
|
256
|
+
readDataverseDate,
|
|
257
|
+
readYesNo,
|
|
258
|
+
toFormParameterDate,
|
|
259
|
+
toQuickCreateParameters,
|
|
260
|
+
toWebApiDate,
|
|
261
|
+
toWebApiPatch
|
|
262
|
+
};
|
|
263
|
+
//# sourceMappingURL=dataverse.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/datetime.ts","../src/dataverse/dates.ts","../src/core/colors.ts","../src/dataverse/mapping.ts"],"sourcesContent":["import type { CalendarValue, ValueKind, ZoneOffset } from './types';\n\n/**\n * Value-kind detection and zone conversion.\n *\n * ★★ Nothing in this file may read the PROCESS time zone. Every `Date` is built and read through\n * its UTC fields, so the same input gives the same output on a laptop in Auckland and a CI\n * runner in UTC. `npm test` runs the suite under three TZ values to prove it — a single-zone\n * run cannot see a leak, because the developer's zone is the one the code was written in.\n */\n\nconst DATE_RE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst FLOATING_RE = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.\\d{1,9})?)?$/;\nconst INSTANT_RE = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,9})?)?(?:Z|[+-]\\d{2}:?\\d{2})$/i;\n\nconst pad = (n: number, w = 2): string => String(n).padStart(w, '0');\n\n/** The browser's own zone, east-positive. The default when a host supplies none. */\nexport const browserZone: ZoneOffset = (instant) => -instant.getTimezoneOffset();\n\n/** A fixed zone (no daylight saving). Mostly for tests and demos. */\nexport const fixedZone =\n (minutesEast: number): ZoneOffset =>\n () =>\n minutesEast;\n\nexport function kindOf(value: CalendarValue | Date): ValueKind {\n if (value instanceof Date) {\n if (Number.isNaN(value.getTime())) throw new RangeError('Invalid Date');\n return 'instant';\n }\n const local = DATE_RE.test(value) ? 'date' : FLOATING_RE.test(value) ? 'floating' : null;\n if (local) {\n // ★ The regex accepts `2026-02-31`; Date.UTC would silently roll it to March 3rd. Reject\n // any date whose fields do not survive a round trip.\n const m = (FLOATING_RE.exec(value) ?? DATE_RE.exec(value))!;\n const [, y, mo, d, h = '0', mi = '0', sec = '0'] = m;\n const t = new Date(Date.UTC(+y, +mo - 1, +d, +h, +mi, +sec));\n if (t.getUTCFullYear() !== +y || t.getUTCMonth() !== +mo - 1 || t.getUTCDate() !== +d || +h > 23 || +mi > 59 || +sec > 59) {\n throw new RangeError(`Not a real calendar date or time: ${JSON.stringify(value)}`);\n }\n return local;\n }\n if (INSTANT_RE.test(value) && !Number.isNaN(new Date(value).getTime())) return 'instant';\n throw new RangeError(`Not an ISO-8601 date, wall-clock time or instant: ${JSON.stringify(value)}`);\n}\n\n/** An instant as canonical UTC ISO text (`…T…Z`, milliseconds kept). */\nexport function toInstant(value: CalendarValue | Date): CalendarValue {\n if (value instanceof Date) return value.toISOString();\n if (kindOf(value) !== 'instant') throw new RangeError(`Not an instant: ${value}`);\n return new Date(value).toISOString();\n}\n\n/** `Date.UTC` from wall-clock fields — i.e. the wall clock treated AS IF it were UTC. */\nfunction wallMillis(wall: string): number {\n const m = FLOATING_RE.exec(wall) ?? DATE_RE.exec(wall);\n if (!m) throw new RangeError(`Not a date or wall-clock time: ${wall}`);\n const [, y, mo, d, h = '0', mi = '0', s = '0'] = m;\n return Date.UTC(+y, +mo - 1, +d, +h, +mi, +s);\n}\n\nfunction formatWall(ms: number): string {\n const d = new Date(ms);\n return (\n `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}` +\n `T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`\n );\n}\n\n/** The wall-clock reading of an instant in `zone`, as floating text (`YYYY-MM-DDTHH:mm:ss`). */\nexport function toWall(instant: CalendarValue | Date, zone: ZoneOffset): CalendarValue {\n const at = instant instanceof Date ? instant : new Date(toInstant(instant));\n return formatWall(at.getTime() + zone(at) * 60_000);\n}\n\n/**\n * The instant at which `zone`'s clocks read `wall`.\n *\n * The offset depends on the instant being solved for, so this takes the offset in force a day\n * BEFORE and a day AFTER the wall reading (no zone changes offset twice in 48 h) and tries both:\n * - an ordinary time: both give the same instant;\n * - a wall time that exists TWICE (fall-back): both round-trip, and the EARLIER is returned;\n * - a wall time that DOES NOT EXIST (spring-forward gap): neither round-trips, and the\n * pre-transition offset is used, which pushes it forward by the gap (02:30 → 03:30), as JS\n * `Date` does. What Dataverse does with one is UNMEASURED.\n *\n * ★ A reviewer caught the first version returning the LATER occurrence east of UTC (Berlin) and\n * the earlier one west of it (Pacific): the two-pass guess settled on whichever offset the\n * first guess happened to land in. Tests now pin both hemispheres with synthetic zones.\n */\nexport function fromWall(wall: CalendarValue, zone: ZoneOffset): CalendarValue {\n const w = wallMillis(wall);\n const before = zone(new Date(w - 86_400_000));\n const after = zone(new Date(w + 86_400_000));\n const fits = (offset: number): number | null => {\n const t = w - offset * 60_000;\n return zone(new Date(t)) === offset ? t : null;\n };\n const candidates = [fits(before), fits(after)].filter((t): t is number => t !== null);\n const t = candidates.length > 0 ? Math.min(...candidates) : w - before * 60_000;\n return new Date(t).toISOString();\n}\n\n/** The calendar day (`YYYY-MM-DD`) of any value, in `zone` for instants. */\nexport function toDate(value: CalendarValue | Date, zone: ZoneOffset): CalendarValue {\n const k = kindOf(value);\n if (k === 'date') return value as string;\n if (k === 'floating') return (value as string).slice(0, 10);\n return toWall(value, zone).slice(0, 10);\n}\n\n/** Calendar-day arithmetic on a `YYYY-MM-DD` value (no zone involved). */\nexport function addDays(date: CalendarValue, days: number): CalendarValue {\n if (kindOf(date) !== 'date') throw new RangeError(`addDays needs a date, got ${date}`);\n return formatWall(wallMillis(date) + days * 86_400_000).slice(0, 10);\n}\n\n/**\n * The UTC fields of a `Date` as floating text. For reading a `Date` that some library has\n * produced in a \"UTC-as-wall-clock\" convention (FullCalendar with `timeZone: 'UTC'`).\n */\nexport function utcFieldsToWall(d: Date): CalendarValue {\n return formatWall(d.getTime());\n}\n\n/** Normalise floating text to seconds precision (`…T09:00` → `…T09:00:00`). */\nexport function normaliseFloating(value: CalendarValue): CalendarValue {\n return formatWall(wallMillis(value));\n}\n","import { addDays, fromWall, kindOf, normaliseFloating, toDate, toInstant, toWall } from '../core/datetime';\nimport type { CalendarValue, ZoneOffset } from '../core/types';\n\n/**\n * Dataverse's three DateTime behaviours, and the FOUR different shapes one value takes on its\n * way through a model-driven app. Every rule below was MEASURED on a live org (2026-09-26,\n * `spikes/calendar-view-fc7/FINDINGS.md` in the parent workspace); none is from documentation.\n *\n * ★★★ The two write paths are DIFFERENT CONTRACTS. The same text means different things to\n * `webAPI.updateRecord` and to `navigation.openForm` parameters:\n *\n * | behaviour | read (dataset getValue) | Web API write | form parameter (quick create) |\n * |------------|-----------------------------|------------------------|-------------------------------|\n * | UserLocal | `…T06:30:00.000Z` instant | instant `…Z` | wall clock, NO `Z` |\n * | DateOnly | `…T00:00:00.000Z` UTC-midn. | `YYYY-MM-DD` | `YYYY-MM-DDT00:00:00`, NO `Z` |\n * | TZI | `…T23:30:00.000Z` face+`Z` | wall clock WITH `Z` | wall clock, NO `Z` |\n *\n * Measured failures of the obvious choice, each of which a unit test here pins:\n * - a DateOnly read through `new Date()` lands on the PREVIOUS day anywhere west of UTC;\n * - a bare `YYYY-MM-DD` form parameter was stored as the previous day (Pacific user);\n * - a TZI form parameter WITH `Z` was treated as UTC and shifted −7 h.\n * The first two are why a well-known client control had a \"+1 day\" hack in its click handler.\n */\nexport const DateTimeBehavior = {\n UserLocal: 1,\n DateOnly: 2,\n TimeZoneIndependent: 3,\n} as const;\nexport type DateTimeBehavior = (typeof DateTimeBehavior)[keyof typeof DateTimeBehavior];\n\n/**\n * The behaviour of a column, from whatever metadata shape the host produced.\n *\n * ★ `getEntityMetadata` in a PCF host answers `Behavior: 1|2|3` (MEASURED). The Web API's\n * `EntityDefinitions` answers `DateTimeBehavior: { Value: 'UserLocal' }`. Both are accepted.\n * ★ A DateOnly column is also recognisable from its PCF `dataType` alone\n * (`DateAndTime.DateOnly`). TZI and UserLocal are NOT — both report `DateAndTime.DateAndTime` —\n * so without metadata a TZI column is indistinguishable and is treated as UserLocal. Callers\n * that can see that ambiguity should surface it (see `adapters/pcf-dataset`).\n */\nexport function behaviorOf(meta: unknown, dataType?: string): DateTimeBehavior {\n const m = (meta ?? {}) as { Behavior?: unknown; DateTimeBehavior?: { Value?: unknown } | string };\n if (m.Behavior === 1 || m.Behavior === 2 || m.Behavior === 3) return m.Behavior;\n const named = typeof m.DateTimeBehavior === 'string' ? m.DateTimeBehavior : m.DateTimeBehavior?.Value;\n if (named === 'DateOnly') return DateTimeBehavior.DateOnly;\n if (named === 'TimeZoneIndependent') return DateTimeBehavior.TimeZoneIndependent;\n if (named === 'UserLocal') return DateTimeBehavior.UserLocal;\n if (dataType === 'DateAndTime.DateOnly') return DateTimeBehavior.DateOnly;\n return DateTimeBehavior.UserLocal;\n}\n\nfunction rawText(raw: unknown): string | null {\n if (raw === null || raw === undefined || raw === '') return null;\n if (raw instanceof Date) return Number.isNaN(raw.getTime()) ? null : raw.toISOString();\n if (typeof raw === 'string') return raw;\n return null;\n}\n\n/**\n * A raw column value (dataset `getValue()`, or a Web API property) → a calendar value.\n *\n * ★★★ `getValue()` returns an ISO STRING for all three behaviours, despite\n * `@types/powerapps-component-framework` declaring `Date`. A `Date` is still accepted, because a\n * test double or another host may produce one — and it is read through its UTC fields, which is\n * what the platform's strings encode.\n */\nexport function readDataverseDate(raw: unknown, behavior: DateTimeBehavior): CalendarValue | null {\n const s = rawText(raw);\n if (s === null) return null;\n switch (behavior) {\n case DateTimeBehavior.DateOnly:\n // `2026-09-29T00:00:00.000Z` (dataset) or `2026-09-29` (Web API): the first ten characters\n // ARE the day. Never through `new Date()`.\n return s.slice(0, 10);\n case DateTimeBehavior.TimeZoneIndependent:\n // Face value with a misleading `Z`: the digits are the wall clock. Strip the offset rather\n // than slicing a fixed width — `…T23:30Z` (no seconds) would keep its `Z` at 19 chars.\n return normaliseFloating(s.replace(/(\\.\\d+)?(Z|[+-]\\d{2}:?\\d{2})$/i, ''));\n default:\n return toInstant(s);\n }\n}\n\n/**\n * A calendar value → the text `webAPI.updateRecord` / `createRecord` wants for this behaviour.\n * `zone` is needed only to turn a value of a different kind into this one (e.g. an all-day drop\n * onto a UserLocal column); same-kind values pass straight through.\n */\nexport function toWebApiDate(value: CalendarValue, behavior: DateTimeBehavior, zone: ZoneOffset): string {\n const k = kindOf(value);\n switch (behavior) {\n case DateTimeBehavior.DateOnly:\n return toDate(value, zone);\n case DateTimeBehavior.TimeZoneIndependent:\n // MEASURED: `…T13:00:00Z` stored and read back as a 1 PM face value.\n return `${k === 'instant' ? toWall(value, zone) : k === 'date' ? `${value}T00:00:00` : normaliseFloating(value)}Z`;\n default:\n return k === 'instant' ? toInstant(value) : fromWall(k === 'date' ? `${value}T00:00:00` : value, zone);\n }\n}\n\n/**\n * A calendar value → the text a `navigation.openForm` form PARAMETER wants (quick create\n * prefill). Wall clock in the user's zone, never with `Z`.\n *\n * ★ UNMEASURED: whether \"wall clock\" here means the Dynamics USER's zone or the BROWSER's when\n * they differ. Measured only with both in Pacific. Pass the user zone; if the org proof shows\n * the browser's is used, this is the one function to change.\n */\nexport function toFormParameterDate(value: CalendarValue, behavior: DateTimeBehavior, zone: ZoneOffset): string {\n const k = kindOf(value);\n if (behavior === DateTimeBehavior.DateOnly) return `${toDate(value, zone)}T00:00:00`;\n if (k === 'instant') return toWall(value, zone);\n if (k === 'date') return `${value}T00:00:00`;\n return normaliseFloating(value);\n}\n\n/** Dataverse stores an all-day END inclusive; the calendar's is exclusive. */\nexport const inclusiveEndToExclusive = (lastDay: CalendarValue): CalendarValue => addDays(lastDay, 1);\nexport const exclusiveEndToInclusive = (dayAfter: CalendarValue): CalendarValue => addDays(dayAfter, -1);\n","/**\n * Event colours.\n *\n * ★ Without FullCalendar Premium there are no resource lanes, so \"appointments by location\"\n * is expressed as ONE COLOUR PER GROUP. `groupColor` is deterministic (same key → same colour\n * on every load and every machine), which is what lets a person learn the legend.\n * ★ Every palette entry carries white text at >= 4.5:1 (WCAG AA, normal text) — asserted by a\n * test, not by eye. Host-supplied colours (Dataverse option colours are often pale) get their\n * text colour from `readableTextOn` instead of assuming white; a well-known client control\n * hard-coded white on yellow, which is ~1.4:1.\n */\nexport const GROUP_PALETTE: readonly string[] = [\n '#0f6cbd', // blue\n '#107c10', // green\n '#c50f1f', // red\n '#8764b8', // lavender\n '#ae4b00', // dark orange\n '#03787c', // teal\n '#4f52b2', // indigo\n '#8a5b00', // dark gold\n '#c0077d', // magenta\n '#5c2e91', // purple\n];\n\n/** FNV-1a — tiny, stable across engines, good enough spread for a 10-colour palette. */\nfunction hash(key: string): number {\n let h = 0x811c9dc5;\n for (let i = 0; i < key.length; i++) {\n h ^= key.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return h >>> 0;\n}\n\nexport function groupColor(key: string, palette: readonly string[] = GROUP_PALETTE): string {\n return palette[hash(key) % palette.length];\n}\n\n/** `#rgb` / `#rrggbb` → [r, g, b] 0-255, or null for anything else (named colours, var()). */\nexport function parseHex(color: string): [number, number, number] | null {\n const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim());\n if (!m) return null;\n const h = m[1].length === 3 ? m[1].replace(/./g, (c) => c + c) : m[1];\n return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16)) as [number, number, number];\n}\n\nfunction luminance([r, g, b]: [number, number, number]): number {\n const lin = (c: number): number => {\n const s = c / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);\n}\n\n/** WCAG contrast ratio between two hex colours, or null if either cannot be parsed. */\nexport function contrastRatio(a: string, b: string): number | null {\n const pa = parseHex(a);\n const pb = parseHex(b);\n if (!pa || !pb) return null;\n const [hi, lo] = [luminance(pa), luminance(pb)].sort((x, y) => y - x);\n return (hi + 0.05) / (lo + 0.05);\n}\n\n/**\n * Black or white text, whichever reads better on `background`. Unparseable backgrounds\n * (a CSS variable, a named colour) get `undefined`, i.e. the theme's own event text colour.\n */\nexport function readableTextOn(background: string): '#000000' | '#ffffff' | undefined {\n const onWhite = contrastRatio(background, '#ffffff');\n const onBlack = contrastRatio(background, '#000000');\n if (onWhite === null || onBlack === null) return undefined;\n return onWhite >= onBlack ? '#ffffff' : '#000000';\n}\n","import { groupColor, parseHex } from '../core/colors';\nimport { addDays, kindOf, toDate, toInstant, toWall } from '../core/datetime';\nimport type { CalendarEvent, CalendarEventChange, CalendarValue, SlotSelection, ZoneOffset } from '../core/types';\nimport {\n DateTimeBehavior,\n exclusiveEndToInclusive,\n inclusiveEndToExclusive,\n readDataverseDate,\n toFormParameterDate,\n toWebApiDate,\n} from './dates';\n\n/**\n * Which columns hold what. Logical names. Only `start` is required — that is the whole\n * genericity story: the same calendar shows Appointments for one client and Orders for another,\n * because a maker names the columns rather than a developer.\n */\nexport interface ColumnMap {\n start: string;\n end?: string;\n title?: string;\n /** A hex colour column, or a choice column whose option colours `colorOf` resolves. */\n color?: string;\n /** Location / staff / queue. Drives `resourceId` and, failing `color`, a group colour. */\n group?: string;\n /** A Yes/No column that forces all-day. */\n allDay?: string;\n}\n\n/** The minimum a record source must answer — a dataset record, a Web API row, a fixture. */\nexport interface RecordAccessor {\n id: string;\n value(column: string): unknown;\n formatted(column: string): string;\n}\n\nexport interface MapOptions {\n /** Behaviour per DATE column (logical name). Missing ⇒ UserLocal. */\n behaviors: Readonly<Record<string, DateTimeBehavior>>;\n zone: ZoneOffset;\n /** Resolve a colour column's value (e.g. choice option colours). Return undefined to fall back. */\n colorOf?: (column: string, raw: unknown, formatted: string) => string | undefined;\n /** Per-record read-only, e.g. a status that forbids rescheduling. */\n isReadOnly?: (record: RecordAccessor) => boolean;\n}\n\nconst behaviorFor = (opts: Pick<MapOptions, 'behaviors'>, column: string): DateTimeBehavior =>\n opts.behaviors[column] ?? DateTimeBehavior.UserLocal;\n\n/**\n * ★★ A Yes/No column's raw value in a PCF dataset is the STRING `\"0\"` / `\"1\"` — and\n * `Boolean(\"0\")` is `true`. MEASURED on a sibling gallery control, where every `false` row\n * rendered ON. Read the digits, never truthiness.\n */\nexport function readYesNo(raw: unknown): boolean {\n if (typeof raw === 'boolean') return raw;\n if (typeof raw === 'number') return raw === 1;\n if (typeof raw === 'string') return raw === '1' || raw.toLowerCase() === 'true';\n return false;\n}\n\n/**\n * ★★★ MEASURED (appointment, 2026-09-27): an event FLAGGED all-day on date-time columns stores its\n * calendar date at UTC MIDNIGHT — `2026-10-01T00:00:00Z`→`2026-10-02T00:00:00Z` for \"Oct 1\",\n * even though the columns are UserLocal and the user is in Pacific. The platform's own formatted\n * value then reads \"9/30 5:00 PM\"; the form shows Oct 1. Reading it through the user's zone put\n * a one-day appointment on Wed AND Thu. So a flagged all-day value's DAY is its UTC date.\n */\nfunction utcDayOf(value: CalendarValue): CalendarValue {\n return kindOf(value) === 'instant' ? toInstant(value).slice(0, 10) : value.slice(0, 10);\n}\nfunction utcExclusiveDayOf(end: CalendarValue): CalendarValue {\n const text = kindOf(end) === 'instant' ? toInstant(end) : end;\n return text.length > 10 && text.slice(11, 19) !== '00:00:00' ? addDays(text.slice(0, 10), 1) : text.slice(0, 10);\n}\n\n/** A date-time end → the exclusive day after the event, for an all-day rendering. */\nfunction exclusiveDayOf(end: CalendarValue, zone: ZoneOffset): CalendarValue {\n const day = toDate(end, zone);\n const wall = kindOf(end) === 'instant' ? toWall(end, zone) : end;\n // Ending exactly at midnight already means \"up to, not including, this day\".\n return wall.length > 10 && wall.slice(11, 19) === '00:00:00' ? day : addDays(day, 1);\n}\n\n/** One record → one event, or null when it has no usable start. */\nexport function mapRecordToEvent(record: RecordAccessor, map: ColumnMap, opts: MapOptions): CalendarEvent | null {\n const startBehavior = behaviorFor(opts, map.start);\n let start = readDataverseDate(record.value(map.start), startBehavior);\n if (start === null) return null;\n\n const endBehavior = map.end ? behaviorFor(opts, map.end) : startBehavior;\n let end = map.end ? readDataverseDate(record.value(map.end), endBehavior) : null;\n\n const forcedAllDay = map.allDay ? readYesNo(record.value(map.allDay)) : false;\n const allDay = forcedAllDay || kindOf(start) === 'date';\n\n if (allDay) {\n const flagged = forcedAllDay && startBehavior !== DateTimeBehavior.DateOnly;\n start = flagged ? utcDayOf(start) : toDate(start, opts.zone);\n if (end !== null) {\n end =\n endBehavior === DateTimeBehavior.DateOnly\n ? inclusiveEndToExclusive(end)\n : flagged\n ? utcExclusiveDayOf(end)\n : exclusiveDayOf(end, opts.zone);\n }\n if (end !== null && end <= start) end = addDays(start, 1);\n } else if (end !== null && kindOf(end) !== kindOf(start)) {\n // A timed start with a date-only end (mixed behaviours): not renderable as one span.\n end = null;\n } else if (end !== null && end <= start) {\n // A zero or negative duration renders as nothing in a time grid. Use the default length.\n end = null;\n }\n\n const title = (map.title ? record.formatted(map.title) : '') || '(untitled)';\n const groupKey = map.group ? record.formatted(map.group) || undefined : undefined;\n\n let color: string | undefined;\n if (map.color) {\n const raw = record.value(map.color);\n const formatted = record.formatted(map.color);\n color = opts.colorOf?.(map.color, raw, formatted);\n if (!color && typeof raw === 'string' && parseHex(raw)) color = raw;\n }\n if (!color && groupKey) color = groupColor(groupKey);\n\n return {\n id: record.id,\n start,\n end: end ?? undefined,\n title,\n color,\n resourceId: groupKey,\n allDay,\n readOnly: opts.isReadOnly?.(record) ?? false,\n };\n}\n\n/**\n * A move/resize → the column values to PATCH through the Web API.\n * Columns the map does not name are never written.\n */\nexport function toWebApiPatch(\n change: CalendarEventChange,\n map: ColumnMap,\n opts: Pick<MapOptions, 'behaviors' | 'zone'>\n): Record<string, string> {\n const patch: Record<string, string> = {};\n // ★★★ An all-day change on DATE-TIME columns is written at UTC midnight (the platform's own\n // convention for flagged all-day events — see utcDayOf), never at the user's midnight.\n const write = (value: CalendarValue, behavior: DateTimeBehavior): string =>\n change.allDay && behavior !== DateTimeBehavior.DateOnly && kindOf(value) === 'date'\n ? `${value}T00:00:00Z`\n : toWebApiDate(value, behavior, opts.zone);\n const sb = behaviorFor(opts, map.start);\n patch[map.start] = write(change.start, sb);\n if (map.end && change.end !== undefined) {\n const eb = behaviorFor(opts, map.end);\n const end = change.allDay && eb === DateTimeBehavior.DateOnly ? exclusiveEndToInclusive(change.end) : change.end;\n patch[map.end] = write(end, eb);\n }\n return patch;\n}\n\n/**\n * A selected empty range → quick-create form parameters. `extra` is merged underneath, so a\n * host can prefill a lookup (the parent record) without it being overwritten by dates.\n *\n * ★ The all-day column is set to boolean `true` for an all-day selection. The accepted shape of\n * a Yes/No FORM PARAMETER is UNMEASURED; the date shapes are measured.\n */\nexport function toQuickCreateParameters(\n selection: SlotSelection,\n map: ColumnMap,\n opts: Pick<MapOptions, 'behaviors' | 'zone'>,\n extra: Record<string, unknown> = {}\n): Record<string, unknown> {\n const params: Record<string, unknown> = { ...extra };\n const sb = behaviorFor(opts, map.start);\n params[map.start] = toFormParameterDate(selection.start, sb, opts.zone);\n if (map.end) {\n const eb = behaviorFor(opts, map.end);\n const end =\n selection.allDay && eb === DateTimeBehavior.DateOnly ? exclusiveEndToInclusive(selection.end) : selection.end;\n params[map.end] = toFormParameterDate(end, eb, opts.zone);\n }\n if (map.allDay && selection.allDay) params[map.allDay] = true;\n return params;\n}\n"],"mappings":";AAWA,IAAM,UAAU;AAChB,IAAM,cAAc;AACpB,IAAM,aAAa;AAEnB,IAAM,MAAM,CAAC,GAAW,IAAI,MAAc,OAAO,CAAC,EAAE,SAAS,GAAG,GAAG;AAW5D,SAAS,OAAO,OAAwC;AAC7D,MAAI,iBAAiB,MAAM;AACzB,QAAI,OAAO,MAAM,MAAM,QAAQ,CAAC,EAAG,OAAM,IAAI,WAAW,cAAc;AACtE,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,QAAQ,KAAK,KAAK,IAAI,SAAS,YAAY,KAAK,KAAK,IAAI,aAAa;AACpF,MAAI,OAAO;AAGT,UAAM,IAAK,YAAY,KAAK,KAAK,KAAK,QAAQ,KAAK,KAAK;AACxD,UAAM,CAAC,EAAE,GAAG,IAAI,GAAG,IAAI,KAAK,KAAK,KAAK,MAAM,GAAG,IAAI;AACnD,UAAM,IAAI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