@m5kdev/commons 0.34.0 → 0.36.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.
Files changed (35) hide show
  1. package/dist/src/modules/auth/auth.roles.cjs +8 -6
  2. package/dist/src/modules/auth/auth.roles.cjs.map +1 -1
  3. package/dist/src/modules/auth/auth.roles.mjs +8 -6
  4. package/dist/src/modules/auth/auth.roles.mjs.map +1 -1
  5. package/dist/src/modules/auth/auth.schema.cjs +0 -3
  6. package/dist/src/modules/auth/auth.schema.cjs.map +1 -1
  7. package/dist/src/modules/auth/auth.schema.d.cts +0 -3
  8. package/dist/src/modules/auth/auth.schema.d.mts +0 -3
  9. package/dist/src/modules/auth/auth.schema.mjs +0 -3
  10. package/dist/src/modules/auth/auth.schema.mjs.map +1 -1
  11. package/dist/src/modules/base/server-event.schema.cjs +22 -0
  12. package/dist/src/modules/base/server-event.schema.cjs.map +1 -0
  13. package/dist/src/modules/base/server-event.schema.d.cts +21 -0
  14. package/dist/src/modules/base/server-event.schema.d.mts +21 -0
  15. package/dist/src/modules/base/server-event.schema.mjs +19 -0
  16. package/dist/src/modules/base/server-event.schema.mjs.map +1 -0
  17. package/dist/src/modules/notification/notification.constants.cjs +19 -2
  18. package/dist/src/modules/notification/notification.constants.cjs.map +1 -1
  19. package/dist/src/modules/notification/notification.constants.d.cts +20 -2
  20. package/dist/src/modules/notification/notification.constants.d.mts +20 -2
  21. package/dist/src/modules/notification/notification.constants.mjs +13 -2
  22. package/dist/src/modules/notification/notification.constants.mjs.map +1 -1
  23. package/dist/src/modules/notification/notification.schema.cjs +49 -6
  24. package/dist/src/modules/notification/notification.schema.cjs.map +1 -1
  25. package/dist/src/modules/notification/notification.schema.d.cts +123 -13
  26. package/dist/src/modules/notification/notification.schema.d.mts +123 -13
  27. package/dist/src/modules/notification/notification.schema.mjs +42 -8
  28. package/dist/src/modules/notification/notification.schema.mjs.map +1 -1
  29. package/dist/src/modules/schemas/query.schema.d.cts +3 -3
  30. package/dist/src/modules/schemas/query.schema.d.mts +3 -3
  31. package/dist/src/modules/tag/tag.schema.d.cts +1 -1
  32. package/dist/src/modules/tag/tag.schema.d.mts +1 -1
  33. package/dist/src/modules/workflow/workflow.schema.d.cts +4 -4
  34. package/dist/src/modules/workflow/workflow.schema.d.mts +4 -4
  35. package/package.json +2 -2
@@ -14,11 +14,7 @@ const DEFAULT_AUTH_ROLES = {
14
14
  "owner"
15
15
  ],
16
16
  managerRoles: ["admin", "owner"],
17
- assignableRoles: [
18
- "member",
19
- "admin",
20
- "owner"
21
- ],
17
+ assignableRoles: ["member", "admin"],
22
18
  defaultRole: "member"
23
19
  },
24
20
  team: {
@@ -47,11 +43,17 @@ function normalizeRoleScopeConfig(scope, defaults) {
47
43
  defaultRole
48
44
  };
49
45
  }
46
+ function withoutOwnerAssignable(scope) {
47
+ return {
48
+ ...scope,
49
+ assignableRoles: scope.assignableRoles.filter((role) => role !== "owner")
50
+ };
51
+ }
50
52
  function normalizeAuthRolesConfig(config) {
51
53
  if (!config) return DEFAULT_AUTH_ROLES;
52
54
  return {
53
55
  user: normalizeRoleScopeConfig(config.user, DEFAULT_AUTH_ROLES.user),
54
- organization: normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization),
56
+ organization: withoutOwnerAssignable(normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization)),
55
57
  team: normalizeRoleScopeConfig(config.team, DEFAULT_AUTH_ROLES.team)
56
58
  };
57
59
  }
@@ -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(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
+ {"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\"],\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\nfunction withoutOwnerAssignable(\r\n scope: NormalizedAuthRoleScopeConfig\r\n): NormalizedAuthRoleScopeConfig {\r\n return {\r\n ...scope,\r\n assignableRoles: scope.assignableRoles.filter((role) => role !== \"owner\"),\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: withoutOwnerAssignable(\r\n normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization)\r\n ),\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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,SAAS,uBACP,OAC+B;AAC/B,QAAO;EACL,GAAG;EACH,iBAAiB,MAAM,gBAAgB,QAAQ,SAAS,SAAS,QAAQ;EAC1E;;AAGH,SAAgB,yBACd,QAC2B;AAC3B,KAAI,CAAC,OACH,QAAO;AAGT,QAAO;EACL,MAAM,yBAAyB,OAAO,MAAM,mBAAmB,KAAK;EACpE,cAAc,uBACZ,yBAAyB,OAAO,cAAc,mBAAmB,aAAa,CAC/E;EACD,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"}
@@ -13,11 +13,7 @@ const DEFAULT_AUTH_ROLES = {
13
13
  "owner"
14
14
  ],
15
15
  managerRoles: ["admin", "owner"],
16
- assignableRoles: [
17
- "member",
18
- "admin",
19
- "owner"
20
- ],
16
+ assignableRoles: ["member", "admin"],
21
17
  defaultRole: "member"
22
18
  },
23
19
  team: {
@@ -46,11 +42,17 @@ function normalizeRoleScopeConfig(scope, defaults) {
46
42
  defaultRole
47
43
  };
48
44
  }
