processfocus 0.1.0-next.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/LICENSE.md +28 -0
- package/README.md +14 -0
- package/dist/auth-FmXptohB.mjs +275 -0
- package/dist/auth-config/src/lib/authentication-config.d.ts +146 -0
- package/dist/auth-config/src/lib/custom-entities-config.d.ts +47 -0
- package/dist/auth-config/src/lib/policies-config.d.ts +52 -0
- package/dist/auth-config/src/lib/provider-types.d.ts +194 -0
- package/dist/auth.d.ts +4 -0
- package/dist/auth.mjs +2 -0
- package/dist/business-calendar/src/index.d.ts +10 -0
- package/dist/business-calendar/src/lib/calendar-config.d.ts +163 -0
- package/dist/business-calendar/src/lib/calendar-period.d.ts +88 -0
- package/dist/business-calendar/src/lib/calendar-service-impl.d.ts +19 -0
- package/dist/business-calendar/src/lib/calendar-service.d.ts +215 -0
- package/dist/business-calendar/src/lib/datetime-utils.d.ts +30 -0
- package/dist/business-calendar/src/lib/duration-calculator.d.ts +49 -0
- package/dist/business-calendar/src/lib/errors.d.ts +69 -0
- package/dist/business-calendar/src/lib/holiday-calculator.d.ts +61 -0
- package/dist/business-calendar/src/lib/holidays.d.ts +141 -0
- package/dist/business-calendar/src/lib/types.d.ts +110 -0
- package/dist/calendar.d.ts +1 -0
- package/dist/calendar.mjs +1204 -0
- package/dist/form-client-representation/src/index.d.ts +6 -0
- package/dist/form-client-representation/src/lib/as-client-representation.d.ts +31 -0
- package/dist/form-client-representation/src/lib/client-form-definition.d.ts +17 -0
- package/dist/form-client-representation/src/lib/extract-annotations.d.ts +20 -0
- package/dist/form-client-representation/src/lib/plugin-registry.d.ts +6 -0
- package/dist/form-client-representation/src/lib/types.d.ts +239 -0
- package/dist/form-client-representation/src/lib/walker.d.ts +68 -0
- package/dist/form-rule/src/index.d.ts +3 -0
- package/dist/form-rule/src/lib/evaluator.d.ts +2 -0
- package/dist/form-rule/src/lib/paths.d.ts +9 -0
- package/dist/form-rule/src/lib/types.d.ts +89 -0
- package/dist/form-schema/src/index.d.ts +8 -0
- package/dist/form-schema/src/lib/annotation-helpers.d.ts +8 -0
- package/dist/form-schema/src/lib/deferred-value.d.ts +10 -0
- package/dist/form-schema/src/lib/email.d.ts +23 -0
- package/dist/form-schema/src/lib/field-count.d.ts +32 -0
- package/dist/form-schema/src/lib/form-annotations.d.ts +25 -0
- package/dist/form-schema/src/lib/form-schema.d.ts +459 -0
- package/dist/form-schema/src/lib/phone.d.ts +4 -0
- package/dist/form-schema/src/lib/property-signature.d.ts +3 -0
- package/dist/form-submission-schema/src/index.d.ts +2 -0
- package/dist/form-submission-schema/src/lib/form-submission-schema.d.ts +49 -0
- package/dist/form-submission-schema/src/lib/schema-defaults.d.ts +16 -0
- package/dist/forms.d.ts +1 -0
- package/dist/forms.mjs +2 -0
- package/dist/frontend-manifest/src/index.d.ts +2 -0
- package/dist/frontend-manifest/src/lib/browser-plugin-artifact.d.ts +25 -0
- package/dist/frontend-manifest/src/lib/frontend-manifest.d.ts +83 -0
- package/dist/frontend-plugin-host/src/index.d.ts +2 -0
- package/dist/frontend-plugin-host/src/lib/frontend-plugin-host.d.ts +124 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.mjs +3780 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.mjs +5 -0
- package/dist/paths-BkzLn-rG.mjs +282 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.mjs +84 -0
- package/dist/process/src/lib/app-icons.d.ts +52 -0
- package/dist/process/src/lib/brands.d.ts +20 -0
- package/dist/process/src/lib/document-store.d.ts +30 -0
- package/dist/process/src/lib/execution-failure-notifications.d.ts +14 -0
- package/dist/process/src/lib/flow-context.d.ts +181 -0
- package/dist/process/src/lib/flow-path.d.ts +123 -0
- package/dist/process/src/lib/form-authoring.d.ts +19 -0
- package/dist/process/src/lib/form-decoration.d.ts +13 -0
- package/dist/process/src/lib/form-defaults.d.ts +5 -0
- package/dist/process/src/lib/form.d.ts +557 -0
- package/dist/process/src/lib/invitation.d.ts +35 -0
- package/dist/process/src/lib/list.d.ts +447 -0
- package/dist/process/src/lib/lookup-accessor.d.ts +68 -0
- package/dist/process/src/lib/node_step.d.ts +68 -0
- package/dist/process/src/lib/org-unit.d.ts +53 -0
- package/dist/process/src/lib/org-utils.d.ts +56 -0
- package/dist/process/src/lib/organisation-frontend-plugin-manifest.d.ts +33 -0
- package/dist/process/src/lib/organisation.d.ts +166 -0
- package/dist/process/src/lib/phase.d.ts +16 -0
- package/dist/process/src/lib/process.d.ts +196 -0
- package/dist/process/src/lib/public-form-branding.d.ts +27 -0
- package/dist/process/src/lib/role.d.ts +29 -0
- package/dist/process/src/lib/schedule.d.ts +239 -0
- package/dist/process/src/lib/sla.d.ts +84 -0
- package/dist/process/src/lib/stats-view.d.ts +68 -0
- package/dist/process/src/lib/step.d.ts +130 -0
- package/dist/process/src/lib/system-step-executor.d.ts +130 -0
- package/dist/process/src/lib/system-step.d.ts +248 -0
- package/dist/sdk/src/auth.d.ts +4 -0
- package/dist/sdk/src/calendar.d.ts +1 -0
- package/dist/sdk/src/forms.d.ts +1 -0
- package/dist/sdk/src/index.d.ts +26 -0
- package/dist/sdk/src/manifest.d.ts +2 -0
- package/dist/sdk/src/plugin.d.ts +3 -0
- package/dist/sdk/src/testing.d.ts +9 -0
- package/dist/src-C-909PVQ.mjs +498 -0
- package/dist/testing.d.ts +9 -0
- package/dist/testing.mjs +5 -0
- package/package.json +67 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Passkey (WebAuthn) provider configuration.
|
|
4
|
+
*/
|
|
5
|
+
export interface PasskeyProviderConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The Relying Party name displayed to users during registration.
|
|
8
|
+
* @example "Process Focus"
|
|
9
|
+
*/
|
|
10
|
+
readonly rpName: string;
|
|
11
|
+
/**
|
|
12
|
+
* The Relying Party ID (domain without protocol).
|
|
13
|
+
* @example "localhost" or "example.com"
|
|
14
|
+
*/
|
|
15
|
+
readonly rpID: string;
|
|
16
|
+
/**
|
|
17
|
+
* The allowed origin(s) for WebAuthn requests.
|
|
18
|
+
* @example "http://localhost:3000" or ["https://example.com", "https://app.example.com"]
|
|
19
|
+
*/
|
|
20
|
+
readonly origin: string | readonly string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Effect Schema for PasskeyProviderConfig validation.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PasskeyProviderConfigSchema: Schema.Struct<{
|
|
26
|
+
rpName: typeof Schema.String;
|
|
27
|
+
rpID: typeof Schema.String;
|
|
28
|
+
origin: Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.String>]>;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Supported OAuth provider names.
|
|
32
|
+
*/
|
|
33
|
+
export declare const OAUTH_PROVIDER_NAMES: readonly ["google", "github", "microsoft", "apple", "discord", "spotify", "slack", "linkedin", "twitch", "yahoo", "x", "keycloak", "cognito", "jumpcloud", "facebook"];
|
|
34
|
+
export type OAuthProviderName = (typeof OAUTH_PROVIDER_NAMES)[number];
|
|
35
|
+
export declare const DEFAULT_OAUTH_PROVIDER_SCOPES: Record<OAuthProviderName, readonly string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* OAuth provider configuration matching OpenAuth's Oauth2WrappedConfig.
|
|
38
|
+
*/
|
|
39
|
+
export interface OAuthProviderConfig {
|
|
40
|
+
readonly clientID: string;
|
|
41
|
+
readonly clientSecret: string;
|
|
42
|
+
readonly scopes: string[];
|
|
43
|
+
readonly pkce?: boolean;
|
|
44
|
+
readonly query?: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
export interface AppleOAuthProviderConfig extends OAuthProviderConfig {
|
|
47
|
+
readonly responseMode?: "query" | "form_post";
|
|
48
|
+
}
|
|
49
|
+
export interface MicrosoftOAuthProviderConfig extends OAuthProviderConfig {
|
|
50
|
+
readonly tenant: string;
|
|
51
|
+
}
|
|
52
|
+
export interface SlackOAuthProviderConfig extends OAuthProviderConfig {
|
|
53
|
+
readonly team: string;
|
|
54
|
+
}
|
|
55
|
+
export interface KeycloakOAuthProviderConfig extends OAuthProviderConfig {
|
|
56
|
+
readonly baseUrl: string;
|
|
57
|
+
readonly realm: string;
|
|
58
|
+
}
|
|
59
|
+
export interface CognitoOAuthProviderConfig extends OAuthProviderConfig {
|
|
60
|
+
readonly domain: string;
|
|
61
|
+
readonly region: string;
|
|
62
|
+
/** Required for OIDC issuer and signing-key verification. */
|
|
63
|
+
readonly userPoolId: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Effect Schema for OAuthProviderConfig validation.
|
|
67
|
+
*/
|
|
68
|
+
export declare const OAuthProviderConfigSchema: Schema.Struct<{
|
|
69
|
+
clientID: typeof Schema.String;
|
|
70
|
+
clientSecret: typeof Schema.String;
|
|
71
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
72
|
+
pkce: Schema.optional<typeof Schema.Boolean>;
|
|
73
|
+
query: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
74
|
+
}>;
|
|
75
|
+
export declare const AppleOAuthProviderConfigSchema: Schema.extend<Schema.Struct<{
|
|
76
|
+
clientID: typeof Schema.String;
|
|
77
|
+
clientSecret: typeof Schema.String;
|
|
78
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
79
|
+
pkce: Schema.optional<typeof Schema.Boolean>;
|
|
80
|
+
query: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
81
|
+
}>, Schema.Struct<{
|
|
82
|
+
responseMode: Schema.optional<Schema.Literal<["query", "form_post"]>>;
|
|
83
|
+
}>>;
|
|
84
|
+
export declare const MicrosoftOAuthProviderConfigSchema: Schema.extend<Schema.Struct<{
|
|
85
|
+
clientID: typeof Schema.String;
|
|
86
|
+
clientSecret: typeof Schema.String;
|
|
87
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
88
|
+
pkce: Schema.optional<typeof Schema.Boolean>;
|
|
89
|
+
query: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
90
|
+
}>, Schema.Struct<{
|
|
91
|
+
tenant: typeof Schema.String;
|
|
92
|
+
}>>;
|
|
93
|
+
export declare const SlackOAuthProviderConfigSchema: Schema.extend<Schema.Struct<{
|
|
94
|
+
clientID: typeof Schema.String;
|
|
95
|
+
clientSecret: typeof Schema.String;
|
|
96
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
97
|
+
pkce: Schema.optional<typeof Schema.Boolean>;
|
|
98
|
+
query: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
99
|
+
}>, Schema.Struct<{
|
|
100
|
+
team: typeof Schema.String;
|
|
101
|
+
}>>;
|
|
102
|
+
export declare const KeycloakOAuthProviderConfigSchema: Schema.extend<Schema.Struct<{
|
|
103
|
+
clientID: typeof Schema.String;
|
|
104
|
+
clientSecret: typeof Schema.String;
|
|
105
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
106
|
+
pkce: Schema.optional<typeof Schema.Boolean>;
|
|
107
|
+
query: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
108
|
+
}>, Schema.Struct<{
|
|
109
|
+
baseUrl: typeof Schema.String;
|
|
110
|
+
realm: typeof Schema.String;
|
|
111
|
+
}>>;
|
|
112
|
+
export declare const CognitoOAuthProviderConfigSchema: Schema.extend<Schema.Struct<{
|
|
113
|
+
clientID: typeof Schema.String;
|
|
114
|
+
clientSecret: typeof Schema.String;
|
|
115
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
116
|
+
pkce: Schema.optional<typeof Schema.Boolean>;
|
|
117
|
+
query: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
118
|
+
}>, Schema.Struct<{
|
|
119
|
+
domain: typeof Schema.String;
|
|
120
|
+
region: typeof Schema.String;
|
|
121
|
+
userPoolId: typeof Schema.String;
|
|
122
|
+
}>>;
|
|
123
|
+
/**
|
|
124
|
+
* Effect Schema for OAuthProviderName validation.
|
|
125
|
+
*/
|
|
126
|
+
export declare const OAuthProviderNameSchema: Schema.Literal<["google", "github", "microsoft", "apple", "discord", "spotify", "slack", "linkedin", "twitch", "yahoo", "x", "keycloak", "cognito", "jumpcloud", "facebook"]>;
|
|
127
|
+
/**
|
|
128
|
+
* Google OAuth provider configuration extending the base OAuth config
|
|
129
|
+
* with Google Workspace organizational unit (OU) invitation support.
|
|
130
|
+
*/
|
|
131
|
+
export interface GoogleOAuthProviderConfig extends OAuthProviderConfig {
|
|
132
|
+
/**
|
|
133
|
+
* Google Workspace organizational unit paths that are automatically invited.
|
|
134
|
+
* Users authenticating via Google whose OU matches one of these paths
|
|
135
|
+
* will be auto-assigned roles.
|
|
136
|
+
* @example ["/Staff", "/Board members"]
|
|
137
|
+
*/
|
|
138
|
+
readonly invitedOrgUnits?: string[];
|
|
139
|
+
/**
|
|
140
|
+
* When true, map the user's Google OU path to a role with the same path.
|
|
141
|
+
* The org model must define roles whose paths mirror the Google OU structure.
|
|
142
|
+
*/
|
|
143
|
+
readonly orgUnitAsRole?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Base64-encoded JSON service account key for Google Directory API access.
|
|
146
|
+
* Required for OU lookups via domain-wide delegation.
|
|
147
|
+
*/
|
|
148
|
+
readonly serviceAccountKey?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Workspace admin email for domain-wide delegation.
|
|
151
|
+
* The service account impersonates this admin to call the Directory API.
|
|
152
|
+
*/
|
|
153
|
+
readonly adminEmail?: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Effect Schema for GoogleOAuthProviderConfig validation.
|
|
157
|
+
* Extends the base OAuthProviderConfigSchema with Google-specific fields.
|
|
158
|
+
*/
|
|
159
|
+
export declare const GoogleOAuthProviderConfigSchema: Schema.extend<Schema.Struct<{
|
|
160
|
+
clientID: typeof Schema.String;
|
|
161
|
+
clientSecret: typeof Schema.String;
|
|
162
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
163
|
+
pkce: Schema.optional<typeof Schema.Boolean>;
|
|
164
|
+
query: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
165
|
+
}>, Schema.Struct<{
|
|
166
|
+
invitedOrgUnits: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
167
|
+
orgUnitAsRole: Schema.optional<typeof Schema.Boolean>;
|
|
168
|
+
serviceAccountKey: Schema.optional<typeof Schema.String>;
|
|
169
|
+
adminEmail: Schema.optional<typeof Schema.String>;
|
|
170
|
+
}>>;
|
|
171
|
+
/**
|
|
172
|
+
* Secret client configuration for M2M (machine-to-machine) authentication
|
|
173
|
+
* via OAuth2 client_credentials grant.
|
|
174
|
+
*/
|
|
175
|
+
export interface SecretClientConfig {
|
|
176
|
+
/**
|
|
177
|
+
* The client secret for authentication.
|
|
178
|
+
* This should be a secure, randomly generated string.
|
|
179
|
+
*/
|
|
180
|
+
readonly secret: string;
|
|
181
|
+
/**
|
|
182
|
+
* The audience claim for tokens issued to this client.
|
|
183
|
+
* This identifies the intended recipient of the token (e.g., "ci" for CI/CD pipelines).
|
|
184
|
+
* The GraphQL server must be configured to accept this audience.
|
|
185
|
+
*/
|
|
186
|
+
readonly audience: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Effect Schema for SecretClientConfig validation.
|
|
190
|
+
*/
|
|
191
|
+
export declare const SecretClientConfigSchema: Schema.Struct<{
|
|
192
|
+
secret: typeof Schema.String;
|
|
193
|
+
audience: typeof Schema.String;
|
|
194
|
+
}>;
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AuthenticationConfig, type AuthenticationConfigProps, type IdentityProvidersConfig, type SecretClientsConfig, isAuthenticationConfig, } from "./auth-config/src/lib/authentication-config.js";
|
|
2
|
+
export { CustomEntitiesConfig, type CustomEntitiesConfigProps, isCustomEntitiesConfig, } from "./auth-config/src/lib/custom-entities-config.js";
|
|
3
|
+
export { PoliciesConfig, type PoliciesConfigProps, isPoliciesConfig, } from "./auth-config/src/lib/policies-config.js";
|
|
4
|
+
export { type AppleOAuthProviderConfig, AppleOAuthProviderConfigSchema, type CognitoOAuthProviderConfig, CognitoOAuthProviderConfigSchema, DEFAULT_OAUTH_PROVIDER_SCOPES, type GoogleOAuthProviderConfig, GoogleOAuthProviderConfigSchema, type KeycloakOAuthProviderConfig, KeycloakOAuthProviderConfigSchema, type MicrosoftOAuthProviderConfig, MicrosoftOAuthProviderConfigSchema, OAUTH_PROVIDER_NAMES, type OAuthProviderConfig, OAuthProviderConfigSchema, type OAuthProviderName, OAuthProviderNameSchema, type PasskeyProviderConfig, PasskeyProviderConfigSchema, type SecretClientConfig, SecretClientConfigSchema, type SlackOAuthProviderConfig, SlackOAuthProviderConfigSchema, } from "./auth-config/src/lib/provider-types.js";
|
package/dist/auth.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as AuthenticationConfig, a as KeycloakOAuthProviderConfigSchema, c as OAuthProviderConfigSchema, d as SecretClientConfigSchema, f as SlackOAuthProviderConfigSchema, g as isCustomEntitiesConfig, h as CustomEntitiesConfig, i as GoogleOAuthProviderConfigSchema, l as OAuthProviderNameSchema, m as isPoliciesConfig, n as CognitoOAuthProviderConfigSchema, o as MicrosoftOAuthProviderConfigSchema, p as PoliciesConfig, r as DEFAULT_OAUTH_PROVIDER_SCOPES, s as OAUTH_PROVIDER_NAMES, t as AppleOAuthProviderConfigSchema, u as PasskeyProviderConfigSchema, v as isAuthenticationConfig } from "./auth-FmXptohB.mjs";
|
|
2
|
+
export { AppleOAuthProviderConfigSchema, AuthenticationConfig, CognitoOAuthProviderConfigSchema, CustomEntitiesConfig, DEFAULT_OAUTH_PROVIDER_SCOPES, GoogleOAuthProviderConfigSchema, KeycloakOAuthProviderConfigSchema, MicrosoftOAuthProviderConfigSchema, OAUTH_PROVIDER_NAMES, OAuthProviderConfigSchema, OAuthProviderNameSchema, PasskeyProviderConfigSchema, PoliciesConfig, SecretClientConfigSchema, SlackOAuthProviderConfigSchema, isAuthenticationConfig, isCustomEntitiesConfig, isPoliciesConfig };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./lib/calendar-config.js";
|
|
2
|
+
export * from "./lib/calendar-period.js";
|
|
3
|
+
export * from "./lib/calendar-service.js";
|
|
4
|
+
export * from "./lib/calendar-service-impl.js";
|
|
5
|
+
export * from "./lib/datetime-utils.js";
|
|
6
|
+
export * from "./lib/duration-calculator.js";
|
|
7
|
+
export * from "./lib/errors.js";
|
|
8
|
+
export * from "./lib/holiday-calculator.js";
|
|
9
|
+
export * from "./lib/holidays.js";
|
|
10
|
+
export * from "./lib/types.js";
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { Holiday } from "./holidays.js";
|
|
3
|
+
import { DaySchedule } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Date exception: one-off override for a specific date.
|
|
6
|
+
* Takes precedence over holidays and periods.
|
|
7
|
+
*
|
|
8
|
+
* @property slots - Time ranges for this date, or "closed" to mark as non-working
|
|
9
|
+
* @property note - Optional human-readable note (e.g., "Early closing for staff party")
|
|
10
|
+
*/
|
|
11
|
+
export declare const DateException: Schema.Struct<{
|
|
12
|
+
date: typeof Schema.DateTimeUtcFromSelf;
|
|
13
|
+
slots: Schema.Union<[Schema.Array$<Schema.Struct<{
|
|
14
|
+
open: Schema.Struct<{
|
|
15
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
16
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
17
|
+
}>;
|
|
18
|
+
close: Schema.Struct<{
|
|
19
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
20
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
21
|
+
}>;
|
|
22
|
+
}>>, Schema.Literal<["closed"]>]>;
|
|
23
|
+
note: Schema.optional<typeof Schema.String>;
|
|
24
|
+
}>;
|
|
25
|
+
export type DateException = typeof DateException.Type;
|
|
26
|
+
/**
|
|
27
|
+
* Schema for encoding DateException to JSON (for database storage).
|
|
28
|
+
*/
|
|
29
|
+
export declare const DateExceptionFromJson: Schema.Struct<{
|
|
30
|
+
date: typeof Schema.DateTimeUtc;
|
|
31
|
+
slots: Schema.Union<[Schema.Array$<Schema.Struct<{
|
|
32
|
+
open: Schema.Struct<{
|
|
33
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
34
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
35
|
+
}>;
|
|
36
|
+
close: Schema.Struct<{
|
|
37
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
38
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
39
|
+
}>;
|
|
40
|
+
}>>, Schema.Literal<["closed"]>]>;
|
|
41
|
+
note: Schema.optional<typeof Schema.String>;
|
|
42
|
+
}>;
|
|
43
|
+
export type DateExceptionFromJson = typeof DateExceptionFromJson.Type;
|
|
44
|
+
/**
|
|
45
|
+
* Complete business calendar configuration.
|
|
46
|
+
* Combines weekly schedule, holidays, exceptions, and periods.
|
|
47
|
+
*
|
|
48
|
+
* Note: Timezone is stored at the Organisation/OrgUnit level, not here.
|
|
49
|
+
* The calendar service receives timezone from context.
|
|
50
|
+
*/
|
|
51
|
+
export declare const BusinessCalendarConfig: Schema.Struct<{
|
|
52
|
+
/**
|
|
53
|
+
* Default weekly schedule.
|
|
54
|
+
* Days without entries are considered non-working.
|
|
55
|
+
*/
|
|
56
|
+
weeklySchedule: Schema.Array$<Schema.Struct<{
|
|
57
|
+
day: Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">;
|
|
58
|
+
ranges: Schema.Array$<Schema.Struct<{
|
|
59
|
+
open: Schema.Struct<{
|
|
60
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
61
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
62
|
+
}>;
|
|
63
|
+
close: Schema.Struct<{
|
|
64
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
65
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
66
|
+
}>;
|
|
67
|
+
}>>;
|
|
68
|
+
}>>;
|
|
69
|
+
/**
|
|
70
|
+
* Holiday rules (fixed, nth weekday, Easter-relative, etc.).
|
|
71
|
+
* Holidays are computed for each year as needed.
|
|
72
|
+
*/
|
|
73
|
+
holidays: Schema.Array$<Schema.Union<[Schema.TaggedStruct<"FixedHoliday", {
|
|
74
|
+
name: typeof Schema.String;
|
|
75
|
+
month: Schema.brand<Schema.filter<typeof Schema.Int>, "Month">;
|
|
76
|
+
day: Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfMonth">;
|
|
77
|
+
}>, Schema.TaggedStruct<"NthWeekdayHoliday", {
|
|
78
|
+
name: typeof Schema.String;
|
|
79
|
+
month: Schema.brand<Schema.filter<typeof Schema.Int>, "Month">;
|
|
80
|
+
weekday: Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">;
|
|
81
|
+
nth: Schema.brand<Schema.filter<typeof Schema.Int>, "NthOccurrence">;
|
|
82
|
+
}>, Schema.TaggedStruct<"LastWeekdayHoliday", {
|
|
83
|
+
name: typeof Schema.String;
|
|
84
|
+
month: Schema.brand<Schema.filter<typeof Schema.Int>, "Month">;
|
|
85
|
+
weekday: Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">;
|
|
86
|
+
}>, Schema.TaggedStruct<"EasterRelativeHoliday", {
|
|
87
|
+
name: typeof Schema.String;
|
|
88
|
+
daysOffset: typeof Schema.Int;
|
|
89
|
+
}>]>>;
|
|
90
|
+
/**
|
|
91
|
+
* One-off date overrides.
|
|
92
|
+
* Take precedence over holidays and periods.
|
|
93
|
+
*/
|
|
94
|
+
exceptions: Schema.Array$<Schema.Struct<{
|
|
95
|
+
date: typeof Schema.DateTimeUtcFromSelf;
|
|
96
|
+
slots: Schema.Union<[Schema.Array$<Schema.Struct<{
|
|
97
|
+
open: Schema.Struct<{
|
|
98
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
99
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
100
|
+
}>;
|
|
101
|
+
close: Schema.Struct<{
|
|
102
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
103
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
104
|
+
}>;
|
|
105
|
+
}>>, Schema.Literal<["closed"]>]>;
|
|
106
|
+
note: Schema.optional<typeof Schema.String>;
|
|
107
|
+
}>>;
|
|
108
|
+
/**
|
|
109
|
+
* Days of week that are non-working (0 = Sunday, 6 = Saturday).
|
|
110
|
+
* Typically [0, 6] for weekends.
|
|
111
|
+
*/
|
|
112
|
+
nonWorkingDays: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">>;
|
|
113
|
+
/**
|
|
114
|
+
* Calendar periods loaded from database.
|
|
115
|
+
* Used for terms, seasons, fiscal periods, etc.
|
|
116
|
+
*/
|
|
117
|
+
periods: Schema.Array$<Schema.Struct<{
|
|
118
|
+
id: typeof Schema.String;
|
|
119
|
+
type: typeof Schema.String;
|
|
120
|
+
name: typeof Schema.String;
|
|
121
|
+
startDate: typeof Schema.DateTimeUtcFromSelf;
|
|
122
|
+
endDate: typeof Schema.DateTimeUtcFromSelf;
|
|
123
|
+
isActive: typeof Schema.Boolean;
|
|
124
|
+
weeklySchedule: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
125
|
+
day: Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">;
|
|
126
|
+
ranges: Schema.Array$<Schema.Struct<{
|
|
127
|
+
open: Schema.Struct<{
|
|
128
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
129
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
130
|
+
}>;
|
|
131
|
+
close: Schema.Struct<{
|
|
132
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
133
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
134
|
+
}>;
|
|
135
|
+
}>>;
|
|
136
|
+
}>>>;
|
|
137
|
+
}>>;
|
|
138
|
+
/**
|
|
139
|
+
* If set, dates outside any active period of this type are non-business days.
|
|
140
|
+
* Example: "school_term" - only dates within active school terms are business days.
|
|
141
|
+
*/
|
|
142
|
+
requireActivePeriod: Schema.optional<typeof Schema.String>;
|
|
143
|
+
/**
|
|
144
|
+
* First day of the business week (0 = Sunday, 6 = Saturday).
|
|
145
|
+
* Defaults to Sunday (0).
|
|
146
|
+
*/
|
|
147
|
+
startDayOfWeek: Schema.optional<Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">>;
|
|
148
|
+
/**
|
|
149
|
+
* IANA timezone identifier for the calendar (e.g., "Pacific/Auckland", "America/New_York").
|
|
150
|
+
* Schedule times are interpreted in this timezone.
|
|
151
|
+
* Defaults to "UTC" if not specified.
|
|
152
|
+
*/
|
|
153
|
+
timezone: Schema.optional<typeof Schema.String>;
|
|
154
|
+
}>;
|
|
155
|
+
export type BusinessCalendarConfig = typeof BusinessCalendarConfig.Type;
|
|
156
|
+
/**
|
|
157
|
+
* Creates a standard Monday-Friday 9:00-17:00 schedule.
|
|
158
|
+
*/
|
|
159
|
+
export declare const createStandardWeekdaySchedule: () => DaySchedule[];
|
|
160
|
+
/**
|
|
161
|
+
* Creates a default business calendar with standard hours.
|
|
162
|
+
*/
|
|
163
|
+
export declare const createDefaultConfig: (holidays?: Holiday[]) => BusinessCalendarConfig;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* A calendar period represents a date range with specific characteristics.
|
|
4
|
+
* Used for school terms, seasonal schedules, fiscal periods, etc.
|
|
5
|
+
*
|
|
6
|
+
* When `requireActivePeriod` is set on a calendar config, dates outside
|
|
7
|
+
* any active period of that type are considered non-business days.
|
|
8
|
+
*
|
|
9
|
+
* Examples:
|
|
10
|
+
* - School terms: { type: "school_term", name: "Term 1", isActive: true }
|
|
11
|
+
* - Shop hours: { type: "shop_season", name: "Christmas Extended", weeklySchedule: [...] }
|
|
12
|
+
* - Company schedule: { type: "fiscal_quarter", name: "Q1 2026", isActive: true }
|
|
13
|
+
*/
|
|
14
|
+
export declare const CalendarPeriod: Schema.Struct<{
|
|
15
|
+
/**
|
|
16
|
+
* Unique identifier for the period.
|
|
17
|
+
*/
|
|
18
|
+
id: typeof Schema.String;
|
|
19
|
+
/**
|
|
20
|
+
* Type categorizes periods (e.g., "school_term", "shop_season", "fiscal_quarter").
|
|
21
|
+
* Used with `requireActivePeriod` to filter relevant periods.
|
|
22
|
+
*/
|
|
23
|
+
type: typeof Schema.String;
|
|
24
|
+
/**
|
|
25
|
+
* Human-readable name (e.g., "Term 1", "Christmas Extended", "Q1 2026").
|
|
26
|
+
*/
|
|
27
|
+
name: typeof Schema.String;
|
|
28
|
+
/**
|
|
29
|
+
* Start date of the period (inclusive).
|
|
30
|
+
* Stored as ISO 8601 date string for serialization.
|
|
31
|
+
*/
|
|
32
|
+
startDate: typeof Schema.DateTimeUtcFromSelf;
|
|
33
|
+
/**
|
|
34
|
+
* End date of the period (inclusive).
|
|
35
|
+
* Stored as ISO 8601 date string for serialization.
|
|
36
|
+
*/
|
|
37
|
+
endDate: typeof Schema.DateTimeUtcFromSelf;
|
|
38
|
+
/**
|
|
39
|
+
* Whether this period counts as "active" or "working".
|
|
40
|
+
* When requireActivePeriod is set, only dates within active periods
|
|
41
|
+
* of that type are considered business days.
|
|
42
|
+
*/
|
|
43
|
+
isActive: typeof Schema.Boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Optional weekly schedule override during this period.
|
|
46
|
+
* If provided, these hours replace the default calendar hours.
|
|
47
|
+
* Useful for extended hours, reduced hours, or different patterns.
|
|
48
|
+
*/
|
|
49
|
+
weeklySchedule: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
50
|
+
day: Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">;
|
|
51
|
+
ranges: Schema.Array$<Schema.Struct<{
|
|
52
|
+
open: Schema.Struct<{
|
|
53
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
54
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
55
|
+
}>;
|
|
56
|
+
close: Schema.Struct<{
|
|
57
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
58
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
59
|
+
}>;
|
|
60
|
+
}>>;
|
|
61
|
+
}>>>;
|
|
62
|
+
}>;
|
|
63
|
+
export type CalendarPeriod = typeof CalendarPeriod.Type;
|
|
64
|
+
/**
|
|
65
|
+
* Schema for encoding CalendarPeriod to JSON (for database storage).
|
|
66
|
+
*/
|
|
67
|
+
export declare const CalendarPeriodFromJson: Schema.Struct<{
|
|
68
|
+
id: typeof Schema.String;
|
|
69
|
+
type: typeof Schema.String;
|
|
70
|
+
name: typeof Schema.String;
|
|
71
|
+
startDate: typeof Schema.DateTimeUtc;
|
|
72
|
+
endDate: typeof Schema.DateTimeUtc;
|
|
73
|
+
isActive: typeof Schema.Boolean;
|
|
74
|
+
weeklySchedule: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
75
|
+
day: Schema.brand<Schema.filter<typeof Schema.Int>, "DayOfWeek">;
|
|
76
|
+
ranges: Schema.Array$<Schema.Struct<{
|
|
77
|
+
open: Schema.Struct<{
|
|
78
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
79
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
80
|
+
}>;
|
|
81
|
+
close: Schema.Struct<{
|
|
82
|
+
hour: Schema.filter<typeof Schema.Int>;
|
|
83
|
+
minute: Schema.filter<typeof Schema.Int>;
|
|
84
|
+
}>;
|
|
85
|
+
}>>;
|
|
86
|
+
}>>>;
|
|
87
|
+
}>;
|
|
88
|
+
export type CalendarPeriodFromJson = typeof CalendarPeriodFromJson.Type;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import type { BusinessCalendarConfig } from "./calendar-config.js";
|
|
3
|
+
import { BusinessCalendarConfigService, BusinessCalendarService, type BusinessCalendarServiceShape } from "./calendar-service.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create the BusinessCalendarService implementation from a config.
|
|
6
|
+
*
|
|
7
|
+
* Prefer this at call sites that already hold a resolved config and need a
|
|
8
|
+
* service value (pass it into helpers) rather than embedding `Effect.provide`
|
|
9
|
+
* inside reusable package logic.
|
|
10
|
+
*/
|
|
11
|
+
export declare const makeBusinessCalendarService: (config: BusinessCalendarConfig) => Effect.Effect<BusinessCalendarServiceShape, never, never>;
|
|
12
|
+
/**
|
|
13
|
+
* Layer that provides BusinessCalendarService from BusinessCalendarConfigService.
|
|
14
|
+
*/
|
|
15
|
+
export declare const BusinessCalendarServiceLive: Layer.Layer<BusinessCalendarService, never, BusinessCalendarConfigService>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a Layer with a specific config.
|
|
18
|
+
*/
|
|
19
|
+
export declare const makeBusinessCalendarServiceLayer: (config: BusinessCalendarConfig) => Layer.Layer<BusinessCalendarService, never, never>;
|