@m5kdev/commons 0.33.0 → 0.34.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.
@@ -1 +1 @@
1
- {"version":3,"file":"auth.locale.cjs","names":["z"],"sources":["../../../../src/modules/auth/auth.locale.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport interface AuthLocaleDefinition {\r\n code: string;\r\n displayName: string;\r\n}\r\n\r\nexport interface AuthLocaleConfig {\r\n defaultLocale: string;\r\n locales: readonly AuthLocaleDefinition[];\r\n}\r\n\r\nexport function getAllowedLocaleCodes(config: AuthLocaleConfig): readonly string[] {\r\n return config.locales.map((locale) => locale.code);\r\n}\r\n\r\nexport function getLocaleDisplayName(config: AuthLocaleConfig, code: string): string {\r\n return config.locales.find((locale) => locale.code === code)?.displayName ?? code;\r\n}\r\n\r\nexport interface NormalizedLocaleTag {\r\n language: string;\r\n region: string | null;\r\n compareKey: string;\r\n}\r\n\r\nexport function normalizeLocaleTag(tag: string): NormalizedLocaleTag | null {\r\n const trimmed = tag.trim();\r\n if (!trimmed) return null;\r\n\r\n const parts = trimmed.replace(/_/g, \"-\").split(\"-\").filter(Boolean);\r\n if (parts.length === 0) return null;\r\n\r\n const language = parts[0].toLowerCase();\r\n const region = parts.length > 1 ? parts[1].toUpperCase() : null;\r\n const compareKey = region ? `${language}_${region}` : language;\r\n\r\n return { language, region, compareKey };\r\n}\r\n\r\nfunction buildCompareKeyFromCanonical(canonical: string): string {\r\n return normalizeLocaleTag(canonical)?.compareKey ?? canonical.toLowerCase();\r\n}\r\n\r\nexport function toCanonicalLocale(\r\n tag: string,\r\n allowedLocales: readonly string[]\r\n): string | null {\r\n const normalized = normalizeLocaleTag(tag);\r\n if (!normalized) return null;\r\n\r\n const allowedByKey = new Map<string, string>();\r\n for (const locale of allowedLocales) {\r\n allowedByKey.set(buildCompareKeyFromCanonical(locale), locale);\r\n }\r\n\r\n if (normalized.region) {\r\n const regionMatch = allowedByKey.get(`${normalized.language}_${normalized.region}`);\r\n if (regionMatch) return regionMatch;\r\n }\r\n\r\n if (!normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n if (normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function toI18nLanguageTag(canonical: string): string {\r\n const normalized = normalizeLocaleTag(canonical);\r\n if (!normalized) return canonical;\r\n if (normalized.region) {\r\n return `${normalized.language}-${normalized.region}`;\r\n }\r\n return normalized.language;\r\n}\r\n\r\nexport function resolveAppLocale(\r\n requested: string | null | undefined,\r\n config: AuthLocaleConfig\r\n): string {\r\n const allowedLocales = getAllowedLocaleCodes(config);\r\n if (requested) {\r\n const canonical = toCanonicalLocale(requested, allowedLocales);\r\n if (canonical) return canonical;\r\n }\r\n\r\n const defaultCanonical = toCanonicalLocale(config.defaultLocale, allowedLocales);\r\n return defaultCanonical ?? allowedLocales[0] ?? config.defaultLocale;\r\n}\r\n\r\nexport function createLocaleValueSchema(config: AuthLocaleConfig) {\r\n const allowed = [...getAllowedLocaleCodes(config)];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n"],"mappings":";;;AAYA,SAAgB,sBAAsB,QAA6C;AACjF,QAAO,OAAO,QAAQ,KAAK,WAAW,OAAO,KAAK;;AAGpD,SAAgB,qBAAqB,QAA0B,MAAsB;AACnF,QAAO,OAAO,QAAQ,MAAM,WAAW,OAAO,SAAS,KAAK,EAAE,eAAe;;AAS/E,SAAgB,mBAAmB,KAAyC;CAC1E,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,QAAQ,QAAQ,QAAQ,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,QAAQ;AACnE,KAAI,MAAM,WAAW,EAAG,QAAO;CAE/B,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AO,CAAC;AAClD,KAAI,QAAQ,WAAW,EACrB,QAAOA,IAAAA,EAAE,QAAQ;AAEnB,QAAOA,IAAAA,EAAE,KAAK,QAAiC"}
1
+ {"version":3,"file":"auth.locale.cjs","names":["z"],"sources":["../../../../src/modules/auth/auth.locale.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport interface AuthLocaleDefinition {\r\n code: string;\r\n displayName: string;\r\n}\r\n\r\nexport interface AuthLocaleConfig {\r\n defaultLocale: string;\r\n locales: readonly AuthLocaleDefinition[];\r\n}\r\n\r\nexport function getAllowedLocaleCodes(config: AuthLocaleConfig): readonly string[] {\r\n return config.locales.map((locale) => locale.code);\r\n}\r\n\r\nexport function getLocaleDisplayName(config: AuthLocaleConfig, code: string): string {\r\n return config.locales.find((locale) => locale.code === code)?.displayName ?? code;\r\n}\r\n\r\nexport interface NormalizedLocaleTag {\r\n language: string;\r\n region: string | null;\r\n compareKey: string;\r\n}\r\n\r\nexport function normalizeLocaleTag(tag: string): NormalizedLocaleTag | null {\r\n const trimmed = tag.trim();\r\n if (!trimmed) return null;\r\n\r\n const parts = trimmed.replace(/_/g, \"-\").split(\"-\").filter(Boolean);\r\n if (parts.length === 0) return null;\r\n\r\n const language = parts[0].toLowerCase();\r\n const region = parts.length > 1 ? parts[1].toUpperCase() : null;\r\n const compareKey = region ? `${language}_${region}` : language;\r\n\r\n return { language, region, compareKey };\r\n}\r\n\r\nfunction buildCompareKeyFromCanonical(canonical: string): string {\r\n return normalizeLocaleTag(canonical)?.compareKey ?? canonical.toLowerCase();\r\n}\r\n\r\nexport function toCanonicalLocale(tag: string, allowedLocales: readonly string[]): string | null {\r\n const normalized = normalizeLocaleTag(tag);\r\n if (!normalized) return null;\r\n\r\n const allowedByKey = new Map<string, string>();\r\n for (const locale of allowedLocales) {\r\n allowedByKey.set(buildCompareKeyFromCanonical(locale), locale);\r\n }\r\n\r\n if (normalized.region) {\r\n const regionMatch = allowedByKey.get(`${normalized.language}_${normalized.region}`);\r\n if (regionMatch) return regionMatch;\r\n }\r\n\r\n if (!normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n if (normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function toI18nLanguageTag(canonical: string): string {\r\n const normalized = normalizeLocaleTag(canonical);\r\n if (!normalized) return canonical;\r\n if (normalized.region) {\r\n return `${normalized.language}-${normalized.region}`;\r\n }\r\n return normalized.language;\r\n}\r\n\r\nexport function resolveAppLocale(\r\n requested: string | null | undefined,\r\n config: AuthLocaleConfig\r\n): string {\r\n const allowedLocales = getAllowedLocaleCodes(config);\r\n if (requested) {\r\n const canonical = toCanonicalLocale(requested, allowedLocales);\r\n if (canonical) return canonical;\r\n }\r\n\r\n const defaultCanonical = toCanonicalLocale(config.defaultLocale, allowedLocales);\r\n return defaultCanonical ?? allowedLocales[0] ?? config.defaultLocale;\r\n}\r\n\r\nexport function createLocaleValueSchema(config: AuthLocaleConfig) {\r\n const allowed = [...getAllowedLocaleCodes(config)];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n"],"mappings":";;;AAYA,SAAgB,sBAAsB,QAA6C;AACjF,QAAO,OAAO,QAAQ,KAAK,WAAW,OAAO,KAAK;;AAGpD,SAAgB,qBAAqB,QAA0B,MAAsB;AACnF,QAAO,OAAO,QAAQ,MAAM,WAAW,OAAO,SAAS,KAAK,EAAE,eAAe;;AAS/E,SAAgB,mBAAmB,KAAyC;CAC1E,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,QAAQ,QAAQ,QAAQ,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,QAAQ;AACnE,KAAI,MAAM,WAAW,EAAG,QAAO;CAE/B,MAAM,WAAW,MAAM,GAAG,aAA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I,QAAQ,WAAW,EACrB,QAAOA,IAAAA,EAAE,QAAQ;AAEnB,QAAOA,IAAAA,EAAE,KAAK,QAAiC"}
@@ -1 +1 @@
1
- {"version":3,"file":"auth.locale.mjs","names":[],"sources":["../../../../src/modules/auth/auth.locale.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport interface AuthLocaleDefinition {\r\n code: string;\r\n displayName: string;\r\n}\r\n\r\nexport interface AuthLocaleConfig {\r\n defaultLocale: string;\r\n locales: readonly AuthLocaleDefinition[];\r\n}\r\n\r\nexport function getAllowedLocaleCodes(config: AuthLocaleConfig): readonly string[] {\r\n return config.locales.map((locale) => locale.code);\r\n}\r\n\r\nexport function getLocaleDisplayName(config: AuthLocaleConfig, code: string): string {\r\n return config.locales.find((locale) => locale.code === code)?.displayName ?? code;\r\n}\r\n\r\nexport interface NormalizedLocaleTag {\r\n language: string;\r\n region: string | null;\r\n compareKey: string;\r\n}\r\n\r\nexport function normalizeLocaleTag(tag: string): NormalizedLocaleTag | null {\r\n const trimmed = tag.trim();\r\n if (!trimmed) return null;\r\n\r\n const parts = trimmed.replace(/_/g, \"-\").split(\"-\").filter(Boolean);\r\n if (parts.length === 0) return null;\r\n\r\n const language = parts[0].toLowerCase();\r\n const region = parts.length > 1 ? parts[1].toUpperCase() : null;\r\n const compareKey = region ? `${language}_${region}` : language;\r\n\r\n return { language, region, compareKey };\r\n}\r\n\r\nfunction buildCompareKeyFromCanonical(canonical: string): string {\r\n return normalizeLocaleTag(canonical)?.compareKey ?? canonical.toLowerCase();\r\n}\r\n\r\nexport function toCanonicalLocale(\r\n tag: string,\r\n allowedLocales: readonly string[]\r\n): string | null {\r\n const normalized = normalizeLocaleTag(tag);\r\n if (!normalized) return null;\r\n\r\n const allowedByKey = new Map<string, string>();\r\n for (const locale of allowedLocales) {\r\n allowedByKey.set(buildCompareKeyFromCanonical(locale), locale);\r\n }\r\n\r\n if (normalized.region) {\r\n const regionMatch = allowedByKey.get(`${normalized.language}_${normalized.region}`);\r\n if (regionMatch) return regionMatch;\r\n }\r\n\r\n if (!normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n if (normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function toI18nLanguageTag(canonical: string): string {\r\n const normalized = normalizeLocaleTag(canonical);\r\n if (!normalized) return canonical;\r\n if (normalized.region) {\r\n return `${normalized.language}-${normalized.region}`;\r\n }\r\n return normalized.language;\r\n}\r\n\r\nexport function resolveAppLocale(\r\n requested: string | null | undefined,\r\n config: AuthLocaleConfig\r\n): string {\r\n const allowedLocales = getAllowedLocaleCodes(config);\r\n if (requested) {\r\n const canonical = toCanonicalLocale(requested, allowedLocales);\r\n if (canonical) return canonical;\r\n }\r\n\r\n const defaultCanonical = toCanonicalLocale(config.defaultLocale, allowedLocales);\r\n return defaultCanonical ?? allowedLocales[0] ?? config.defaultLocale;\r\n}\r\n\r\nexport function createLocaleValueSchema(config: AuthLocaleConfig) {\r\n const allowed = [...getAllowedLocaleCodes(config)];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n"],"mappings":";;AAYA,SAAgB,sBAAsB,QAA6C;AACjF,QAAO,OAAO,QAAQ,KAAK,WAAW,OAAO,KAAK;;AAGpD,SAAgB,qBAAqB,QAA0B,MAAsB;AACnF,QAAO,OAAO,QAAQ,MAAM,WAAW,OAAO,SAAS,KAAK,EAAE,eAAe;;AAS/E,SAAgB,mBAAmB,KAAyC;CAC1E,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,QAAQ,QAAQ,QAAQ,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,QAAQ;AACnE,KAAI,MAAM,WAAW,EAAG,QAAO;CAE/B,MAAM,WAAW,MAAM,GAAG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AAQ,WAAW,EACrB,QAAO,EAAE,QAAQ;AAEnB,QAAO,EAAE,KAAK,QAAiC"}
1
+ {"version":3,"file":"auth.locale.mjs","names":[],"sources":["../../../../src/modules/auth/auth.locale.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport interface AuthLocaleDefinition {\r\n code: string;\r\n displayName: string;\r\n}\r\n\r\nexport interface AuthLocaleConfig {\r\n defaultLocale: string;\r\n locales: readonly AuthLocaleDefinition[];\r\n}\r\n\r\nexport function getAllowedLocaleCodes(config: AuthLocaleConfig): readonly string[] {\r\n return config.locales.map((locale) => locale.code);\r\n}\r\n\r\nexport function getLocaleDisplayName(config: AuthLocaleConfig, code: string): string {\r\n return config.locales.find((locale) => locale.code === code)?.displayName ?? code;\r\n}\r\n\r\nexport interface NormalizedLocaleTag {\r\n language: string;\r\n region: string | null;\r\n compareKey: string;\r\n}\r\n\r\nexport function normalizeLocaleTag(tag: string): NormalizedLocaleTag | null {\r\n const trimmed = tag.trim();\r\n if (!trimmed) return null;\r\n\r\n const parts = trimmed.replace(/_/g, \"-\").split(\"-\").filter(Boolean);\r\n if (parts.length === 0) return null;\r\n\r\n const language = parts[0].toLowerCase();\r\n const region = parts.length > 1 ? parts[1].toUpperCase() : null;\r\n const compareKey = region ? `${language}_${region}` : language;\r\n\r\n return { language, region, compareKey };\r\n}\r\n\r\nfunction buildCompareKeyFromCanonical(canonical: string): string {\r\n return normalizeLocaleTag(canonical)?.compareKey ?? canonical.toLowerCase();\r\n}\r\n\r\nexport function toCanonicalLocale(tag: string, allowedLocales: readonly string[]): string | null {\r\n const normalized = normalizeLocaleTag(tag);\r\n if (!normalized) return null;\r\n\r\n const allowedByKey = new Map<string, string>();\r\n for (const locale of allowedLocales) {\r\n allowedByKey.set(buildCompareKeyFromCanonical(locale), locale);\r\n }\r\n\r\n if (normalized.region) {\r\n const regionMatch = allowedByKey.get(`${normalized.language}_${normalized.region}`);\r\n if (regionMatch) return regionMatch;\r\n }\r\n\r\n if (!normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n if (normalized.region) {\r\n const languageMatch = allowedByKey.get(normalized.language);\r\n if (languageMatch) return languageMatch;\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport function toI18nLanguageTag(canonical: string): string {\r\n const normalized = normalizeLocaleTag(canonical);\r\n if (!normalized) return canonical;\r\n if (normalized.region) {\r\n return `${normalized.language}-${normalized.region}`;\r\n }\r\n return normalized.language;\r\n}\r\n\r\nexport function resolveAppLocale(\r\n requested: string | null | undefined,\r\n config: AuthLocaleConfig\r\n): string {\r\n const allowedLocales = getAllowedLocaleCodes(config);\r\n if (requested) {\r\n const canonical = toCanonicalLocale(requested, allowedLocales);\r\n if (canonical) return canonical;\r\n }\r\n\r\n const defaultCanonical = toCanonicalLocale(config.defaultLocale, allowedLocales);\r\n return defaultCanonical ?? allowedLocales[0] ?? config.defaultLocale;\r\n}\r\n\r\nexport function createLocaleValueSchema(config: AuthLocaleConfig) {\r\n const allowed = [...getAllowedLocaleCodes(config)];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n"],"mappings":";;AAYA,SAAgB,sBAAsB,QAA6C;AACjF,QAAO,OAAO,QAAQ,KAAK,WAAW,OAAO,KAAK;;AAGpD,SAAgB,qBAAqB,QAA0B,MAAsB;AACnF,QAAO,OAAO,QAAQ,MAAM,WAAW,OAAO,SAAS,KAAK,EAAE,eAAe;;AAS/E,SAAgB,mBAAmB,KAAyC;CAC1E,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,QAAQ,QAAQ,QAAQ,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,QAAQ;AACnE,KAAI,MAAM,WAAW,EAAG,QAAO;CAE/B,MAAM,WAAW,MAAM,GAAG,aAAa;CACvC,MAAM,SAAS,MAAM,SAAS,IAAI,MAAM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EnB,QAAO,EAAE,KAAK,QAAiC"}
@@ -1 +1 @@
1
- {"version":3,"file":"auth.roles.cjs","names":["z"],"sources":["../../../../src/modules/auth/auth.roles.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport type AuthRoleScope = \"user\" | \"organization\" | \"team\";\r\n\r\nexport interface AuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles?: readonly string[];\r\n assignableRoles?: readonly string[];\r\n defaultRole?: string;\r\n}\r\n\r\nexport interface AuthRolesConfig {\r\n user: AuthRoleScopeConfig;\r\n organization: AuthRoleScopeConfig;\r\n team: AuthRoleScopeConfig;\r\n}\r\n\r\nexport interface NormalizedAuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles: readonly string[];\r\n assignableRoles: readonly string[];\r\n defaultRole: string;\r\n}\r\n\r\nexport interface NormalizedAuthRolesConfig {\r\n user: NormalizedAuthRoleScopeConfig;\r\n organization: NormalizedAuthRoleScopeConfig;\r\n team: NormalizedAuthRoleScopeConfig;\r\n}\r\n\r\nconst DEFAULT_USER_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"user\", \"admin\"],\r\n managerRoles: [\"admin\"],\r\n assignableRoles: [\"user\", \"admin\"],\r\n defaultRole: \"user\",\r\n};\r\n\r\nconst DEFAULT_ORGANIZATION_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"member\", \"admin\", \"owner\"],\r\n managerRoles: [\"admin\", \"owner\"],\r\n assignableRoles: [\"member\", \"admin\", \"owner\"],\r\n defaultRole: \"member\",\r\n};\r\n\r\nconst DEFAULT_TEAM_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"owner\"],\r\n managerRoles: [\"owner\"],\r\n assignableRoles: [\"owner\"],\r\n defaultRole: \"owner\",\r\n};\r\n\r\nexport const DEFAULT_AUTH_ROLES: NormalizedAuthRolesConfig = {\r\n user: DEFAULT_USER_SCOPE,\r\n organization: DEFAULT_ORGANIZATION_SCOPE,\r\n team: DEFAULT_TEAM_SCOPE,\r\n};\r\n\r\nfunction pickSubset(\r\n values: readonly string[],\r\n allowed: readonly string[],\r\n fallback: readonly string[]\r\n): readonly string[] {\r\n const allowedSet = new Set(allowed);\r\n const picked = values.filter((value) => allowedSet.has(value));\r\n if (picked.length > 0) {\r\n return picked;\r\n }\r\n\r\n const fallbackPicked = fallback.filter((value) => allowedSet.has(value));\r\n if (fallbackPicked.length > 0) {\r\n return fallbackPicked;\r\n }\r\n\r\n return allowed.length > 0 ? [allowed[0]] : [];\r\n}\r\n\r\nexport function normalizeRoleScopeConfig(\r\n scope: AuthRoleScopeConfig,\r\n defaults: NormalizedAuthRoleScopeConfig\r\n): NormalizedAuthRoleScopeConfig {\r\n const roles = scope.roles.length > 0 ? scope.roles : defaults.roles;\r\n const roleSet = new Set(roles);\r\n\r\n const defaultRole =\r\n scope.defaultRole && roleSet.has(scope.defaultRole)\r\n ? scope.defaultRole\r\n : defaults.defaultRole && roleSet.has(defaults.defaultRole)\r\n ? defaults.defaultRole\r\n : roles[0];\r\n\r\n const managerRoles = pickSubset(\r\n scope.managerRoles ?? defaults.managerRoles,\r\n roles,\r\n defaults.managerRoles\r\n );\r\n\r\n const assignableRoles = pickSubset(\r\n scope.assignableRoles ?? roles,\r\n roles,\r\n roles\r\n );\r\n\r\n return {\r\n roles,\r\n managerRoles,\r\n assignableRoles,\r\n defaultRole,\r\n };\r\n}\r\n\r\nexport function normalizeAuthRolesConfig(\r\n config?: AuthRolesConfig | null\r\n): NormalizedAuthRolesConfig {\r\n if (!config) {\r\n return DEFAULT_AUTH_ROLES;\r\n }\r\n\r\n return {\r\n user: normalizeRoleScopeConfig(config.user, DEFAULT_AUTH_ROLES.user),\r\n organization: normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization),\r\n team: normalizeRoleScopeConfig(config.team, DEFAULT_AUTH_ROLES.team),\r\n };\r\n}\r\n\r\nexport function defineAuthRoles(config: AuthRolesConfig): NormalizedAuthRolesConfig {\r\n return normalizeAuthRolesConfig(config);\r\n}\r\n\r\nexport function getRoleKeys(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope\r\n): readonly string[] {\r\n return config[scope].roles;\r\n}\r\n\r\nexport function isAllowedRole(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope,\r\n role: string\r\n): boolean {\r\n return getRoleKeys(config, scope).includes(role);\r\n}\r\n\r\nexport function createRoleValueSchema(scope: NormalizedAuthRoleScopeConfig) {\r\n const allowed = [...scope.roles];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n\r\nexport function getAppRoleTranslationKey(scope: AuthRoleScope, role: string): string {\r\n return `${scope}.role.${role}`;\r\n}\r\n"],"mappings":";;AAmDA,MAAa,qBAAgD;CAC3D,MAtBwD;EACxD,OAAO,CAAC,QAAQ,QAAQ;EACxB,cAAc,CAAC,QAAQ;EACvB,iBAAiB,CAAC,QAAQ,QAAQ;EAClC,aAAa;EACd;CAkBC,cAhBgE;EAChE,OAAO;GAAC;GAAU;GAAS;GAAQ;EACnC,cAAc,CAAC,SAAS,QAAQ;EAChC,iBAAiB;GAAC;GAAU;GAAS;GAAQ;EAC7C,aAAa;EACd;CAYC,MAVwD;EACxD,OAAO,CAAC,QAAQ;EAChB,cAAc,CAAC,QAAQ;EACvB,iBAAiB,CAAC,QAAQ;EAC1B,aAAa;EACd;CAMA;AAED,SAAS,WACP,QACA,SACA,UACmB;CACnB,MAAM,aAAa,IAAI,IAAI,QAAQ;CACnC,MAAM,SAAS,OAAO,QAAQ,UAAU,WAAW,IAAI,MAAM,CAAC;AAC9D,KAAI,OAAO,SAAS,EAClB,QAAO;CAGT,MAAM,iBAAiB,SAAS,QAAQ,UAAU,WAAW,IAAI,MAAM,CAAC;AACxE,KAAI,eAAe,SAAS,EAC1B,QAAO;AAGT,QAAO,QAAQ,SAAS,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE;;AAG/C,SAAgB,yBACd,OACA,UAC+B;CAC/B,MAAM,QAAQ,MAAM,MAAM,SAAS,IAAI,MAAM,QAAQ,SAAS;CAC9D,MAAM,UAAU,IAAI,IAAI,MAAM;CAE9B,MAAM,cACJ,MAAM,eAAe,QAAQ,IAAI,MAAM,YAAY,GAC/C,MAAM,cACN,SAAS,eAAe,QAAQ,IAAI,SAAS,YAAY,GACvD,SAAS,cACT,MAAM;AAcd,QAAO;EACL;EACA,cAdmB,WACnB,MAAM,gBAAgB,SAAS,cAC/B,OACA,SAAS,aACV;EAWC,iBATsB,WACtB,MAAM,mBAAmB,OACzB,OACA,MACD;EAMC;EACD;;AAGH,SAAgB,yBACd,QAC2B;AAC3B,KAAI,CAAC,OACH,QAAO;AAGT,QAAO;EACL,MAAM,yBAAyB,OAAO,MAAM,mBAAmB,KAAK;EACpE,cAAc,yBAAyB,OAAO,cAAc,mBAAmB,aAAa;EAC5F,MAAM,yBAAyB,OAAO,MAAM,mBAAmB,KAAK;EACrE;;AAGH,SAAgB,gBAAgB,QAAoD;AAClF,QAAO,yBAAyB,OAAO;;AAGzC,SAAgB,YACd,QACA,OACmB;AACnB,QAAO,OAAO,OAAO;;AAGvB,SAAgB,cACd,QACA,OACA,MACS;AACT,QAAO,YAAY,QAAQ,MAAM,CAAC,SAAS,KAAK;;AAGlD,SAAgB,sBAAsB,OAAsC;CAC1E,MAAM,UAAU,CAAC,GAAG,MAAM,MAAM;AAChC,KAAI,QAAQ,WAAW,EACrB,QAAOA,IAAAA,EAAE,QAAQ;AAEnB,QAAOA,IAAAA,EAAE,KAAK,QAAiC;;AAGjD,SAAgB,yBAAyB,OAAsB,MAAsB;AACnF,QAAO,GAAG,MAAM,QAAQ"}
1
+ {"version":3,"file":"auth.roles.cjs","names":["z"],"sources":["../../../../src/modules/auth/auth.roles.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport type AuthRoleScope = \"user\" | \"organization\" | \"team\";\r\n\r\nexport interface AuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles?: readonly string[];\r\n assignableRoles?: readonly string[];\r\n defaultRole?: string;\r\n}\r\n\r\nexport interface AuthRolesConfig {\r\n user: AuthRoleScopeConfig;\r\n organization: AuthRoleScopeConfig;\r\n team: AuthRoleScopeConfig;\r\n}\r\n\r\nexport interface NormalizedAuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles: readonly string[];\r\n assignableRoles: readonly string[];\r\n defaultRole: string;\r\n}\r\n\r\nexport interface NormalizedAuthRolesConfig {\r\n user: NormalizedAuthRoleScopeConfig;\r\n organization: NormalizedAuthRoleScopeConfig;\r\n team: NormalizedAuthRoleScopeConfig;\r\n}\r\n\r\nconst DEFAULT_USER_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"user\", \"admin\"],\r\n managerRoles: [\"admin\"],\r\n assignableRoles: [\"user\", \"admin\"],\r\n defaultRole: \"user\",\r\n};\r\n\r\nconst DEFAULT_ORGANIZATION_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"member\", \"admin\", \"owner\"],\r\n managerRoles: [\"admin\", \"owner\"],\r\n assignableRoles: [\"member\", \"admin\", \"owner\"],\r\n defaultRole: \"member\",\r\n};\r\n\r\nconst DEFAULT_TEAM_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"owner\"],\r\n managerRoles: [\"owner\"],\r\n assignableRoles: [\"owner\"],\r\n defaultRole: \"owner\",\r\n};\r\n\r\nexport const DEFAULT_AUTH_ROLES: NormalizedAuthRolesConfig = {\r\n user: DEFAULT_USER_SCOPE,\r\n organization: DEFAULT_ORGANIZATION_SCOPE,\r\n team: DEFAULT_TEAM_SCOPE,\r\n};\r\n\r\nfunction pickSubset(\r\n values: readonly string[],\r\n allowed: readonly string[],\r\n fallback: readonly string[]\r\n): readonly string[] {\r\n const allowedSet = new Set(allowed);\r\n const picked = values.filter((value) => allowedSet.has(value));\r\n if (picked.length > 0) {\r\n return picked;\r\n }\r\n\r\n const fallbackPicked = fallback.filter((value) => allowedSet.has(value));\r\n if (fallbackPicked.length > 0) {\r\n return fallbackPicked;\r\n }\r\n\r\n return allowed.length > 0 ? [allowed[0]] : [];\r\n}\r\n\r\nexport function normalizeRoleScopeConfig(\r\n scope: AuthRoleScopeConfig,\r\n defaults: NormalizedAuthRoleScopeConfig\r\n): NormalizedAuthRoleScopeConfig {\r\n const roles = scope.roles.length > 0 ? scope.roles : defaults.roles;\r\n const roleSet = new Set(roles);\r\n\r\n const defaultRole =\r\n scope.defaultRole && roleSet.has(scope.defaultRole)\r\n ? scope.defaultRole\r\n : defaults.defaultRole && roleSet.has(defaults.defaultRole)\r\n ? defaults.defaultRole\r\n : roles[0];\r\n\r\n const managerRoles = pickSubset(\r\n scope.managerRoles ?? defaults.managerRoles,\r\n roles,\r\n defaults.managerRoles\r\n );\r\n\r\n const assignableRoles = pickSubset(scope.assignableRoles ?? roles, roles, roles);\r\n\r\n return {\r\n roles,\r\n managerRoles,\r\n assignableRoles,\r\n defaultRole,\r\n };\r\n}\r\n\r\nexport function normalizeAuthRolesConfig(\r\n config?: AuthRolesConfig | null\r\n): NormalizedAuthRolesConfig {\r\n if (!config) {\r\n return DEFAULT_AUTH_ROLES;\r\n }\r\n\r\n return {\r\n user: normalizeRoleScopeConfig(config.user, DEFAULT_AUTH_ROLES.user),\r\n organization: normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization),\r\n team: normalizeRoleScopeConfig(config.team, DEFAULT_AUTH_ROLES.team),\r\n };\r\n}\r\n\r\nexport function defineAuthRoles(config: AuthRolesConfig): NormalizedAuthRolesConfig {\r\n return normalizeAuthRolesConfig(config);\r\n}\r\n\r\nexport function getRoleKeys(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope\r\n): readonly string[] {\r\n return config[scope].roles;\r\n}\r\n\r\nexport function isAllowedRole(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope,\r\n role: string\r\n): boolean {\r\n return getRoleKeys(config, scope).includes(role);\r\n}\r\n\r\nexport function createRoleValueSchema(scope: NormalizedAuthRoleScopeConfig) {\r\n const allowed = [...scope.roles];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n\r\nexport function getAppRoleTranslationKey(scope: AuthRoleScope, role: string): string {\r\n return `${scope}.role.${role}`;\r\n}\r\n"],"mappings":";;AAmDA,MAAa,qBAAgD;CAC3D,MAtBwD;EACxD,OAAO,CAAC,QAAQ,QAAQ;EACxB,cAAc,CAAC,QAAQ;EACvB,iBAAiB,CAAC,QAAQ,QAAQ;EAClC,aAAa;EACd;CAkBC,cAhBgE;EAChE,OAAO;GAAC;GAAU;GAAS;GAAQ;EACnC,cAAc,CAAC,SAAS,QAAQ;EAChC,iBAAiB;GAAC;GAAU;GAAS;GAAQ;EAC7C,aAAa;EACd;CAYC,MAVwD;EACxD,OAAO,CAAC,QAAQ;EAChB,cAAc,CAAC,QAAQ;EACvB,iBAAiB,CAAC,QAAQ;EAC1B,aAAa;EACd;CAMA;AAED,SAAS,WACP,QACA,SACA,UACmB;CACnB,MAAM,aAAa,IAAI,IAAI,QAAQ;CACnC,MAAM,SAAS,OAAO,QAAQ,UAAU,WAAW,IAAI,MAAM,CAAC;AAC9D,KAAI,OAAO,SAAS,EAClB,QAAO;CAGT,MAAM,iBAAiB,SAAS,QAAQ,UAAU,WAAW,IAAI,MAAM,CAAC;AACxE,KAAI,eAAe,SAAS,EAC1B,QAAO;AAGT,QAAO,QAAQ,SAAS,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE;;AAG/C,SAAgB,yBACd,OACA,UAC+B;CAC/B,MAAM,QAAQ,MAAM,MAAM,SAAS,IAAI,MAAM,QAAQ,SAAS;CAC9D,MAAM,UAAU,IAAI,IAAI,MAAM;CAE9B,MAAM,cACJ,MAAM,eAAe,QAAQ,IAAI,MAAM,YAAY,GAC/C,MAAM,cACN,SAAS,eAAe,QAAQ,IAAI,SAAS,YAAY,GACvD,SAAS,cACT,MAAM;AAUd,QAAO;EACL;EACA,cAVmB,WACnB,MAAM,gBAAgB,SAAS,cAC/B,OACA,SAAS,aACV;EAOC,iBALsB,WAAW,MAAM,mBAAmB,OAAO,OAAO,MAAM;EAM9E;EACD;;AAGH,SAAgB,yBACd,QAC2B;AAC3B,KAAI,CAAC,OACH,QAAO;AAGT,QAAO;EACL,MAAM,yBAAyB,OAAO,MAAM,mBAAmB,KAAK;EACpE,cAAc,yBAAyB,OAAO,cAAc,mBAAmB,aAAa;EAC5F,MAAM,yBAAyB,OAAO,MAAM,mBAAmB,KAAK;EACrE;;AAGH,SAAgB,gBAAgB,QAAoD;AAClF,QAAO,yBAAyB,OAAO;;AAGzC,SAAgB,YACd,QACA,OACmB;AACnB,QAAO,OAAO,OAAO;;AAGvB,SAAgB,cACd,QACA,OACA,MACS;AACT,QAAO,YAAY,QAAQ,MAAM,CAAC,SAAS,KAAK;;AAGlD,SAAgB,sBAAsB,OAAsC;CAC1E,MAAM,UAAU,CAAC,GAAG,MAAM,MAAM;AAChC,KAAI,QAAQ,WAAW,EACrB,QAAOA,IAAAA,EAAE,QAAQ;AAEnB,QAAOA,IAAAA,EAAE,KAAK,QAAiC;;AAGjD,SAAgB,yBAAyB,OAAsB,MAAsB;AACnF,QAAO,GAAG,MAAM,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"auth.roles.mjs","names":[],"sources":["../../../../src/modules/auth/auth.roles.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport type AuthRoleScope = \"user\" | \"organization\" | \"team\";\r\n\r\nexport interface AuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles?: readonly string[];\r\n assignableRoles?: readonly string[];\r\n defaultRole?: string;\r\n}\r\n\r\nexport interface AuthRolesConfig {\r\n user: AuthRoleScopeConfig;\r\n organization: AuthRoleScopeConfig;\r\n team: AuthRoleScopeConfig;\r\n}\r\n\r\nexport interface NormalizedAuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles: readonly string[];\r\n assignableRoles: readonly string[];\r\n defaultRole: string;\r\n}\r\n\r\nexport interface NormalizedAuthRolesConfig {\r\n user: NormalizedAuthRoleScopeConfig;\r\n organization: NormalizedAuthRoleScopeConfig;\r\n team: NormalizedAuthRoleScopeConfig;\r\n}\r\n\r\nconst DEFAULT_USER_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"user\", \"admin\"],\r\n managerRoles: [\"admin\"],\r\n assignableRoles: [\"user\", \"admin\"],\r\n defaultRole: \"user\",\r\n};\r\n\r\nconst DEFAULT_ORGANIZATION_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"member\", \"admin\", \"owner\"],\r\n managerRoles: [\"admin\", \"owner\"],\r\n assignableRoles: [\"member\", \"admin\", \"owner\"],\r\n defaultRole: \"member\",\r\n};\r\n\r\nconst DEFAULT_TEAM_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"owner\"],\r\n managerRoles: [\"owner\"],\r\n assignableRoles: [\"owner\"],\r\n defaultRole: \"owner\",\r\n};\r\n\r\nexport const DEFAULT_AUTH_ROLES: NormalizedAuthRolesConfig = {\r\n user: DEFAULT_USER_SCOPE,\r\n organization: DEFAULT_ORGANIZATION_SCOPE,\r\n team: DEFAULT_TEAM_SCOPE,\r\n};\r\n\r\nfunction pickSubset(\r\n values: readonly string[],\r\n allowed: readonly string[],\r\n fallback: readonly string[]\r\n): readonly string[] {\r\n const allowedSet = new Set(allowed);\r\n const picked = values.filter((value) => allowedSet.has(value));\r\n if (picked.length > 0) {\r\n return picked;\r\n }\r\n\r\n const fallbackPicked = fallback.filter((value) => allowedSet.has(value));\r\n if (fallbackPicked.length > 0) {\r\n return fallbackPicked;\r\n }\r\n\r\n return allowed.length > 0 ? [allowed[0]] : [];\r\n}\r\n\r\nexport function normalizeRoleScopeConfig(\r\n scope: AuthRoleScopeConfig,\r\n defaults: NormalizedAuthRoleScopeConfig\r\n): NormalizedAuthRoleScopeConfig {\r\n const roles = scope.roles.length > 0 ? scope.roles : defaults.roles;\r\n const roleSet = new Set(roles);\r\n\r\n const defaultRole =\r\n scope.defaultRole && roleSet.has(scope.defaultRole)\r\n ? scope.defaultRole\r\n : defaults.defaultRole && roleSet.has(defaults.defaultRole)\r\n ? defaults.defaultRole\r\n : roles[0];\r\n\r\n const managerRoles = pickSubset(\r\n scope.managerRoles ?? defaults.managerRoles,\r\n roles,\r\n defaults.managerRoles\r\n );\r\n\r\n const assignableRoles = pickSubset(\r\n scope.assignableRoles ?? roles,\r\n roles,\r\n roles\r\n );\r\n\r\n return {\r\n roles,\r\n managerRoles,\r\n assignableRoles,\r\n defaultRole,\r\n };\r\n}\r\n\r\nexport function normalizeAuthRolesConfig(\r\n config?: AuthRolesConfig | null\r\n): NormalizedAuthRolesConfig {\r\n if (!config) {\r\n return DEFAULT_AUTH_ROLES;\r\n }\r\n\r\n return {\r\n user: normalizeRoleScopeConfig(config.user, DEFAULT_AUTH_ROLES.user),\r\n organization: normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization),\r\n team: normalizeRoleScopeConfig(config.team, DEFAULT_AUTH_ROLES.team),\r\n };\r\n}\r\n\r\nexport function defineAuthRoles(config: AuthRolesConfig): NormalizedAuthRolesConfig {\r\n return normalizeAuthRolesConfig(config);\r\n}\r\n\r\nexport function getRoleKeys(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope\r\n): readonly string[] {\r\n return config[scope].roles;\r\n}\r\n\r\nexport function isAllowedRole(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope,\r\n role: string\r\n): boolean {\r\n return getRoleKeys(config, scope).includes(role);\r\n}\r\n\r\nexport function createRoleValueSchema(scope: NormalizedAuthRoleScopeConfig) {\r\n const allowed = [...scope.roles];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n\r\nexport function getAppRoleTranslationKey(scope: AuthRoleScope,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,CAAC,OACH,QAAO;AAGT,QAAO;EACL,MAAM,yBAAyB,OAAO,MAAM,mBAAmB,KAAK;EACpE,cAAc,yBAAyB,OAAO,cAAc,mBAAmB,aAAa;EAC5F,MAAM,yBAAyB,OAAO,MAAM,mBAAmB,KAAK;EACrE;;AAGH,SAAgB,gBAAgB,QAAoD;AAClF,QAAO,yBAAyB,OAAO;;AAGzC,SAAgB,YACd,QACA,OACmB;AACnB,QAAO,OAAO,OAAO;;AAGvB,SAAgB,cACd,QACA,OACA,MACS;AACT,QAAO,YAAY,QAAQ,MAAM,CAAC,SAAS,KAAK;;AAGlD,SAAgB,sBAAsB,OAAsC;CAC1E,MAAM,UAAU,CAAC,GAAG,MAAM,MAAM;AAChC,KAAI,QAAQ,WAAW,EACrB,QAAO,EAAE,QAAQ;AAEnB,QAAO,EAAE,KAAK,QAAiC;;AAGjD,SAAgB,yBAAyB,OAAsB,MAAsB;AACnF,QAAO,GAAG,MAAM,QAAQ"}
1
+ {"version":3,"file":"auth.roles.mjs","names":[],"sources":["../../../../src/modules/auth/auth.roles.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport type AuthRoleScope = \"user\" | \"organization\" | \"team\";\r\n\r\nexport interface AuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles?: readonly string[];\r\n assignableRoles?: readonly string[];\r\n defaultRole?: string;\r\n}\r\n\r\nexport interface AuthRolesConfig {\r\n user: AuthRoleScopeConfig;\r\n organization: AuthRoleScopeConfig;\r\n team: AuthRoleScopeConfig;\r\n}\r\n\r\nexport interface NormalizedAuthRoleScopeConfig {\r\n roles: readonly string[];\r\n managerRoles: readonly string[];\r\n assignableRoles: readonly string[];\r\n defaultRole: string;\r\n}\r\n\r\nexport interface NormalizedAuthRolesConfig {\r\n user: NormalizedAuthRoleScopeConfig;\r\n organization: NormalizedAuthRoleScopeConfig;\r\n team: NormalizedAuthRoleScopeConfig;\r\n}\r\n\r\nconst DEFAULT_USER_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"user\", \"admin\"],\r\n managerRoles: [\"admin\"],\r\n assignableRoles: [\"user\", \"admin\"],\r\n defaultRole: \"user\",\r\n};\r\n\r\nconst DEFAULT_ORGANIZATION_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"member\", \"admin\", \"owner\"],\r\n managerRoles: [\"admin\", \"owner\"],\r\n assignableRoles: [\"member\", \"admin\", \"owner\"],\r\n defaultRole: \"member\",\r\n};\r\n\r\nconst DEFAULT_TEAM_SCOPE: NormalizedAuthRoleScopeConfig = {\r\n roles: [\"owner\"],\r\n managerRoles: [\"owner\"],\r\n assignableRoles: [\"owner\"],\r\n defaultRole: \"owner\",\r\n};\r\n\r\nexport const DEFAULT_AUTH_ROLES: NormalizedAuthRolesConfig = {\r\n user: DEFAULT_USER_SCOPE,\r\n organization: DEFAULT_ORGANIZATION_SCOPE,\r\n team: DEFAULT_TEAM_SCOPE,\r\n};\r\n\r\nfunction pickSubset(\r\n values: readonly string[],\r\n allowed: readonly string[],\r\n fallback: readonly string[]\r\n): readonly string[] {\r\n const allowedSet = new Set(allowed);\r\n const picked = values.filter((value) => allowedSet.has(value));\r\n if (picked.length > 0) {\r\n return picked;\r\n }\r\n\r\n const fallbackPicked = fallback.filter((value) => allowedSet.has(value));\r\n if (fallbackPicked.length > 0) {\r\n return fallbackPicked;\r\n }\r\n\r\n return allowed.length > 0 ? [allowed[0]] : [];\r\n}\r\n\r\nexport function normalizeRoleScopeConfig(\r\n scope: AuthRoleScopeConfig,\r\n defaults: NormalizedAuthRoleScopeConfig\r\n): NormalizedAuthRoleScopeConfig {\r\n const roles = scope.roles.length > 0 ? scope.roles : defaults.roles;\r\n const roleSet = new Set(roles);\r\n\r\n const defaultRole =\r\n scope.defaultRole && roleSet.has(scope.defaultRole)\r\n ? scope.defaultRole\r\n : defaults.defaultRole && roleSet.has(defaults.defaultRole)\r\n ? defaults.defaultRole\r\n : roles[0];\r\n\r\n const managerRoles = pickSubset(\r\n scope.managerRoles ?? defaults.managerRoles,\r\n roles,\r\n defaults.managerRoles\r\n );\r\n\r\n const assignableRoles = pickSubset(scope.assignableRoles ?? roles, roles, roles);\r\n\r\n return {\r\n roles,\r\n managerRoles,\r\n assignableRoles,\r\n defaultRole,\r\n };\r\n}\r\n\r\nexport function normalizeAuthRolesConfig(\r\n config?: AuthRolesConfig | null\r\n): NormalizedAuthRolesConfig {\r\n if (!config) {\r\n return DEFAULT_AUTH_ROLES;\r\n }\r\n\r\n return {\r\n user: normalizeRoleScopeConfig(config.user, DEFAULT_AUTH_ROLES.user),\r\n organization: normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization),\r\n team: normalizeRoleScopeConfig(config.team, DEFAULT_AUTH_ROLES.team),\r\n };\r\n}\r\n\r\nexport function defineAuthRoles(config: AuthRolesConfig): NormalizedAuthRolesConfig {\r\n return normalizeAuthRolesConfig(config);\r\n}\r\n\r\nexport function getRoleKeys(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope\r\n): readonly string[] {\r\n return config[scope].roles;\r\n}\r\n\r\nexport function isAllowedRole(\r\n config: NormalizedAuthRolesConfig,\r\n scope: AuthRoleScope,\r\n role: string\r\n): boolean {\r\n return getRoleKeys(config, scope).includes(role);\r\n}\r\n\r\nexport function createRoleValueSchema(scope: NormalizedAuthRoleScopeConfig) {\r\n const allowed = [...scope.roles];\r\n if (allowed.length === 0) {\r\n return z.string();\r\n }\r\n return z.enum(allowed as [string, ...string[]]);\r\n}\r\n\r\nexport function getAppRoleTranslationKey(scope: AuthRoleScope, role: string): string {\r\n return `${scope}.role.${role}`;\r\n}\r\n"],"mappings":";AAmDA,MAAa,qBAAgD;CAC3D,MAtBwD;EACxD,OAAO,CAAC,QAAQ,QAAQ;EACxB,cAAc,CAAC,QAAQ;EACvB,iBAAiB,CAAC,QAAQ,QAAQ;EAClC,aAAa;EACd;CAkBC,cAhBgE;EAChE,OAAO;GAAC;GAAU;GAAS;GAAQ;EACnC,cA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QACA,OACmB;AACnB,QAAO,OAAO,OAAO;;AAGvB,SAAgB,cACd,QACA,OACA,MACS;AACT,QAAO,YAAY,QAAQ,MAAM,CAAC,SAAS,KAAK;;AAGlD,SAAgB,sBAAsB,OAAsC;CAC1E,MAAM,UAAU,CAAC,GAAG,MAAM,MAAM;AAChC,KAAI,QAAQ,WAAW,EACrB,QAAO,EAAE,QAAQ;AAEnB,QAAO,EAAE,KAAK,QAAiC;;AAGjD,SAAgB,yBAAyB,OAAsB,MAAsB;AACnF,QAAO,GAAG,MAAM,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"notification.schema.cjs","names":["z","NOTIFICATION_PLATFORMS","NOTIFICATION_PROVIDERS","NOTIFICATION_SEND_STATUSES"],"sources":["../../../../src/modules/notification/notification.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport {\r\n NOTIFICATION_PLATFORMS,\r\n NOTIFICATION_PROVIDERS,\r\n NOTIFICATION_SEND_STATUSES,\r\n} from \"./notification.constants\";\r\n\r\nexport const notificationPlatformSchema = z.enum(NOTIFICATION_PLATFORMS);\r\nexport const notificationProviderSchema = z.enum(NOTIFICATION_PROVIDERS);\r\nexport const notificationSendStatusSchema = z.enum(NOTIFICATION_SEND_STATUSES);\r\n\r\n/** Web Push `PushSubscriptionJSON` subset we persist and accept from clients. */\r\nexport const pushSubscriptionJsonSchema = z.object({\r\n endpoint: z.string().url(),\r\n expirationTime: z.number().nullable().optional(),\r\n keys: z.object({\r\n p256dh: z.string(),\r\n auth: z.string(),\r\n }),\r\n});\r\n\r\nexport const notificationRegisterDeviceInputSchema = z.discriminatedUnion(\"platform\", [\r\n z.object({\r\n platform: z.literal(\"web\"),\r\n subscription: pushSubscriptionJsonSchema,\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"ios\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"android\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n]);\r\n\r\nexport type NotificationRegisterDeviceInput = z.infer<typeof notificationRegisterDeviceInputSchema>;\r\n\r\nexport const notificationRegisterDeviceOutputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceInputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceOutputSchema = z.object({\r\n ok: z.literal(true),\r\n});\r\n\r\nexport const notificationDeviceSelectSchema = z.object({\r\n id: z.string(),\r\n userId: z.string(),\r\n platform: notificationPlatformSchema,\r\n endpoint: z.string().nullable(),\r\n label: z.string().nullable(),\r\n enabled: z.boolean(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListDevicesOutputSchema = z.array(notificationDeviceSelectSchema);\r\n\r\nexport const notificationVapidPublicKeyOutputSchema = z.object({\r\n publicKey: z.string(),\r\n});\r\n\r\nexport const notificationSendLogSelectSchema = z.object({\r\n id: z.string(),\r\n batchId: z.string(),\r\n userId: z.string(),\r\n deviceId: z.string(),\r\n provider: notificationProviderSchema,\r\n title: z.string(),\r\n body: z.string(),\r\n data: z.record(z.string(), z.unknown()).nullable(),\r\n status: notificationSendStatusSchema,\r\n error: z.string().nullable(),\r\n jobId: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListSendLogsInputSchema = z.object({\r\n batchId: z.string().optional(),\r\n limit: z.number().int().min(1).max(100).optional(),\r\n});\r\n\r\nexport const notificationListSendLogsOutputSchema = z.array(notificationSendLogSelectSchema);\r\n\r\nexport const notificationSendTestInputSchema = z.object({\r\n userId: z.string().optional(),\r\n title: z.string().min(1).max(200),\r\n body: z.string().min(1).max(2000),\r\n data: z.record(z.string(), z.unknown()).optional(),\r\n});\r\n\r\nexport const notificationSendTestOutputSchema = z.object({\r\n batchId: z.string(),\r\n jobId: z.string(),\r\n});"],"mappings":";;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Q,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU;CACnD,CAAC;AAEF,MAAa,uCAAuCA,IAAAA,EAAE,MAAM,gCAAgC;AAE5F,MAAa,kCAAkCA,IAAAA,EAAE,OAAO;CACtD,QAAQA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC7B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI;CACjC,MAAMA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAK;CACjC,MAAMA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,SAAS,CAAC,CAAC,UAAU;CACnD,CAAC;AAEF,MAAa,mCAAmCA,IAAAA,EAAE,OAAO;CACvD,SAASA,IAAAA,EAAE,QAAQ;CACnB,OAAOA,IAAAA,EAAE,QAAQ;CAClB,CAAC"}
1
+ {"version":3,"file":"notification.schema.cjs","names":["z","NOTIFICATION_PLATFORMS","NOTIFICATION_PROVIDERS","NOTIFICATION_SEND_STATUSES"],"sources":["../../../../src/modules/notification/notification.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport {\r\n NOTIFICATION_PLATFORMS,\r\n NOTIFICATION_PROVIDERS,\r\n NOTIFICATION_SEND_STATUSES,\r\n} from \"./notification.constants\";\r\n\r\nexport const notificationPlatformSchema = z.enum(NOTIFICATION_PLATFORMS);\r\nexport const notificationProviderSchema = z.enum(NOTIFICATION_PROVIDERS);\r\nexport const notificationSendStatusSchema = z.enum(NOTIFICATION_SEND_STATUSES);\r\n\r\n/** Web Push `PushSubscriptionJSON` subset we persist and accept from clients. */\r\nexport const pushSubscriptionJsonSchema = z.object({\r\n endpoint: z.string().url(),\r\n expirationTime: z.number().nullable().optional(),\r\n keys: z.object({\r\n p256dh: z.string(),\r\n auth: z.string(),\r\n }),\r\n});\r\n\r\nexport const notificationRegisterDeviceInputSchema = z.discriminatedUnion(\"platform\", [\r\n z.object({\r\n platform: z.literal(\"web\"),\r\n subscription: pushSubscriptionJsonSchema,\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"ios\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"android\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n]);\r\n\r\nexport type NotificationRegisterDeviceInput = z.infer<typeof notificationRegisterDeviceInputSchema>;\r\n\r\nexport const notificationRegisterDeviceOutputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceInputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceOutputSchema = z.object({\r\n ok: z.literal(true),\r\n});\r\n\r\nexport const notificationDeviceSelectSchema = z.object({\r\n id: z.string(),\r\n userId: z.string(),\r\n platform: notificationPlatformSchema,\r\n endpoint: z.string().nullable(),\r\n label: z.string().nullable(),\r\n enabled: z.boolean(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListDevicesOutputSchema = z.array(notificationDeviceSelectSchema);\r\n\r\nexport const notificationVapidPublicKeyOutputSchema = z.object({\r\n publicKey: z.string(),\r\n});\r\n\r\nexport const notificationSendLogSelectSchema = z.object({\r\n id: z.string(),\r\n batchId: z.string(),\r\n userId: z.string(),\r\n deviceId: z.string(),\r\n provider: notificationProviderSchema,\r\n title: z.string(),\r\n body: z.string(),\r\n data: z.record(z.string(), z.unknown()).nullable(),\r\n status: notificationSendStatusSchema,\r\n error: z.string().nullable(),\r\n jobId: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListSendLogsInputSchema = z.object({\r\n batchId: z.string().optional(),\r\n limit: z.number().int().min(1).max(100).optional(),\r\n});\r\n\r\nexport const notificationListSendLogsOutputSchema = z.array(notificationSendLogSelectSchema);\r\n\r\nexport const notificationSendTestInputSchema = z.object({\r\n userId: z.string().optional(),\r\n title: z.string().min(1).max(200),\r\n body: z.string().min(1).max(2000),\r\n data: z.record(z.string(), z.unknown()).optional(),\r\n});\r\n\r\nexport const notificationSendTestOutputSchema = z.object({\r\n batchId: z.string(),\r\n jobId: z.string(),\r\n});\r\n"],"mappings":";;;;AAOA,MAAa,6BAA6BA,IAAAA,EAAE,KAAKC,wDAAAA,uBAAuB;AACxE,MAAa,6BAA6BD,IAAAA,EAAE,KAAKE,wDAAAA,uBAAuB;AACxE,MAAa,+BAA+BF,IAAAA,EAAE,KAAKG,wDAAAA,2BAA2B;;AAG9E,MAAa,6BAA6BH,IAAAA,EAAE,OAAO;CACjD,UAAUA,IAAAA,EAAE,QAAQ,CAAC,KAAK;CAC1B,gBAAgBA,IAAAA,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAChD,MAAMA,IAAAA,EAAE,OAAO;EACb,QAAQA,IAAAA,EAAE,QAAQ;EAClB,MAAMA,IAAAA,EAAE,QAAQ;EACjB,CAAC;CACH,CAAC;AAEF,MAAa,wCAAwCA,IAAAA,EAAE,mBAAmB,YAAY;CACpFA,IAAAA,EAAE,OAAO;EACP,UAAUA,IAAAA,EAAE,QAAQ,MAAM;EAC1B,cAAc;EACd,OAAOA,IAAAA,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU;EACtC,CAAC;CACFA,IAAAA,EAAE,OAAO;EACP,UAAUA,IAAAA,EAAE,QAAQ,MAAM;EAC1B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK;EAClC,OAAOA,IAAAA,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU;EACtC,CAAC;CACFA,IAAAA,EAAE,OAAO;EACP,UAAUA,IAAAA,EAAE,QAAQ,UAAU;EAC9B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK;EACl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,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC5B,WAAWA,IAAAA,EAAE,MAAM;CACnB,WAAWA,IAAAA,EAAE,MAAM;CACpB,CAAC;AAEF,MAAa,sCAAsCA,IAAAA,EAAE,OAAO;CAC1D,SAASA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU;CACnD,CAAC;AAEF,MAAa,uCAAuCA,IAAAA,EAAE,MAAM,gCAAgC;AAE5F,MAAa,kCAAkCA,IAAAA,EAAE,OAAO;CACtD,QAAQA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC7B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI;CACjC,MAAMA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAK;CACjC,MAAMA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,SAAS,CAAC,CAAC,UAAU;CACnD,CAAC;AAEF,MAAa,mCAAmCA,IAAAA,EAAE,OAAO;CACvD,SAASA,IAAAA,EAAE,QAAQ;CACnB,OAAOA,IAAAA,EAAE,QAAQ;CAClB,CAAC"}
@@ -12,9 +12,9 @@ declare const notificationProviderSchema: z.ZodEnum<{
12
12
  fcm: "fcm";
13
13
  }>;