45
+ function withoutOwnerAssignable(scope) {
46
+ return {
47
+ ...scope,
48
+ assignableRoles: scope.assignableRoles.filter((role) => role !== "owner")
49
+ };
50
+ }
49
51
  function normalizeAuthRolesConfig(config) {
50
52
  if (!config) return DEFAULT_AUTH_ROLES;
51
53
  return {
52
54
  user: normalizeRoleScopeConfig(config.user, DEFAULT_AUTH_ROLES.user),
53
- organization: normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization),
55
+ organization: withoutOwnerAssignable(normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization)),
54
56
  team: normalizeRoleScopeConfig(config.team, DEFAULT_AUTH_ROLES.team)
55
57
  };
56
58
  }
@@ -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(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,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AAM,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\"],\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\nfunction withoutOwnerAssignable(\r\n scope: NormalizedAuthRoleScopeConfig\r\n): NormalizedAuthRoleScopeConfig {\r\n return {\r\n ...scope,\r\n assignableRoles: scope.assignableRoles.filter((role) => role !== \"owner\"),\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: withoutOwnerAssignable(\r\n normalizeRoleScopeConfig(config.organization, DEFAULT_AUTH_ROLES.organization)\r\n ),\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,CAAC,UAAU,QAAQ;EACpC,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,M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BAAyB,OAAsB,MAAsB;AACnF,QAAO,GAAG,MAAM,QAAQ"}
@@ -13,9 +13,6 @@ const userSchema = zod.z.object({
13
13
  banned: zod.z.boolean().nullable(),
14
14
  banReason: zod.z.string().nullable(),
15
15
  banExpires: zod.z.date().nullable(),
16
- paymentCustomerId: zod.z.string().nullable(),
17
- paymentPlanTier: zod.z.string().nullable(),
18
- paymentPlanExpiresAt: zod.z.date().nullable(),
19
16
  preferences: zod.z.string().nullable(),
20
17
  onboarding: zod.z.boolean().nullable()
21
18
  });
@@ -1 +1 @@
1
- {"version":3,"file":"auth.schema.cjs","names":["z"],"sources":["../../../../src/modules/auth/auth.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const userSchema = z.object({\r\n id: z.string(),\r\n name: z.string(),\r\n email: z.string(),\r\n emailVerified: z.boolean(),\r\n image: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n role: z.string().nullable(),\r\n banned: z.boolean().nullable(),\r\n banReason: z.string().nullable(),\r\n banExpires: z.date().nullable(),\r\n paymentCustomerId: z.string().nullable(),\r\n paymentPlanTier: z.string().nullable(),\r\n paymentPlanExpiresAt: z.date().nullable(),\r\n preferences: z.string().nullable(),\r\n onboarding: z.boolean().nullable(),\r\n});\r\n\r\nexport type UserSchema = z.infer<typeof userSchema>;\r\n"],"mappings":";;;AAEA,MAAa,aAAaA,IAAAA,EAAE,OAAO;CACjC,IAAIA,IAAAA,EAAE,QAAQ;CACd,MAAMA,IAAAA,EAAE,QAAQ;CAChB,OAAOA,IAAAA,EAAE,QAAQ;CACjB,eAAeA,IAAAA,EAAE,SAAS;CAC1B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC5B,WAAWA,IAAAA,EAAE,MAAM;CACnB,WAAWA,IAAAA,EAAE,MAAM;CACnB,MAAMA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC3B,QAAQA,IAAAA,EAAE,SAAS,CAAC,UAAU;CAC9B,WAAWA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAChC,YAAYA,IAAAA,EAAE,MAAM,CAAC,UAAU;CAC/B,mBAAmBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACxC,iBAAiBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACtC,sBAAsBA,IAAAA,EAAE,MAAM,CAAC,UAAU;CACzC,aAAaA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAClC,YAAYA,IAAAA,EAAE,SAAS,CAAC,UAAU;CACnC,CAAC"}
1
+ {"version":3,"file":"auth.schema.cjs","names":["z"],"sources":["../../../../src/modules/auth/auth.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const userSchema = z.object({\r\n id: z.string(),\r\n name: z.string(),\r\n email: z.string(),\r\n emailVerified: z.boolean(),\r\n image: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n role: z.string().nullable(),\r\n banned: z.boolean().nullable(),\r\n banReason: z.string().nullable(),\r\n banExpires: z.date().nullable(),\r\n preferences: z.string().nullable(),\r\n onboarding: z.boolean().nullable(),\r\n});\r\n\r\nexport type UserSchema = z.infer<typeof userSchema>;\r\n"],"mappings":";;;AAEA,MAAa,aAAaA,IAAAA,EAAE,OAAO;CACjC,IAAIA,IAAAA,EAAE,QAAQ;CACd,MAAMA,IAAAA,EAAE,QAAQ;CAChB,OAAOA,IAAAA,EAAE,QAAQ;CACjB,eAAeA,IAAAA,EAAE,SAAS;CAC1B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC5B,WAAWA,IAAAA,EAAE,MAAM;CACnB,WAAWA,IAAAA,EAAE,MAAM;CACnB,MAAMA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC3B,QAAQA,IAAAA,EAAE,SAAS,CAAC,UAAU;CAC9B,WAAWA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAChC,YAAYA,IAAAA,EAAE,MAAM,CAAC,UAAU;CAC/B,aAAaA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAClC,YAAYA,IAAAA,EAAE,SAAS,CAAC,UAAU;CACnC,CAAC"}
@@ -13,9 +13,6 @@ declare const userSchema: z.ZodObject<{
13
13
  banned: z.ZodNullable<z.ZodBoolean>;
14
14
  banReason: z.ZodNullable<z.ZodString>;
15
15
  banExpires: z.ZodNullable<z.ZodDate>;
16
- paymentCustomerId: z.ZodNullable<z.ZodString>;
17
- paymentPlanTier: z.ZodNullable<z.ZodString>;
18
- paymentPlanExpiresAt: z.ZodNullable<z.ZodDate>;
19
16
  preferences: z.ZodNullable<z.ZodString>;
20
17
  onboarding: z.ZodNullable<z.ZodBoolean>;
21
18
  }, z.core.$strip>;
