@things-factory/organization 10.1.267 → 10.1.269

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.
@@ -0,0 +1,6 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import { Domain } from '@things-factory/shell';
3
+ import { isActiveEmployee } from '../employee-profile/employee-profile-rules.js';
4
+ export { isActiveEmployee };
5
+ /** The accounts of the domain's employees working today, in the domain's calendar. */
6
+ export declare function workingEmployeeUserIds(domain: Partial<Domain>, tx?: EntityManager, now?: Date): Promise<string[]>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isActiveEmployee = void 0;
4
+ exports.workingEmployeeUserIds = workingEmployeeUserIds;
5
+ /*
6
+ * Who works here today - the accounts tied to an employee record still working in the domain (not marked inactive, no
7
+ * retire day that has come). A partner, an operator's account or a system account has no such record and is not one.
8
+ *
9
+ * The rule is `isActiveEmployee` (employee-profile-rules.ts); this reads the records it is asked of. Those who address
10
+ * "the employees" - a vote on a proposal (ADR-0197) - narrow their people to these.
11
+ */
12
+ const typeorm_1 = require("typeorm");
13
+ const shell_1 = require("@things-factory/shell");
14
+ const employee_profile_rules_js_1 = require("../employee-profile/employee-profile-rules.js");
15
+ Object.defineProperty(exports, "isActiveEmployee", { enumerable: true, get: function () { return employee_profile_rules_js_1.isActiveEmployee; } });
16
+ const employee_js_1 = require("./employee.js");
17
+ /** The accounts of the domain's employees working today, in the domain's calendar. */
18
+ async function workingEmployeeUserIds(domain, tx, now = new Date()) {
19
+ if (!domain?.id)
20
+ return [];
21
+ const today = (0, shell_1.calendarDay)(domain.timezone, now);
22
+ const records = await (0, shell_1.getRepository)(employee_js_1.Employee, tx).find({ where: { domain: { id: domain.id }, user: { id: (0, typeorm_1.Not)((0, typeorm_1.IsNull)()) } }, relations: ['user'] });
23
+ return [...new Set(records.filter(one => one.user?.id && (0, employee_profile_rules_js_1.isActiveEmployee)(one, today)).map(one => one.user.id))];
24
+ }
25
+ //# sourceMappingURL=working-employees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working-employees.js","sourceRoot":"","sources":["../../../server/service/employee/working-employees.ts"],"names":[],"mappings":";;;AAiBA,wDAKC;AAtBD;;;;;;GAMG;AACH,qCAAoD;AAEpD,iDAA0E;AAE1E,6FAAgF;AAGvE,iGAHA,4CAAgB,OAGA;AAFzB,+CAAwC;AAIxC,sFAAsF;AAC/E,KAAK,UAAU,sBAAsB,CAAC,MAAuB,EAAE,EAAkB,EAAE,MAAY,IAAI,IAAI,EAAE;IAC9G,IAAI,CAAC,MAAM,EAAE,EAAE;QAAE,OAAO,EAAE,CAAA;IAC1B,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAE,MAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACxD,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAa,EAAC,sBAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAA,aAAG,EAAC,IAAA,gBAAM,GAAE,CAAC,EAAE,EAAS,EAAE,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACzJ,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,IAAA,4CAAgB,EAAC,GAAU,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC1H,CAAC","sourcesContent":["/*\n * Who works here today - the accounts tied to an employee record still working in the domain (not marked inactive, no\n * retire day that has come). A partner, an operator's account or a system account has no such record and is not one.\n *\n * The rule is `isActiveEmployee` (employee-profile-rules.ts); this reads the records it is asked of. Those who address\n * \"the employees\" - a vote on a proposal (ADR-0197) - narrow their people to these.\n */\nimport { EntityManager, IsNull, Not } from 'typeorm'\n\nimport { calendarDay, Domain, getRepository } from '@things-factory/shell'\n\nimport { isActiveEmployee } from '../employee-profile/employee-profile-rules.js'\nimport { Employee } from './employee.js'\n\nexport { isActiveEmployee }\n\n/** The accounts of the domain's employees working today, in the domain's calendar. */\nexport async function workingEmployeeUserIds(domain: Partial<Domain>, tx?: EntityManager, now: Date = new Date()): Promise<string[]> {\n if (!domain?.id) return []\n const today = calendarDay((domain as any).timezone, now)\n const records = await getRepository(Employee, tx).find({ where: { domain: { id: domain.id }, user: { id: Not(IsNull()) } } as any, relations: ['user'] })\n return [...new Set(records.filter(one => one.user?.id && isActiveEmployee(one as any, today)).map(one => one.user!.id))]\n}\n"]}
@@ -2,4 +2,4 @@ import { EmployeeProfile } from './employee-profile';
2
2
  import { EmployeeProfileMutation } from './employee-profile-mutation';