14
14
  declare const notificationSendStatusSchema: z.ZodEnum<{
15
- failed: "failed";
16
15
  pending: "pending";
17
16
  sent: "sent";
17
+ failed: "failed";
18
18
  }>;
19
19
  /** Web Push `PushSubscriptionJSON` subset we persist and accept from clients. */
20
20
  declare const pushSubscriptionJsonSchema: z.ZodObject<{
@@ -100,9 +100,9 @@ declare const notificationSendLogSelectSchema: z.ZodObject<{
100
100
  body: z.ZodString;
101
101
  data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
102
102
  status: z.ZodEnum<{
103
- failed: "failed";
104
103
  pending: "pending";
105
104
  sent: "sent";
105
+ failed: "failed";
106
106
  }>;
107
107
  error: z.ZodNullable<z.ZodString>;
108
108
  jobId: z.ZodNullable<z.ZodString>;
@@ -127,9 +127,9 @@ declare const notificationListSendLogsOutputSchema: z.ZodArray<z.ZodObject<{
127
127
  body: z.ZodString;
128
128
  data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
129
129
  status: z.ZodEnum<{
130
- failed: "failed";
131
130
  pending: "pending";
132
131
  sent: "sent";
132
+ failed: "failed";
133
133
  }>;
134
134
  error: z.ZodNullable<z.ZodString>;
135
135
  jobId: z.ZodNullable<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"notification.schema.mjs","names":[],"sources":["../../../../src/modules/notification/notification.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport {\r\n NOTIFICATION_PLATFORMS,\r\n NOTIFICATION_PROVIDERS,\r\n NOTIFICATION_SEND_STATUSES,\r\n} from \"./notification.constants\";\r\n\r\nexport const notificationPlatformSchema = z.enum(NOTIFICATION_PLATFORMS);\r\nexport const notificationProviderSchema = z.enum(NOTIFICATION_PROVIDERS);\r\nexport const notificationSendStatusSchema = z.enum(NOTIFICATION_SEND_STATUSES);\r\n\r\n/** Web Push `PushSubscriptionJSON` subset we persist and accept from clients. */\r\nexport const pushSubscriptionJsonSchema = z.object({\r\n endpoint: z.string().url(),\r\n expirationTime: z.number().nullable().optional(),\r\n keys: z.object({\r\n p256dh: z.string(),\r\n auth: z.string(),\r\n }),\r\n});\r\n\r\nexport const notificationRegisterDeviceInputSchema = z.discriminatedUnion(\"platform\", [\r\n z.object({\r\n platform: z.literal(\"web\"),\r\n subscription: pushSubscriptionJsonSchema,\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"ios\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"android\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n]);\r\n\r\nexport type NotificationRegisterDeviceInput = z.infer<typeof notificationRegisterDeviceInputSchema>;\r\n\r\nexport const notificationRegisterDeviceOutputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceInputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceOutputSchema = z.object({\r\n ok: z.literal(true),\r\n});\r\n\r\nexport const notificationDeviceSelectSchema = z.object({\r\n id: z.string(),\r\n userId: z.string(),\r\n platform: notificationPlatformSchema,\r\n endpoint: z.string().nullable(),\r\n label: z.string().nullable(),\r\n enabled: z.boolean(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListDevicesOutputSchema = z.array(notificationDeviceSelectSchema);\r\n\r\nexport const notificationVapidPublicKeyOutputSchema = z.object({\r\n publicKey: z.string(),\r\n});\r\n\r\nexport const notificationSendLogSelectSchema = z.object({\r\n id: z.string(),\r\n batchId: z.string(),\r\n userId: z.string(),\r\n deviceId: z.string(),\r\n provider: notificationProviderSchema,\r\n title: z.string(),\r\n body: z.string(),\r\n data: z.record(z.string(), z.unknown()).nullable(),\r\n status: notificationSendStatusSchema,\r\n error: z.string().nullable(),\r\n jobId: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListSendLogsInputSchema = z.object({\r\n batchId: z.string().optional(),\r\n limit: z.number().int().min(1).max(100).optional(),\r\n});\r\n\r\nexport const notificationListSendLogsOutputSchema = z.array(notificationSendLogSelectSchema);\r\n\r\nexport const notificationSendTestInputSchema = z.object({\r\n userId: z.string().optional(),\r\n title: z.string().min(1).max(200),\r\n body: z.string().min(1).max(2000),\r\n data: z.record(z.string(), z.unknown()).optional(),\r\n});\r\n\r\nexport const notificationSendTestOutputSchema = z.object({\r\n batchId: z.string(),\r\n jobId: z.string(),\r\n});"],"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;CAClB,CAAC"}
1
+ {"version":3,"file":"notification.schema.mjs","names":[],"sources":["../../../../src/modules/notification/notification.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport {\r\n NOTIFICATION_PLATFORMS,\r\n NOTIFICATION_PROVIDERS,\r\n NOTIFICATION_SEND_STATUSES,\r\n} from \"./notification.constants\";\r\n\r\nexport const notificationPlatformSchema = z.enum(NOTIFICATION_PLATFORMS);\r\nexport const notificationProviderSchema = z.enum(NOTIFICATION_PROVIDERS);\r\nexport const notificationSendStatusSchema = z.enum(NOTIFICATION_SEND_STATUSES);\r\n\r\n/** Web Push `PushSubscriptionJSON` subset we persist and accept from clients. */\r\nexport const pushSubscriptionJsonSchema = z.object({\r\n endpoint: z.string().url(),\r\n expirationTime: z.number().nullable().optional(),\r\n keys: z.object({\r\n p256dh: z.string(),\r\n auth: z.string(),\r\n }),\r\n});\r\n\r\nexport const notificationRegisterDeviceInputSchema = z.discriminatedUnion(\"platform\", [\r\n z.object({\r\n platform: z.literal(\"web\"),\r\n subscription: pushSubscriptionJsonSchema,\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"ios\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n z.object({\r\n platform: z.literal(\"android\"),\r\n token: z.string().min(1).max(4096),\r\n label: z.string().max(120).optional(),\r\n }),\r\n]);\r\n\r\nexport type NotificationRegisterDeviceInput = z.infer<typeof notificationRegisterDeviceInputSchema>;\r\n\r\nexport const notificationRegisterDeviceOutputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceInputSchema = z.object({\r\n deviceId: z.string(),\r\n});\r\n\r\nexport const notificationUnregisterDeviceOutputSchema = z.object({\r\n ok: z.literal(true),\r\n});\r\n\r\nexport const notificationDeviceSelectSchema = z.object({\r\n id: z.string(),\r\n userId: z.string(),\r\n platform: notificationPlatformSchema,\r\n endpoint: z.string().nullable(),\r\n label: z.string().nullable(),\r\n enabled: z.boolean(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListDevicesOutputSchema = z.array(notificationDeviceSelectSchema);\r\n\r\nexport const notificationVapidPublicKeyOutputSchema = z.object({\r\n publicKey: z.string(),\r\n});\r\n\r\nexport const notificationSendLogSelectSchema = z.object({\r\n id: z.string(),\r\n batchId: z.string(),\r\n userId: z.string(),\r\n deviceId: z.string(),\r\n provider: notificationProviderSchema,\r\n title: z.string(),\r\n body: z.string(),\r\n data: z.record(z.string(), z.unknown()).nullable(),\r\n status: notificationSendStatusSchema,\r\n error: z.string().nullable(),\r\n jobId: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListSendLogsInputSchema = z.object({\r\n batchId: z.string().optional(),\r\n limit: z.number().int().min(1).max(100).optional(),\r\n});\r\n\r\nexport const notificationListSendLogsOutputSchema = z.array(notificationSendLogSelectSchema);\r\n\r\nexport const notificationSendTestInputSchema = z.object({\r\n userId: z.string().optional(),\r\n title: z.string().min(1).max(200),\r\n body: z.string().min(1).max(2000),\r\n data: z.record(z.string(), z.unknown()).optional(),\r\n});\r\n\r\nexport const notificationSendTestOutputSchema = z.object({\r\n batchId: z.string(),\r\n jobId: z.string(),\r\n});\r\n"],"mappings":";;;AAOA,MAAa,6BAA6B,EAAE,KAAK,uBAAuB;AACxE,MAAa,6BAA6B,EAAE,KAAK,uBAAuB;AACxE,MAAa,+BAA+B,EAAE,KAAK,2BAA2B;;AAG9E,MAAa,6BAA6B,EAAE,OAAO;CACjD,UAAU,EAAE,QAAQ,CAAC,KAAK;CAC1B,gBAAgB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAChD,MAAM,EAAE,OAAO;EACb,QAAQ,EAAE,QAAQ;EAClB,MAAM,EAAE,QAAQ;EACjB,CAAC;CACH,CAAC;AAEF,MAAa,wCAAwC,EAAE,mBAAmB,YAAY;CACpF,EAAE,OAAO;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ACjB,MAAM,EAAE,QAAQ;CAChB,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,UAAU;CAClD,QAAQ;CACR,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAa,sCAAsC,EAAE,OAAO;CAC1D,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU;CACnD,CAAC;AAEF,MAAa,uCAAuC,EAAE,MAAM,gCAAgC;AAE5F,MAAa,kCAAkC,EAAE,OAAO;CACtD,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI;CACjC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAK;CACjC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,UAAU;CACnD,CAAC;AAEF,MAAa,mCAAmC,EAAE,OAAO;CACvD,SAAS,EAAE,QAAQ;CACnB,OAAO,EAAE,QAAQ;CAClB,CAAC"}
@@ -7,8 +7,8 @@ declare const filterSchema: z.ZodObject<{
7
7
  string: "string";
8
8
  number: "number";
9
9
  boolean: "boolean";
10
- enum: "enum";
11
10
  date: "date";
11
+ enum: "enum";
12
12
  jsonArray: "jsonArray";
13
13
  }>;
14
14
  method: z.ZodEnum<{
@@ -39,8 +39,8 @@ declare const filtersSchema: z.ZodArray<z.ZodObject<{
39
39
  string: "string";
40
40
  number: "number";
41
41
  boolean: "boolean";
42
- enum: "enum";
43
42
  date: "date";
43
+ enum: "enum";
44
44
  jsonArray: "jsonArray";
45
45
  }>;
46
46
  method: z.ZodEnum<{
@@ -79,8 +79,8 @@ declare const querySchema: z.ZodObject<{
79
79
  string: "string";
80
80
  number: "number";
81
81
  boolean: "boolean";
82
- enum: "enum";
83
82
  date: "date";
83
+ enum: "enum";
84
84
  jsonArray: "jsonArray";
85
85
  }>;
86
86
  method: z.ZodEnum<{
@@ -7,8 +7,8 @@ declare const filterSchema: z.ZodObject<{
7
7
  string: "string";
8
8
  number: "number";
9
9
  boolean: "boolean";
10
- enum: "enum";
11
10
  date: "date";
11
+ enum: "enum";
12
12
  jsonArray: "jsonArray";
13
13
  }>;
14
14
  method: z.ZodEnum<{
@@ -39,8 +39,8 @@ declare const filtersSchema: z.ZodArray<z.ZodObject<{
39
39
  string: "string";
40
40
  number: "number";
41
41
  boolean: "boolean";
42
- enum: "enum";
43
42
  date: "date";
43
+ enum: "enum";
44
44
  jsonArray: "jsonArray";
45
45
  }>;
46
46
  method: z.ZodEnum<{
@@ -79,8 +79,8 @@ declare const querySchema: z.ZodObject<{
79
79
  string: "string";
80
80
  number: "number";
81
81
  boolean: "boolean";
82
- enum: "enum";
83
82
  date: "date";
83
+ enum: "enum";
84
84
  jsonArray: "jsonArray";
85
85
  }>;
86
86
  method: z.ZodEnum<{
@@ -1 +1 @@
1
- {"version":3,"file":"queryMatch.cjs","names":["z"],"sources":["../../../../src/modules/schemas/queryMatch.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport type { QueryFilter, QueryFilters } from \"./query.schema\";\r\n\r\nconst QUERY_FILTER_METHOD_TO_OP = {\r\n equals: \"$eq\",\r\n contains: \"$contains\",\r\n starts_with: \"$starts_with\",\r\n ends_with: \"$ends_with\",\r\n greater_than: \"$greater_than\",\r\n less_than: \"$less_than\",\r\n on: \"$on\",\r\n between: \"$between\",\r\n before: \"$before\",\r\n after: \"$after\",\r\n oneOf: \"$oneOf\",\r\n intersect: \"$intersect\",\r\n isEmpty: \"$isEmpty\",\r\n isNotEmpty: \"$isNotEmpty\",\r\n is_null: \"$is_null\",\r\n is_not_null: \"$is_not_null\",\r\n} as const;\r\n\r\nexport type QueryMatchOp = (typeof QUERY_FILTER_METHOD_TO_OP)[QueryFilter[\"method\"]];\r\n\r\n/** Scalar or list value in a QueryMatch field / operator payload. */\r\nexport type QueryMatchScalar = string | number | boolean | Date | null;\r\n\r\nexport interface QueryMatchIntersect {\r\n readonly endColumnId: string;\r\n readonly from: string;\r\n readonly to: string;\r\n}\r\n\r\nexport interface QueryMatchOperators {\r\n readonly $eq?: QueryMatchScalar | readonly string[];\r\n readonly $ne?: QueryMatchScalar;\r\n readonly $gt?: QueryMatchScalar;\r\n readonly $gte?: QueryMatchScalar;\r\n readonly $lt?: QueryMatchScalar;\r\n readonly $lte?: QueryMatchScalar;\r\n readonly $in?: readonly QueryMatchScalar[];\r\n readonly $nin?: readonly QueryMatchScalar[];\r\n readonly $exists?: boolean;\r\n readonly $like?: string;\r\n readonly $contains?: QueryMatchScalar;\r\n readonly $starts_with?: QueryMatchScalar;\r\n readonly $ends_with?: QueryMatchScalar;\r\n readonly $greater_than?: QueryMatchScalar;\r\n readonly $less_than?: QueryMatchScalar;\r\n readonly $on?: QueryMatchScalar;\r\n readonly $between?: readonly [QueryMatchScalar, QueryMatchScalar];\r\n readonly $before?: QueryMatchScalar;\r\n readonly $after?: QueryMatchScalar;\r\n readonly $oneOf?: readonly string[];\r\n readonly $intersect?: QueryMatchIntersect;\r\n readonly $isEmpty?: boolean;\r\n readonly $isNotEmpty?: boolean;\r\n readonly $is_null?: boolean;\r\n readonly $is_not_null?: boolean;\r\n readonly $not?: QueryMatchOperators;\r\n}\r\n\r\nexport type QueryMatchFieldValue = QueryMatchScalar | readonly string[] | QueryMatchOperators;\r\n\r\nexport interface QueryMatch {\r\n readonly $and?: readonly QueryMatch[];\r\n readonly $or?: readonly QueryMatch[];\r\n readonly $not?: QueryMatch;\r\n readonly [field: string]:\r\n | QueryMatchFieldValue\r\n | readonly QueryMatch[]\r\n | QueryMatch\r\n | undefined;\r\n}\r\n\r\nexport const queryMatchSchema: z.ZodType<QueryMatch> = z.lazy(() =>\r\n z.record(z.string(), z.unknown())\r\n) as z.ZodType<QueryMatch>;\r\n\r\nexport const matchQuerySchema = z.object({\r\n page: z.number().optional(),\r\n limit: z.number().optional(),\r\n sort: z.string().optional(),\r\n order: z.enum([\"asc\", \"desc\"]).optional(),\r\n match: queryMatchSchema.optional(),\r\n /** Global substring search. Clients should trim; servers treat empty / whitespace-only as no-op. */\r\n q: z.string().optional(),\r\n});\r\n\r\nexport type MatchQueryInput = z.infer<typeof matchQuerySchema>;\r\n\r\nfunction queryFilterToMatch(filter: QueryFilter): QueryMatch {\r\n const op = QUERY_FILTER_METHOD_TO_OP[filter.method];\r\n switch (filter.method) {\r\n case \"between\":\r\n return {\r\n [filter.columnId]: {\r\n $between: [String(filter.value), filter.valueTo ?? \"\"],\r\n },\r\n };\r\n case \"intersect\":\r\n return {\r\n [filter.columnId]: {\r\n $intersect: {\r\n endColumnId: filter.endColumnId ?? \"\",\r\n from: String(filter.value),\r\n to: filter.valueTo ?? \"\",\r\n },\r\n },\r\n };\r\n case \"isEmpty\":\r\n case \"isNotEmpty\":\r\n case \"is_null\":\r\n case \"is_not_null\":\r\n return { [filter.columnId]: { [op]: true } };\r\n default:\r\n return { [filter.columnId]: { [op]: filter.value } };\r\n }\r\n}\r\n\r\n/** Rename QueryFilters into a QueryMatch. Does not bake day bounds or gte. */\r\nexport function queryFiltersToMatch(filters: QueryFilters | undefined): QueryMatch {\r\n if (!filters || filters.length === 0) {\r\n return {};\r\n }\r\n if (filters.length === 1) {\r\n return queryFilterToMatch(filters[0]);\r\n }\r\n return { $and: filters.map(queryFilterToMatch) };\r\n}\r\n"],"mappings":";;;AAGA,MAAM,4BAA4B;CAChC,QAAQ;CACR,UAAU;CACV,aAAa;CACb,WAAW;CACX,cAAc;CACd,WAAW;CACX,IAAI;CACJ,SAAS;CACT,QAAQ;CACR,OAAO;CACP,OAAO;CACP,WAAW;CACX,SAAS;CACT,YAAY;CACZ,SAAS;CACT,aAAa;CACd;AAuDD,MAAa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":["import { z } from \"zod\";\r\nimport type { QueryFilter, QueryFilters } from \"./query.schema\";\r\n\r\nconst QUERY_FILTER_METHOD_TO_OP = {\r\n equals: \"$eq\",\r\n contains: \"$contains\",\r\n starts_with: \"$starts_with\",\r\n ends_with: \"$ends_with\",\r\n greater_than: \"$greater_than\",\r\n less_than: \"$less_than\",\r\n on: \"$on\",\r\n between: \"$between\",\r\n before: \"$before\",\r\n after: \"$after\",\r\n oneOf: \"$oneOf\",\r\n intersect: \"$intersect\",\r\n isEmpty: \"$isEmpty\",\r\n isNotEmpty: \"$isNotEmpty\",\r\n is_null: \"$is_null\",\r\n is_not_null: \"$is_not_null\",\r\n} as const;\r\n\r\nexport type QueryMatchOp = (typeof QUERY_FILTER_METHOD_TO_OP)[QueryFilter[\"method\"]];\r\n\r\n/** Scalar or list value in a QueryMatch field / operator payload. */\r\nexport type QueryMatchScalar = string | number | boolean | Date | null;\r\n\r\nexport interface QueryMatchIntersect {\r\n readonly endColumnId: string;\r\n readonly from: string;\r\n readonly to: string;\r\n}\r\n\r\nexport interface QueryMatchOperators {\r\n readonly $eq?: QueryMatchScalar | readonly string[];\r\n readonly $ne?: QueryMatchScalar;\r\n readonly $gt?: QueryMatchScalar;\r\n readonly $gte?: QueryMatchScalar;\r\n readonly $lt?: QueryMatchScalar;\r\n readonly $lte?: QueryMatchScalar;\r\n readonly $in?: readonly QueryMatchScalar[];\r\n readonly $nin?: readonly QueryMatchScalar[];\r\n readonly $exists?: boolean;\r\n readonly $like?: string;\r\n readonly $contains?: QueryMatchScalar;\r\n readonly $starts_with?: QueryMatchScalar;\r\n readonly $ends_with?: QueryMatchScalar;\r\n readonly $greater_than?: QueryMatchScalar;\r\n readonly $less_than?: QueryMatchScalar;\r\n readonly $on?: QueryMatchScalar;\r\n readonly $between?: readonly [QueryMatchScalar, QueryMatchScalar];\r\n readonly $before?: QueryMatchScalar;\r\n readonly $after?: QueryMatchScalar;\r\n readonly $oneOf?: readonly string[];\r\n readonly $intersect?: QueryMatchIntersect;\r\n readonly $isEmpty?: boolean;\r\n readonly $isNotEmpty?: boolean;\r\n readonly $is_null?: boolean;\r\n readonly $is_not_null?: boolean;\r\n readonly $not?: QueryMatchOperators;\r\n}\r\n\r\nexport type QueryMatchFieldValue = QueryMatchScalar | readonly string[] | QueryMatchOperators;\r\n\r\nexport interface QueryMatch {\r\n readonly $and?: readonly QueryMatch[];\r\n readonly $or?: readonly QueryMatch[];\r\n readonly $not?: QueryMatch;\r\n readonly [field: string]: QueryMatchFieldValue | readonly QueryMatch[] | QueryMatch | undefined;\r\n}\r\n\r\nexport const queryMatchSchema: z.ZodType<QueryMatch> = z.lazy(() =>\r\n z.record(z.string(), z.unknown())\r\n) as z.ZodType<QueryMatch>;\r\n\r\nexport const matchQuerySchema = z.object({\r\n page: z.number().optional(),\r\n limit: z.number().optional(),\r\n sort: z.string().optional(),\r\n order: z.enum([\"asc\", \"desc\"]).optional(),\r\n match: queryMatchSchema.optional(),\r\n /** Global substring search. Clients should trim; servers treat empty / whitespace-only as no-op. */\r\n q: z.string().optional(),\r\n});\r\n\r\nexport type MatchQueryInput = z.infer<typeof matchQuerySchema>;\r\n\r\nfunction queryFilterToMatch(filter: QueryFilter): QueryMatch {\r\n const op = QUERY_FILTER_METHOD_TO_OP[filter.method];\r\n switch (filter.method) {\r\n case \"between\":\r\n return {\r\n [filter.columnId]: {\r\n $between: [String(filter.value), filter.valueTo ?? \"\"],\r\n },\r\n };\r\n case \"intersect\":\r\n return {\r\n [filter.columnId]: {\r\n $intersect: {\r\n endColumnId: filter.endColumnId ?? \"\",\r\n from: String(filter.value),\r\n to: filter.valueTo ?? \"\",\r\n },\r\n },\r\n };\r\n case \"isEmpty\":\r\n case \"isNotEmpty\":\r\n case \"is_null\":\r\n case \"is_not_null\":\r\n return { [filter.columnId]: { [op]: true } };\r\n default:\r\n return { [filter.columnId]: { [op]: filter.value } };\r\n }\r\n}\r\n\r\n/** Rename QueryFilters into a QueryMatch. Does not bake day bounds or gte. */\r\nexport function queryFiltersToMatch(filters: QueryFilters | undefined): QueryMatch {\r\n if (!filters || filters.length === 0) {\r\n return {};\r\n }\r\n if (filters.length === 1) {\r\n return queryFilterToMatch(filters[0]);\r\n }\r\n return { $and: filters.map(queryFilterToMatch) };\r\n}\r\n"],"mappings":";;;AAGA,MAAM,4BAA4B;CAChC,QAAQ;CACR,UAAU;CACV,aAAa;CACb,WAAW;CACX,cAAc;CACd,WAAW;CACX,IAAI;CACJ,SAAS;CACT,QAAQ;CACR,OAAO;CACP,OAAO;CACP,WAAW;CACX,SAAS;CACT,YAAY;CACZ,SAAS;CACT,aAAa;CACd;AAmDD,MAAa,mBAA0CA,IAAAA,EAAE,WACvDA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,SAAS,CAAC,CAClC;AAED,MAAa,mBAAmBA,IAAAA,EAAE,OAAO;CACvC,MAAMA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC3B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC5B,MAAMA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC3B,OAAOA,IAAAA,EAAE,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC,UAAU;CACzC,OAAO,iBAAiB,UAAU;CAElC,GAAGA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACzB,CAAC;AAIF,SAAS,mBAAmB,QAAiC;CAC3D,MAAM,KAAK,0BAA0B,OAAO;AAC5C,SAAQ,OAAO,QAAf;EACE,KAAK,UACH,QAAO,GACJ,OAAO,WAAW,EACjB,UAAU,CAAC,OAAO,OAAO,MAAM,EAAE,OAAO,WAAW,GAAG,EACvD,EACF;EACH,KAAK,YACH,QAAO,GACJ,OAAO,WAAW,EACjB,YAAY;GACV,aAAa,OAAO,eAAe;GACnC,MAAM,OAAO,OAAO,MAAM;GAC1B,IAAI,OAAO,WAAW;GACvB,EACF,EACF;EACH,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,cACH,QAAO,GAAG,OAAO,WAAW,GAAG,KAAK,MAAM,EAAE;EAC9C,QACE,QAAO,GAAG,OAAO,WAAW,GAAG,KAAK,OAAO,OAAO,EAAE;;;;AAK1D,SAAgB,oBAAoB,SAA+C;AACjF,KAAI,CAAC,WAAW,QAAQ,WAAW,EACjC,QAAO,EAAE;AAEX,KAAI,QAAQ,WAAW,EACrB,QAAO,mBAAmB,QAAQ,GAAG;AAEvC,QAAO,EAAE,MAAM,QAAQ,IAAI,mBAAmB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"queryMatch.mjs","names":[],"sources":["../../../../src/modules/schemas/queryMatch.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport type { QueryFilter, QueryFilters } from \"./query.schema\";\r\n\r\nconst QUERY_FILTER_METHOD_TO_OP = {\r\n equals: \"$eq\",\r\n contains: \"$contains\",\r\n starts_with: \"$starts_with\",\r\n ends_with: \"$ends_with\",\r\n greater_than: \"$greater_than\",\r\n less_than: \"$less_than\",\r\n on: \"$on\",\r\n between: \"$between\",\r\n before: \"$before\",\r\n after: \"$after\",\r\n oneOf: \"$oneOf\",\r\n intersect: \"$intersect\",\r\n isEmpty: \"$isEmpty\",\r\n isNotEmpty: \"$isNotEmpty\",\r\n is_null: \"$is_null\",\r\n is_not_null: \"$is_not_null\",\r\n} as const;\r\n\r\nexport type QueryMatchOp = (typeof QUERY_FILTER_METHOD_TO_OP)[QueryFilter[\"method\"]];\r\n\r\n/** Scalar or list value in a QueryMatch field / operator payload. */\r\nexport type QueryMatchScalar = string | number | boolean | Date | null;\r\n\r\nexport interface QueryMatchIntersect {\r\n readonly endColumnId: string;\r\n readonly from: string;\r\n readonly to: string;\r\n}\r\n\r\nexport interface QueryMatchOperators {\r\n readonly $eq?: QueryMatchScalar | readonly string[];\r\n readonly $ne?: QueryMatchScalar;\r\n readonly $gt?: QueryMatchScalar;\r\n readonly $gte?: QueryMatchScalar;\r\n readonly $lt?: QueryMatchScalar;\r\n readonly $lte?: QueryMatchScalar;\r\n readonly $in?: readonly QueryMatchScalar[];\r\n readonly $nin?: readonly QueryMatchScalar[];\r\n readonly $exists?: boolean;\r\n readonly $like?: string;\r\n readonly $contains?: QueryMatchScalar;\r\n readonly $starts_with?: QueryMatchScalar;\r\n readonly $ends_with?: QueryMatchScalar;\r\n readonly $greater_than?: QueryMatchScalar;\r\n readonly $less_than?: QueryMatchScalar;\r\n readonly $on?: QueryMatchScalar;\r\n readonly $between?: readonly [QueryMatchScalar, QueryMatchScalar];\r\n readonly $before?: QueryMatchScalar;\r\n readonly $after?: QueryMatchScalar;\r\n readonly $oneOf?: readonly string[];\r\n readonly $intersect?: QueryMatchIntersect;\r\n readonly $isEmpty?: boolean;\r\n readonly $isNotEmpty?: boolean;\r\n readonly $is_null?: boolean;\r\n readonly $is_not_null?: boolean;\r\n readonly $not?: QueryMatchOperators;\r\n}\r\n\r\nexport type QueryMatchFieldValue = QueryMatchScalar | readonly string[] | QueryMatchOperators;\r\n\r\nexport interface QueryMatch {\r\n readonly $and?: readonly QueryMatch[];\r\n readonly $or?: readonly QueryMatch[];\r\n readonly $not?: QueryMatch;\r\n readonly [field: string]:\r\n | QueryMatchFieldValue\r\n | readonly QueryMatch[]\r\n | QueryMatch\r\n | undefined;\r\n}\r\n\r\nexport const queryMatchSchema: z.ZodType<QueryMatch> = z.lazy(() =>\r\n z.record(z.string(), z.unknown())\r\n) as z.ZodType<QueryMatch>;\r\n\r\nexport const matchQuerySchema = z.object({\r\n page: z.number().optional(),\r\n limit: z.number().optional(),\r\n sort: z.string().optional(),\r\n order: z.enum([\"asc\", \"desc\"]).optional(),\r\n match: queryMatchSchema.optional(),\r\n /** Global substring search. Clients should trim; servers treat empty / whitespace-only as no-op. */\r\n q: z.string().optional(),\r\n});\r\n\r\nexport type MatchQueryInput = z.infer<typeof matchQuerySchema>;\r\n\r\nfunction queryFilterToMatch(filter: QueryFilter): QueryMatch {\r\n const op = QUERY_FILTER_METHOD_TO_OP[filter.method];\r\n switch (filter.method) {\r\n case \"between\":\r\n return {\r\n [filter.columnId]: {\r\n $between: [String(filter.value), filter.valueTo ?? \"\"],\r\n },\r\n };\r\n case \"intersect\":\r\n return {\r\n [filter.columnId]: {\r\n $intersect: {\r\n endColumnId: filter.endColumnId ?? \"\",\r\n from: String(filter.value),\r\n to: filter.valueTo ?? \"\",\r\n },\r\n },\r\n };\r\n case \"isEmpty\":\r\n case \"isNotEmpty\":\r\n case \"is_null\":\r\n case \"is_not_null\":\r\n return { [filter.columnId]: { [op]: true } };\r\n default:\r\n return { [filter.columnId]: { [op]: filter.value } };\r\n }\r\n}\r\n\r\n/** Rename QueryFilters into a QueryMatch. Does not bake day bounds or gte. */\r\nexport function queryFiltersToMatch(filters: QueryFilters | undefined): QueryMatch {\r\n if (!filters || filters.length === 0) {\r\n return {};\r\n }\r\n if (filters.length === 1) {\r\n return queryFilterToMatch(filters[0]);\r\n }\r\n return { $and: filters.map(queryFilterToMatch) };\r\n}\r\n"],"mappings":";;AAGA,MAAM,4BAA4B;CAChC,QAAQ;CACR,UAAU;CACV,aAAa;CACb,WAAW;CACX,cAAc;CACd,WAAW;CACX,IAAI;CACJ,SAAS;CACT,QAAQ;CACR,OAAO;CACP,OAAO;CACP,WAAW;CACX,SAAS;CACT,YAAY;CACZ,SAAS;CACT,aAAa;CACd;AAuDD,MAAa,mBAA0C,EAAE,WACvD,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAClC;AAED,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,OAAO,EAAE,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC,UAAU;CACzC,OAAO,iBAAiB,UAAU;CAElC,GAAG,EAAE,QAAQ,CAAC,UAAU;CACzB,CAAC;AAIF,SAAS,mBAAmB,QAAiC;CAC3D,MAAM,KAAK,0BAA0B,OAAO;AAC5C,SAAQ,OAAO,QAAf;EACE,KAAK,UACH,QAAO,GACJ,OAAO,WAAW,EACjB,UAAU,CAAC,OAAO,OAAO,MAAM,EAAE,OAAO,WAAW,GAAG,EACvD,EACF;EACH,KAAK,YACH,QAAO,GACJ,OAAO,WAAW,EACjB,YAAY;GACV,aAAa,OAAO,eAAe;GACnC,MAAM,OAAO,OAAO,MAAM;GAC1B,IAAI,OAAO,WAAW;GACvB,EACF,EACF;EACH,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,cACH,QAAO,GAAG,OAAO,WAAW,GAAG,KAAK,MAAM,EAAE;EAC9C,QACE,QAAO,GAAG,OAAO,WAAW,GAAG,KAAK,OAAO,OAAO,EAAE;;;;AAK1D,SAAgB,oBAAoB,SAA+C;AACjF,KAAI,CAAC,WAAW,QAAQ,WAAW,EACjC,QAAO,EAAE;AAEX,KAAI,QAAQ,WAAW,EACrB,QAAO,mBAAmB,QAAQ,GAAG;AAEvC,QAAO,EAAE,MAAM,QAAQ,IAAI,mBAAmB,EAAE"}
1
+ {"version":3,"file":"queryMatch.mjs","names":[],"sources":["../../../../src/modules/schemas/queryMatch.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport type { QueryFilter, QueryFilters } from \"./query.schema\";\r\n\r\nconst QUERY_FILTER_METHOD_TO_OP = {\r\n equals: \"$eq\",\r\n contains: \"$contains\",\r\n starts_with: \"$starts_with\",\r\n ends_with: \"$ends_with\",\r\n greater_than: \"$greater_than\",\r\n less_than: \"$less_than\",\r\n on: \"$on\",\r\n between: \"$between\",\r\n before: \"$before\",\r\n after: \"$after\",\r\n oneOf: \"$oneOf\",\r\n intersect: \"$intersect\",\r\n isEmpty: \"$isEmpty\",\r\n isNotEmpty: \"$isNotEmpty\",\r\n is_null: \"$is_null\",\r\n is_not_null: \"$is_not_null\",\r\n} as const;\r\n\r\nexport type QueryMatchOp = (typeof QUERY_FILTER_METHOD_TO_OP)[QueryFilter[\"method\"]];\r\n\r\n/** Scalar or list value in a QueryMatch field / operator payload. */\r\nexport type QueryMatchScalar = string | number | boolean | Date | null;\r\n\r\nexport interface QueryMatchIntersect {\r\n readonly endColumnId: string;\r\n readonly from: string;\r\n readonly to: string;\r\n}\r\n\r\nexport interface QueryMatchOperators {\r\n readonly $eq?: QueryMatchScalar | readonly string[];\r\n readonly $ne?: QueryMatchScalar;\r\n readonly $gt?: QueryMatchScalar;\r\n readonly $gte?: QueryMatchScalar;\r\n readonly $lt?: QueryMatchScalar;\r\n readonly $lte?: QueryMatchScalar;\r\n readonly $in?: readonly QueryMatchScalar[];\r\n readonly $nin?: readonly QueryMatchScalar[];\r\n readonly $exists?: boolean;\r\n readonly $like?: string;\r\n readonly $contains?: QueryMatchScalar;\r\n readonly $starts_with?: QueryMatchScalar;\r\n readonly $ends_with?: QueryMatchScalar;\r\n readonly $greater_than?: QueryMatchScalar;\r\n readonly $less_than?: QueryMatchScalar;\r\n readonly $on?: QueryMatchScalar;\r\n readonly $between?: readonly [QueryMatchScalar, QueryMatchScalar];\r\n readonly $before?: QueryMatchScalar;\r\n readonly $after?: QueryMatchScalar;\r\n readonly $oneOf?: readonly string[];\r\n readonly $intersect?: QueryMatchIntersect;\r\n readonly $isEmpty?: boolean;\r\n readonly $isNotEmpty?: boolean;\r\n readonly $is_null?: boolean;\r\n readonly $is_not_null?: boolean;\r\n readonly $not?: QueryMatchOperators;\r\n}\r\n\r\nexport type QueryMatchFieldValue = QueryMatchScalar | readonly string[] | QueryMatchOperators;\r\n\r\nexport interface QueryMatch {\r\n readonly $and?: readonly QueryMatch[];\r\n readonly $or?: readonly QueryMatch[];\r\n readonly $not?: QueryMatch;\r\n readonly [field: string]: QueryMatchFieldValue | readonly QueryMatch[] | QueryMatch | undefined;\r\n}\r\n\r\nexport const queryMatchSchema: z.ZodType<QueryMatch> = z.lazy(() =>\r\n z.record(z.string(), z.unknown())\r\n) as z.ZodType<QueryMatch>;\r\n\r\nexport const matchQuerySchema = z.object({\r\n page: z.number().optional(),\r\n limit: z.number().optional(),\r\n sort: z.string().optional(),\r\n order: z.enum([\"asc\", \"desc\"]).optional(),\r\n match: queryMatchSchema.optional(),\r\n /** Global substring search. Clients should trim; servers treat empty / whitespace-only as no-op. */\r\n q: z.string().optional(),\r\n});\r\n\r\nexport type MatchQueryInput = z.infer<typeof matchQuerySchema>;\r\n\r\nfunction queryFilterToMatch(filter: QueryFilter): QueryMatch {\r\n const op = QUERY_FILTER_METHOD_TO_OP[filter.method];\r\n switch (filter.method) {\r\n case \"between\":\r\n return {\r\n [filter.columnId]: {\r\n $between: [String(filter.value), filter.valueTo ?? \"\"],\r\n },\r\n };\r\n case \"intersect\":\r\n return {\r\n [filter.columnId]: {\r\n $intersect: {\r\n endColumnId: filter.endColumnId ?? \"\",\r\n from: String(filter.value),\r\n to: filter.valueTo ?? \"\",\r\n },\r\n },\r\n };\r\n case \"isEmpty\":\r\n case \"isNotEmpty\":\r\n case \"is_null\":\r\n case \"is_not_null\":\r\n return { [filter.columnId]: { [op]: true } };\r\n default:\r\n return { [filter.columnId]: { [op]: filter.value } };\r\n }\r\n}\r\n\r\n/** Rename QueryFilters into a QueryMatch. Does not bake day bounds or gte. */\r\nexport function queryFiltersToMatch(filters: QueryFilters | undefined): QueryMatch {\r\n if (!filters || filters.length === 0) {\r\n return {};\r\n }\r\n if (filters.length === 1) {\r\n return queryFilterToMatch(filters[0]);\r\n }\r\n return { $and: filters.map(queryFilterToMatch) };\r\n}\r\n"],"mappings":";;AAGA,MAAM,4BAA4B;CAChC,QAAQ;CACR,UAAU;CACV,aAAa;CACb,WAAW;CACX,cAAc;CACd,WAAW;CACX,IAAI;CACJ,SAAS;CACT,QAAQ;CACR,OAAO;CACP,OAAO;CACP,WAAW;CACX,SAAS;CACT,YAAY;CACZ,SAAS;CACT,aAAa;CACd;AAmDD,MAAa,mBAA0C,EAAE,WACvD,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAClC;AAED,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,OAAO,EAAE,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC,UAAU;CACzC,OAAO,iBAAiB,UAAU;CAElC,GAAG,EAAE,QAAQ,CAAC,UAAU;CACzB,CAAC;AAIF,SAAS,mBAAmB,QAAiC;CAC3D,MAAM,KAAK,0BAA0B,OAAO;AAC5C,SAAQ,OAAO,QAAf;EACE,KAAK,UACH,QAAO,GACJ,OAAO,WAAW,EACjB,UAAU,CAAC,OAAO,OAAO,MAAM,EAAE,OAAO,WAAW,GAAG,EACvD,EACF;EACH,KAAK,YACH,QAAO,GACJ,OAAO,WAAW,EACjB,YAAY;GACV,aAAa,OAAO,eAAe;GACnC,MAAM,OAAO,OAAO,MAAM;GAC1B,IAAI,OAAO,WAAW;GACvB,EACF,EACF;EACH,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,cACH,QAAO,GAAG,OAAO,WAAW,GAAG,KAAK,MAAM,EAAE;EAC9C,QACE,QAAO,GAAG,OAAO,WAAW,GAAG,KAAK,OAAO,OAAO,EAAE;;;;AAK1D,SAAgB,oBAAoB,SAA+C;AACjF,KAAI,CAAC,WAAW,QAAQ,WAAW,EACjC,QAAO,EAAE;AAEX,KAAI,QAAQ,WAAW,EACrB,QAAO,mBAAmB,QAAQ,GAAG;AAEvC,QAAO,EAAE,MAAM,QAAQ,IAAI,mBAAmB,EAAE"}
@@ -37,8 +37,8 @@ declare const tagListInputSchema: z.ZodObject<{
37
37
  string: "string";
38
38
  number: "number";
39
39
  boolean: "boolean";
40
- enum: "enum";
41
40
  date: "date";
41
+ enum: "enum";
42
42
  jsonArray: "jsonArray";
43
43
  }>;
44
44
  method: z.ZodEnum<{
@@ -37,8 +37,8 @@ declare const tagListInputSchema: z.ZodObject<{
37
37
  string: "string";
38
38
  number: "number";
39
39
  boolean: "boolean";
40
- enum: "enum";
41
40
  date: "date";
41
+ enum: "enum";
42
42
  jsonArray: "jsonArray";
43
43
  }>;
44
44
  method: z.ZodEnum<{
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.constants.cjs","names":[],"sources":["../../../../src/modules/workflow/workflow.constants.ts"],"sourcesContent":["export const WORKFLOW_STATUSES = [\"queued\", \"running\", \"completed\", \"failed\"] as const;\nexport type WorkflowStatus = (typeof WORKFLOW_STATUSES)[number];\n\n/** @deprecated Use WORKFLOW_STATUSES instead. */\nexport const WORFLOW_STATUSES = WORKFLOW_STATUSES;\n"],"mappings":";;AAAA,MAAa,oBAAoB;CAAC;CAAU;CAAW;CAAa;CAAS;;AAI7E,MAAa,mBAAmB"}
1
+ {"version":3,"file":"workflow.constants.cjs","names":[],"sources":["../../../../src/modules/workflow/workflow.constants.ts"],"sourcesContent":["export const WORKFLOW_STATUSES = [\"queued\", \"running\", \"completed\", \"failed\"] as const;\r\nexport type WorkflowStatus = (typeof WORKFLOW_STATUSES)[number];\r\n\r\n/** @deprecated Use WORKFLOW_STATUSES instead. */\r\nexport const WORFLOW_STATUSES = WORKFLOW_STATUSES;\r\n"],"mappings":";;AAAA,MAAa,oBAAoB;CAAC;CAAU;CAAW;CAAa;CAAS;;AAI7E,MAAa,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.constants.mjs","names":[],"sources":["../../../../src/modules/workflow/workflow.constants.ts"],"sourcesContent":["export const WORKFLOW_STATUSES = [\"queued\", \"running\", \"completed\", \"failed\"] as const;\nexport type WorkflowStatus = (typeof WORKFLOW_STATUSES)[number];\n\n/** @deprecated Use WORKFLOW_STATUSES instead. */\nexport const WORFLOW_STATUSES = WORKFLOW_STATUSES;\n"],"mappings":";AAAA,MAAa,oBAAoB;CAAC;CAAU;CAAW;CAAa;CAAS;;AAI7E,MAAa,mBAAmB"}
1
+ {"version":3,"file":"workflow.constants.mjs","names":[],"sources":["../../../../src/modules/workflow/workflow.constants.ts"],"sourcesContent":["export const WORKFLOW_STATUSES = [\"queued\", \"running\", \"completed\", \"failed\"] as const;\r\nexport type WorkflowStatus = (typeof WORKFLOW_STATUSES)[number];\r\n\r\n/** @deprecated Use WORKFLOW_STATUSES instead. */\r\nexport const WORFLOW_STATUSES = WORKFLOW_STATUSES;\r\n"],"mappings":";AAAA,MAAa,oBAAoB;CAAC;CAAU;CAAW;CAAa;CAAS;;AAI7E,MAAa,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.schema.cjs","names":["z","WORKFLOW_STATUSES"],"sources":["../../../../src/modules/workflow/workflow.schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { WORKFLOW_STATUSES } from \"./workflow.constants\";\n\nexport const workflowSelectSchema = z.object({\n id: z.uuid(),\n userId: z.string().nullable(),\n jobId: z.string(),\n jobName: z.string(),\n queueName: z.string(),\n tags: z.array(z.string()).nullable(),\n input: z.unknown(),\n output: z.unknown(),\n status: z.enum(WORKFLOW_STATUSES),\n error: z.string().nullable(),\n retries: z.number(),\n finishedAt: z.date().nullable(),\n processedAt: z.date().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const workflowReadInputSchema = z.object({\n jobId: z.string(),\n});\n\nexport const workflowListInputSchema = z.object({\n status: z.enum(WORKFLOW_STATUSES).array().optional(),\n jobName: z.string().optional(),\n});\n\nexport const workflowTriggerOutputSchema = z.object({\n jobId: z.string(),\n});\n\nexport const workflowTriggerManyOutputSchema = z.object({\n jobIds: z.array(z.string()),\n});\n\nexport const workflowReadOutputSchema = workflowSelectSchema;\nexport const workflowListOutputSchema = workflowSelectSchema.array();\n\nexport type WorkflowSelectSchema = z.infer<typeof workflowSelectSchema>;\nexport type WorkflowReadInputSchema = z.infer<typeof workflowReadInputSchema>;\nexport type WorkflowListInputSchema = z.infer<typeof workflowListInputSchema>;\nexport type WorkflowReadOutputSchema = z.infer<typeof workflowReadOutputSchema>;\nexport type WorkflowListOutputSchema = z.infer<typeof workflowListOutputSchema>;\nexport type WorkflowTriggerOutputSchema = z.infer<typeof workflowTriggerOutputSchema>;\nexport type WorkflowTriggerManyOutputSchema = z.infer<typeof workflowTriggerManyOutputSchema>;\n"],"mappings":";;;;AAGA,MAAa,uBAAuBA,IAAAA,EAAE,OAAO;CAC3C,IAAIA,IAAAA,EAAE,MAAM;CACZ,QAAQA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC7B,OAAOA,IAAAA,EAAE,QAAQ;CACjB,SAASA,IAAAA,EAAE,QAAQ;CACnB,WAAWA,IAAAA,EAAE,QAAQ;CACrB,MAAMA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU;CACpC,OAAOA,IAAAA,EAAE,SAAS;CAClB,QAAQA,IAAAA,EAAE,SAAS;CACnB,QAAQA,IAAAA,EAAE,KAAKC,gDAAAA,kBAAkB;CACjC,OAAOD,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC5B,SAASA,IAAAA,EAAE,QAAQ;CACnB,YAAYA,IAAAA,EAAE,MAAM,CAAC,UAAU;CAC/B,aAAaA,IAAAA,EAAE,MAAM,CAAC,UAAU;CAChC,WAAWA,IAAAA,EAAE,MAAM;CACnB,WAAWA,IAAAA,EAAE,MAAM;CACpB,CAAC;AAEF,MAAa,0BAA0BA,IAAAA,EAAE,OAAO,EAC9C,OAAOA,IAAAA,EAAE,QAAQ,EAClB,CAAC;AAEF,MAAa,0BAA0BA,IAAAA,EAAE,OAAO;CAC9C,QAAQA,IAAAA,EAAE,KAAKC,gDAAAA,kBAAkB,CAAC,OAAO,CAAC,UAAU;CACpD,SAASD,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC/B,CAAC;AAEF,MAAa,8BAA8BA,IAAAA,EAAE,OAAO,EAClD,OAAOA,IAAAA,EAAE,QAAQ,EAClB,CAAC;AAEF,MAAa,kCAAkCA,IAAAA,EAAE,OAAO,EACtD,QAAQA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,EAC5B,CAAC;AAEF,MAAa,2BAA2B;AACxC,MAAa,2BAA2B,qBAAqB,OAAO"}
1
+ {"version":3,"file":"workflow.schema.cjs","names":["z","WORKFLOW_STATUSES"],"sources":["../../../../src/modules/workflow/workflow.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport { WORKFLOW_STATUSES } from \"./workflow.constants\";\r\n\r\nexport const workflowSelectSchema = z.object({\r\n id: z.uuid(),\r\n userId: z.string().nullable(),\r\n jobId: z.string(),\r\n jobName: z.string(),\r\n queueName: z.string(),\r\n tags: z.array(z.string()).nullable(),\r\n input: z.unknown(),\r\n output: z.unknown(),\r\n status: z.enum(WORKFLOW_STATUSES),\r\n error: z.string().nullable(),\r\n retries: z.number(),\r\n finishedAt: z.date().nullable(),\r\n processedAt: z.date().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const workflowReadInputSchema = z.object({\r\n jobId: z.string(),\r\n});\r\n\r\nexport const workflowListInputSchema = z.object({\r\n status: z.enum(WORKFLOW_STATUSES).array().optional(),\r\n jobName: z.string().optional(),\r\n});\r\n\r\nexport const workflowTriggerOutputSchema = z.object({\r\n jobId: z.string(),\r\n});\r\n\r\nexport const workflowTriggerManyOutputSchema = z.object({\r\n jobIds: z.array(z.string()),\r\n});\r\n\r\nexport const workflowReadOutputSchema = workflowSelectSchema;\r\nexport const workflowListOutputSchema = workflowSelectSchema.array();\r\n\r\nexport type WorkflowSelectSchema = z.infer<typeof workflowSelectSchema>;\r\nexport type WorkflowReadInputSchema = z.infer<typeof workflowReadInputSchema>;\r\nexport type WorkflowListInputSchema = z.infer<typeof workflowListInputSchema>;\r\nexport type WorkflowReadOutputSchema = z.infer<typeof workflowReadOutputSchema>;\r\nexport type WorkflowListOutputSchema = z.infer<typeof workflowListOutputSchema>;\r\nexport type WorkflowTriggerOutputSchema = z.infer<typeof workflowTriggerOutputSchema>;\r\nexport type WorkflowTriggerManyOutputSchema =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10 +11,10 @@ declare const workflowSelectSchema: z.ZodObject<{
11
11
  input: z.ZodUnknown;
12
12
  output: z.ZodUnknown;
13
13
  status: z.ZodEnum<{
14
+ failed: "failed";
14
15
  queued: "queued";
15
16
  running: "running";
16
17
  completed: "completed";
17
- failed: "failed";
18
18
  }>;
19
19
  error: z.ZodNullable<z.ZodString>;
20
20
  retries: z.ZodNumber;
@@ -28,10 +28,10 @@ declare const workflowReadInputSchema: z.ZodObject<{
28
28
  }, z.core.$strip>;
29
29
  declare const workflowListInputSchema: z.ZodObject<{
30
30
  status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
31
+ failed: "failed";
31
32
  queued: "queued";
32
33
  running: "running";
33
34
  completed: "completed";
34
- failed: "failed";
35
35
  }>>>;
36
36
  jobName: z.ZodOptional<z.ZodString>;
37
37
  }, z.core.$strip>;
@@ -51,10 +51,10 @@ declare const workflowReadOutputSchema: z.ZodObject<{
51
51
  input: z.ZodUnknown;
52
52
  output: z.ZodUnknown;
53
53
  status: z.ZodEnum<{
54
+ failed: "failed";
54
55
  queued: "queued";
55
56
  running: "running";
56
57
  completed: "completed";
57
- failed: "failed";
58
58
  }>;
59
59
  error: z.ZodNullable<z.ZodString>;
60
60
  retries: z.ZodNumber;
@@ -73,10 +73,10 @@ declare const workflowListOutputSchema: z.ZodArray<z.ZodObject<{
73
73
  input: z.ZodUnknown;
74
74
  output: z.ZodUnknown;
75
75
  status: z.ZodEnum<{
76
+ failed: "failed";
76
77
  queued: "queued";
77
78
  running: "running";
78
79
  completed: "completed";
79
- failed: "failed";
80
80
  }>;
81
81
  error: z.ZodNullable<z.ZodString>;
82
82
  retries: z.ZodNumber;
@@ -11,10 +11,10 @@ declare const workflowSelectSchema: z.ZodObject<{
11
11
  input: z.ZodUnknown;
12
12
  output: z.ZodUnknown;
13
13
  status: z.ZodEnum<{
14
+ failed: "failed";
14
15
  queued: "queued";
15
16
  running: "running";
16
17
  completed: "completed";
17
- failed: "failed";
18
18
  }>;
19
19
  error: z.ZodNullable<z.ZodString>;
20
20
  retries: z.ZodNumber;
@@ -28,10 +28,10 @@ declare const workflowReadInputSchema: z.ZodObject<{
28
28
  }, z.core.$strip>;
29
29
  declare const workflowListInputSchema: z.ZodObject<{
30
30
  status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
31
+ failed: "failed";
31
32
  queued: "queued";
32
33
  running: "running";
33
34
  completed: "completed";
34
- failed: "failed";
35
35
  }>>>;
36
36
  jobName: z.ZodOptional<z.ZodString>;
37
37
  }, z.core.$strip>;
@@ -51,10 +51,10 @@ declare const workflowReadOutputSchema: z.ZodObject<{
51
51
  input: z.ZodUnknown;
52
52
  output: z.ZodUnknown;
53
53
  status: z.ZodEnum<{
54
+ failed: "failed";
54
55
  queued: "queued";
55
56
  running: "running";
56
57
  completed: "completed";
57
- failed: "failed";
58
58
  }>;
59
59
  error: z.ZodNullable<z.ZodString>;
60
60
  retries: z.ZodNumber;
@@ -73,10 +73,10 @@ declare const workflowListOutputSchema: z.ZodArray<z.ZodObject<{
73
73
  input: z.ZodUnknown;
74
74
  output: z.ZodUnknown;
75
75
  status: z.ZodEnum<{
76
+ failed: "failed";
76
77
  queued: "queued";
77
78
  running: "running";
78
79
  completed: "completed";
79
- failed: "failed";
80
80
  }>;
81
81
  error: z.ZodNullable<z.ZodString>;
82
82
  retries: z.ZodNumber;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.schema.mjs","names":[],"sources":["../../../../src/modules/workflow/workflow.schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { WORKFLOW_STATUSES } from \"./workflow.constants\";\n\nexport const workflowSelectSchema = z.object({\n id: z.uuid(),\n userId: z.string().nullable(),\n jobId: z.string(),\n jobName: z.string(),\n queueName: z.string(),\n tags: z.array(z.string()).nullable(),\n input: z.unknown(),\n output: z.unknown(),\n status: z.enum(WORKFLOW_STATUSES),\n error: z.string().nullable(),\n retries: z.number(),\n finishedAt: z.date().nullable(),\n processedAt: z.date().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const workflowReadInputSchema = z.object({\n jobId: z.string(),\n});\n\nexport const workflowListInputSchema = z.object({\n status: z.enum(WORKFLOW_STATUSES).array().optional(),\n jobName: z.string().optional(),\n});\n\nexport const workflowTriggerOutputSchema = z.object({\n jobId: z.string(),\n});\n\nexport const workflowTriggerManyOutputSchema = z.object({\n jobIds: z.array(z.string()),\n});\n\nexport const workflowReadOutputSchema = workflowSelectSchema;\nexport const workflowListOutputSchema = workflowSelectSchema.array();\n\nexport type WorkflowSelectSchema = z.infer<typeof workflowSelectSchema>;\nexport type WorkflowReadInputSchema = z.infer<typeof workflowReadInputSchema>;\nexport type WorkflowListInputSchema = z.infer<typeof workflowListInputSchema>;\nexport type WorkflowReadOutputSchema = z.infer<typeof workflowReadOutputSchema>;\nexport type WorkflowListOutputSchema = z.infer<typeof workflowListOutputSchema>;\nexport type WorkflowTriggerOutputSchema = z.infer<typeof workflowTriggerOutputSchema>;\nexport type WorkflowTriggerManyOutputSchema = z.infer<typeof workflowTriggerManyOutputSchema>;\n"],"mappings":";;;AAGA,MAAa,uBAAuB,EAAE,OAAO;CAC3C,IAAI,EAAE,MAAM;CACZ,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,OAAO,EAAE,QAAQ;CACjB,SAAS,EAAE,QAAQ;CACnB,WAAW,EAAE,QAAQ;CACrB,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CACpC,OAAO,EAAE,SAAS;CAClB,QAAQ,EAAE,SAAS;CACnB,QAAQ,EAAE,KAAK,kBAAkB;CACjC,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,SAAS,EAAE,QAAQ;CACnB,YAAY,EAAE,MAAM,CAAC,UAAU;CAC/B,aAAa,EAAE,MAAM,CAAC,UAAU;CAChC,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAa,0BAA0B,EAAE,OAAO,EAC9C,OAAO,EAAE,QAAQ,EAClB,CAAC;AAEF,MAAa,0BAA0B,EAAE,OAAO;CAC9C,QAAQ,EAAE,KAAK,kBAAkB,CAAC,OAAO,CAAC,UAAU;CACpD,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC/B,CAAC;AAEF,MAAa,8BAA8B,EAAE,OAAO,EAClD,OAAO,EAAE,QAAQ,EAClB,CAAC;AAEF,MAAa,kCAAkC,EAAE,OAAO,EACtD,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAC5B,CAAC;AAEF,MAAa,2BAA2B;AACxC,MAAa,2BAA2B,qBAAqB,OAAO"}
1
+ {"version":3,"file":"workflow.schema.mjs","names":[],"sources":["../../../../src/modules/workflow/workflow.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport { WORKFLOW_STATUSES } from \"./workflow.constants\";\r\n\r\nexport const workflowSelectSchema = z.object({\r\n id: z.uuid(),\r\n userId: z.string().nullable(),\r\n jobId: z.string(),\r\n jobName: z.string(),\r\n queueName: z.string(),\r\n tags: z.array(z.string()).nullable(),\r\n input: z.unknown(),\r\n output: z.unknown(),\r\n status: z.enum(WORKFLOW_STATUSES),\r\n error: z.string().nullable(),\r\n retries: z.number(),\r\n finishedAt: z.date().nullable(),\r\n processedAt: z.date().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const workflowReadInputSchema = z.object({\r\n jobId: z.string(),\r\n});\r\n\r\nexport const workflowListInputSchema = z.object({\r\n status: z.enum(WORKFLOW_STATUSES).array().optional(),\r\n jobName: z.string().optional(),\r\n});\r\n\r\nexport const workflowTriggerOutputSchema = z.object({\r\n jobId: z.string(),\r\n});\r\n\r\nexport const workflowTriggerManyOutputSchema = z.object({\r\n jobIds: z.array(z.string()),\r\n});\r\n\r\nexport const workflowReadOutputSchema = workflowSelectSchema;\r\nexport const workflowListOutputSchema = workflowSelectSchema.array();\r\n\r\nexport type WorkflowSelectSchema = z.infer<typeof workflowSelectSchema>;\r\nexport type WorkflowReadInputSchema = z.infer<typeof workflowReadInputSchema>;\r\nexport type WorkflowListInputSchema = z.infer<typeof workflowListInputSchema>;\r\nexport type WorkflowReadOutputSchema = z.infer<typeof workflowReadOutputSchema>;\r\nexport type WorkflowListOutputSchema = z.infer<typeof workflowListOutputSchema>;\r\nexport type WorkflowTriggerOutputSchema = z.infer<typeof workflowTriggerOutputSchema>;\r\nexport type WorkflowTriggerManyOutputSchema = z.infer<typeof workflowTriggerManyOutputSchema>;\r\n"],"mappings":";;;AAGA,MAAa,uBAAuB,EAAE,OAAO;CAC3C,IAAI,EAAE,MAAM;CACZ,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,OAAO,EAAE,QAAQ;CACjB,SAAS,EAAE,QAAQ;CACnB,WAAW,EAAE,QAAQ;CACrB,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CACpC,OAAO,EAAE,SAAS;CAClB,QAAQ,EAAE,SAAS;CACnB,QAAQ,EAAE,KAAK,kBAAkB;CACjC,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,SAAS,EAAE,QAAQ;CACnB,YAAY,EAAE,MAAM,CAAC,UAAU;CAC/B,aAAa,EAAE,MAAM,CAAC,UAAU;CAChC,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAa,0BAA0B,EAAE,OAAO,EAC9C,OAAO,EAAE,QAAQ,EAClB,CAAC;AAEF,MAAa,0BAA0B,EAAE,OAAO;CAC9C,QAAQ,EAAE,KAAK,kBAAkB,CAAC,OAAO,CAAC,UAAU;CACpD,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC/B,CAAC;AAEF,MAAa,8BAA8B,EAAE,OAAO,EAClD,OAAO,EAAE,QAAQ,EAClB,CAAC;AAEF,MAAa,kCAAkC,EAAE,OAAO,EACtD,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAC5B,CAAC;AAEF,MAAa,2BAA2B;AACxC,MAAa,2BAA2B,qBAAqB,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m5kdev/commons",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "license": "GPL-3.0-only",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "tsdown": "0.21.7",
22
22
  "typescript": "6.0.3",
23
23
  "zod": "4.2.1",
24
- "@m5kdev/config": "0.33.0"
24
+ "@m5kdev/config": "0.34.0"
25
25
  },
26
26
  "exports": {
27
27
  "./utils/*": {
@@ -54,16 +54,6 @@
54
54
  "default": "./dist/src/modules/schemas/*.cjs"
55
55
  }
56
56
  },
57
- "./modules/crypto/*": {
58
- "import": {
59
- "types": "./dist/src/modules/crypto/*.d.mts",
60
- "default": "./dist/src/modules/crypto/*.mjs"
61
- },
62
- "require": {
63
- "types": "./dist/src/modules/crypto/*.d.cts",
64
- "default": "./dist/src/modules/crypto/*.cjs"
65
- }
66
- },
67
57
  "./modules/recurrence/*": {
68
58
  "import": {
69
59
  "types": "./dist/src/modules/recurrence/*.d.mts",