@@ -13,9 +13,6 @@ declare const userSchema: z.ZodObject<{
13
13
  banned: z.ZodNullable<z.ZodBoolean>;
14
14
  banReason: z.ZodNullable<z.ZodString>;
15
15
  banExpires: z.ZodNullable<z.ZodDate>;
16
- paymentCustomerId: z.ZodNullable<z.ZodString>;
17
- paymentPlanTier: z.ZodNullable<z.ZodString>;
18
- paymentPlanExpiresAt: z.ZodNullable<z.ZodDate>;
19
16
  preferences: z.ZodNullable<z.ZodString>;
20
17
  onboarding: z.ZodNullable<z.ZodBoolean>;
21
18
  }, z.core.$strip>;
@@ -12,9 +12,6 @@ const userSchema = z.object({
12
12
  banned: z.boolean().nullable(),
13
13
  banReason: z.string().nullable(),
14
14
  banExpires: z.date().nullable(),
15
- paymentCustomerId: z.string().nullable(),
16
- paymentPlanTier: z.string().nullable(),
17
- paymentPlanExpiresAt: z.date().nullable(),
18
15
  preferences: z.string().nullable(),
19
16
  onboarding: z.boolean().nullable()
20
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"auth.schema.mjs","names":[],"sources":["../../../../src/modules/auth/auth.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const userSchema = z.object({\r\n id: z.string(),\r\n name: z.string(),\r\n email: z.string(),\r\n emailVerified: z.boolean(),\r\n image: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n role: z.string().nullable(),\r\n banned: z.boolean().nullable(),\r\n banReason: z.string().nullable(),\r\n banExpires: z.date().nullable(),\r\n paymentCustomerId: z.string().nullable(),\r\n paymentPlanTier: z.string().nullable(),\r\n paymentPlanExpiresAt: z.date().nullable(),\r\n preferences: z.string().nullable(),\r\n onboarding: z.boolean().nullable(),\r\n});\r\n\r\nexport type UserSchema = z.infer<typeof userSchema>;\r\n"],"mappings":";;AAEA,MAAa,aAAa,EAAE,OAAO;CACjC,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,QAAQ;CAChB,OAAO,EAAE,QAAQ;CACjB,eAAe,EAAE,SAAS;CAC1B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACnB,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,QAAQ,EAAE,SAAS,CAAC,UAAU;CAC9B,WAAW,EAAE,QAAQ,CAAC,UAAU;CAChC,YAAY,EAAE,MAAM,CAAC,UAAU;CAC/B,mBAAmB,EAAE,QAAQ,CAAC,UAAU;CACxC,iBAAiB,EAAE,QAAQ,CAAC,UAAU;CACtC,sBAAsB,EAAE,MAAM,CAAC,UAAU;CACzC,aAAa,EAAE,QAAQ,CAAC,UAAU;CAClC,YAAY,EAAE,SAAS,CAAC,UAAU;CACnC,CAAC"}
1
+ {"version":3,"file":"auth.schema.mjs","names":[],"sources":["../../../../src/modules/auth/auth.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const userSchema = z.object({\r\n id: z.string(),\r\n name: z.string(),\r\n email: z.string(),\r\n emailVerified: z.boolean(),\r\n image: z.string().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n role: z.string().nullable(),\r\n banned: z.boolean().nullable(),\r\n banReason: z.string().nullable(),\r\n banExpires: z.date().nullable(),\r\n preferences: z.string().nullable(),\r\n onboarding: z.boolean().nullable(),\r\n});\r\n\r\nexport type UserSchema = z.infer<typeof userSchema>;\r\n"],"mappings":";;AAEA,MAAa,aAAa,EAAE,OAAO;CACjC,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,QAAQ;CAChB,OAAO,EAAE,QAAQ;CACjB,eAAe,EAAE,SAAS;CAC1B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACnB,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,QAAQ,EAAE,SAAS,CAAC,UAAU;CAC9B,WAAW,EAAE,QAAQ,CAAC,UAAU;CAChC,YAAY,EAAE,MAAM,CAAC,UAAU;CAC/B,aAAa,EAAE,QAAQ,CAAC,UAAU;CAClC,YAAY,EAAE,SAAS,CAAC,UAAU;CACnC,CAAC"}
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let zod = require("zod");
3
+ //#region src/modules/base/server-event.schema.ts
4
+ const SERVER_EVENT_SUBSCRIBE_PATH = "/events";
5
+ const SERVER_EVENT_CHANGES = [
6
+ "created",
7
+ "updated",
8
+ "deleted"
9
+ ];
10
+ const serverEventEnvelopeSchema = zod.z.object({
11
+ resource: zod.z.string().min(1),
12
+ id: zod.z.string().min(1),
13
+ change: zod.z.enum(SERVER_EVENT_CHANGES),
14
+ organizationId: zod.z.string().nullable(),
15
+ snapshot: zod.z.unknown().optional()
16
+ });
17
+ //#endregion
18
+ exports.SERVER_EVENT_CHANGES = SERVER_EVENT_CHANGES;
19
+ exports.SERVER_EVENT_SUBSCRIBE_PATH = SERVER_EVENT_SUBSCRIBE_PATH;
20
+ exports.serverEventEnvelopeSchema = serverEventEnvelopeSchema;
21
+
22
+ //# sourceMappingURL=server-event.schema.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-event.schema.cjs","names":["z"],"sources":["../../../../src/modules/base/server-event.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const SERVER_EVENT_SUBSCRIBE_PATH = \"/events\";\r\n\r\nexport const SERVER_EVENT_CHANGES = [\"created\", \"updated\", \"deleted\"] as const;\r\n\r\nexport const serverEventEnvelopeSchema = z.object({\r\n resource: z.string().min(1),\r\n id: z.string().min(1),\r\n change: z.enum(SERVER_EVENT_CHANGES),\r\n organizationId: z.string().nullable(),\r\n snapshot: z.unknown().optional(),\r\n});\r\n\r\nexport type ServerEventChange = (typeof SERVER_EVENT_CHANGES)[number];\r\nexport type ServerEventEnvelope = z.infer<typeof serverEventEnvelopeSchema>;\r\n"],"mappings":";;;AAEA,MAAa,8BAA8B;AAE3C,MAAa,uBAAuB;CAAC;CAAW;CAAW;CAAU;AAErE,MAAa,4BAA4BA,IAAAA,EAAE,OAAO;CAChD,UAAUA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC3B,IAAIA,IAAAA,EAAE,QAAQ,CAAC,IAAI,EAAE;CACrB,QAAQA,IAAAA,EAAE,KAAK,qBAAqB;CACpC,gBAAgBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACrC,UAAUA,IAAAA,EAAE,SAAS,CAAC,UAAU;CACjC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/modules/base/server-event.schema.d.ts
4
+ declare const SERVER_EVENT_SUBSCRIBE_PATH = "/events";
5
+ declare const SERVER_EVENT_CHANGES: readonly ["created", "updated", "deleted"];
6
+ declare const serverEventEnvelopeSchema: z.ZodObject<{
7
+ resource: z.ZodString;
8
+ id: z.ZodString;
9
+ change: z.ZodEnum<{
10
+ created: "created";
11
+ updated: "updated";
12
+ deleted: "deleted";
13
+ }>;
14
+ organizationId: z.ZodNullable<z.ZodString>;
15
+ snapshot: z.ZodOptional<z.ZodUnknown>;
16
+ }, z.core.$strip>;
17
+ type ServerEventChange = (typeof SERVER_EVENT_CHANGES)[number];
18
+ type ServerEventEnvelope = z.infer<typeof serverEventEnvelopeSchema>;
19
+ //#endregion
20
+ export { SERVER_EVENT_CHANGES, SERVER_EVENT_SUBSCRIBE_PATH, ServerEventChange, ServerEventEnvelope, serverEventEnvelopeSchema };
21
+ //# sourceMappingURL=server-event.schema.d.cts.map
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/modules/base/server-event.schema.d.ts
4
+ declare const SERVER_EVENT_SUBSCRIBE_PATH = "/events";
5
+ declare const SERVER_EVENT_CHANGES: readonly ["created", "updated", "deleted"];
6
+ declare const serverEventEnvelopeSchema: z.ZodObject<{
7
+ resource: z.ZodString;
8
+ id: z.ZodString;
9
+ change: z.ZodEnum<{
10
+ created: "created";
11
+ updated: "updated";
12
+ deleted: "deleted";
13
+ }>;
14
+ organizationId: z.ZodNullable<z.ZodString>;
15
+ snapshot: z.ZodOptional<z.ZodUnknown>;
16
+ }, z.core.$strip>;
17
+ type ServerEventChange = (typeof SERVER_EVENT_CHANGES)[number];
18
+ type ServerEventEnvelope = z.infer<typeof serverEventEnvelopeSchema>;
19
+ //#endregion
20
+ export { SERVER_EVENT_CHANGES, SERVER_EVENT_SUBSCRIBE_PATH, ServerEventChange, ServerEventEnvelope, serverEventEnvelopeSchema };
21
+ //# sourceMappingURL=server-event.schema.d.mts.map
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ //#region src/modules/base/server-event.schema.ts
3
+ const SERVER_EVENT_SUBSCRIBE_PATH = "/events";
4
+ const SERVER_EVENT_CHANGES = [
5
+ "created",
6
+ "updated",
7
+ "deleted"
8
+ ];
9
+ const serverEventEnvelopeSchema = z.object({
10
+ resource: z.string().min(1),
11
+ id: z.string().min(1),
12
+ change: z.enum(SERVER_EVENT_CHANGES),
13
+ organizationId: z.string().nullable(),
14
+ snapshot: z.unknown().optional()
15
+ });
16
+ //#endregion
17
+ export { SERVER_EVENT_CHANGES, SERVER_EVENT_SUBSCRIBE_PATH, serverEventEnvelopeSchema };
18
+
19
+ //# sourceMappingURL=server-event.schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-event.schema.mjs","names":[],"sources":["../../../../src/modules/base/server-event.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const SERVER_EVENT_SUBSCRIBE_PATH = \"/events\";\r\n\r\nexport const SERVER_EVENT_CHANGES = [\"created\", \"updated\", \"deleted\"] as const;\r\n\r\nexport const serverEventEnvelopeSchema = z.object({\r\n resource: z.string().min(1),\r\n id: z.string().min(1),\r\n change: z.enum(SERVER_EVENT_CHANGES),\r\n organizationId: z.string().nullable(),\r\n snapshot: z.unknown().optional(),\r\n});\r\n\r\nexport type ServerEventChange = (typeof SERVER_EVENT_CHANGES)[number];\r\nexport type ServerEventEnvelope = z.infer<typeof serverEventEnvelopeSchema>;\r\n"],"mappings":";;AAEA,MAAa,8BAA8B;AAE3C,MAAa,uBAAuB;CAAC;CAAW;CAAW;CAAU;AAErE,MAAa,4BAA4B,EAAE,OAAO;CAChD,UAAU,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;CACrB,QAAQ,EAAE,KAAK,qBAAqB;CACpC,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CACrC,UAAU,EAAE,SAAS,CAAC,UAAU;CACjC,CAAC"}
@@ -15,11 +15,28 @@ const NOTIFICATION_SEND_STATUSES = [
15
15
  "sent",
16
16
  "failed"
17
17
  ];
18
- const NOTIFICATION_DELIVER_JOB_NAME = "notification.deliver";
18
+ const NOTIFICATION_WEB_PUSH_JOB_NAME = "notification.webPush";
19
+ const NOTIFICATION_MOBILE_PUSH_JOB_NAME = "notification.mobilePush";
20
+ const NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS = 120 * 1e3;
21
+ const NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS = 300 * 1e3;
22
+ const NOTIFICATION_EMAIL_JOB_NAME = "notification.email";
23
+ const NOTIFICATION_DEFAULT_EMAIL_DELAY_MS = 900 * 1e3;
24
+ const NOTIFICATION_CHANNELS = [
25
+ "in-app",
26
+ "web-push",
27
+ "mobile-push",
28
+ "email"
29
+ ];
19
30
  //#endregion
20
- exports.NOTIFICATION_DELIVER_JOB_NAME = NOTIFICATION_DELIVER_JOB_NAME;
31
+ exports.NOTIFICATION_CHANNELS = NOTIFICATION_CHANNELS;
32
+ exports.NOTIFICATION_DEFAULT_EMAIL_DELAY_MS = NOTIFICATION_DEFAULT_EMAIL_DELAY_MS;
33
+ exports.NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS = NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS;
34
+ exports.NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS = NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS;
35
+ exports.NOTIFICATION_EMAIL_JOB_NAME = NOTIFICATION_EMAIL_JOB_NAME;
36
+ exports.NOTIFICATION_MOBILE_PUSH_JOB_NAME = NOTIFICATION_MOBILE_PUSH_JOB_NAME;
21
37
  exports.NOTIFICATION_PLATFORMS = NOTIFICATION_PLATFORMS;
22
38
  exports.NOTIFICATION_PROVIDERS = NOTIFICATION_PROVIDERS;
23
39
  exports.NOTIFICATION_SEND_STATUSES = NOTIFICATION_SEND_STATUSES;
40
+ exports.NOTIFICATION_WEB_PUSH_JOB_NAME = NOTIFICATION_WEB_PUSH_JOB_NAME;
24
41
 
25
42
  //# sourceMappingURL=notification.constants.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.constants.cjs","names":[],"sources":["../../../../src/modules/notification/notification.constants.ts"],"sourcesContent":["export const NOTIFICATION_PLATFORMS = [\"web\", \"ios\", \"android\"] as const;\r\nexport type NotificationPlatform = (typeof NOTIFICATION_PLATFORMS)[number];\r\n\r\nexport const NOTIFICATION_PROVIDERS = [\"web\", \"apn\", \"fcm\"] as const;\r\nexport type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];\r\n\r\nexport const NOTIFICATION_SEND_STATUSES = [\"pending\", \"sent\", \"failed\"] as const;\r\nexport type NotificationSendStatus = (typeof NOTIFICATION_SEND_STATUSES)[number];\r\n\r\nexport const NOTIFICATION_DELIVER_JOB_NAME = \"notification.deliver\" as const;\r\n"],"mappings":";;AAAA,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAU;AAG/D,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAM;AAG3D,MAAa,6BAA6B;CAAC;CAAW;CAAQ;CAAS;AAGvE,MAAa,gCAAgC"}
1
+ {"version":3,"file":"notification.constants.cjs","names":[],"sources":["../../../../src/modules/notification/notification.constants.ts"],"sourcesContent":["export const NOTIFICATION_PLATFORMS = [\"web\", \"ios\", \"android\"] as const;\r\nexport type NotificationPlatform = (typeof NOTIFICATION_PLATFORMS)[number];\r\n\r\nexport const NOTIFICATION_PROVIDERS = [\"web\", \"apn\", \"fcm\"] as const;\r\nexport type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];\r\n\r\nexport const NOTIFICATION_SEND_STATUSES = [\"pending\", \"sent\", \"failed\"] as const;\r\nexport type NotificationSendStatus = (typeof NOTIFICATION_SEND_STATUSES)[number];\r\n\r\nexport const NOTIFICATION_WEB_PUSH_JOB_NAME = \"notification.webPush\" as const;\r\nexport const NOTIFICATION_MOBILE_PUSH_JOB_NAME = \"notification.mobilePush\" as const;\r\n\r\nexport const NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS = 2 * 60 * 1000;\r\nexport const NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS = 5 * 60 * 1000;\r\nexport const NOTIFICATION_EMAIL_JOB_NAME = \"notification.email\" as const;\r\nexport const NOTIFICATION_DEFAULT_EMAIL_DELAY_MS = 15 * 60 * 1000;\r\n\r\nexport const NOTIFICATION_CHANNELS = [\"in-app\", \"web-push\", \"mobile-push\", \"email\"] as const;\r\nexport type NotificationChannel = (typeof NOTIFICATION_CHANNELS)[number];\r\n\r\nexport interface NotificationKindDelays {\r\n readonly webPushMs?: number;\r\n readonly mobilePushMs?: number;\r\n readonly emailMs?: number;\r\n}\r\n\r\nexport interface NotificationKind {\r\n readonly id: string;\r\n readonly defaultChannels: readonly NotificationChannel[];\r\n readonly delays?: NotificationKindDelays;\r\n readonly emailTemplate?: string;\r\n}\r\n"],"mappings":";;AAAA,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAU;AAG/D,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAM;AAG3D,MAAa,6BAA6B;CAAC;CAAW;CAAQ;CAAS;AAGvE,MAAa,iCAAiC;AAC9C,MAAa,oCAAoC;AAEjD,MAAa,yCAAyC,MAAS;AAC/D,MAAa,4CAA4C,MAAS;AAClE,MAAa,8BAA8B;AAC3C,MAAa,sCAAsC,MAAU;AAE7D,MAAa,wBAAwB;CAAC;CAAU;CAAY;CAAe;CAAQ"}
@@ -5,7 +5,25 @@ declare const NOTIFICATION_PROVIDERS: readonly ["web", "apn", "fcm"];
5
5
  type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];