3
3
  import { EmployeeProfileQuery } from './employee-profile-query';
4
4
  export declare const entities: (typeof EmployeeProfile)[];
5
- export declare const resolvers: (typeof EmployeeProfileMutation | typeof EmployeeProfileQuery)[];
5
+ export declare const resolvers: (typeof EmployeeProfileQuery | typeof EmployeeProfileMutation)[];
@@ -1,11 +1,12 @@
1
1
  export * from './approval-line/approval-line';
2
2
  export * from './department/department';
3
3
  export * from './employee/employee';
4
+ export * from './employee/working-employees';
4
5
  export * from './employee-profile/employee-profile';
5
6
  export * from './audience/audience';
6
7
  export * from './audience/audience-member';
7
- export declare const entities: (typeof import("./department/department").Department | typeof import("./employee/employee").Employee | typeof import("./approval-line/approval-line").ApprovalLine | typeof import("./employee-profile/employee-profile").EmployeeProfile | typeof import("./department/department-history").DepartmentHistory | typeof import("./employee/employee-history").EmployeeHistory)[];
8
+ export declare const entities: (typeof import("./approval-line/approval-line").ApprovalLine | typeof import("./department/department").Department | typeof import("./department/department-history").DepartmentHistory | typeof import("./employee/employee").Employee | typeof import("./employee/employee-history").EmployeeHistory | typeof import("./employee-profile/employee-profile").EmployeeProfile)[];
8
9
  export declare const subscribers: (typeof import("./department/event-subscriber").DepartmentHistoryEntitySubscriber | typeof import("./employee/event-subscriber").EmployeeHistoryEntitySubscriber)[];
9
10
  export declare const schema: {
10
- resolverClasses: (typeof import("./approval-line/approval-line-query").ApprovalLineQuery | typeof import("./approval-line/approval-line-mutation").ApprovalLineMutation | typeof import("./department/department-query").DepartmentQuery | typeof import("./department/department-mutation").DepartmentMutation | typeof import("./employee/employee-query").EmployeeQuery | typeof import("./employee/employee-mutation").EmployeeMutation | typeof import("./employee-profile/employee-profile-mutation").EmployeeProfileMutation | typeof import("./employee-profile/employee-profile-query").EmployeeProfileQuery)[];
11
+ resolverClasses: (typeof import("./approval-line/approval-line-query").ApprovalLineQuery | typeof import("./approval-line/approval-line-mutation").ApprovalLineMutation | typeof import("./department/department-query").DepartmentQuery | typeof import("./department/department-mutation").DepartmentMutation | typeof import("./employee/employee-query").EmployeeQuery | typeof import("./employee/employee-mutation").EmployeeMutation | typeof import("./employee-profile/employee-profile-query").EmployeeProfileQuery | typeof import("./employee-profile/employee-profile-mutation").EmployeeProfileMutation)[];
11
12
  };
@@ -6,6 +6,8 @@ const tslib_1 = require("tslib");
6
6
  tslib_1.__exportStar(require("./approval-line/approval-line"), exports);
7
7
  tslib_1.__exportStar(require("./department/department"), exports);
8
8
  tslib_1.__exportStar(require("./employee/employee"), exports);
9
+ /* Who works here today - those who address the employees narrow their people to these (ADR-0197). */
10
+ tslib_1.__exportStar(require("./employee/working-employees"), exports);
9
11
  tslib_1.__exportStar(require("./employee-profile/employee-profile"), exports);
10
12
  tslib_1.__exportStar(require("./audience/audience"), exports);
