@objectstack/core 9.8.0 → 9.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1741,6 +1741,40 @@ declare function getMemoryUsage(): {
|
|
|
1741
1741
|
heapTotal: number;
|
|
1742
1742
|
};
|
|
1743
1743
|
|
|
1744
|
+
/**
|
|
1745
|
+
* Timezone-aware calendar utilities (ADR-0053 Phase 2).
|
|
1746
|
+
*
|
|
1747
|
+
* The one primitive everything else builds on is {@link calendarPartsInTz}:
|
|
1748
|
+
* the year/month/day an instant falls on *as seen in a reference timezone*.
|
|
1749
|
+
* It uses `Intl.DateTimeFormat().formatToParts()` so DST transitions are
|
|
1750
|
+
* handled by the platform's tz database — never hand-rolled offset math, which
|
|
1751
|
+
* is the classic source of off-by-one-hour bucket errors.
|
|
1752
|
+
*
|
|
1753
|
+
* This lives in `@objectstack/core` (not `@objectstack/formula`) because both
|
|
1754
|
+
* the ObjectQL aggregation engine and the analytics service need it and both
|
|
1755
|
+
* already depend on core, whereas neither depends on formula's public surface.
|
|
1756
|
+
* (`@objectstack/formula` keeps its own private copy for `today()`/`daysFromNow`
|
|
1757
|
+
* to avoid a layering dependency on core.)
|
|
1758
|
+
*/
|
|
1759
|
+
/** Calendar-day parts in a reference timezone. `month` is 1-12. */
|
|
1760
|
+
interface CalendarParts {
|
|
1761
|
+
year: number;
|
|
1762
|
+
month: number;
|
|
1763
|
+
day: number;
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* The year/month/day an instant falls on in `tz`. Throws if `tz` is not a
|
|
1767
|
+
* valid IANA zone (callers treat that as a fall-through to UTC).
|
|
1768
|
+
*/
|
|
1769
|
+
declare function calendarPartsInTz(d: Date, tz: string): CalendarParts;
|
|
1770
|
+
/**
|
|
1771
|
+
* The calendar-day parts of an instant, in `tz` when it's a real non-UTC zone,
|
|
1772
|
+
* otherwise in UTC. Never throws: an unset, `'UTC'`, or invalid zone falls back
|
|
1773
|
+
* to the UTC calendar day. This is the safe entry point for bucketing code that
|
|
1774
|
+
* must degrade to the historical UTC behavior rather than error.
|
|
1775
|
+
*/
|
|
1776
|
+
declare function calendarPartsInTzOrUtc(d: Date, tz?: string): CalendarParts;
|
|
1777
|
+
|
|
1744
1778
|
/**
|
|
1745
1779
|
* In-memory Map-backed cache fallback.
|
|
1746
1780
|
*
|
|
@@ -2133,4 +2167,4 @@ declare class NamespaceResolver {
|
|
|
2133
2167
|
private suggestAlternative;
|
|
2134
2168
|
}
|
|
2135
2169
|
|
|
2136
|
-
export { API_KEY_PREFIX, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, DependencyResolver, type GeneratedApiKey, HotReloadManager, type KernelState, type KeyInput, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PublisherVerifyResult, index as QA, type ResourceUsage, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isExpired, isNode, parseScopes, parseSignature, resolveApiKeyPrincipal, resolveLocale, safeExit, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature };
|
|
2170
|
+
export { API_KEY_PREFIX, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, type CalendarParts, DependencyResolver, type GeneratedApiKey, HotReloadManager, type KernelState, type KeyInput, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PublisherVerifyResult, index as QA, type ResourceUsage, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, calendarPartsInTz, calendarPartsInTzOrUtc, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isExpired, isNode, parseScopes, parseSignature, resolveApiKeyPrincipal, resolveLocale, safeExit, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1741,6 +1741,40 @@ declare function getMemoryUsage(): {
|
|
|
1741
1741
|
heapTotal: number;
|
|
1742
1742
|
};
|
|
1743
1743
|
|
|
1744
|
+
/**
|
|
1745
|
+
* Timezone-aware calendar utilities (ADR-0053 Phase 2).
|
|
1746
|
+
*
|
|
1747
|
+
* The one primitive everything else builds on is {@link calendarPartsInTz}:
|
|
1748
|
+
* the year/month/day an instant falls on *as seen in a reference timezone*.
|
|
1749
|
+
* It uses `Intl.DateTimeFormat().formatToParts()` so DST transitions are
|
|
1750
|
+
* handled by the platform's tz database — never hand-rolled offset math, which
|
|
1751
|
+
* is the classic source of off-by-one-hour bucket errors.
|
|
1752
|
+
*
|
|
1753
|
+
* This lives in `@objectstack/core` (not `@objectstack/formula`) because both
|
|
1754
|
+
* the ObjectQL aggregation engine and the analytics service need it and both
|
|
1755
|
+
* already depend on core, whereas neither depends on formula's public surface.
|
|
1756
|
+
* (`@objectstack/formula` keeps its own private copy for `today()`/`daysFromNow`
|
|
1757
|
+
* to avoid a layering dependency on core.)
|
|
1758
|
+
*/
|
|
1759
|
+
/** Calendar-day parts in a reference timezone. `month` is 1-12. */
|
|
1760
|
+
interface CalendarParts {
|
|
1761
|
+
year: number;
|
|
1762
|
+
month: number;
|
|
1763
|
+
day: number;
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* The year/month/day an instant falls on in `tz`. Throws if `tz` is not a
|
|
1767
|
+
* valid IANA zone (callers treat that as a fall-through to UTC).
|
|
1768
|
+
*/
|
|
1769
|
+
declare function calendarPartsInTz(d: Date, tz: string): CalendarParts;
|
|
1770
|
+
/**
|
|
1771
|
+
* The calendar-day parts of an instant, in `tz` when it's a real non-UTC zone,
|
|
1772
|
+
* otherwise in UTC. Never throws: an unset, `'UTC'`, or invalid zone falls back
|
|
1773
|
+
* to the UTC calendar day. This is the safe entry point for bucketing code that
|
|
1774
|
+
* must degrade to the historical UTC behavior rather than error.
|
|
1775
|
+
*/
|
|
1776
|
+
declare function calendarPartsInTzOrUtc(d: Date, tz?: string): CalendarParts;
|
|
1777
|
+
|
|
1744
1778
|
/**
|
|
1745
1779
|
* In-memory Map-backed cache fallback.
|
|
1746
1780
|
*
|
|
@@ -2133,4 +2167,4 @@ declare class NamespaceResolver {
|
|
|
2133
2167
|
private suggestAlternative;
|
|
2134
2168
|
}
|
|
2135
2169
|
|
|
2136
|
-
export { API_KEY_PREFIX, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, DependencyResolver, type GeneratedApiKey, HotReloadManager, type KernelState, type KeyInput, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PublisherVerifyResult, index as QA, type ResourceUsage, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isExpired, isNode, parseScopes, parseSignature, resolveApiKeyPrincipal, resolveLocale, safeExit, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature };
|
|
2170
|
+
export { API_KEY_PREFIX, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, CORE_FALLBACK_FACTORIES, type CalendarParts, DependencyResolver, type GeneratedApiKey, HotReloadManager, type KernelState, type KeyInput, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PublisherVerifyResult, index as QA, type ResourceUsage, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, calendarPartsInTz, calendarPartsInTzOrUtc, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isExpired, isNode, parseScopes, parseSignature, resolveApiKeyPrincipal, resolveLocale, safeExit, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature };
|
package/dist/index.js
CHANGED
|
@@ -3987,6 +3987,31 @@ function safeJsonParse(s, fallback) {
|
|
|
3987
3987
|
}
|
|
3988
3988
|
}
|
|
3989
3989
|
|
|
3990
|
+
// src/utils/datetime.ts
|
|
3991
|
+
function calendarPartsInTz(d, tz) {
|
|
3992
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
3993
|
+
timeZone: tz,
|
|
3994
|
+
year: "numeric",
|
|
3995
|
+
month: "2-digit",
|
|
3996
|
+
day: "2-digit"
|
|
3997
|
+
}).formatToParts(d);
|
|
3998
|
+
const get = (t) => Number(parts.find((p) => p.type === t)?.value);
|
|
3999
|
+
return { year: get("year"), month: get("month"), day: get("day") };
|
|
4000
|
+
}
|
|
4001
|
+
function calendarPartsInTzOrUtc(d, tz) {
|
|
4002
|
+
if (tz && tz !== "UTC") {
|
|
4003
|
+
try {
|
|
4004
|
+
return calendarPartsInTz(d, tz);
|
|
4005
|
+
} catch {
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
return {
|
|
4009
|
+
year: d.getUTCFullYear(),
|
|
4010
|
+
month: d.getUTCMonth() + 1,
|
|
4011
|
+
day: d.getUTCDate()
|
|
4012
|
+
};
|
|
4013
|
+
}
|
|
4014
|
+
|
|
3990
4015
|
// src/health-monitor.ts
|
|
3991
4016
|
var PluginHealthMonitor = class {
|
|
3992
4017
|
constructor(logger) {
|
|
@@ -4925,6 +4950,8 @@ export {
|
|
|
4925
4950
|
SemanticVersionManager,
|
|
4926
4951
|
ServiceLifecycle,
|
|
4927
4952
|
buildPermissionsFromGrants,
|
|
4953
|
+
calendarPartsInTz,
|
|
4954
|
+
calendarPartsInTzOrUtc,
|
|
4928
4955
|
counterSignPayload,
|
|
4929
4956
|
createApiRegistryPlugin,
|
|
4930
4957
|
createLogger,
|