6
6
  declare const NOTIFICATION_SEND_STATUSES: readonly ["pending", "sent", "failed"];
7
7
  type NotificationSendStatus = (typeof NOTIFICATION_SEND_STATUSES)[number];
8
- declare const NOTIFICATION_DELIVER_JOB_NAME: "notification.deliver";
8
+ declare const NOTIFICATION_WEB_PUSH_JOB_NAME: "notification.webPush";
9
+ declare const NOTIFICATION_MOBILE_PUSH_JOB_NAME: "notification.mobilePush";
10
+ declare const NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS: number;
11
+ declare const NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS: number;
12
+ declare const NOTIFICATION_EMAIL_JOB_NAME: "notification.email";
13
+ declare const NOTIFICATION_DEFAULT_EMAIL_DELAY_MS: number;
14
+ declare const NOTIFICATION_CHANNELS: readonly ["in-app", "web-push", "mobile-push", "email"];
15
+ type NotificationChannel = (typeof NOTIFICATION_CHANNELS)[number];
16
+ interface NotificationKindDelays {
17
+ readonly webPushMs?: number;
18
+ readonly mobilePushMs?: number;
19
+ readonly emailMs?: number;
20
+ }
21
+ interface NotificationKind {
22
+ readonly id: string;
23
+ readonly defaultChannels: readonly NotificationChannel[];
24
+ readonly delays?: NotificationKindDelays;
25
+ readonly emailTemplate?: string;
26
+ }
9
27
  //#endregion