11
13
  tslib_1.__exportStar(require("./audience/audience-member"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,wEAA6C;AAC7C,kEAAuC;AACvC,8DAAmC;AACnC,8EAAmD;AACnD,8DAAmC;AACnC,qEAA0C;AAE1C,mCAAmC;AACnC,mDAAsG;AACtG,6CAIqB;AACrB,yCAImB;AACnB,yDAA+G;AAElG,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,wBAAoB;IACvB,GAAG,qBAAkB;IACrB,GAAG,mBAAgB;IACnB,GAAG,2BAAuB;CAC3B,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,iBAAiB;IACjB,GAAG,wBAAqB;IACxB,GAAG,sBAAmB;CACvB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,yBAAqB;QACxB,GAAG,sBAAmB;QACtB,GAAG,oBAAiB;QACpB,GAAG,4BAAwB;KAC5B;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './approval-line/approval-line'\nexport * from './department/department'\nexport * from './employee/employee'\nexport * from './employee-profile/employee-profile'\nexport * from './audience/audience'\nexport * from './audience/audience-member'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as ApprovalLineEntities, resolvers as ApprovalLineResolvers } from './approval-line'\nimport {\n entities as DepartmentEntities,\n resolvers as DepartmentResolvers,\n subscribers as DepartmentSubscribers\n} from './department'\nimport {\n entities as EmployeeEntities,\n resolvers as EmployeeResolvers,\n subscribers as EmployeeSubscribers\n} from './employee'\nimport { entities as EmployeeProfileEntities, resolvers as EmployeeProfileResolvers } from './employee-profile'\n\nexport const entities = [\n /* ENTITIES */\n ...ApprovalLineEntities,\n ...DepartmentEntities,\n ...EmployeeEntities,\n ...EmployeeProfileEntities\n]\n\nexport const subscribers = [\n /* SUBSCRIBERS */\n ...DepartmentSubscribers,\n ...EmployeeSubscribers\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...ApprovalLineResolvers,\n ...DepartmentResolvers,\n ...EmployeeResolvers,\n ...EmployeeProfileResolvers\n ]\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,wEAA6C;AAC7C,kEAAuC;AACvC,8DAAmC;AACnC,qGAAqG;AACrG,uEAA4C;AAC5C,8EAAmD;AACnD,8DAAmC;AACnC,qEAA0C;AAE1C,mCAAmC;AACnC,mDAAsG;AACtG,6CAIqB;AACrB,yCAImB;AACnB,yDAA+G;AAElG,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,wBAAoB;IACvB,GAAG,qBAAkB;IACrB,GAAG,mBAAgB;IACnB,GAAG,2BAAuB;CAC3B,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,iBAAiB;IACjB,GAAG,wBAAqB;IACxB,GAAG,sBAAmB;CACvB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,yBAAqB;QACxB,GAAG,sBAAmB;QACtB,GAAG,oBAAiB;QACpB,GAAG,4BAAwB;KAC5B;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './approval-line/approval-line'\nexport * from './department/department'\nexport * from './employee/employee'\n/* Who works here today - those who address the employees narrow their people to these (ADR-0197). */\nexport * from './employee/working-employees'\nexport * from './employee-profile/employee-profile'\nexport * from './audience/audience'\nexport * from './audience/audience-member'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as ApprovalLineEntities, resolvers as ApprovalLineResolvers } from './approval-line'\nimport {\n entities as DepartmentEntities,\n resolvers as DepartmentResolvers,\n subscribers as DepartmentSubscribers\n} from './department'\nimport {\n entities as EmployeeEntities,\n resolvers as EmployeeResolvers,\n subscribers as EmployeeSubscribers\n} from './employee'\nimport { entities as EmployeeProfileEntities, resolvers as EmployeeProfileResolvers } from './employee-profile'\n\nexport const entities = [\n /* ENTITIES */\n ...ApprovalLineEntities,\n ...DepartmentEntities,\n ...EmployeeEntities,\n ...EmployeeProfileEntities\n]\n\nexport const subscribers = [\n /* SUBSCRIBERS */\n ...DepartmentSubscribers,\n ...EmployeeSubscribers\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...ApprovalLineResolvers,\n ...DepartmentResolvers,\n ...EmployeeResolvers,\n ...EmployeeProfileResolvers\n ]\n}\n"]}