@carlonicora/nextjs-jsonapi 6.24.0 → 6.26.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/dist/{BlockNoteEditor-MONT74RQ.js → BlockNoteEditor-JHXDOCS5.js} +28 -25
- package/dist/BlockNoteEditor-JHXDOCS5.js.map +1 -0
- package/dist/{BlockNoteEditor-ENDOVTAW.mjs → BlockNoteEditor-RVDSB6TF.mjs} +13 -10
- package/dist/{BlockNoteEditor-ENDOVTAW.mjs.map → BlockNoteEditor-RVDSB6TF.mjs.map} +1 -1
- package/dist/{BlockNoteViewer-2TJZ6JET.mjs → BlockNoteViewer-76CKL6W5.mjs} +8 -6
- package/dist/{BlockNoteViewer-2TJZ6JET.mjs.map → BlockNoteViewer-76CKL6W5.mjs.map} +1 -1
- package/dist/{BlockNoteViewer-K2HBF3IP.js → BlockNoteViewer-B25WKYQP.js} +9 -7
- package/dist/BlockNoteViewer-B25WKYQP.js.map +1 -0
- package/dist/JsonApiRequest-OKNQZLS6.js +26 -0
- package/dist/{JsonApiRequest-KC6DOHKT.js.map → JsonApiRequest-OKNQZLS6.js.map} +1 -1
- package/dist/{JsonApiRequest-ADLBJ5RX.mjs → JsonApiRequest-WNPDS356.mjs} +2 -2
- package/dist/billing/index.js +504 -517
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +20 -33
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-VNUT2D27.mjs → chunk-2PWYG2WJ.mjs} +2 -2
- package/dist/{chunk-W4ML6D2X.mjs → chunk-3U7YJ73T.mjs} +7 -7
- package/dist/{chunk-BQ2WAG4K.js → chunk-3VNDFKT7.js} +19 -19
- package/dist/{chunk-BQ2WAG4K.js.map → chunk-3VNDFKT7.js.map} +1 -1
- package/dist/{chunk-BE6UMM5X.mjs → chunk-47HNJQ7U.mjs} +3 -3
- package/dist/chunk-5T2AQMQ2.mjs +90 -0
- package/dist/chunk-5T2AQMQ2.mjs.map +1 -0
- package/dist/{chunk-A5M3MORY.js → chunk-5WM72MLE.js} +3 -3
- package/dist/{chunk-A5M3MORY.js.map → chunk-5WM72MLE.js.map} +1 -1
- package/dist/{chunk-OZADFYE7.mjs → chunk-64REWDSK.mjs} +308 -241
- package/dist/chunk-64REWDSK.mjs.map +1 -0
- package/dist/{chunk-S7SPAC6X.mjs → chunk-73NKUBMP.mjs} +3 -3
- package/dist/chunk-743M4TIB.mjs +76 -0
- package/dist/chunk-743M4TIB.mjs.map +1 -0
- package/dist/{chunk-HN7L6RRW.js → chunk-77JC2UCF.js} +903 -955
- package/dist/chunk-77JC2UCF.js.map +1 -0
- package/dist/{chunk-7OIWOPM5.mjs → chunk-7MGXQIEP.mjs} +4 -3
- package/dist/chunk-7MGXQIEP.mjs.map +1 -0
- package/dist/{chunk-YTDGYI62.mjs → chunk-DWPHHUMV.mjs} +3 -3
- package/dist/{chunk-SO3YUCL6.js → chunk-F3EVYBMA.js} +6 -5
- package/dist/chunk-F3EVYBMA.js.map +1 -0
- package/dist/{chunk-53SD4YRF.js → chunk-FBHUUPRV.js} +5 -5
- package/dist/{chunk-53SD4YRF.js.map → chunk-FBHUUPRV.js.map} +1 -1
- package/dist/{chunk-T6G2F2BK.mjs → chunk-FJUKLVVX.mjs} +16 -68
- package/dist/chunk-FJUKLVVX.mjs.map +1 -0
- package/dist/chunk-HROKKUBQ.js +156 -0
- package/dist/chunk-HROKKUBQ.js.map +1 -0
- package/dist/{chunk-BDWV4KYR.js → chunk-JE6QWCNE.js} +1386 -1319
- package/dist/chunk-JE6QWCNE.js.map +1 -0
- package/dist/{chunk-RCOKQ3R4.js → chunk-LNO2JLU3.js} +2 -2
- package/dist/{chunk-RCOKQ3R4.js.map → chunk-LNO2JLU3.js.map} +1 -1
- package/dist/{chunk-TMV7TL7O.mjs → chunk-M7YK5CCE.mjs} +8 -6
- package/dist/{chunk-TMV7TL7O.mjs.map → chunk-M7YK5CCE.mjs.map} +1 -1
- package/dist/{chunk-GMMDXINC.js → chunk-N3NQS7X6.js} +12 -12
- package/dist/{chunk-GMMDXINC.js.map → chunk-N3NQS7X6.js.map} +1 -1
- package/dist/chunk-NP3AFULU.js +76 -0
- package/dist/chunk-NP3AFULU.js.map +1 -0
- package/dist/{chunk-TNTCLVUR.js → chunk-ONU4WCDG.js} +17 -15
- package/dist/chunk-ONU4WCDG.js.map +1 -0
- package/dist/{chunk-YSE2Z4RB.js → chunk-PQQFOONG.js} +12 -12
- package/dist/{chunk-YSE2Z4RB.js.map → chunk-PQQFOONG.js.map} +1 -1
- package/dist/chunk-RW6XZGZG.mjs +156 -0
- package/dist/chunk-RW6XZGZG.mjs.map +1 -0
- package/dist/chunk-SYMI4IDW.js +90 -0
- package/dist/chunk-SYMI4IDW.js.map +1 -0
- package/dist/{chunk-N2BFT7KI.mjs → chunk-W7U6O3OE.mjs} +2 -71
- package/dist/chunk-W7U6O3OE.mjs.map +1 -0
- package/dist/{chunk-YMCL3JXZ.mjs → chunk-YPBIPE2B.mjs} +2 -2
- package/dist/{chunk-P7L6OFX5.js → chunk-Z6T2575A.js} +12 -81
- package/dist/chunk-Z6T2575A.js.map +1 -0
- package/dist/client/index.js +13 -10
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +17 -14
- package/dist/components/forms/DatePickerPopover.d.ts.map +1 -1
- package/dist/components/forms/DateRangeSelector.d.ts.map +1 -1
- package/dist/components/forms/FormDate.d.ts.map +1 -1
- package/dist/components/forms/FormDateTime.d.ts.map +1 -1
- package/dist/components/forms/time-cycle.d.ts +14 -0
- package/dist/components/forms/time-cycle.d.ts.map +1 -0
- package/dist/components/index.js +11 -8
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -7
- package/dist/components/tables/cells/cell.date.d.ts.map +1 -1
- package/dist/components/tables/cells/cell.dateTime.d.ts.map +1 -1
- package/dist/contexts/DateLocaleContext.d.ts +56 -0
- package/dist/contexts/DateLocaleContext.d.ts.map +1 -0
- package/dist/contexts/index.d.ts +1 -0
- package/dist/contexts/index.d.ts.map +1 -1
- package/dist/contexts/index.js +24 -8
- package/dist/contexts/index.js.map +1 -1
- package/dist/contexts/index.mjs +23 -7
- package/dist/core/index.js +17 -6
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +19 -8
- package/dist/date-locale/index.d.ts +2 -0
- package/dist/date-locale/index.d.ts.map +1 -0
- package/dist/date-locale/index.js +21 -0
- package/dist/date-locale/index.js.map +1 -0
- package/dist/date-locale/index.mjs +21 -0
- package/dist/email-automations/index.js +131 -123
- package/dist/email-automations/index.js.map +1 -1
- package/dist/email-automations/index.mjs +23 -15
- package/dist/email-automations/index.mjs.map +1 -1
- package/dist/features/account-deletion/components/AccountDeletionAdminTrigger.d.ts.map +1 -1
- package/dist/features/analytics/components/AnalyticsJourneyContainer.d.ts.map +1 -1
- package/dist/features/analytics/components/AnalyticsSessionsTable.d.ts.map +1 -1
- package/dist/features/analytics/index.js +154 -147
- package/dist/features/analytics/index.js.map +1 -1
- package/dist/features/analytics/index.mjs +32 -25
- package/dist/features/analytics/index.mjs.map +1 -1
- package/dist/features/analytics/server.js +11 -9
- package/dist/features/analytics/server.js.map +1 -1
- package/dist/features/analytics/server.mjs +9 -7
- package/dist/features/analytics/server.mjs.map +1 -1
- package/dist/features/billing/components/utils/date.d.ts +3 -3
- package/dist/features/billing/components/utils/format-options.d.ts +6 -4
- package/dist/features/billing/components/utils/format-options.d.ts.map +1 -1
- package/dist/features/billing/components/utils/useBillingFormatOptions.d.ts +5 -1
- package/dist/features/billing/components/utils/useBillingFormatOptions.d.ts.map +1 -1
- package/dist/features/billing/stripe-usage/components/details/UsageSummaryCard.d.ts.map +1 -1
- package/dist/features/billing/stripe-usage/components/lists/UsageHistoryTable.d.ts.map +1 -1
- package/dist/features/blog/components/admin/BlogTranslationStatus.d.ts.map +1 -1
- package/dist/features/blog/components/public/BlogPostMeta.d.ts.map +1 -1
- package/dist/features/blog/hooks/useBlogPostTableStructure.d.ts.map +1 -1
- package/dist/features/blog/index.js +168 -162
- package/dist/features/blog/index.js.map +1 -1
- package/dist/features/blog/index.mjs +25 -19
- package/dist/features/blog/index.mjs.map +1 -1
- package/dist/features/blog/server.js +29 -27
- package/dist/features/blog/server.js.map +1 -1
- package/dist/features/blog/server.mjs +8 -6
- package/dist/features/blog/server.mjs.map +1 -1
- package/dist/features/email-automation/hooks/useEmailAutomationEnrollmentTableStructure.d.ts.map +1 -1
- package/dist/features/handbook/components/parts/HandbookIndexStatus.d.ts.map +1 -1
- package/dist/features/help/components/HelpArticleBody.d.ts.map +1 -1
- package/dist/features/help/index.js +48 -43
- package/dist/features/help/index.js.map +1 -1
- package/dist/features/help/index.mjs +15 -10
- package/dist/features/help/index.mjs.map +1 -1
- package/dist/features/notification/components/notifications/Notification.d.ts +2 -1
- package/dist/features/notification/components/notifications/Notification.d.ts.map +1 -1
- package/dist/features/notification/contexts/NotificationContext.d.ts.map +1 -1
- package/dist/features/notification/hooks/useNotificationTableStructure.d.ts.map +1 -1
- package/dist/features/oauth/components/OAuthClientCard.d.ts.map +1 -1
- package/dist/features/oauth/components/OAuthClientDetail.d.ts.map +1 -1
- package/dist/features/tokenusage/index.js +133 -130
- package/dist/features/tokenusage/index.js.map +1 -1
- package/dist/features/tokenusage/index.mjs +10 -7
- package/dist/features/tokenusage/index.mjs.map +1 -1
- package/dist/features/tokenusage/lib/formatters.d.ts +6 -3
- package/dist/features/tokenusage/lib/formatters.d.ts.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -11
- package/dist/local-transport-AT4TE264.js +15 -0
- package/dist/{local-transport-MJPOKPTU.js.map → local-transport-AT4TE264.js.map} +1 -1
- package/dist/{local-transport-RVD4FZGA.mjs → local-transport-KWEUZ4GX.mjs} +5 -5
- package/dist/offline/index.js +56 -54
- package/dist/offline/index.js.map +1 -1
- package/dist/offline/index.mjs +23 -21
- package/dist/offline/index.mjs.map +1 -1
- package/dist/{request-4AWGPIGH.mjs → request-6GAIWWTG.mjs} +2 -2
- package/dist/{request-H5FZBZA2.js → request-BWO4Y434.js} +3 -3
- package/dist/{request-H5FZBZA2.js.map → request-BWO4Y434.js.map} +1 -1
- package/dist/server/ServerSession.d.ts +2 -0
- package/dist/server/ServerSession.d.ts.map +1 -1
- package/dist/server/index.js +10 -8
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +9 -7
- package/dist/utils/date-formatter.d.ts +45 -4
- package/dist/utils/date-formatter.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/toast.d.ts +2 -0
- package/dist/utils/toast.d.ts.map +1 -1
- package/dist/write-through-KNRI5L4V.mjs +15 -0
- package/dist/write-through-KNRI5L4V.mjs.map +1 -0
- package/dist/write-through-MYHQ6GJU.js +15 -0
- package/dist/{write-through-HE2QSOVI.js.map → write-through-MYHQ6GJU.js.map} +1 -1
- package/messages/en.json +1 -0
- package/messages/it.json +1 -0
- package/package.json +6 -1
- package/src/components/forms/DatePickerPopover.tsx +5 -3
- package/src/components/forms/DateRangeSelector.tsx +9 -7
- package/src/components/forms/FormDate.tsx +5 -3
- package/src/components/forms/FormDateTime.tsx +75 -39
- package/src/components/forms/__tests__/time-cycle.spec.ts +37 -0
- package/src/components/forms/time-cycle.ts +27 -0
- package/src/components/tables/cells/cell.date.tsx +3 -5
- package/src/components/tables/cells/cell.dateTime.tsx +3 -7
- package/src/contexts/DateLocaleContext.tsx +106 -0
- package/src/contexts/__tests__/DateLocaleContext.spec.tsx +175 -0
- package/src/contexts/index.ts +1 -0
- package/src/date-locale/index.ts +12 -0
- package/src/features/account-deletion/components/AccountDeletionAdminTrigger.tsx +3 -4
- package/src/features/analytics/components/AnalyticsJourneyContainer.tsx +8 -8
- package/src/features/analytics/components/AnalyticsSessionsTable.tsx +4 -6
- package/src/features/auth/components/two-factor/PasskeyList.tsx +3 -3
- package/src/features/auth/components/two-factor/TotpAuthenticatorList.tsx +3 -3
- package/src/features/billing/components/utils/__tests__/billing-formatters.spec.ts +14 -6
- package/src/features/billing/components/utils/date.ts +5 -5
- package/src/features/billing/components/utils/format-options.ts +6 -4
- package/src/features/billing/components/utils/useBillingFormatOptions.ts +8 -2
- package/src/features/billing/stripe-usage/components/details/UsageSummaryCard.tsx +4 -12
- package/src/features/billing/stripe-usage/components/lists/UsageHistoryTable.tsx +4 -17
- package/src/features/blog/components/admin/BlogTranslationStatus.tsx +3 -2
- package/src/features/blog/components/public/BlogPostMeta.tsx +5 -4
- package/src/features/blog/components/public/__tests__/BlogList.spec.tsx +1 -2
- package/src/features/blog/components/public/__tests__/BlogPostView.spec.tsx +2 -3
- package/src/features/blog/hooks/useBlogPostTableStructure.tsx +4 -8
- package/src/features/email-automation/hooks/useEmailAutomationEnrollmentTableStructure.tsx +11 -5
- package/src/features/email-blast/components/containers/EmailBlastContainer.tsx +3 -3
- package/src/features/email-blast/hooks/useEmailBlastTableStructure.tsx +4 -4
- package/src/features/handbook/components/parts/HandbookIndexStatus.tsx +4 -3
- package/src/features/help/components/HelpArticleBody.tsx +4 -3
- package/src/features/notification/components/notifications/Notification.tsx +38 -7
- package/src/features/notification/contexts/NotificationContext.tsx +6 -3
- package/src/features/notification/hooks/useNotificationTableStructure.tsx +6 -5
- package/src/features/oauth/components/OAuthClientCard.tsx +8 -5
- package/src/features/oauth/components/OAuthClientDetail.tsx +3 -6
- package/src/features/tokenusage/lib/__tests__/formatters.spec.ts +19 -0
- package/src/features/tokenusage/lib/formatters.ts +11 -6
- package/src/features/waitlist/hooks/useWaitlistTableStructure.tsx +5 -5
- package/src/server/ServerSession.ts +3 -0
- package/src/server/__tests__/ServerSession.read.spec.ts +18 -1
- package/src/utils/__tests__/date-formatter.spec.ts +134 -10
- package/src/utils/__tests__/toast.spec.ts +39 -0
- package/src/utils/date-formatter.ts +200 -44
- package/src/utils/index.ts +11 -1
- package/src/utils/toast.ts +2 -0
- package/dist/BlockNoteEditor-MONT74RQ.js.map +0 -1
- package/dist/BlockNoteViewer-K2HBF3IP.js.map +0 -1
- package/dist/JsonApiRequest-KC6DOHKT.js +0 -26
- package/dist/chunk-7OIWOPM5.mjs.map +0 -1
- package/dist/chunk-BDWV4KYR.js.map +0 -1
- package/dist/chunk-HN7L6RRW.js.map +0 -1
- package/dist/chunk-N2BFT7KI.mjs.map +0 -1
- package/dist/chunk-OZADFYE7.mjs.map +0 -1
- package/dist/chunk-P7L6OFX5.js.map +0 -1
- package/dist/chunk-SO3YUCL6.js.map +0 -1
- package/dist/chunk-T6G2F2BK.mjs.map +0 -1
- package/dist/chunk-TNTCLVUR.js.map +0 -1
- package/dist/local-transport-MJPOKPTU.js +0 -15
- package/dist/write-through-7I3LA2WN.mjs +0 -15
- package/dist/write-through-HE2QSOVI.js +0 -15
- /package/dist/{JsonApiRequest-ADLBJ5RX.mjs.map → JsonApiRequest-WNPDS356.mjs.map} +0 -0
- /package/dist/{chunk-VNUT2D27.mjs.map → chunk-2PWYG2WJ.mjs.map} +0 -0
- /package/dist/{chunk-W4ML6D2X.mjs.map → chunk-3U7YJ73T.mjs.map} +0 -0
- /package/dist/{chunk-BE6UMM5X.mjs.map → chunk-47HNJQ7U.mjs.map} +0 -0
- /package/dist/{chunk-S7SPAC6X.mjs.map → chunk-73NKUBMP.mjs.map} +0 -0
- /package/dist/{chunk-YTDGYI62.mjs.map → chunk-DWPHHUMV.mjs.map} +0 -0
- /package/dist/{chunk-YMCL3JXZ.mjs.map → chunk-YPBIPE2B.mjs.map} +0 -0
- /package/dist/{local-transport-RVD4FZGA.mjs.map → date-locale/index.mjs.map} +0 -0
- /package/dist/{request-4AWGPIGH.mjs.map → local-transport-KWEUZ4GX.mjs.map} +0 -0
- /package/dist/{write-through-7I3LA2WN.mjs.map → request-6GAIWWTG.mjs.map} +0 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
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
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk77JC2UCFjs = require('./chunk-77JC2UCF.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
var _chunkZ6T2575Ajs = require('./chunk-Z6T2575A.js');
|
|
7
8
|
|
|
8
|
-
var _chunkP7L6OFX5js = require('./chunk-P7L6OFX5.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
var _chunkLNO2JLU3js = require('./chunk-LNO2JLU3.js');
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
var _chunkNP3AFULUjs = require('./chunk-NP3AFULU.js');
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
|
|
@@ -38,7 +40,7 @@ function configureJsonApi(config) {
|
|
|
38
40
|
_setStaticHelpContent(helpContent);
|
|
39
41
|
}
|
|
40
42
|
if (config.bootstrapper) {
|
|
41
|
-
|
|
43
|
+
_chunkLNO2JLU3js.setBootstrapper.call(void 0, config.bootstrapper);
|
|
42
44
|
config.bootstrapper();
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -51,19 +53,19 @@ function getApiUrl() {
|
|
|
51
53
|
if (_optionalChain([_clientConfig, 'optionalAccess', _ => _.apiUrl])) {
|
|
52
54
|
return _clientConfig.apiUrl;
|
|
53
55
|
}
|
|
54
|
-
return
|
|
56
|
+
return _chunkLNO2JLU3js.ENV.API_URL;
|
|
55
57
|
}
|
|
56
58
|
_chunk7QVYU63Ejs.__name.call(void 0, getApiUrl, "getApiUrl");
|
|
57
59
|
function getPublicApiUrl() {
|
|
58
|
-
return
|
|
60
|
+
return _chunkLNO2JLU3js.ENV.API_URL;
|
|
59
61
|
}
|
|
60
62
|
_chunk7QVYU63Ejs.__name.call(void 0, getPublicApiUrl, "getPublicApiUrl");
|
|
61
63
|
function getAppUrl() {
|
|
62
64
|
if (_optionalChain([_clientConfig, 'optionalAccess', _2 => _2.appUrl])) {
|
|
63
65
|
return _clientConfig.appUrl;
|
|
64
66
|
}
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
67
|
+
if (_chunkLNO2JLU3js.ENV.APP_URL_ALTERNATE) {
|
|
68
|
+
return _chunkLNO2JLU3js.ENV.APP_URL_ALTERNATE;
|
|
67
69
|
}
|
|
68
70
|
if (typeof window !== "undefined") {
|
|
69
71
|
return window.location.origin;
|
|
@@ -126,7 +128,7 @@ function getWaitlistConfig() {
|
|
|
126
128
|
}
|
|
127
129
|
_chunk7QVYU63Ejs.__name.call(void 0, getWaitlistConfig, "getWaitlistConfig");
|
|
128
130
|
function useWaitlistText() {
|
|
129
|
-
const t =
|
|
131
|
+
const t = _chunkNP3AFULUjs.useI18nTranslations.call(void 0, );
|
|
130
132
|
const translate = getWaitlistConfig().translate === true;
|
|
131
133
|
return (value) => {
|
|
132
134
|
if (!value) return void 0;
|
|
@@ -264,7 +266,7 @@ var COMPANY_ADMINISTRATOR_ROLE_ID = "2e1eee00-6cba-4506-9059-ccd24e4ea5b0";
|
|
|
264
266
|
var ACTION_TYPES = ["read", "create", "update", "delete"];
|
|
265
267
|
|
|
266
268
|
// src/features/rbac/data/RbacService.ts
|
|
267
|
-
var RbacService = class extends
|
|
269
|
+
var RbacService = class extends _chunk77JC2UCFjs.AbstractService {
|
|
268
270
|
static {
|
|
269
271
|
_chunk7QVYU63Ejs.__name.call(void 0, this, "RbacService");
|
|
270
272
|
}
|
|
@@ -275,9 +277,9 @@ var RbacService = class extends _chunkHN7L6RRWjs.AbstractService {
|
|
|
275
277
|
* Dev-only endpoint — see class header.
|
|
276
278
|
*/
|
|
277
279
|
static async fetchMatrix() {
|
|
278
|
-
const endpoint = new (0,
|
|
280
|
+
const endpoint = new (0, _chunkZ6T2575Ajs.EndpointCreator)({ endpoint: _chunkZ6T2575Ajs.Modules.RbacMatrix }).generate();
|
|
279
281
|
const model = await this.callApi({
|
|
280
|
-
type:
|
|
282
|
+
type: _chunkZ6T2575Ajs.Modules.RbacMatrix,
|
|
281
283
|
method: "GET" /* GET */,
|
|
282
284
|
endpoint
|
|
283
285
|
});
|
|
@@ -297,9 +299,9 @@ var RbacService = class extends _chunkHN7L6RRWjs.AbstractService {
|
|
|
297
299
|
* Dev-only endpoint — see class header.
|
|
298
300
|
*/
|
|
299
301
|
static async saveMatrix(args) {
|
|
300
|
-
const endpoint = new (0,
|
|
302
|
+
const endpoint = new (0, _chunkZ6T2575Ajs.EndpointCreator)({ endpoint: _chunkZ6T2575Ajs.Modules.RbacMatrix }).generate();
|
|
301
303
|
const model = await this.callApi({
|
|
302
|
-
type:
|
|
304
|
+
type: _chunkZ6T2575Ajs.Modules.RbacMatrix,
|
|
303
305
|
method: "PUT" /* PUT */,
|
|
304
306
|
endpoint,
|
|
305
307
|
input: args
|
|
@@ -342,4 +344,4 @@ var RbacService = class extends _chunkHN7L6RRWjs.AbstractService {
|
|
|
342
344
|
|
|
343
345
|
|
|
344
346
|
exports._getStaticHelpContent = _getStaticHelpContent; exports.configureJsonApi = configureJsonApi; exports.configureClientConfig = configureClientConfig; exports.getApiUrl = getApiUrl; exports.getPublicApiUrl = getPublicApiUrl; exports.getAppUrl = getAppUrl; exports.getTrackablePages = getTrackablePages; exports.getStripePublishableKey = getStripePublishableKey; exports.configureLogin = configureLogin; exports.isDiscordAuthEnabled = isDiscordAuthEnabled; exports.isGoogleAuthEnabled = isGoogleAuthEnabled; exports.isInternalAuthEnabled = isInternalAuthEnabled; exports.isRegistrationAllowed = isRegistrationAllowed; exports.getRegistrationMode = getRegistrationMode; exports.configureWaitlist = configureWaitlist; exports.getWaitlistConfig = getWaitlistConfig; exports.useWaitlistText = useWaitlistText; exports.configureReferral = configureReferral; exports.getReferralConfig = getReferralConfig; exports.isReferralEnabled = isReferralEnabled; exports.SIGNUP_SOURCE_COOKIE = SIGNUP_SOURCE_COOKIE; exports.SIGNUP_SOURCE_COOKIE_MAX_AGE = SIGNUP_SOURCE_COOKIE_MAX_AGE; exports.SIGNUP_SOURCE_FIELDS = SIGNUP_SOURCE_FIELDS; exports.readSignupSourceFromLocation = readSignupSourceFromLocation; exports.captureSignupSource = captureSignupSource; exports.getSignupSource = getSignupSource; exports.COMPANY_ADMINISTRATOR_ROLE_ID = COMPANY_ADMINISTRATOR_ROLE_ID; exports.ACTION_TYPES = ACTION_TYPES; exports.RbacService = RbacService;
|
|
345
|
-
//# sourceMappingURL=chunk-
|
|
347
|
+
//# sourceMappingURL=chunk-ONU4WCDG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-ONU4WCDG.js","../src/core/registry/helpStore.ts","../src/client/config.ts","../src/login/config.ts","../src/features/waitlist/config/waitlist.config.ts","../src/features/referral/config.ts","../src/features/signup-source/signup-source.ts","../src/features/rbac/data/RbacTypes.ts","../src/features/rbac/data/RbacService.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACPA,IAAM,iBAAA,kBAAmB,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AAEhE,IAAM,YAAA,EAAc,UAAA;AAIpB,GAAA,CAAI,WAAA,CAAY,gBAAgB,EAAA,IAAM,KAAA,CAAA,EAAW;AAC/C,EAAA,WAAA,CAAY,gBAAgB,EAAA,EAAI,IAAA;AAClC;AAEO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sourcesContent":[null,"/**\n * Centralized help-content store accessible from client and server contexts.\n * Uses a globalThis Symbol key to persist across HMR/Turbopack reloads and to\n * bridge between the client-side `configureJsonApi` (in `client/config.ts`)\n * and the HelpProvider context. Holds the brand-only HelpContentConfig.\n *\n * NO external dependencies to avoid circular imports.\n *\n * Pattern mirrors `bootstrapStore.ts`.\n */\n\nconst HELP_CONTENT_KEY = Symbol.for(\"nextjs-jsonapi:helpContent\");\n\nconst globalStore = globalThis as unknown as {\n [HELP_CONTENT_KEY]?: unknown | null;\n};\n\nif (globalStore[HELP_CONTENT_KEY] === undefined) {\n globalStore[HELP_CONTENT_KEY] = null;\n}\n\nexport function _setStaticHelpContent(cfg: unknown | null): void {\n globalStore[HELP_CONTENT_KEY] = cfg;\n}\n\nexport function _getStaticHelpContent<T = unknown>(): T | null {\n return (globalStore[HELP_CONTENT_KEY] as T | null) ?? null;\n}\n","\"use client\";\n\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { ENV } from \"../core/env\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\nimport { _setStaticHelpContent } from \"../core/registry/helpStore\";\nimport type { HelpContentConfig } from \"../features/help/interfaces/help-content-config.interface\";\n\n// Config storage for client-side contexts\nlet _clientConfig: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n stripePublishableKey?: string;\n} | null = null;\n\n/**\n * Configure the JSON:API client. This is the main configuration function.\n * This is typically called during app initialization.\n * @param config.helpContent - Optional help-content config (brand only). Forwarded to the help feature's globalThis-backed store; not stored on the client config.\n */\nexport function configureJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n stripePublishableKey?: string;\n helpContent?: HelpContentConfig;\n}): void {\n const { helpContent, ...rest } = config;\n _clientConfig = rest;\n if (helpContent) {\n _setStaticHelpContent(helpContent);\n }\n // Register and call bootstrapper to register all modules\n if (config.bootstrapper) {\n setBootstrapper(config.bootstrapper);\n config.bootstrapper();\n }\n}\n\n/**\n * Configure the client config. This is typically called during app initialization.\n * @deprecated Use configureJsonApi instead\n */\nexport function configureClientConfig(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n}): void {\n _clientConfig = config;\n}\n\n/**\n * Get the configured API URL.\n *\n * This may resolve to an internal/private host (e.g. a docker-network\n * hostname) when configured to do so for SSR fetches. Do NOT use this for\n * URLs that are rendered into HTML and followed by the browser — use\n * `getPublicApiUrl()` instead.\n */\nexport function getApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n return ENV.API_URL;\n}\n\n/**\n * Get the public-facing API URL.\n *\n * Always sourced from `NEXT_PUBLIC_API_URL` so it is identical on server\n * and client, and reachable from the user's browser. Use for any URL that\n * gets rendered into HTML the browser will navigate to (links, redirects,\n * OAuth hrefs).\n */\nexport function getPublicApiUrl(): string {\n return ENV.API_URL;\n}\n\n/**\n * Get the configured app URL.\n */\nexport function getAppUrl(): string {\n if (_clientConfig?.appUrl) {\n return _clientConfig.appUrl;\n }\n if (ENV.APP_URL_ALTERNATE) {\n return ENV.APP_URL_ALTERNATE;\n }\n if (typeof window !== \"undefined\") {\n return window.location.origin;\n }\n return \"\";\n}\n\n/**\n * Get the configured trackable pages.\n */\nexport function getTrackablePages(): ModuleWithPermissions[] {\n return _clientConfig?.trackablePages ?? [];\n}\n\n/**\n * Get the configured Stripe publishable key.\n */\nexport function getStripePublishableKey(): string | undefined {\n return _clientConfig?.stripePublishableKey;\n}\n","let _useDiscordAuth: boolean = false;\nlet _useGoogleAuth: boolean = false;\nlet _useInternalAuth: boolean = true;\nlet _allowRegistration: boolean = true;\nlet _registrationMode: \"open\" | \"closed\" | \"waitlist\" = \"open\";\n\nexport type RegistrationMode = \"open\" | \"closed\" | \"waitlist\";\n\nexport interface LoginConfig {\n discordClientId?: string;\n googleClientId?: string;\n useInternalAuth?: boolean;\n allowRegistration?: boolean;\n registrationMode?: RegistrationMode;\n}\n\nexport function configureLogin(params: LoginConfig): void {\n _useDiscordAuth = !!params.discordClientId;\n _useGoogleAuth = !!params.googleClientId;\n _useInternalAuth = params.useInternalAuth ?? true;\n _allowRegistration = params.allowRegistration ?? true;\n _registrationMode = params.registrationMode ?? \"open\";\n}\n\nexport function isDiscordAuthEnabled(): boolean {\n return _useDiscordAuth;\n}\n\nexport function isGoogleAuthEnabled(): boolean {\n return _useGoogleAuth;\n}\n\nexport function isInternalAuthEnabled(): boolean {\n return _useInternalAuth;\n}\n\nexport function isRegistrationAllowed(): boolean {\n return _allowRegistration;\n}\n\nexport function getRegistrationMode(): RegistrationMode {\n return _registrationMode;\n}\n","import { useI18nTranslations } from \"../../../i18n\";\n\nexport type QuestionnaireFieldType = \"text\" | \"textarea\" | \"select\" | \"checkbox\";\n\nexport interface QuestionnaireOption {\n value: string;\n label: string;\n description?: string;\n}\n\nexport interface QuestionnaireField {\n id: string;\n type: QuestionnaireFieldType;\n label: string;\n description?: string;\n placeholder?: string;\n required?: boolean;\n options?: QuestionnaireOption[];\n}\n\nexport interface WaitlistConfig {\n questionnaire?: QuestionnaireField[];\n heroTitle?: string;\n heroSubtitle?: string;\n heroDescription?: string;\n benefits?: string[];\n /**\n * When true, every text above (hero title, subtitle, description, benefits and\n * the questionnaire's labels, descriptions, placeholders and option labels) is\n * a message key and renders through `t()`. Defaults to false: the strings\n * render as given.\n */\n translate?: boolean;\n}\n\nlet _waitlistConfig: WaitlistConfig = {};\n\nexport function configureWaitlist(config: WaitlistConfig): void {\n _waitlistConfig = config;\n}\n\nexport function getWaitlistConfig(): WaitlistConfig {\n return _waitlistConfig;\n}\n\n/**\n * Resolves a waitlist config text: `t(value)` when the config sets\n * `translate`, the value itself otherwise. Empty values stay undefined.\n */\nexport function useWaitlistText(): (value?: string) => string | undefined {\n const t = useI18nTranslations();\n const translate = getWaitlistConfig().translate === true;\n\n return (value?: string) => {\n if (!value) return undefined;\n return translate ? t(value) : value;\n };\n}\n","/**\n * Configuration interface for frontend referral feature.\n */\nexport interface ReferralConfig {\n /**\n * Whether the referral feature is enabled.\n * When false, components render nothing and hooks return null.\n * @default false\n */\n enabled?: boolean;\n\n /**\n * Name of the cookie used to store referral codes.\n * @default \"referral_code\"\n */\n cookieName?: string;\n\n /**\n * Number of days the referral cookie is valid.\n * @default 30\n */\n cookieDays?: number;\n\n /**\n * Query parameter name for referral code in URL.\n * @default \"ref\"\n */\n urlParamName?: string;\n\n /**\n * Base URL for referral links.\n * @default window.location.origin (client-side only)\n */\n referralUrlBase?: string;\n\n /**\n * Path to append to base URL for referral links.\n * @default \"/\"\n */\n referralPath?: string;\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_REFERRAL_CONFIG: Required<ReferralConfig> = {\n enabled: false,\n cookieName: \"referral_code\",\n cookieDays: 30,\n urlParamName: \"ref\",\n referralUrlBase: \"\",\n referralPath: \"/\",\n};\n\n// Private storage for configuration\nlet _referralConfig: Required<ReferralConfig> = { ...DEFAULT_REFERRAL_CONFIG };\n\n/**\n * Configure referral feature settings.\n * Call this at app startup to enable and configure referral functionality.\n *\n * @example\n * ```typescript\n * import { configureReferral } from \"@carlonicora/nextjs-jsonapi\";\n *\n * configureReferral({\n * enabled: process.env.NEXT_PUBLIC_REFERRAL_ENABLED === 'true',\n * cookieDays: 30,\n * });\n * ```\n */\nexport function configureReferral(config: ReferralConfig): void {\n _referralConfig = { ...DEFAULT_REFERRAL_CONFIG, ...config };\n}\n\n/**\n * Get the current referral configuration.\n * @internal\n */\nexport function getReferralConfig(): Required<ReferralConfig> {\n return _referralConfig;\n}\n\n/**\n * Check if referral feature is enabled.\n */\nexport function isReferralEnabled(): boolean {\n return _referralConfig.enabled;\n}\n","export type SignupSource = {\n sourceRef?: string;\n sourceUtmSource?: string;\n sourceUtmMedium?: string;\n sourceUtmCampaign?: string;\n sourceReferrer?: string;\n sourceLandingPath?: string;\n};\n\nexport const SIGNUP_SOURCE_COOKIE = \"signup_source\";\nexport const SIGNUP_SOURCE_COOKIE_MAX_AGE = 2592000;\n\n/** The six source fields, in display order. */\nexport const SIGNUP_SOURCE_FIELDS: readonly (keyof SignupSource)[] = [\n \"sourceRef\",\n \"sourceUtmSource\",\n \"sourceUtmMedium\",\n \"sourceUtmCampaign\",\n \"sourceReferrer\",\n \"sourceLandingPath\",\n];\n\nconst SIGNUP_SOURCE_MAX_LENGTH = 200;\n\n// First touch for the current page session. Survives client navigations, lost on a full reload.\nlet memorySource: SignupSource | undefined;\n\nfunction clean(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (!trimmed) return undefined;\n return trimmed.slice(0, SIGNUP_SOURCE_MAX_LENGTH);\n}\n\nfunction sanitise(input: unknown): SignupSource | undefined {\n if (!input || typeof input !== \"object\") return undefined;\n const result: SignupSource = {};\n for (const field of SIGNUP_SOURCE_FIELDS) {\n const value = clean((input as Record<string, unknown>)[field]);\n if (value !== undefined) result[field] = value;\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\n/**\n * Pure. Reads ref and utm_source/medium/campaign from the URL, the referrer host when it is not ownHost,\n * and the landing path. Returns undefined for a direct visit (no ref, no UTM, no external referrer).\n */\nexport function readSignupSourceFromLocation(params: {\n url: string;\n referrer: string;\n ownHost: string;\n}): SignupSource | undefined {\n let url: URL;\n try {\n url = new URL(params.url);\n } catch {\n return undefined;\n }\n\n const sourceRef = clean(url.searchParams.get(\"ref\"));\n const sourceUtmSource = clean(url.searchParams.get(\"utm_source\"));\n const sourceUtmMedium = clean(url.searchParams.get(\"utm_medium\"));\n const sourceUtmCampaign = clean(url.searchParams.get(\"utm_campaign\"));\n\n let sourceReferrer: string | undefined;\n if (params.referrer) {\n try {\n const referrerHost = new URL(params.referrer).host;\n if (referrerHost && referrerHost !== params.ownHost) sourceReferrer = clean(referrerHost);\n } catch {\n sourceReferrer = undefined;\n }\n }\n\n if (!sourceRef && !sourceUtmSource && !sourceUtmMedium && !sourceUtmCampaign && !sourceReferrer) return undefined;\n\n return sanitise({\n sourceRef,\n sourceUtmSource,\n sourceUtmMedium,\n sourceUtmCampaign,\n sourceReferrer,\n sourceLandingPath: url.pathname,\n });\n}\n\nfunction readSignupSourceCookie(): SignupSource | undefined {\n if (typeof document === \"undefined\") return undefined;\n const cookies = document.cookie ? document.cookie.split(\"; \") : [];\n for (const cookie of cookies) {\n const separator = cookie.indexOf(\"=\");\n if (separator === -1) continue;\n if (cookie.slice(0, separator) !== SIGNUP_SOURCE_COOKIE) continue;\n const value = cookie.slice(separator + 1);\n if (!value) return undefined;\n try {\n return sanitise(JSON.parse(decodeURIComponent(value)));\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nfunction writeSignupSourceCookie(source: SignupSource): void {\n document.cookie = `${SIGNUP_SOURCE_COOKIE}=${encodeURIComponent(JSON.stringify(source))}; path=/; max-age=${SIGNUP_SOURCE_COOKIE_MAX_AGE}; SameSite=Lax`;\n}\n\n/**\n * First touch: an existing in-memory value or cookie is never overwritten.\n * Writes the cookie only when persist is true and no cookie exists yet.\n */\nexport function captureSignupSource(params: { persist: boolean }): void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") return;\n\n const existingCookie = readSignupSourceCookie();\n\n if (!memorySource) {\n memorySource =\n existingCookie ??\n readSignupSourceFromLocation({\n url: window.location.href,\n referrer: document.referrer,\n ownHost: window.location.host,\n });\n }\n\n if (params.persist && !existingCookie && memorySource) writeSignupSourceCookie(memorySource);\n}\n\n/** The in-memory value, else the cookie value, else undefined. */\nexport function getSignupSource(): SignupSource | undefined {\n return memorySource ?? readSignupSourceCookie();\n}\n","export const COMPANY_ADMINISTRATOR_ROLE_ID = \"2e1eee00-6cba-4506-9059-ccd24e4ea5b0\";\n\nexport type PermissionValue = boolean | string;\n\nexport type ActionType = \"read\" | \"create\" | \"update\" | \"delete\";\n\nexport const ACTION_TYPES: ActionType[] = [\"read\", \"create\", \"update\", \"delete\"];\n\n/** The permissions object shape used by both Module and PermissionMapping entities */\nexport type PermissionsMap = {\n create?: PermissionValue;\n read?: PermissionValue;\n update?: PermissionValue;\n delete?: PermissionValue;\n};\n\n/**\n * Declarative-RBAC matrix types.\n *\n * Mirror of the library types defined in\n * `packages/nestjs-neo4jsonapi/src/foundations/rbac/dsl/types.ts`.\n * Frontend does not import from backend, so the shape is redefined here.\n *\n * A `PermToken` represents a single permission entry:\n * - `scope: true` → unconditional (e.g. full read of the module)\n * - `scope: false` → nothing (rarely used, mostly a placeholder)\n * - `scope: \"path\"` → scoped by relationship path (e.g. \"orders.account\")\n */\nexport type PermToken = { action: string; scope: boolean | string };\n\n/**\n * A per-module block of the matrix. Always has a `default` row (permissions\n * granted to every role). Additional keys are role IDs → role-specific\n * permission tokens that are unioned with `default` to produce the effective\n * permissions for that role in that module.\n */\nexport type RbacModuleBlock = { default: PermToken[] } & Record<string, PermToken[]>;\n\n/**\n * The full RBAC matrix as served by the dev endpoint `GET /_dev/rbac/matrix`.\n * Keys are module IDs; values are module blocks.\n */\nexport type RbacMatrix = Record<string, RbacModuleBlock>;\n","import { AbstractService, EndpointCreator, HttpMethod, Modules } from \"../../../core\";\nimport type { RbacMatrixModel } from \"./RbacMatrixModel\";\nimport type { RbacMatrix } from \"./RbacTypes\";\n\n/**\n * RbacService — fetches RBAC configuration for the admin UI.\n *\n * Declarative-matrix methods (`fetchMatrix`, `saveMatrix`) talk to the\n * dev-only endpoints added in\n * `packages/nestjs-neo4jsonapi/.../rbac-dev.controller.ts`. The controller\n * speaks JSON:API (singleton resource with `type: \"rbac-matrix\"`, `id:\n * \"singleton\"`), so these methods go through the standard `callApi()`\n * pipeline like every other service in the codebase.\n *\n * The backend only registers these routes when `devMode` is enabled on\n * `RbacModule.register` (see `apps/api/src/features/features.modules.ts`).\n * In production the routes return 404; callers should guard with a dev-mode\n * check.\n */\nexport class RbacService extends AbstractService {\n /**\n * Fetch the current RBAC matrix plus each module's known BFS relationship\n * paths (used by the permission picker as scope suggestions).\n *\n * Dev-only endpoint — see class header.\n */\n static async fetchMatrix(): Promise<{\n matrix: RbacMatrix;\n modulePaths: Record<string, readonly string[]>;\n }> {\n const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();\n\n const model = await this.callApi<RbacMatrixModel>({\n type: Modules.RbacMatrix,\n method: HttpMethod.GET,\n endpoint,\n });\n\n return {\n matrix: model.matrix ?? {},\n modulePaths: model.modulePaths ?? {},\n };\n }\n\n /**\n * Persist a matrix back to the declarative `permissions.ts` file.\n *\n * The backend serializes the matrix to formatted TypeScript using the\n * provided `roleNames` / `moduleNames` lookup tables (so the emitted file\n * references `RoleId.X` / `ModuleId.X` rather than raw UUIDs) and writes\n * it to `outputPath` (absolute, or relative to the repo root).\n *\n * Dev-only endpoint — see class header.\n */\n static async saveMatrix(args: {\n matrix: RbacMatrix;\n roleNames: Record<string, string>;\n moduleNames: Record<string, string>;\n outputPath: string;\n }): Promise<{ bytesWritten: number; path: string }> {\n const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();\n\n const model = await this.callApi<RbacMatrixModel>({\n type: Modules.RbacMatrix,\n method: HttpMethod.PUT,\n endpoint,\n input: args,\n });\n\n return {\n bytesWritten: model.bytesWritten ?? 0,\n path: model.path ?? \"\",\n };\n }\n}\n"]}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var _chunk6RCZ64BQjs = require('./chunk-6RCZ64BQ.js');
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
|
|
8
|
+
var _chunkFBHUUPRVjs = require('./chunk-FBHUUPRV.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk6RCZ64BQjs = require('./chunk-6RCZ64BQ.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -115,9 +115,9 @@ async function updateLinks(store, typeConfig, record, before, after) {
|
|
|
115
115
|
if (!relationship || !("data" in relationship)) continue;
|
|
116
116
|
const next = new Map(identifiersOf(relationship).map((identifier) => [identifier.id, identifier]));
|
|
117
117
|
const previous = new Set(identifiersOf(_optionalChain([before, 'optionalAccess', _6 => _6[name]])).map((identifier) => identifier.id));
|
|
118
|
-
const kinds = _nullishCoalesce(
|
|
119
|
-
const ofRelationship = await
|
|
120
|
-
const mapped =
|
|
118
|
+
const kinds = _nullishCoalesce(_chunkFBHUUPRVjs.linkKindsOf.call(void 0, typeConfig, name), () => ( [name]));
|
|
119
|
+
const ofRelationship = await _chunkFBHUUPRVjs.linksOfKind.call(void 0, store, record.id, kinds, "both");
|
|
120
|
+
const mapped = _chunkFBHUUPRVjs.linkKindsOf.call(void 0, typeConfig, name) !== void 0;
|
|
121
121
|
const stale = [
|
|
122
122
|
...ofRelationship.filter((link) => !next.has(otherEnd(link))),
|
|
123
123
|
// Unmapped: the link to an identifier the record held before may carry any kind.
|
|
@@ -125,7 +125,7 @@ async function updateLinks(store, typeConfig, record, before, after) {
|
|
|
125
125
|
];
|
|
126
126
|
for (const link of stale) await store.deleteLink({ fromId: link.fromId, toId: link.toId, kind: link.kind });
|
|
127
127
|
const linked = new Set(
|
|
128
|
-
(mapped ? await
|
|
128
|
+
(mapped ? await _chunkFBHUUPRVjs.linksOfKind.call(void 0, store, record.id, kinds, "both") : await allLinks()).map(otherEnd)
|
|
129
129
|
);
|
|
130
130
|
for (const [id, identifier] of next) {
|
|
131
131
|
if (linked.has(id)) continue;
|
|
@@ -134,7 +134,7 @@ async function updateLinks(store, typeConfig, record, before, after) {
|
|
|
134
134
|
fromId: record.id,
|
|
135
135
|
toType: identifier.type,
|
|
136
136
|
toId: id,
|
|
137
|
-
kind:
|
|
137
|
+
kind: _chunkFBHUUPRVjs.linkKindFor.call(void 0, typeConfig, name),
|
|
138
138
|
props: {}
|
|
139
139
|
});
|
|
140
140
|
}
|
|
@@ -148,7 +148,7 @@ async function storeResource(store, resource, pathRootId, waiting, kept, primary
|
|
|
148
148
|
if (waiting.has(recordKeyOf(resource.type, resource.id))) return;
|
|
149
149
|
const existing = await store.getRecord(resource.type, resource.id);
|
|
150
150
|
if (existing && existing.base !== null) return;
|
|
151
|
-
const rootId = await _asyncNullishCoalesce(await _asyncNullishCoalesce(await _asyncOptionalChain([existing, 'optionalAccess', async _9 => _9.rootId]), async () => ( await
|
|
151
|
+
const rootId = await _asyncNullishCoalesce(await _asyncNullishCoalesce(await _asyncOptionalChain([existing, 'optionalAccess', async _9 => _9.rootId]), async () => ( await _chunkFBHUUPRVjs.rootIdForResource.call(void 0, store, config, resource))), async () => ( pathRootId));
|
|
152
152
|
if (!rootId) return;
|
|
153
153
|
if (!kept.has(rootId)) return;
|
|
154
154
|
const before = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _10 => _10.resource]), () => ( {}));
|
|
@@ -182,11 +182,11 @@ async function writeThrough(request, response) {
|
|
|
182
182
|
try {
|
|
183
183
|
const config = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, );
|
|
184
184
|
if (!config.getUserId()) return;
|
|
185
|
-
const { path } =
|
|
185
|
+
const { path } = _chunkFBHUUPRVjs.splitApiUrl.call(void 0, request.url);
|
|
186
186
|
const store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
187
187
|
if (method === "DELETE") {
|
|
188
188
|
for (const typeConfig of config.types) {
|
|
189
|
-
const params =
|
|
189
|
+
const params = _chunkFBHUUPRVjs.matchPattern.call(void 0, [typeConfig.module, ":id"], path);
|
|
190
190
|
if (params) {
|
|
191
191
|
await store.deleteRecord(typeConfig.module.name, params.id);
|
|
192
192
|
return;
|
|
@@ -195,7 +195,7 @@ async function writeThrough(request, response) {
|
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
197
|
const rootSegments = path.split("/").slice(0, 2).join("/");
|
|
198
|
-
const pathRootId = _chunkWUNSG3INjs.rootKinds.call(void 0, config).map((kind) => _optionalChain([
|
|
198
|
+
const pathRootId = _chunkWUNSG3INjs.rootKinds.call(void 0, config).map((kind) => _optionalChain([_chunkFBHUUPRVjs.matchPattern.call(void 0, [kind.module, ":rootId"], rootSegments), 'optionalAccess', _13 => _13.rootId])).find((rootId) => rootId !== void 0);
|
|
199
199
|
const document = response.data;
|
|
200
200
|
const primary = Array.isArray(_optionalChain([document, 'optionalAccess', _14 => _14.data])) ? document.data : _optionalChain([document, 'optionalAccess', _15 => _15.data]) ? [document.data] : [];
|
|
201
201
|
const waiting = waitingRecordKeys(
|
|
@@ -230,4 +230,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, writeThrough, "writeThrough");
|
|
|
230
230
|
|
|
231
231
|
|
|
232
232
|
exports.rememberSyncRoots = rememberSyncRoots; exports.knownRootIds = knownRootIds; exports.knownPrimaryRootIds = knownPrimaryRootIds; exports.refreshLockedRoots = refreshLockedRoots; exports.recordKeyOf = recordKeyOf; exports.recordKeysOfEntry = recordKeysOfEntry; exports.waitingRecordKeys = waitingRecordKeys; exports.writeThrough = writeThrough;
|
|
233
|
-
//# sourceMappingURL=chunk-
|
|
233
|
+
//# sourceMappingURL=chunk-PQQFOONG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-YSE2Z4RB.js","../src/offline/sync/known-roots.ts","../src/offline/sync/waiting.ts","../src/offline/write-through.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACnBA,IAAI,eAAA,EAA2B,CAAC,CAAA;AAChC,IAAI,oBAAA,EAAgC,CAAC,CAAA;AAM9B,SAAS,iBAAA,CAAkB,GAAA,EAAe,SAAA,EAAqB,CAAC,CAAA,EAAS;AAC9E,EAAA,eAAA,EAAiB,CAAC,GAAG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AACsB,IAAA;AAChC,IAAA;AACI,MAAA;AACuB,MAAA;AAC3C,IAAA;AAG8C,IAAA;AACf,IAAA;AACqB,IAAA;AAClB,MAAA;AACkB,QAAA;AAClD,MAAA;AACiD,MAAA;AACC,QAAA;AAClD,MAAA;AACD,IAAA;AAEmD,IAAA;AACtC,EAAA;AAEgC,IAAA;AACjC,IAAA;AACf,EAAA;AACF;AApDsB;AHkFkC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-YSE2Z4RB.js","sourcesContent":[null,"import { getOfflineConfig, getOfflineStore, rootKinds } from \"../config\";\nimport { setOfflineState } from \"../state\";\nimport type { DeviceStore } from \"../store/DeviceStore\";\nimport { isRootLocked } from \"../store/lifecycle\";\n\nlet _lastSyncRoots: string[] = [];\nlet _lastExtraSyncRoots: string[] = [];\n\n/**\n * Remembers the root records the last online sync listed: `ids` of every kind, `extraIds` those\n * of the `extraRootKinds` among them.\n */\nexport function rememberSyncRoots(ids: string[], extraIds: string[] = []): void {\n _lastSyncRoots = [...ids];\n _lastExtraSyncRoots = [...extraIds];\n}\n\n/**\n * Every root record the device knows of, of every kind: its stored root records, the root records\n * with waiting changes, and the last sync roots (a locked root record is never downloaded, so it\n * may have no stored record).\n */\nexport async function knownRootIds(store: DeviceStore): Promise<string[]> {\n const config = getOfflineConfig();\n const ids = new Set<string>(_lastSyncRoots);\n for (const kind of rootKinds(config)) {\n for (const record of await store.listRecords({ type: kind.module.name })) ids.add(record.id);\n }\n for (const entry of await store.queue()) ids.add(entry.rootId);\n return [...ids].sort();\n}\n\n/** The known root records of the `extraRootKinds`: stored, or listed by the last sync. */\nasync function extraRootIds(store: DeviceStore): Promise<Set<string>> {\n const ids = new Set<string>(_lastExtraSyncRoots);\n for (const kind of getOfflineConfig().extraRootKinds ?? []) {\n for (const record of await store.listRecords({ type: kind.module.name })) ids.add(record.id);\n }\n return ids;\n}\n\n/** `knownRootIds` without the root records of the `extraRootKinds` (the primary kind only). */\nexport async function knownPrimaryRootIds(store: DeviceStore): Promise<string[]> {\n const extra = await extraRootIds(store);\n return (await knownRootIds(store)).filter((id) => !extra.has(id));\n}\n\n/** Recomputes `lockedRootIds` from the stored sync states, now. */\nexport async function refreshLockedRoots(): Promise<void> {\n const config = getOfflineConfig();\n if (!config.getUserId()) return;\n const store = await getOfflineStore();\n const now = new Date();\n const locked: string[] = [];\n for (const id of await knownRootIds(store)) {\n if (isRootLocked(await store.getSyncState(id), now)) locked.push(id);\n }\n setOfflineState({ lockedRootIds: locked });\n}\n","import type { QueueEntry } from \"../store/DeviceStore\";\n\nexport const recordKeyOf = (type: string, id: string) => `${type}:${id}`;\n\n/**\n * The records a queue entry targets: its `recordType`/`recordId`, the `data.type`/`data.id` of\n * its body (a record created on this device), and the `<type>/<id>` of its path (the last\n * segment naming a synced type, when an id follows it: `npcs/n1`, `npcs/n1/merge`; a collection\n * path such as `roots/C/npcs` targets no record).\n */\nexport function recordKeysOfEntry(entry: QueueEntry, typeNames: Set<string>): string[] {\n const keys: string[] = [];\n if (entry.recordType && entry.recordId) keys.push(recordKeyOf(entry.recordType, entry.recordId));\n\n const data = entry.body?.data;\n if (data && !Array.isArray(data) && typeof data.type === \"string\" && typeof data.id === \"string\") {\n keys.push(recordKeyOf(data.type, data.id));\n }\n\n const segments = String(entry.path ?? \"\")\n .split(\"?\")[0]\n .split(\"/\")\n .filter(Boolean);\n for (let index = segments.length - 1; index >= 0; index--) {\n if (!typeNames.has(segments[index])) continue;\n if (index + 1 < segments.length) keys.push(recordKeyOf(segments[index], segments[index + 1]));\n break;\n }\n return keys;\n}\n\n/**\n * Every record with a waiting change: targeted by a queue entry that is pending, sending, in\n * conflict or failed. Such a record is never overwritten or deleted by a sync or a write-through.\n */\nexport function waitingRecordKeys(queue: QueueEntry[], typeNames: Set<string>): Set<string> {\n const keys = new Set<string>();\n for (const entry of queue) for (const key of recordKeysOfEntry(entry, typeNames)) keys.add(key);\n return keys;\n}\n","import type { ApiData } from \"../core/interfaces/ApiData\";\nimport { getOfflineConfig, getOfflineStore, OfflineUnavailableError, rootKinds } from \"./config\";\nimport { rootIdForResource, linkKindFor, linkKindsOf, linksOfKind } from \"./generic-answers\";\nimport { splitApiUrl } from \"./local-transport\";\nimport { matchPattern } from \"./router\";\nimport type { DeviceStore, StoredLink } from \"./store/DeviceStore\";\nimport type { OfflineTypeConfig } from \"./types\";\nimport { cacheArtworkImage, imageUrlOf } from \"./sync/artwork-cache\";\nimport { knownRootIds } from \"./sync/known-roots\";\nimport { recordKeyOf, waitingRecordKeys } from \"./sync/waiting\";\n\nexport type WriteThroughRequest = { method: string; url: string };\n\nfunction updatedAtOf(resource: any): Date | null {\n const value = resource?.attributes?.updatedAt;\n if (!value) return null;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\ntype Identifier = { type: string; id: string };\n\nfunction identifiersOf(relationship: any): Identifier[] {\n const data = relationship?.data;\n if (!data) return [];\n return (Array.isArray(data) ? data : [data]).filter((item: any) => item && item.type && item.id);\n}\n\n/**\n * Brings the stored links of the written record in line with the relationships the answer\n * carries (only those whose `data` it holds), as the local answers do: a link of the\n * relationship (its name or mapped Neo4j type; any kind when the type is not mapped, for an\n * identifier the record held before) to an identifier no longer there is removed, and a new\n * identifier gets a link of `linkKindFor` the relationship.\n */\nasync function updateLinks(\n store: DeviceStore,\n typeConfig: OfflineTypeConfig | undefined,\n record: Identifier,\n before: any,\n after: any,\n): Promise<void> {\n const otherEnd = (link: StoredLink) => (link.fromId === record.id ? link.toId : link.fromId);\n const allLinks = async (): Promise<StoredLink[]> => [\n ...(await store.linksFrom(record.id)),\n ...(await store.linksTo(record.id)),\n ];\n\n for (const [name, relationship] of Object.entries<any>(after ?? {})) {\n if (!relationship || !(\"data\" in relationship)) continue;\n const next = new Map(identifiersOf(relationship).map((identifier) => [identifier.id, identifier]));\n const previous = new Set(identifiersOf(before?.[name]).map((identifier) => identifier.id));\n const kinds = linkKindsOf(typeConfig, name) ?? [name];\n const ofRelationship = await linksOfKind(store, record.id, kinds, \"both\");\n const mapped = linkKindsOf(typeConfig, name) !== undefined;\n\n const stale = [\n ...ofRelationship.filter((link) => !next.has(otherEnd(link))),\n // Unmapped: the link to an identifier the record held before may carry any kind.\n ...(mapped ? [] : (await allLinks()).filter((link) => previous.has(otherEnd(link)) && !next.has(otherEnd(link)))),\n ];\n for (const link of stale) await store.deleteLink({ fromId: link.fromId, toId: link.toId, kind: link.kind });\n\n const linked = new Set(\n (mapped ? await linksOfKind(store, record.id, kinds, \"both\") : await allLinks()).map(otherEnd),\n );\n for (const [id, identifier] of next) {\n if (linked.has(id)) continue;\n await store.putLink({\n fromType: record.type,\n fromId: record.id,\n toType: identifier.type,\n toId: id,\n kind: linkKindFor(typeConfig, name),\n props: {},\n });\n }\n }\n}\n\ntype ImageChange = { url: string; previousUrl?: string };\n\nasync function storeResource(\n store: DeviceStore,\n resource: any,\n pathRootId: string | undefined,\n waiting: Set<string>,\n kept: Set<string>,\n primary: boolean,\n images: ImageChange[],\n): Promise<void> {\n const config = getOfflineConfig();\n if (!resource?.type || !resource?.id) return;\n if (!config.types.some((typeConfig) => typeConfig.module.name === resource.type)) return;\n // A record with unsent local changes keeps them: the next sync, once they are sent, brings\n // the server's version.\n if (waiting.has(recordKeyOf(resource.type, resource.id))) return;\n\n const existing = await store.getRecord(resource.type, resource.id);\n if (existing && existing.base !== null) return;\n const rootId = existing?.rootId ?? (await rootIdForResource(store, config, resource)) ?? pathRootId;\n // A record that belongs to no root record on this device waits for the next sync.\n if (!rootId) return;\n // Only the root records the device keeps are written through (never a player's root record).\n if (!kept.has(rootId)) return;\n\n // An answer can carry a sparse resource (fields limited): it is merged onto what is stored.\n const before = existing?.resource ?? {};\n const merged = {\n ...before,\n ...resource,\n attributes: { ...(before.attributes ?? {}), ...(resource.attributes ?? {}) },\n relationships: { ...(before.relationships ?? {}), ...(resource.relationships ?? {}) },\n };\n\n await store.putRecord({\n type: resource.type,\n id: resource.id,\n rootId,\n resource: merged,\n updatedAt: updatedAtOf(resource) ?? existing?.updatedAt ?? null,\n base: null,\n localOnly: false,\n });\n if (primary) {\n const typeConfig = config.types.find((candidate) => candidate.module.name === resource.type);\n await updateLinks(store, typeConfig, resource, before.relationships, resource.relationships);\n }\n\n const url = imageUrlOf(merged);\n const previousUrl = imageUrlOf(existing?.resource);\n if (url && url !== previousUrl) images.push({ url, previousUrl });\n}\n\n/**\n * After a successful online write, copies the answer into the device copy so it is never behind\n * the GM's own work: the resource and its `included` for POST/PUT/PATCH, the record removed for a\n * DELETE. It never fails the request: a problem is logged and the next sync repairs the copy.\n */\nexport async function writeThrough(request: WriteThroughRequest, response: ApiData): Promise<void> {\n const method = request.method.toUpperCase();\n if (method === \"GET\" || !response.ok) return;\n\n try {\n const config = getOfflineConfig();\n if (!config.getUserId()) return;\n const { path } = splitApiUrl(request.url);\n const store = await getOfflineStore();\n\n if (method === \"DELETE\") {\n for (const typeConfig of config.types) {\n const params = matchPattern([typeConfig.module, \":id\"], path);\n if (params) {\n await store.deleteRecord(typeConfig.module.name, params.id);\n return;\n }\n }\n return;\n }\n\n // A path under a root record of any kind (`<root module>/:rootId/...`).\n const rootSegments = path.split(\"/\").slice(0, 2).join(\"/\");\n const pathRootId = rootKinds(config)\n .map((kind) => matchPattern([kind.module, \":rootId\"], rootSegments)?.rootId)\n .find((rootId) => rootId !== undefined);\n\n const document = response.data;\n const primary = Array.isArray(document?.data) ? document.data : document?.data ? [document.data] : [];\n const waiting = waitingRecordKeys(\n await store.queue(),\n new Set(config.types.map((typeConfig) => typeConfig.module.name)),\n );\n // The root records this device keeps for the signed-in user (stored roots, waiting changes, last\n // sync roots): a write in any other root record (a player's) stores nothing.\n const kept = new Set(await knownRootIds(store));\n const images: ImageChange[] = [];\n await store.transaction(async (transactionStore) => {\n for (const resource of primary) {\n await storeResource(transactionStore, resource, pathRootId, waiting, kept, true, images);\n }\n for (const resource of document?.included ?? []) {\n await storeResource(transactionStore, resource, pathRootId, waiting, kept, false, images);\n }\n });\n // A new image URL of an artwork: downloaded, the old cached image removed (as the sync does).\n for (const image of images) await cacheArtworkImage(image.url, image.previousUrl);\n } catch (error) {\n // A browser that cannot keep the device copy was already warned about once.\n if (error instanceof OfflineUnavailableError) return;\n console.warn(\"[offline] could not copy the answer to the device\", error);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-PQQFOONG.js","../src/offline/sync/known-roots.ts","../src/offline/sync/waiting.ts","../src/offline/write-through.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACnBA,IAAI,eAAA,EAA2B,CAAC,CAAA;AAChC,IAAI,oBAAA,EAAgC,CAAC,CAAA;AAM9B,SAAS,iBAAA,CAAkB,GAAA,EAAe,SAAA,EAAqB,CAAC,CAAA,EAAS;AAC9E,EAAA,eAAA,EAAiB,CAAC,GAAG,GAAG,CAAA;AACxB,EAAA,oBAAA,EAAsB,CAAC,GAAG,QAAQ,CAAA;AACpC;AAHgB,qCAAA,iBAAA,EAAA,mBAAA,CAAA;AAUhB,MAAA,SAAsB,YAAA,CAAa,KAAA,EAAuC;AACxE,EAAA,MAAM,OAAA,EAAS,+CAAA,CAAiB;AAChC,EAAA,MAAM,IAAA,EAAM,IAAI,GAAA,CAAY,cAAc,CAAA;AAC1C,EAAA,IAAA,CAAA,MAAW,KAAA,GAAQ,wCAAA,MAAgB,CAAA,EAAG;AACpC,IAAA,IAAA,CAAA,MAAW,OAAA,GAAU,MAAM,KAAA,CAAM,WAAA,CAAY,EAAE,IAAA,EAAM,IAAA,CAAK,MAAA,CAAO,KAAK,CAAC,CAAA,EAAG,GAAA,CAAI,GAAA,CAAI,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AA;AACI,QAAA;AACb,QAAA;AAC4B,QAAA;AAC1B,QAAA;AACT,MAAA;AACH,IAAA;AACF,EAAA;AACF;AA3Ce;AAkDb;AAMgC,EAAA;AACM,EAAA;AACY,EAAA;AAGI,EAAA;AAEA,EAAA;AACd,EAAA;AACE,EAAA;AAE7B,EAAA;AAEU,EAAA;AAGe,EAAA;AACvB,EAAA;AACV,IAAA;AACA,IAAA;AAC6C,IAAA;AACM,IAAA;AACxD,EAAA;AAEsB,EAAA;AACL,IAAA;AACF,IAAA;AACb,IAAA;AACU,IAAA;AACoC,IAAA;AACxC,IAAA;AACK,IAAA;AACZ,EAAA;AACY,EAAA;AACyC,IAAA;AACL,IAAA;AACjD,EAAA;AAE6B,EAAA;AACoB,EAAA;AACE,EAAA;AACrD;AAlDe;AAyDoF;AACvD,EAAA;AACJ,EAAA;AAElC,EAAA;AAC8B,IAAA;AACP,IAAA;AACe,IAAA;AACJ,IAAA;AAEX,IAAA;AACgB,MAAA;AACW,QAAA;AACpC,QAAA;AACiC,UAAA;AAC3C,UAAA;AACF,QAAA;AACF,MAAA;AACA,MAAA;AACF,IAAA;AAGiD,IAAA;AAEhC,IAAA;AAGS,IAAA;AACsB,IAAA;AAChC,IAAA;AACI,MAAA;AACuB,MAAA;AAC3C,IAAA;AAG8C,IAAA;AACf,IAAA;AACqB,IAAA;AAClB,MAAA;AACkB,QAAA;AAClD,MAAA;AACiD,MAAA;AACC,QAAA;AAClD,MAAA;AACD,IAAA;AAEmD,IAAA;AACtC,EAAA;AAEgC,IAAA;AACjC,IAAA;AACf,EAAA;AACF;AApDsB;AHkFkC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-PQQFOONG.js","sourcesContent":[null,"import { getOfflineConfig, getOfflineStore, rootKinds } from \"../config\";\nimport { setOfflineState } from \"../state\";\nimport type { DeviceStore } from \"../store/DeviceStore\";\nimport { isRootLocked } from \"../store/lifecycle\";\n\nlet _lastSyncRoots: string[] = [];\nlet _lastExtraSyncRoots: string[] = [];\n\n/**\n * Remembers the root records the last online sync listed: `ids` of every kind, `extraIds` those\n * of the `extraRootKinds` among them.\n */\nexport function rememberSyncRoots(ids: string[], extraIds: string[] = []): void {\n _lastSyncRoots = [...ids];\n _lastExtraSyncRoots = [...extraIds];\n}\n\n/**\n * Every root record the device knows of, of every kind: its stored root records, the root records\n * with waiting changes, and the last sync roots (a locked root record is never downloaded, so it\n * may have no stored record).\n */\nexport async function knownRootIds(store: DeviceStore): Promise<string[]> {\n const config = getOfflineConfig();\n const ids = new Set<string>(_lastSyncRoots);\n for (const kind of rootKinds(config)) {\n for (const record of await store.listRecords({ type: kind.module.name })) ids.add(record.id);\n }\n for (const entry of await store.queue()) ids.add(entry.rootId);\n return [...ids].sort();\n}\n\n/** The known root records of the `extraRootKinds`: stored, or listed by the last sync. */\nasync function extraRootIds(store: DeviceStore): Promise<Set<string>> {\n const ids = new Set<string>(_lastExtraSyncRoots);\n for (const kind of getOfflineConfig().extraRootKinds ?? []) {\n for (const record of await store.listRecords({ type: kind.module.name })) ids.add(record.id);\n }\n return ids;\n}\n\n/** `knownRootIds` without the root records of the `extraRootKinds` (the primary kind only). */\nexport async function knownPrimaryRootIds(store: DeviceStore): Promise<string[]> {\n const extra = await extraRootIds(store);\n return (await knownRootIds(store)).filter((id) => !extra.has(id));\n}\n\n/** Recomputes `lockedRootIds` from the stored sync states, now. */\nexport async function refreshLockedRoots(): Promise<void> {\n const config = getOfflineConfig();\n if (!config.getUserId()) return;\n const store = await getOfflineStore();\n const now = new Date();\n const locked: string[] = [];\n for (const id of await knownRootIds(store)) {\n if (isRootLocked(await store.getSyncState(id), now)) locked.push(id);\n }\n setOfflineState({ lockedRootIds: locked });\n}\n","import type { QueueEntry } from \"../store/DeviceStore\";\n\nexport const recordKeyOf = (type: string, id: string) => `${type}:${id}`;\n\n/**\n * The records a queue entry targets: its `recordType`/`recordId`, the `data.type`/`data.id` of\n * its body (a record created on this device), and the `<type>/<id>` of its path (the last\n * segment naming a synced type, when an id follows it: `npcs/n1`, `npcs/n1/merge`; a collection\n * path such as `roots/C/npcs` targets no record).\n */\nexport function recordKeysOfEntry(entry: QueueEntry, typeNames: Set<string>): string[] {\n const keys: string[] = [];\n if (entry.recordType && entry.recordId) keys.push(recordKeyOf(entry.recordType, entry.recordId));\n\n const data = entry.body?.data;\n if (data && !Array.isArray(data) && typeof data.type === \"string\" && typeof data.id === \"string\") {\n keys.push(recordKeyOf(data.type, data.id));\n }\n\n const segments = String(entry.path ?? \"\")\n .split(\"?\")[0]\n .split(\"/\")\n .filter(Boolean);\n for (let index = segments.length - 1; index >= 0; index--) {\n if (!typeNames.has(segments[index])) continue;\n if (index + 1 < segments.length) keys.push(recordKeyOf(segments[index], segments[index + 1]));\n break;\n }\n return keys;\n}\n\n/**\n * Every record with a waiting change: targeted by a queue entry that is pending, sending, in\n * conflict or failed. Such a record is never overwritten or deleted by a sync or a write-through.\n */\nexport function waitingRecordKeys(queue: QueueEntry[], typeNames: Set<string>): Set<string> {\n const keys = new Set<string>();\n for (const entry of queue) for (const key of recordKeysOfEntry(entry, typeNames)) keys.add(key);\n return keys;\n}\n","import type { ApiData } from \"../core/interfaces/ApiData\";\nimport { getOfflineConfig, getOfflineStore, OfflineUnavailableError, rootKinds } from \"./config\";\nimport { rootIdForResource, linkKindFor, linkKindsOf, linksOfKind } from \"./generic-answers\";\nimport { splitApiUrl } from \"./local-transport\";\nimport { matchPattern } from \"./router\";\nimport type { DeviceStore, StoredLink } from \"./store/DeviceStore\";\nimport type { OfflineTypeConfig } from \"./types\";\nimport { cacheArtworkImage, imageUrlOf } from \"./sync/artwork-cache\";\nimport { knownRootIds } from \"./sync/known-roots\";\nimport { recordKeyOf, waitingRecordKeys } from \"./sync/waiting\";\n\nexport type WriteThroughRequest = { method: string; url: string };\n\nfunction updatedAtOf(resource: any): Date | null {\n const value = resource?.attributes?.updatedAt;\n if (!value) return null;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\ntype Identifier = { type: string; id: string };\n\nfunction identifiersOf(relationship: any): Identifier[] {\n const data = relationship?.data;\n if (!data) return [];\n return (Array.isArray(data) ? data : [data]).filter((item: any) => item && item.type && item.id);\n}\n\n/**\n * Brings the stored links of the written record in line with the relationships the answer\n * carries (only those whose `data` it holds), as the local answers do: a link of the\n * relationship (its name or mapped Neo4j type; any kind when the type is not mapped, for an\n * identifier the record held before) to an identifier no longer there is removed, and a new\n * identifier gets a link of `linkKindFor` the relationship.\n */\nasync function updateLinks(\n store: DeviceStore,\n typeConfig: OfflineTypeConfig | undefined,\n record: Identifier,\n before: any,\n after: any,\n): Promise<void> {\n const otherEnd = (link: StoredLink) => (link.fromId === record.id ? link.toId : link.fromId);\n const allLinks = async (): Promise<StoredLink[]> => [\n ...(await store.linksFrom(record.id)),\n ...(await store.linksTo(record.id)),\n ];\n\n for (const [name, relationship] of Object.entries<any>(after ?? {})) {\n if (!relationship || !(\"data\" in relationship)) continue;\n const next = new Map(identifiersOf(relationship).map((identifier) => [identifier.id, identifier]));\n const previous = new Set(identifiersOf(before?.[name]).map((identifier) => identifier.id));\n const kinds = linkKindsOf(typeConfig, name) ?? [name];\n const ofRelationship = await linksOfKind(store, record.id, kinds, \"both\");\n const mapped = linkKindsOf(typeConfig, name) !== undefined;\n\n const stale = [\n ...ofRelationship.filter((link) => !next.has(otherEnd(link))),\n // Unmapped: the link to an identifier the record held before may carry any kind.\n ...(mapped ? [] : (await allLinks()).filter((link) => previous.has(otherEnd(link)) && !next.has(otherEnd(link)))),\n ];\n for (const link of stale) await store.deleteLink({ fromId: link.fromId, toId: link.toId, kind: link.kind });\n\n const linked = new Set(\n (mapped ? await linksOfKind(store, record.id, kinds, \"both\") : await allLinks()).map(otherEnd),\n );\n for (const [id, identifier] of next) {\n if (linked.has(id)) continue;\n await store.putLink({\n fromType: record.type,\n fromId: record.id,\n toType: identifier.type,\n toId: id,\n kind: linkKindFor(typeConfig, name),\n props: {},\n });\n }\n }\n}\n\ntype ImageChange = { url: string; previousUrl?: string };\n\nasync function storeResource(\n store: DeviceStore,\n resource: any,\n pathRootId: string | undefined,\n waiting: Set<string>,\n kept: Set<string>,\n primary: boolean,\n images: ImageChange[],\n): Promise<void> {\n const config = getOfflineConfig();\n if (!resource?.type || !resource?.id) return;\n if (!config.types.some((typeConfig) => typeConfig.module.name === resource.type)) return;\n // A record with unsent local changes keeps them: the next sync, once they are sent, brings\n // the server's version.\n if (waiting.has(recordKeyOf(resource.type, resource.id))) return;\n\n const existing = await store.getRecord(resource.type, resource.id);\n if (existing && existing.base !== null) return;\n const rootId = existing?.rootId ?? (await rootIdForResource(store, config, resource)) ?? pathRootId;\n // A record that belongs to no root record on this device waits for the next sync.\n if (!rootId) return;\n // Only the root records the device keeps are written through (never a player's root record).\n if (!kept.has(rootId)) return;\n\n // An answer can carry a sparse resource (fields limited): it is merged onto what is stored.\n const before = existing?.resource ?? {};\n const merged = {\n ...before,\n ...resource,\n attributes: { ...(before.attributes ?? {}), ...(resource.attributes ?? {}) },\n relationships: { ...(before.relationships ?? {}), ...(resource.relationships ?? {}) },\n };\n\n await store.putRecord({\n type: resource.type,\n id: resource.id,\n rootId,\n resource: merged,\n updatedAt: updatedAtOf(resource) ?? existing?.updatedAt ?? null,\n base: null,\n localOnly: false,\n });\n if (primary) {\n const typeConfig = config.types.find((candidate) => candidate.module.name === resource.type);\n await updateLinks(store, typeConfig, resource, before.relationships, resource.relationships);\n }\n\n const url = imageUrlOf(merged);\n const previousUrl = imageUrlOf(existing?.resource);\n if (url && url !== previousUrl) images.push({ url, previousUrl });\n}\n\n/**\n * After a successful online write, copies the answer into the device copy so it is never behind\n * the GM's own work: the resource and its `included` for POST/PUT/PATCH, the record removed for a\n * DELETE. It never fails the request: a problem is logged and the next sync repairs the copy.\n */\nexport async function writeThrough(request: WriteThroughRequest, response: ApiData): Promise<void> {\n const method = request.method.toUpperCase();\n if (method === \"GET\" || !response.ok) return;\n\n try {\n const config = getOfflineConfig();\n if (!config.getUserId()) return;\n const { path } = splitApiUrl(request.url);\n const store = await getOfflineStore();\n\n if (method === \"DELETE\") {\n for (const typeConfig of config.types) {\n const params = matchPattern([typeConfig.module, \":id\"], path);\n if (params) {\n await store.deleteRecord(typeConfig.module.name, params.id);\n return;\n }\n }\n return;\n }\n\n // A path under a root record of any kind (`<root module>/:rootId/...`).\n const rootSegments = path.split(\"/\").slice(0, 2).join(\"/\");\n const pathRootId = rootKinds(config)\n .map((kind) => matchPattern([kind.module, \":rootId\"], rootSegments)?.rootId)\n .find((rootId) => rootId !== undefined);\n\n const document = response.data;\n const primary = Array.isArray(document?.data) ? document.data : document?.data ? [document.data] : [];\n const waiting = waitingRecordKeys(\n await store.queue(),\n new Set(config.types.map((typeConfig) => typeConfig.module.name)),\n );\n // The root records this device keeps for the signed-in user (stored roots, waiting changes, last\n // sync roots): a write in any other root record (a player's) stores nothing.\n const kept = new Set(await knownRootIds(store));\n const images: ImageChange[] = [];\n await store.transaction(async (transactionStore) => {\n for (const resource of primary) {\n await storeResource(transactionStore, resource, pathRootId, waiting, kept, true, images);\n }\n for (const resource of document?.included ?? []) {\n await storeResource(transactionStore, resource, pathRootId, waiting, kept, false, images);\n }\n });\n // A new image URL of an artwork: downloaded, the old cached image removed (as the sync does).\n for (const image of images) await cacheArtworkImage(image.url, image.previousUrl);\n } catch (error) {\n // A browser that cannot keep the device copy was already warned about once.\n if (error instanceof OfflineUnavailableError) return;\n console.warn(\"[offline] could not copy the answer to the device\", error);\n }\n}\n"]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/date-formatter.ts
|
|
6
|
+
var formatLocalDate = /* @__PURE__ */ __name((d) => {
|
|
7
|
+
const year = d.getFullYear();
|
|
8
|
+
const month = String(d.getMonth() + 1).padStart(2, "0");
|
|
9
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
10
|
+
return `${year}-${month}-${day}`;
|
|
11
|
+
}, "formatLocalDate");
|
|
12
|
+
var NUMERIC_DATE = { day: "2-digit", month: "2-digit", year: "numeric" };
|
|
13
|
+
var DATE_STYLE_OPTIONS = {
|
|
14
|
+
date: NUMERIC_DATE,
|
|
15
|
+
dateMedium: { dateStyle: "medium" },
|
|
16
|
+
dateLong: { dateStyle: "long" },
|
|
17
|
+
dateTime: { ...NUMERIC_DATE, hour: "numeric", minute: "2-digit" },
|
|
18
|
+
dateTimeMedium: { dateStyle: "medium", timeStyle: "short" },
|
|
19
|
+
dateTimeLong: { day: "numeric", month: "long", year: "numeric", hour: "numeric", minute: "2-digit" },
|
|
20
|
+
dateTimeSeconds: { ...NUMERIC_DATE, hour: "numeric", minute: "2-digit", second: "2-digit" },
|
|
21
|
+
time: { hour: "numeric", minute: "2-digit" },
|
|
22
|
+
weekdayDateTime: { weekday: "short", day: "numeric", month: "short", hour: "numeric", minute: "2-digit" },
|
|
23
|
+
weekdayDay: { weekday: "short", day: "numeric", month: "long", year: "numeric" },
|
|
24
|
+
monthYear: { month: "short", year: "numeric" },
|
|
25
|
+
monthYearLong: { month: "long", year: "numeric" },
|
|
26
|
+
month: { month: "short" },
|
|
27
|
+
monthLong: { month: "long" },
|
|
28
|
+
dayMonth: { day: "numeric", month: "short" },
|
|
29
|
+
weekday: { weekday: "short" },
|
|
30
|
+
weekdayLong: { weekday: "long" }
|
|
31
|
+
};
|
|
32
|
+
var PUBLIC_STYLE_MAP = {
|
|
33
|
+
date: "dateMedium",
|
|
34
|
+
dateTime: "dateTimeMedium",
|
|
35
|
+
dateTimeSeconds: "dateTimeMedium"
|
|
36
|
+
};
|
|
37
|
+
var formatterCache = /* @__PURE__ */ new Map();
|
|
38
|
+
var cachedDateTimeFormat = /* @__PURE__ */ __name((locale, key, options, timeZone) => {
|
|
39
|
+
const cacheKey = `${locale}|${key}|${timeZone ?? ""}`;
|
|
40
|
+
let formatter = formatterCache.get(cacheKey);
|
|
41
|
+
if (!formatter) {
|
|
42
|
+
formatter = new Intl.DateTimeFormat(locale, timeZone ? { ...options, timeZone } : options);
|
|
43
|
+
formatterCache.set(cacheKey, formatter);
|
|
44
|
+
}
|
|
45
|
+
return formatter;
|
|
46
|
+
}, "cachedDateTimeFormat");
|
|
47
|
+
var relativeCache = /* @__PURE__ */ new Map();
|
|
48
|
+
var cachedRelativeTimeFormat = /* @__PURE__ */ __name((locale) => {
|
|
49
|
+
let formatter = relativeCache.get(locale);
|
|
50
|
+
if (!formatter) {
|
|
51
|
+
formatter = new Intl.RelativeTimeFormat(locale, { numeric: "always" });
|
|
52
|
+
relativeCache.set(locale, formatter);
|
|
53
|
+
}
|
|
54
|
+
return formatter;
|
|
55
|
+
}, "cachedRelativeTimeFormat");
|
|
56
|
+
var toValidDate = /* @__PURE__ */ __name((date) => {
|
|
57
|
+
if (date === void 0 || date === null) return void 0;
|
|
58
|
+
const value = date instanceof Date ? date : new Date(date);
|
|
59
|
+
return Number.isNaN(value.getTime()) ? void 0 : value;
|
|
60
|
+
}, "toValidDate");
|
|
61
|
+
var languageOf = /* @__PURE__ */ __name((tag) => tag.split("-")[0].toLowerCase(), "languageOf");
|
|
62
|
+
var MAX_ACCEPT_LANGUAGE_ENTRIES = 50;
|
|
63
|
+
function resolveDateLocale(params) {
|
|
64
|
+
const { appLocale, acceptLanguage } = params;
|
|
65
|
+
if (!acceptLanguage) return appLocale;
|
|
66
|
+
const appLanguage = languageOf(appLocale);
|
|
67
|
+
const entries = [];
|
|
68
|
+
const parts = acceptLanguage.split(",");
|
|
69
|
+
for (let index = 0; index < parts.length && entries.length < MAX_ACCEPT_LANGUAGE_ENTRIES; index++) {
|
|
70
|
+
const [rawTag, ...rawParams] = parts[index].split(";");
|
|
71
|
+
const tag = rawTag.trim();
|
|
72
|
+
if (!tag || tag === "*") continue;
|
|
73
|
+
let quality = 1;
|
|
74
|
+
const qualityParam = rawParams.map((param) => param.trim()).find((param) => param.startsWith("q="));
|
|
75
|
+
if (qualityParam !== void 0) {
|
|
76
|
+
const raw = qualityParam.slice(2);
|
|
77
|
+
quality = /^\d+(\.\d+)?$/.test(raw) ? Number(raw) : NaN;
|
|
78
|
+
}
|
|
79
|
+
if (!(quality > 0)) continue;
|
|
80
|
+
if (languageOf(tag) !== appLanguage) continue;
|
|
81
|
+
entries.push({ tag, quality, index });
|
|
82
|
+
}
|
|
83
|
+
entries.sort((a, b) => b.quality - a.quality || a.index - b.index);
|
|
84
|
+
for (const entry of entries) {
|
|
85
|
+
try {
|
|
86
|
+
const [supported] = Intl.DateTimeFormat.supportedLocalesOf([entry.tag]);
|
|
87
|
+
if (supported && languageOf(supported) === appLanguage) return supported;
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return appLocale;
|
|
92
|
+
}
|
|
93
|
+
__name(resolveDateLocale, "resolveDateLocale");
|
|
94
|
+
function formatDateStyle(params) {
|
|
95
|
+
const value = toValidDate(params.date);
|
|
96
|
+
if (!value) return "";
|
|
97
|
+
const style = params.isPublic && PUBLIC_STYLE_MAP[params.style] || params.style;
|
|
98
|
+
return cachedDateTimeFormat(params.locale, style, DATE_STYLE_OPTIONS[style], params.timeZone).format(value);
|
|
99
|
+
}
|
|
100
|
+
__name(formatDateStyle, "formatDateStyle");
|
|
101
|
+
function formatRelativeDate(params) {
|
|
102
|
+
const value = toValidDate(params.date);
|
|
103
|
+
if (!value) return "";
|
|
104
|
+
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
105
|
+
const diff = now.getTime() - value.getTime();
|
|
106
|
+
const sign = diff < 0 ? 1 : -1;
|
|
107
|
+
const seconds = Math.floor(Math.abs(diff) / 1e3);
|
|
108
|
+
const minutes = Math.floor(seconds / 60);
|
|
109
|
+
const hours = Math.floor(minutes / 60);
|
|
110
|
+
const days = Math.floor(hours / 24);
|
|
111
|
+
const relative = cachedRelativeTimeFormat(params.locale);
|
|
112
|
+
if (days > 0) return relative.format(sign * days, "day");
|
|
113
|
+
if (hours > 0) return relative.format(sign * hours, "hour");
|
|
114
|
+
if (minutes > 0) return relative.format(sign * minutes, "minute");
|
|
115
|
+
return relative.format(sign * seconds, "second");
|
|
116
|
+
}
|
|
117
|
+
__name(formatRelativeDate, "formatRelativeDate");
|
|
118
|
+
function usesTwelveHourClock(locale) {
|
|
119
|
+
const hourCycle = cachedDateTimeFormat(locale, "__hourCycle", { hour: "numeric" }).resolvedOptions().hourCycle;
|
|
120
|
+
return hourCycle === "h11" || hourCycle === "h12";
|
|
121
|
+
}
|
|
122
|
+
__name(usesTwelveHourClock, "usesTwelveHourClock");
|
|
123
|
+
var dateFormatLocale = /* @__PURE__ */ __name((appLocale) => appLocale ?? "en", "dateFormatLocale");
|
|
124
|
+
var LEGACY_DATE_OPTIONS = { year: "numeric", month: "2-digit", day: "2-digit" };
|
|
125
|
+
var LEGACY_TIME_OPTIONS = { hour: "2-digit", minute: "2-digit" };
|
|
126
|
+
var formatDate = /* @__PURE__ */ __name((eventDate, formatOption, locale = "en-GB", now) => {
|
|
127
|
+
const reference = now ?? /* @__PURE__ */ new Date();
|
|
128
|
+
const diff = reference.getTime() - eventDate.getTime();
|
|
129
|
+
if (formatOption === "default") {
|
|
130
|
+
if (diff < 24 * 60 * 60 * 1e3) formatOption = "timeSince";
|
|
131
|
+
else formatOption = "dateTime";
|
|
132
|
+
}
|
|
133
|
+
switch (formatOption) {
|
|
134
|
+
case "timeSince":
|
|
135
|
+
return formatRelativeDate({ date: eventDate, locale, now: reference });
|
|
136
|
+
case "date":
|
|
137
|
+
return cachedDateTimeFormat(locale, "__legacyDate", LEGACY_DATE_OPTIONS).format(eventDate);
|
|
138
|
+
case "time":
|
|
139
|
+
return cachedDateTimeFormat(locale, "__legacyTime", LEGACY_TIME_OPTIONS).format(eventDate);
|
|
140
|
+
case "dateTime":
|
|
141
|
+
return `${cachedDateTimeFormat(locale, "__legacyDate", LEGACY_DATE_OPTIONS).format(eventDate)} ${cachedDateTimeFormat(locale, "__legacyTime", LEGACY_TIME_OPTIONS).format(eventDate)}`;
|
|
142
|
+
default:
|
|
143
|
+
throw new Error("Invalid format option");
|
|
144
|
+
}
|
|
145
|
+
}, "formatDate");
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
formatLocalDate,
|
|
149
|
+
resolveDateLocale,
|
|
150
|
+
formatDateStyle,
|
|
151
|
+
formatRelativeDate,
|
|
152
|
+
usesTwelveHourClock,
|
|
153
|
+
dateFormatLocale,
|
|
154
|
+
formatDate
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=chunk-RW6XZGZG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/date-formatter.ts"],"sourcesContent":["type FormatOption = \"date\" | \"time\" | \"dateTime\" | \"timeSince\" | \"default\";\n\n/**\n * Format a `Date` as `YYYY-MM-DD` using the value's local-time components.\n *\n * Use for JSON:API attributes whose backend field type is `\"date\"` (calendar\n * date with no time component). `JSON.stringify(new Date(...))` would call\n * `.toISOString()`, which UTC-shifts and can lose a day west of UTC; this\n * helper avoids that by emitting the local-date components verbatim.\n *\n * For `\"datetime\"` fields use `.toISOString()` instead — those represent an\n * instant in time and the UTC shift is correct.\n */\nexport const formatLocalDate = (d: Date): string => {\n const year = d.getFullYear();\n const month = String(d.getMonth() + 1).padStart(2, \"0\");\n const day = String(d.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n};\n\nexport type DateFormatStyle =\n | \"date\"\n | \"dateMedium\"\n | \"dateLong\"\n | \"dateTime\"\n | \"dateTimeMedium\"\n | \"dateTimeLong\"\n | \"dateTimeSeconds\"\n | \"time\"\n | \"weekdayDateTime\"\n | \"weekdayDay\"\n | \"monthYear\"\n | \"monthYearLong\"\n | \"month\"\n | \"monthLong\"\n | \"dayMonth\"\n | \"weekday\"\n | \"weekdayLong\";\n\nconst NUMERIC_DATE: Intl.DateTimeFormatOptions = { day: \"2-digit\", month: \"2-digit\", year: \"numeric\" };\n\n/**\n * The option set behind each named style. No style pins `hour12` / `hourCycle`:\n * the clock (12 or 24 hours) follows the locale.\n */\nexport const DATE_STYLE_OPTIONS: Record<DateFormatStyle, Intl.DateTimeFormatOptions> = {\n date: NUMERIC_DATE,\n dateMedium: { dateStyle: \"medium\" },\n dateLong: { dateStyle: \"long\" },\n dateTime: { ...NUMERIC_DATE, hour: \"numeric\", minute: \"2-digit\" },\n dateTimeMedium: { dateStyle: \"medium\", timeStyle: \"short\" },\n dateTimeLong: { day: \"numeric\", month: \"long\", year: \"numeric\", hour: \"numeric\", minute: \"2-digit\" },\n dateTimeSeconds: { ...NUMERIC_DATE, hour: \"numeric\", minute: \"2-digit\", second: \"2-digit\" },\n time: { hour: \"numeric\", minute: \"2-digit\" },\n weekdayDateTime: { weekday: \"short\", day: \"numeric\", month: \"short\", hour: \"numeric\", minute: \"2-digit\" },\n weekdayDay: { weekday: \"short\", day: \"numeric\", month: \"long\", year: \"numeric\" },\n monthYear: { month: \"short\", year: \"numeric\" },\n monthYearLong: { month: \"long\", year: \"numeric\" },\n month: { month: \"short\" },\n monthLong: { month: \"long\" },\n dayMonth: { day: \"numeric\", month: \"short\" },\n weekday: { weekday: \"short\" },\n weekdayLong: { weekday: \"long\" },\n};\n\n/** Public pages never show an all-numeric date: the month is spelled out. */\nexport const PUBLIC_STYLE_MAP: Partial<Record<DateFormatStyle, DateFormatStyle>> = {\n date: \"dateMedium\",\n dateTime: \"dateTimeMedium\",\n dateTimeSeconds: \"dateTimeMedium\",\n};\n\nconst formatterCache = new Map<string, Intl.DateTimeFormat>();\n\n/** One cached `Intl.DateTimeFormat` per locale + option-set key + time zone. */\nconst cachedDateTimeFormat = (\n locale: string,\n key: string,\n options: Intl.DateTimeFormatOptions,\n timeZone?: string,\n): Intl.DateTimeFormat => {\n const cacheKey = `${locale}|${key}|${timeZone ?? \"\"}`;\n let formatter = formatterCache.get(cacheKey);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, timeZone ? { ...options, timeZone } : options);\n formatterCache.set(cacheKey, formatter);\n }\n return formatter;\n};\n\nconst relativeCache = new Map<string, Intl.RelativeTimeFormat>();\n\nconst cachedRelativeTimeFormat = (locale: string): Intl.RelativeTimeFormat => {\n let formatter = relativeCache.get(locale);\n if (!formatter) {\n formatter = new Intl.RelativeTimeFormat(locale, { numeric: \"always\" });\n relativeCache.set(locale, formatter);\n }\n return formatter;\n};\n\nconst toValidDate = (date: Date | string | undefined): Date | undefined => {\n if (date === undefined || date === null) return undefined;\n const value = date instanceof Date ? date : new Date(date);\n return Number.isNaN(value.getTime()) ? undefined : value;\n};\n\nconst languageOf = (tag: string): string => tag.split(\"-\")[0].toLowerCase();\n\nconst MAX_ACCEPT_LANGUAGE_ENTRIES = 50;\n\n/**\n * The locale every real-world date is formatted in.\n *\n * The first `Accept-Language` entry (quality order) whose language equals the\n * app language's and that `Intl` supports; otherwise the app language. A\n * malformed entry (`*`, an unparseable or zero quality, an unknown tag) is\n * skipped, never thrown on.\n */\nexport function resolveDateLocale(params: { appLocale: string; acceptLanguage?: string }): string {\n const { appLocale, acceptLanguage } = params;\n if (!acceptLanguage) return appLocale;\n\n const appLanguage = languageOf(appLocale);\n const entries: { tag: string; quality: number; index: number }[] = [];\n\n const parts = acceptLanguage.split(\",\");\n for (let index = 0; index < parts.length && entries.length < MAX_ACCEPT_LANGUAGE_ENTRIES; index++) {\n const [rawTag, ...rawParams] = parts[index].split(\";\");\n const tag = rawTag.trim();\n if (!tag || tag === \"*\") continue;\n\n let quality = 1;\n const qualityParam = rawParams.map((param) => param.trim()).find((param) => param.startsWith(\"q=\"));\n if (qualityParam !== undefined) {\n const raw = qualityParam.slice(2);\n quality = /^\\d+(\\.\\d+)?$/.test(raw) ? Number(raw) : NaN;\n }\n if (!(quality > 0)) continue;\n if (languageOf(tag) !== appLanguage) continue;\n\n entries.push({ tag, quality, index });\n }\n\n entries.sort((a, b) => b.quality - a.quality || a.index - b.index);\n\n for (const entry of entries) {\n try {\n const [supported] = Intl.DateTimeFormat.supportedLocalesOf([entry.tag]);\n if (supported && languageOf(supported) === appLanguage) return supported;\n } catch {\n // An invalid language tag: skip it.\n }\n }\n\n return appLocale;\n}\n\n/**\n * Formats a date in a named style. Returns \"\" for `undefined` or a value that\n * does not parse. `isPublic` swaps the all-numeric styles for month-as-word.\n */\nexport function formatDateStyle(params: {\n date: Date | string | undefined;\n style: DateFormatStyle;\n locale: string;\n timeZone?: string;\n isPublic?: boolean;\n}): string {\n const value = toValidDate(params.date);\n if (!value) return \"\";\n const style = (params.isPublic && PUBLIC_STYLE_MAP[params.style]) || params.style;\n return cachedDateTimeFormat(params.locale, style, DATE_STYLE_OPTIONS[style], params.timeZone).format(value);\n}\n\n/** \"3 hours ago\" / \"3 ore fa\", always numeric (\"1 day ago\", never \"yesterday\"). */\nexport function formatRelativeDate(params: { date: Date | string; locale: string; now?: Date }): string {\n const value = toValidDate(params.date);\n if (!value) return \"\";\n const now = params.now ?? new Date();\n const diff = now.getTime() - value.getTime();\n const sign = diff < 0 ? 1 : -1;\n const seconds = Math.floor(Math.abs(diff) / 1000);\n const minutes = Math.floor(seconds / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n\n const relative = cachedRelativeTimeFormat(params.locale);\n if (days > 0) return relative.format(sign * days, \"day\");\n if (hours > 0) return relative.format(sign * hours, \"hour\");\n if (minutes > 0) return relative.format(sign * minutes, \"minute\");\n return relative.format(sign * seconds, \"second\");\n}\n\n/** True when the locale's clock is 12-hour (hour cycle h11 / h12). */\nexport function usesTwelveHourClock(locale: string): boolean {\n const hourCycle = cachedDateTimeFormat(locale, \"__hourCycle\", { hour: \"numeric\" }).resolvedOptions().hourCycle;\n return hourCycle === \"h11\" || hourCycle === \"h12\";\n}\n\n/** The locale to format dates in for an app locale: the app locale itself, English when missing. */\nexport const dateFormatLocale = (appLocale?: string): string => appLocale ?? \"en\";\n\nconst LEGACY_DATE_OPTIONS: Intl.DateTimeFormatOptions = { year: \"numeric\", month: \"2-digit\", day: \"2-digit\" };\nconst LEGACY_TIME_OPTIONS: Intl.DateTimeFormatOptions = { hour: \"2-digit\", minute: \"2-digit\" };\n\n/**\n * @deprecated Use `formatDateStyle` (or `useDateFormatter().format`) and\n * `formatRelativeDate` (or `useDateFormatter().relative`). Kept for other nja\n * apps: same default locale and the same \"date\" / \"time\" / \"dateTime\" output.\n * Pass `now` from render code; the `new Date()` fallback is for legacy callers.\n */\nexport const formatDate = (\n eventDate: Date,\n formatOption: FormatOption,\n locale: string = \"en-GB\",\n now?: Date,\n): string => {\n const reference = now ?? new Date();\n const diff = reference.getTime() - eventDate.getTime();\n\n if (formatOption === \"default\") {\n if (diff < 24 * 60 * 60 * 1000) formatOption = \"timeSince\";\n else formatOption = \"dateTime\";\n }\n\n switch (formatOption) {\n case \"timeSince\":\n return formatRelativeDate({ date: eventDate, locale, now: reference });\n case \"date\":\n return cachedDateTimeFormat(locale, \"__legacyDate\", LEGACY_DATE_OPTIONS).format(eventDate);\n case \"time\":\n return cachedDateTimeFormat(locale, \"__legacyTime\", LEGACY_TIME_OPTIONS).format(eventDate);\n case \"dateTime\":\n return `${cachedDateTimeFormat(locale, \"__legacyDate\", LEGACY_DATE_OPTIONS).format(eventDate)} ${cachedDateTimeFormat(locale, \"__legacyTime\", LEGACY_TIME_OPTIONS).format(eventDate)}`;\n default:\n throw new Error(\"Invalid format option\");\n }\n};\n\nexport type { FormatOption };\n"],"mappings":";;;;;AAaO,IAAM,kBAAkB,wBAAC,MAAoB;AAClD,QAAM,OAAO,EAAE,YAAY;AAC3B,QAAM,QAAQ,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACtD,QAAM,MAAM,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAC/C,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG;AAChC,GAL+B;AA0B/B,IAAM,eAA2C,EAAE,KAAK,WAAW,OAAO,WAAW,M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QAAQ,gBAAgB,mBAAmB,EAAE,OAAO,SAAS,CAAC;AAAA,IACtL;AACE,YAAM,IAAI,MAAM,uBAAuB;AAAA,EAC3C;AACF,GA1B0B;","names":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkHROKKUBQjs = require('./chunk-HROKKUBQ.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkNP3AFULUjs = require('./chunk-NP3AFULU.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
|
|
13
|
+
|
|
14
|
+
// src/contexts/DateLocaleContext.tsx
|
|
15
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react);
|
|
16
|
+
|
|
17
|
+
// src/utils/map-thenable.ts
|
|
18
|
+
function mapThenable(thenable, map) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
thenable.then((value) => resolve(map(value)), reject);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_chunk7QVYU63Ejs.__name.call(void 0, mapThenable, "mapThenable");
|
|
24
|
+
|
|
25
|
+
// src/contexts/DateLocaleContext.tsx
|
|
26
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
27
|
+
var DateLocaleContext = React.createContext(null);
|
|
28
|
+
function DateLocaleProvider(props) {
|
|
29
|
+
const { session, children } = props;
|
|
30
|
+
const value = React.useMemo(
|
|
31
|
+
() => props.mode === "public" || !session ? { mode: "public" } : { mode: "session", acceptLanguage: mapThenable(session, (snapshot) => snapshot.acceptLanguage) },
|
|
32
|
+
// Created once, like ViewportProvider's seed.
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
35
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DateLocaleContext.Provider, { value, children });
|
|
36
|
+
}
|
|
37
|
+
_chunk7QVYU63Ejs.__name.call(void 0, DateLocaleProvider, "DateLocaleProvider");
|
|
38
|
+
function useDateLocaleSource() {
|
|
39
|
+
return React.useContext(DateLocaleContext);
|
|
40
|
+
}
|
|
41
|
+
_chunk7QVYU63Ejs.__name.call(void 0, useDateLocaleSource, "useDateLocaleSource");
|
|
42
|
+
function DateLocaleSourceProvider({
|
|
43
|
+
value,
|
|
44
|
+
children
|
|
45
|
+
}) {
|
|
46
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DateLocaleContext.Provider, { value, children });
|
|
47
|
+
}
|
|
48
|
+
_chunk7QVYU63Ejs.__name.call(void 0, DateLocaleSourceProvider, "DateLocaleSourceProvider");
|
|
49
|
+
function useDateLocale() {
|
|
50
|
+
const source = React.useContext(DateLocaleContext);
|
|
51
|
+
const appLocale = _chunkNP3AFULUjs.useI18nLocale.call(void 0, );
|
|
52
|
+
const acceptLanguage = _optionalChain([source, 'optionalAccess', _ => _.mode]) === "session" ? React.use(source.acceptLanguage) : void 0;
|
|
53
|
+
const isPublic = _optionalChain([source, 'optionalAccess', _2 => _2.mode]) === "public";
|
|
54
|
+
const locale = _optionalChain([source, 'optionalAccess', _3 => _3.mode]) === "session" ? _chunkHROKKUBQjs.resolveDateLocale.call(void 0, { appLocale, acceptLanguage }) : appLocale;
|
|
55
|
+
return React.useMemo(() => ({ locale, isPublic }), [locale, isPublic]);
|
|
56
|
+
}
|
|
57
|
+
_chunk7QVYU63Ejs.__name.call(void 0, useDateLocale, "useDateLocale");
|
|
58
|
+
function useDateFormatter() {
|
|
59
|
+
const { locale, isPublic } = useDateLocale();
|
|
60
|
+
return React.useMemo(
|
|
61
|
+
() => ({
|
|
62
|
+
locale,
|
|
63
|
+
isPublic,
|
|
64
|
+
format: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (date, style, options) => _chunkHROKKUBQjs.formatDateStyle.call(void 0, { date, style, locale, timeZone: _optionalChain([options, 'optionalAccess', _4 => _4.timeZone]), isPublic }), "format"),
|
|
65
|
+
relative: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (date, options) => _chunkHROKKUBQjs.formatRelativeDate.call(void 0, { date, locale, now: options.now }), "relative"),
|
|
66
|
+
twelveHourClock: _chunkHROKKUBQjs.usesTwelveHourClock.call(void 0, locale)
|
|
67
|
+
}),
|
|
68
|
+
[locale, isPublic]
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
_chunk7QVYU63Ejs.__name.call(void 0, useDateFormatter, "useDateFormatter");
|
|
72
|
+
function useMountedNow() {
|
|
73
|
+
const [now, setNow] = React.useState(void 0);
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
setNow(/* @__PURE__ */ new Date());
|
|
76
|
+
}, []);
|
|
77
|
+
return now;
|
|
78
|
+
}
|
|
79
|
+
_chunk7QVYU63Ejs.__name.call(void 0, useMountedNow, "useMountedNow");
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
exports.mapThenable = mapThenable; exports.DateLocaleProvider = DateLocaleProvider; exports.useDateLocaleSource = useDateLocaleSource; exports.DateLocaleSourceProvider = DateLocaleSourceProvider; exports.useDateLocale = useDateLocale; exports.useDateFormatter = useDateFormatter; exports.useMountedNow = useMountedNow;
|
|
90
|
+
//# sourceMappingURL=chunk-SYMI4IDW.js.map
|