10
- export { NOTIFICATION_DELIVER_JOB_NAME, NOTIFICATION_PLATFORMS, NOTIFICATION_PROVIDERS, NOTIFICATION_SEND_STATUSES, NotificationPlatform, NotificationProvider, NotificationSendStatus };
28
+ export { NOTIFICATION_CHANNELS, NOTIFICATION_DEFAULT_EMAIL_DELAY_MS, NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS, NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS, NOTIFICATION_EMAIL_JOB_NAME, NOTIFICATION_MOBILE_PUSH_JOB_NAME, NOTIFICATION_PLATFORMS, NOTIFICATION_PROVIDERS, NOTIFICATION_SEND_STATUSES, NOTIFICATION_WEB_PUSH_JOB_NAME, NotificationChannel, NotificationKind, NotificationKindDelays, NotificationPlatform, NotificationProvider, NotificationSendStatus };
11
29
  //# sourceMappingURL=notification.constants.d.cts.map
@@ -5,7 +5,25 @@ declare const NOTIFICATION_PROVIDERS: readonly ["web", "apn", "fcm"];
5
5
  type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];
6
6
  declare const NOTIFICATION_SEND_STATUSES: readonly ["pending", "sent", "failed"];
7
7
  type NotificationSendStatus = (typeof NOTIFICATION_SEND_STATUSES)[number];
8
- declare const NOTIFICATION_DELIVER_JOB_NAME: "notification.deliver";
8
+ declare const NOTIFICATION_WEB_PUSH_JOB_NAME: "notification.webPush";
9
+ declare const NOTIFICATION_MOBILE_PUSH_JOB_NAME: "notification.mobilePush";
10
+ declare const NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS: number;
11
+ declare const NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS: number;
12
+ declare const NOTIFICATION_EMAIL_JOB_NAME: "notification.email";
13
+ declare const NOTIFICATION_DEFAULT_EMAIL_DELAY_MS: number;
14
+ declare const NOTIFICATION_CHANNELS: readonly ["in-app", "web-push", "mobile-push", "email"];
15
+ type NotificationChannel = (typeof NOTIFICATION_CHANNELS)[number];
16
+ interface NotificationKindDelays {
17
+ readonly webPushMs?: number;
18
+ readonly mobilePushMs?: number;
19
+ readonly emailMs?: number;
20
+ }
21
+ interface NotificationKind {
22
+ readonly id: string;
23
+ readonly defaultChannels: readonly NotificationChannel[];
24
+ readonly delays?: NotificationKindDelays;
25
+ readonly emailTemplate?: string;
26
+ }
9
27
  //#endregion
10
- export { NOTIFICATION_DELIVER_JOB_NAME, NOTIFICATION_PLATFORMS, NOTIFICATION_PROVIDERS, NOTIFICATION_SEND_STATUSES, NotificationPlatform, NotificationProvider, NotificationSendStatus };
28
+ export { NOTIFICATION_CHANNELS, NOTIFICATION_DEFAULT_EMAIL_DELAY_MS, NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS, NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS, NOTIFICATION_EMAIL_JOB_NAME, NOTIFICATION_MOBILE_PUSH_JOB_NAME, NOTIFICATION_PLATFORMS, NOTIFICATION_PROVIDERS, NOTIFICATION_SEND_STATUSES, NOTIFICATION_WEB_PUSH_JOB_NAME, NotificationChannel, NotificationKind, NotificationKindDelays, NotificationPlatform, NotificationProvider, NotificationSendStatus };
11
29
  //# sourceMappingURL=notification.constants.d.mts.map
@@ -14,8 +14,19 @@ const NOTIFICATION_SEND_STATUSES = [
14
14
  "sent",
15
15
  "failed"
16
16
  ];
17
- const NOTIFICATION_DELIVER_JOB_NAME = "notification.deliver";
17
+ const NOTIFICATION_WEB_PUSH_JOB_NAME = "notification.webPush";
18
+ const NOTIFICATION_MOBILE_PUSH_JOB_NAME = "notification.mobilePush";
19
+ const NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS = 120 * 1e3;
20
+ const NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS = 300 * 1e3;
21
+ const NOTIFICATION_EMAIL_JOB_NAME = "notification.email";
22
+ const NOTIFICATION_DEFAULT_EMAIL_DELAY_MS = 900 * 1e3;
23
+ const NOTIFICATION_CHANNELS = [
24
+ "in-app",
25
+ "web-push",
26
+ "mobile-push",
27
+ "email"
28
+ ];
18
29
  //#endregion
19
- export { NOTIFICATION_DELIVER_JOB_NAME, NOTIFICATION_PLATFORMS, NOTIFICATION_PROVIDERS, NOTIFICATION_SEND_STATUSES };
30
+ export { NOTIFICATION_CHANNELS, NOTIFICATION_DEFAULT_EMAIL_DELAY_MS, NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS, NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS, NOTIFICATION_EMAIL_JOB_NAME, NOTIFICATION_MOBILE_PUSH_JOB_NAME, NOTIFICATION_PLATFORMS, NOTIFICATION_PROVIDERS, NOTIFICATION_SEND_STATUSES, NOTIFICATION_WEB_PUSH_JOB_NAME };
20
31
 
21
32
  //# sourceMappingURL=notification.constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.constants.mjs","names":[],"sources":["../../../../src/modules/notification/notification.constants.ts"],"sourcesContent":["export const NOTIFICATION_PLATFORMS = [\"web\", \"ios\", \"android\"] as const;\r\nexport type NotificationPlatform = (typeof NOTIFICATION_PLATFORMS)[number];\r\n\r\nexport const NOTIFICATION_PROVIDERS = [\"web\", \"apn\", \"fcm\"] as const;\r\nexport type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];\r\n\r\nexport const NOTIFICATION_SEND_STATUSES = [\"pending\", \"sent\", \"failed\"] as const;\r\nexport type NotificationSendStatus = (typeof NOTIFICATION_SEND_STATUSES)[number];\r\n\r\nexport const NOTIFICATION_DELIVER_JOB_NAME = \"notification.deliver\" as const;\r\n"],"mappings":";AAAA,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAU;AAG/D,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAM;AAG3D,MAAa,6BAA6B;CAAC;CAAW;CAAQ;CAAS;AAGvE,MAAa,gCAAgC"}
1
+ {"version":3,"file":"notification.constants.mjs","names":[],"sources":["../../../../src/modules/notification/notification.constants.ts"],"sourcesContent":["export const NOTIFICATION_PLATFORMS = [\"web\", \"ios\", \"android\"] as const;\r\nexport type NotificationPlatform = (typeof NOTIFICATION_PLATFORMS)[number];\r\n\r\nexport const NOTIFICATION_PROVIDERS = [\"web\", \"apn\", \"fcm\"] as const;\r\nexport type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];\r\n\r\nexport const NOTIFICATION_SEND_STATUSES = [\"pending\", \"sent\", \"failed\"] as const;\r\nexport type NotificationSendStatus = (typeof NOTIFICATION_SEND_STATUSES)[number];\r\n\r\nexport const NOTIFICATION_WEB_PUSH_JOB_NAME = \"notification.webPush\" as const;\r\nexport const NOTIFICATION_MOBILE_PUSH_JOB_NAME = \"notification.mobilePush\" as const;\r\n\r\nexport const NOTIFICATION_DEFAULT_WEB_PUSH_DELAY_MS = 2 * 60 * 1000;\r\nexport const NOTIFICATION_DEFAULT_MOBILE_PUSH_DELAY_MS = 5 * 60 * 1000;\r\nexport const NOTIFICATION_EMAIL_JOB_NAME = \"notification.email\" as const;\r\nexport const NOTIFICATION_DEFAULT_EMAIL_DELAY_MS = 15 * 60 * 1000;\r\n\r\nexport const NOTIFICATION_CHANNELS = [\"in-app\", \"web-push\", \"mobile-push\", \"email\"] as const;\r\nexport type NotificationChannel = (typeof NOTIFICATION_CHANNELS)[number];\r\n\r\nexport interface NotificationKindDelays {\r\n readonly webPushMs?: number;\r\n readonly mobilePushMs?: number;\r\n readonly emailMs?: number;\r\n}\r\n\r\nexport interface NotificationKind {\r\n readonly id: string;\r\n readonly defaultChannels: readonly NotificationChannel[];\r\n readonly delays?: NotificationKindDelays;\r\n readonly emailTemplate?: string;\r\n}\r\n"],"mappings":";AAAA,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAU;AAG/D,MAAa,yBAAyB;CAAC;CAAO;CAAO;CAAM;AAG3D,MAAa,6BAA6B;CAAC;CAAW;CAAQ;CAAS;AAGvE,MAAa,iCAAiC;AAC9C,MAAa,oCAAoC;AAEjD,MAAa,yCAAyC,MAAS;AAC/D,MAAa,4CAA4C,MAAS;AAClE,MAAa,8BAA8B;AAC3C,MAAa,sCAAsC,MAAU;AAE7D,MAAa,wBAAwB;CAAC;CAAU;CAAY;CAAe;CAAQ"}
@@ -46,12 +46,15 @@ const notificationDeviceSelectSchema = zod.z.object({
46
46
  });
47
47
  const notificationListDevicesOutputSchema = zod.z.array(notificationDeviceSelectSchema);
48
48
  const notificationVapidPublicKeyOutputSchema = zod.z.object({ publicKey: zod.z.string() });
49
+ const notificationChannelSchema = zod.z.enum(require_src_modules_notification_notification_constants.NOTIFICATION_CHANNELS);
49
50
  const notificationSendLogSelectSchema = zod.z.object({
50
51
  id: zod.z.string(),
51
52
  batchId: zod.z.string(),
53
+ notificationId: zod.z.string(),
52
54
  userId: zod.z.string(),
53
- deviceId: zod.z.string(),
54
- provider: notificationProviderSchema,
55
+ deviceId: zod.z.string().nullable(),
56
+ channel: notificationChannelSchema,
57
+ provider: notificationProviderSchema.nullable(),
55
58
  title: zod.z.string(),
56
59
  body: zod.z.string(),
57
60
  data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
@@ -66,21 +69,59 @@ const notificationListSendLogsInputSchema = zod.z.object({
66
69
  limit: zod.z.number().int().min(1).max(100).optional()
67
70
  });
68
71
  const notificationListSendLogsOutputSchema = zod.z.array(notificationSendLogSelectSchema);
72
+ const notificationInstanceSelectSchema = zod.z.object({
73
+ id: zod.z.string(),
74
+ memberId: zod.z.string(),
75
+ userId: zod.z.string(),
76
+ kind: zod.z.string(),
77
+ title: zod.z.string(),
78
+ body: zod.z.string(),
79
+ data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
80
+ visibleInInbox: zod.z.boolean(),
81
+ webPushedAt: zod.z.date().nullable(),
82
+ mobilePushedAt: zod.z.date().nullable(),
83
+ emailedAt: zod.z.date().nullable(),
84
+ readAt: zod.z.date().nullable(),
85
+ createdAt: zod.z.date(),
86
+ updatedAt: zod.z.date()
87
+ });
88
+ const notificationListInboxOutputSchema = zod.z.array(notificationInstanceSelectSchema);
89
+ const notificationMarkReadInputSchema = zod.z.object({ id: zod.z.string() });
69
90
  const notificationSendTestInputSchema = zod.z.object({
70
- userId: zod.z.string().optional(),
91
+ memberId: zod.z.string().min(1),
92
+ kind: zod.z.string().min(1),
71
93
  title: zod.z.string().min(1).max(200),
72
94
  body: zod.z.string().min(1).max(2e3),
73
95
  data: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
74
96
  });
75
- const notificationSendTestOutputSchema = zod.z.object({
76
- batchId: zod.z.string(),
77
- jobId: zod.z.string()
97
+ const notificationSendTestOutputSchema = zod.z.object({ id: zod.z.string() });
98
+ const notificationKindPreferenceChannelSchema = zod.z.object({
99
+ channel: notificationChannelSchema,
100
+ enabled: zod.z.boolean()
101
+ });
102
+ const notificationKindPreferenceSchema = zod.z.object({
103
+ kind: zod.z.string(),
104
+ channels: zod.z.array(notificationKindPreferenceChannelSchema)
105
+ });
106
+ const notificationListPreferencesOutputSchema = zod.z.array(notificationKindPreferenceSchema);
107
+ const notificationSetPreferenceInputSchema = zod.z.object({
108
+ kind: zod.z.string().min(1),
109
+ channel: notificationChannelSchema,
110
+ enabled: zod.z.boolean()
78
111
  });
112
+ const notificationSetPreferenceOutputSchema = notificationKindPreferenceSchema;
79
113
  //#endregion
114
+ exports.notificationChannelSchema = notificationChannelSchema;
80
115
  exports.notificationDeviceSelectSchema = notificationDeviceSelectSchema;
116
+ exports.notificationInstanceSelectSchema = notificationInstanceSelectSchema;
117
+ exports.notificationKindPreferenceChannelSchema = notificationKindPreferenceChannelSchema;
118
+ exports.notificationKindPreferenceSchema = notificationKindPreferenceSchema;
81
119
  exports.notificationListDevicesOutputSchema = notificationListDevicesOutputSchema;
120
+ exports.notificationListInboxOutputSchema = notificationListInboxOutputSchema;
121
+ exports.notificationListPreferencesOutputSchema = notificationListPreferencesOutputSchema;
82
122
  exports.notificationListSendLogsInputSchema = notificationListSendLogsInputSchema;
83
123
  exports.notificationListSendLogsOutputSchema = notificationListSendLogsOutputSchema;
124
+ exports.notificationMarkReadInputSchema = notificationMarkReadInputSchema;
84
125
  exports.notificationPlatformSchema = notificationPlatformSchema;
85
126
  exports.notificationProviderSchema = notificationProviderSchema;
86
127
  exports.notificationRegisterDeviceInputSchema = notificationRegisterDeviceInputSchema;
@@ -89,6 +130,8 @@ exports.notificationSendLogSelectSchema = notificationSendLogSelectSchema;
89
130
  exports.notificationSendStatusSchema = notificationSendStatusSchema;
90
131
  exports.notificationSendTestInputSchema = notificationSendTestInputSchema;
91
132
  exports.notificationSendTestOutputSchema = notificationSendTestOutputSchema;
133
+ exports.notificationSetPreferenceInputSchema = notificationSetPreferenceInputSchema;
134
+ exports.notificationSetPreferenceOutputSchema = notificationSetPreferenceOutputSchema;
92
135
  exports.notificationUnregisterDeviceInputSchema = notificationUnregisterDeviceInputSchema;
93
136
  exports.notificationUnregisterDeviceOutputSchema = notificationUnregisterDeviceOutputSchema;
94
137
  exports.notificationVapidPublicKeyOutputSchema = notificationVapidPublicKeyOutputSchema;
@@ -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});\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,CA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,QAAQ;CAChB,MAAMA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,SAAS,CAAC,CAAC,UAAU;CAClD,QAAQ;CACR,OAAOA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC5B,OAAOA,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"}
1
+ {"version":3,"file":"notification.schema.cjs","names":["z","NOTIFICATION_PLATFORMS","NOTIFICATION_PROVIDERS","NOTIFICATION_SEND_STATUSES","NOTIFICATION_CHANNELS"],"sources":["../../../../src/modules/notification/notification.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport {\r\n NOTIFICATION_CHANNELS,\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 notificationChannelSchema = z.enum(NOTIFICATION_CHANNELS);\r\n\r\nexport const notificationSendLogSelectSchema = z.object({\r\n id: z.string(),\r\n batchId: z.string(),\r\n notificationId: z.string(),\r\n userId: z.string(),\r\n deviceId: z.string().nullable(),\r\n channel: notificationChannelSchema,\r\n provider: notificationProviderSchema.nullable(),\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 notificationInstanceSelectSchema = z.object({\r\n id: z.string(),\r\n memberId: z.string(),\r\n userId: z.string(),\r\n kind: z.string(),\r\n title: z.string(),\r\n body: z.string(),\r\n data: z.record(z.string(), z.unknown()).nullable(),\r\n visibleInInbox: z.boolean(),\r\n webPushedAt: z.date().nullable(),\r\n mobilePushedAt: z.date().nullable(),\r\n emailedAt: z.date().nullable(),\r\n readAt: z.date().nullable(),\r\n createdAt: z.date(),\r\n updatedAt: z.date(),\r\n});\r\n\r\nexport const notificationListInboxOutputSchema = z.array(notificationInstanceSelectSchema);\r\n\r\nexport const notificationMarkReadInputSchema = z.object({\r\n id: z.string(),\r\n});\r\n\r\nexport const notificationSendTestInputSchema = z.object({\r\n memberId: z.string().min(1),\r\n kind: z.string().min(1),\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 id: z.string(),\r\n});\r\n\r\nexport const notificationKindPreferenceChannelSchema = z.object({\r\n channel: notificationChannelSchema,\r\n enabled: z.boolean(),\r\n});\r\n\r\nexport const notificationKindPreferenceSchema = z.object({\r\n kind: z.string(),\r\n channels: z.array(notificationKindPreferenceChannelSchema),\r\n});\r\n\r\nexport const notificationListPreferencesOutputSchema = z.array(notificationKindPreferenceSchema);\r\n\r\nexport const notificationSetPreferenceInputSchema = z.object({\r\n kind: z.string().min(1),\r\n channel: notificationChannelSchema,\r\n enabled: z.boolean(),\r\n});\r\n\r\nexport const notificationSetPreferenceOutputSchema = notificationKindPreferenceSchema;\r\n"],"mappings":";;;;AAQA,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;EAC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