@rytass/bpm-core-nestjs-module 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +160 -3
  3. package/package.json +3 -3
  4. package/src/lib/attachment/attachment-options.d.ts +11 -0
  5. package/src/lib/attachment/attachment-options.js +21 -6
  6. package/src/lib/attachment/attachment-options.js.map +1 -1
  7. package/src/lib/attachment/index.d.ts +1 -0
  8. package/src/lib/attachment/index.js +1 -0
  9. package/src/lib/attachment/index.js.map +1 -1
  10. package/src/lib/bpm/bpm-root.module.d.ts +35 -0
  11. package/src/lib/bpm/bpm-root.module.js +8 -0
  12. package/src/lib/bpm/bpm-root.module.js.map +1 -1
  13. package/src/lib/bpm-auth/bpm-auth.authorization.js +3 -2
  14. package/src/lib/bpm-auth/bpm-auth.authorization.js.map +1 -1
  15. package/src/lib/bpm-auth/bpm-auth.decorators.js +2 -1
  16. package/src/lib/bpm-auth/bpm-auth.decorators.js.map +1 -1
  17. package/src/lib/bpm-auth/bpm-resolver-access.decorator.d.ts +13 -0
  18. package/src/lib/bpm-auth/bpm-resolver-access.decorator.js +27 -0
  19. package/src/lib/bpm-auth/bpm-resolver-access.decorator.js.map +1 -0
  20. package/src/lib/bpm-auth/bpm-resolver-metadata.d.ts +73 -0
  21. package/src/lib/bpm-auth/bpm-resolver-metadata.js +158 -0
  22. package/src/lib/bpm-auth/bpm-resolver-metadata.js.map +1 -0
  23. package/src/lib/bpm-auth/index.d.ts +2 -0
  24. package/src/lib/bpm-auth/index.js +2 -0
  25. package/src/lib/bpm-auth/index.js.map +1 -1
  26. package/src/lib/condition/condition.service.js +45 -4
  27. package/src/lib/condition/condition.service.js.map +1 -1
  28. package/src/lib/identity/identity-options.d.ts +16 -0
  29. package/src/lib/identity/identity-options.js.map +1 -1
  30. package/src/lib/identity/identity.module.d.ts +6 -0
  31. package/src/lib/identity/identity.module.js +9 -2
  32. package/src/lib/identity/identity.module.js.map +1 -1
  33. package/src/lib/migrations/0000000000001-enable-postgres-extensions.d.ts +9 -1
  34. package/src/lib/migrations/0000000000001-enable-postgres-extensions.js +55 -4
  35. package/src/lib/migrations/0000000000001-enable-postgres-extensions.js.map +1 -1
  36. package/src/lib/notification/index.d.ts +1 -0
  37. package/src/lib/notification/index.js +1 -0
  38. package/src/lib/notification/index.js.map +1 -1
  39. package/src/lib/organization/dto/manager-resolution.input.d.ts +7 -7
  40. package/src/lib/organization/dto/membership.input.d.ts +7 -7
  41. package/src/lib/organization/dto/org-unit.input.d.ts +28 -6
  42. package/src/lib/organization/dto/org-unit.input.js +4 -2
  43. package/src/lib/organization/dto/org-unit.input.js.map +1 -1
  44. package/src/lib/organization/dto/position.input.d.ts +4 -4
  45. package/src/lib/organization/index.d.ts +4 -0
  46. package/src/lib/organization/index.js +4 -0
  47. package/src/lib/organization/index.js.map +1 -1
  48. package/src/lib/organization/organization.mutations.d.ts +1 -0
  49. package/src/lib/organization/organization.mutations.js +10 -0
  50. package/src/lib/organization/organization.mutations.js.map +1 -1
  51. package/src/lib/organization/organization.service.d.ts +43 -0
  52. package/src/lib/organization/organization.service.js +166 -7
  53. package/src/lib/organization/organization.service.js.map +1 -1
  54. package/src/lib/template/dto/approval-template.input.d.ts +31 -20
  55. package/src/lib/template/dto/approval-template.input.js.map +1 -1
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Extension point that lets a host stamp its own route metadata onto every BPM
3
+ * GraphQL handler.
4
+ *
5
+ * BPM guards its own resolvers with `@BPMAuthenticated()`, `@BPMAdminOnly()`
6
+ * and `@BPMDesignerOnly()`. A host that also installs a *global* guard of its
7
+ * own — `@rytass/member-base-nestjs-module` registers a `CasbinGuard` that
8
+ * rejects any route carrying no `@CheckPermission` metadata — rejects all of
9
+ * them before BPM's guards ever run, and the two packages cannot be mounted
10
+ * together at all.
11
+ *
12
+ * BPM cannot import the host's decorator, and a decorator cannot read module
13
+ * options because it runs when the class is defined. So the resolver classes
14
+ * register themselves here as they are decorated, and the host supplies a
15
+ * factory that BPM replays over them at module wiring time — before Nest reads
16
+ * any of this metadata, which it only does per request.
17
+ */
18
+ /**
19
+ * How much authority BPM itself demands of a caller for one handler. A host
20
+ * maps this onto its own permission vocabulary.
21
+ */
22
+ export type BPMResolverAccessLevel = 'admin' | 'authenticated' | 'designer';
23
+ export interface BPMResolverHandlerDescriptor {
24
+ /** Authority BPM's own guards require for this handler. */
25
+ readonly access: BPMResolverAccessLevel;
26
+ /**
27
+ * Method name on the resolver class. Across BPM this is also the GraphQL
28
+ * field name — `orgUnits`, `createOrgUnit`, `member`.
29
+ */
30
+ readonly methodName: string;
31
+ /** Resolver class name, for example `OrganizationQueries`. */
32
+ readonly resolverName: string;
33
+ }
34
+ /**
35
+ * Returns the metadata to attach to one BPM handler, keyed exactly as the
36
+ * host's guard reads it. Return `null` or `undefined` to leave a handler
37
+ * alone.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const resolverMetadataFactory: BPMResolverMetadataFactory = ({ access }) => ({
42
+ * // the key `@CheckPermission` writes, and the value its guard expects
43
+ * PERMISSION_METADATA_KEY: access === 'authenticated' ? ['bpm:use'] : ['bpm:admin'],
44
+ * });
45
+ * ```
46
+ */
47
+ export type BPMResolverMetadataFactory = (handler: BPMResolverHandlerDescriptor) => Readonly<Record<string | symbol, unknown>> | null | undefined;
48
+ /**
49
+ * Records that a whole resolver class sits behind `access`. Called by BPM's
50
+ * own authorization decorators; hosts do not call this.
51
+ */
52
+ export declare function registerBPMResolverClassAccess(resolverClass: object, access: BPMResolverAccessLevel): void;
53
+ /**
54
+ * Records that a single handler sits behind `access`, overriding whatever the
55
+ * class-level decorator asked for. Called by BPM's own authorization
56
+ * decorators; hosts do not call this.
57
+ */
58
+ export declare function registerBPMResolverMethodAccess(resolverClass: object, methodName: string, access: BPMResolverAccessLevel): void;
59
+ /**
60
+ * Replays `factory` over every registered BPM handler and writes the metadata
61
+ * it returns onto the prototype method, which is what Nest hands a guard as
62
+ * `context.getHandler()`.
63
+ *
64
+ * `BPMRootModule` calls this for `resolverMetadataFactory`. Calling it twice
65
+ * with the same factory simply writes the same values again.
66
+ */
67
+ export declare function applyBPMResolverMetadata(factory: BPMResolverMetadataFactory): void;
68
+ /**
69
+ * Every BPM handler the metadata factory would be offered, in registration
70
+ * order. Exposed so a host can print the list while mapping BPM operations
71
+ * onto its own permissions.
72
+ */
73
+ export declare function listBPMResolverHandlers(): readonly BPMResolverHandlerDescriptor[];
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ /**
3
+ * Extension point that lets a host stamp its own route metadata onto every BPM
4
+ * GraphQL handler.
5
+ *
6
+ * BPM guards its own resolvers with `@BPMAuthenticated()`, `@BPMAdminOnly()`
7
+ * and `@BPMDesignerOnly()`. A host that also installs a *global* guard of its
8
+ * own — `@rytass/member-base-nestjs-module` registers a `CasbinGuard` that
9
+ * rejects any route carrying no `@CheckPermission` metadata — rejects all of
10
+ * them before BPM's guards ever run, and the two packages cannot be mounted
11
+ * together at all.
12
+ *
13
+ * BPM cannot import the host's decorator, and a decorator cannot read module
14
+ * options because it runs when the class is defined. So the resolver classes
15
+ * register themselves here as they are decorated, and the host supplies a
16
+ * factory that BPM replays over them at module wiring time — before Nest reads
17
+ * any of this metadata, which it only does per request.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.registerBPMResolverClassAccess = registerBPMResolverClassAccess;
21
+ exports.registerBPMResolverMethodAccess = registerBPMResolverMethodAccess;
22
+ exports.applyBPMResolverMetadata = applyBPMResolverMetadata;
23
+ exports.listBPMResolverHandlers = listBPMResolverHandlers;
24
+ const graphql_1 = require("@nestjs/graphql");
25
+ const ACCESS_BY_RESOLVER = new Map();
26
+ /**
27
+ * Records that a whole resolver class sits behind `access`. Called by BPM's
28
+ * own authorization decorators; hosts do not call this.
29
+ */
30
+ function registerBPMResolverClassAccess(resolverClass, access) {
31
+ readRegistration(resolverClass).classAccess = access;
32
+ }
33
+ /**
34
+ * Records that a single handler sits behind `access`, overriding whatever the
35
+ * class-level decorator asked for. Called by BPM's own authorization
36
+ * decorators; hosts do not call this.
37
+ */
38
+ function registerBPMResolverMethodAccess(resolverClass, methodName, access) {
39
+ readRegistration(resolverClass).accessByMethod.set(methodName, access);
40
+ }
41
+ /**
42
+ * Replays `factory` over every registered BPM handler and writes the metadata
43
+ * it returns onto the prototype method, which is what Nest hands a guard as
44
+ * `context.getHandler()`.
45
+ *
46
+ * `BPMRootModule` calls this for `resolverMetadataFactory`. Calling it twice
47
+ * with the same factory simply writes the same values again.
48
+ */
49
+ function applyBPMResolverMetadata(factory) {
50
+ for (const [resolverClass, registration] of ACCESS_BY_RESOLVER) {
51
+ const prototype = readPrototype(resolverClass);
52
+ if (!prototype) {
53
+ continue;
54
+ }
55
+ for (const methodName of listHandlerMethodNames(prototype)) {
56
+ const access = registration.accessByMethod.get(methodName) ??
57
+ registration.classAccess;
58
+ if (access === null || access === undefined) {
59
+ continue;
60
+ }
61
+ const metadata = factory({
62
+ access,
63
+ methodName,
64
+ resolverName: readResolverName(resolverClass),
65
+ });
66
+ if (!metadata) {
67
+ continue;
68
+ }
69
+ const handler = prototype[methodName];
70
+ // `Reflect.ownKeys`, not `Object.entries`: several Nest ecosystem guards
71
+ // key their metadata by symbol, and dropping those silently would look
72
+ // to a host exactly like the factory never ran.
73
+ for (const key of Reflect.ownKeys(metadata)) {
74
+ Reflect.defineMetadata(key, metadata[key], handler);
75
+ }
76
+ }
77
+ }
78
+ }
79
+ /**
80
+ * Every BPM handler the metadata factory would be offered, in registration
81
+ * order. Exposed so a host can print the list while mapping BPM operations
82
+ * onto its own permissions.
83
+ */
84
+ function listBPMResolverHandlers() {
85
+ const handlers = [];
86
+ for (const [resolverClass, registration] of ACCESS_BY_RESOLVER) {
87
+ const prototype = readPrototype(resolverClass);
88
+ if (!prototype) {
89
+ continue;
90
+ }
91
+ for (const methodName of listHandlerMethodNames(prototype)) {
92
+ const access = registration.accessByMethod.get(methodName) ??
93
+ registration.classAccess;
94
+ if (access === null || access === undefined) {
95
+ continue;
96
+ }
97
+ handlers.push({
98
+ access,
99
+ methodName,
100
+ resolverName: readResolverName(resolverClass),
101
+ });
102
+ }
103
+ }
104
+ return handlers;
105
+ }
106
+ function readRegistration(resolverClass) {
107
+ const existing = ACCESS_BY_RESOLVER.get(resolverClass);
108
+ if (existing) {
109
+ return existing;
110
+ }
111
+ const registration = {
112
+ accessByMethod: new Map(),
113
+ classAccess: null,
114
+ };
115
+ ACCESS_BY_RESOLVER.set(resolverClass, registration);
116
+ return registration;
117
+ }
118
+ function readPrototype(resolverClass) {
119
+ const prototype = resolverClass
120
+ .prototype;
121
+ return typeof prototype === 'object' && prototype !== null
122
+ ? prototype
123
+ : null;
124
+ }
125
+ function readResolverName(resolverClass) {
126
+ const name = resolverClass.name;
127
+ return typeof name === 'string' ? name : '';
128
+ }
129
+ /**
130
+ * The GraphQL handlers on a resolver prototype and everything it inherits.
131
+ *
132
+ * Two things this must not do. It must not list a plain helper method: a host
133
+ * builds its permission map from `listBPMResolverHandlers()`, and a private
134
+ * helper would show up there as a GraphQL field that does not exist. And it
135
+ * must not stop at the class's own prototype: a handler inherited from a base
136
+ * resolver would then get no metadata at all, which a host sees only as an
137
+ * unexplained 403.
138
+ *
139
+ * `@Query` / `@Mutation` / `@ResolveField` each stamp
140
+ * `RESOLVER_TYPE_METADATA` on the method, so that is the test.
141
+ */
142
+ function listHandlerMethodNames(prototype) {
143
+ const methodNames = new Set();
144
+ for (let current = prototype; current !== null && current !== Object.prototype; current = Object.getPrototypeOf(current)) {
145
+ for (const methodName of Object.getOwnPropertyNames(current)) {
146
+ if (methodName === 'constructor') {
147
+ continue;
148
+ }
149
+ const member = current[methodName];
150
+ if (typeof member === 'function' &&
151
+ Reflect.getMetadata(graphql_1.RESOLVER_TYPE_METADATA, member) !== undefined) {
152
+ methodNames.add(methodName);
153
+ }
154
+ }
155
+ }
156
+ return [...methodNames];
157
+ }
158
+ //# sourceMappingURL=bpm-resolver-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bpm-resolver-metadata.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/bpm-auth/bpm-resolver-metadata.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AAoDH,wEAKC;AAOD,0EAMC;AAUD,4DA2CC;AAOD,0DA4BC;AA5JD,6CAAyD;AAEzD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAyC,CAAC;AA4C5E;;;GAGG;AACH,SAAgB,8BAA8B,CAC5C,aAAqB,EACrB,MAA8B;IAE9B,gBAAgB,CAAC,aAAa,CAAC,CAAC,WAAW,GAAG,MAAM,CAAC;AACvD,CAAC;AAED;;;;GAIG;AACH,SAAgB,+BAA+B,CAC7C,aAAqB,EACrB,UAAkB,EAClB,MAA8B;IAE9B,gBAAgB,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CACtC,OAAmC;IAEnC,KAAK,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,IAAI,kBAAkB,EAAE,CAAC;QAC/D,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;QAE/C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3D,MAAM,MAAM,GACV,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;gBAC3C,YAAY,CAAC,WAAW,CAAC;YAE3B,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC5C,SAAS;YACX,CAAC;YAED,MAAM,QAAQ,GAAG,OAAO,CAAC;gBACvB,MAAM;gBACN,UAAU;gBACV,YAAY,EAAE,g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S,EACjE,CAAC;gBACD,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;AAC1B,CAAC"}
@@ -4,3 +4,5 @@ export * from './bpm-auth.decorators';
4
4
  export * from './bpm-auth.guard';
5
5
  export * from './bpm-auth.module';
6
6
  export * from './bpm-auth.options';
7
+ export * from './bpm-resolver-access.decorator';
8
+ export * from './bpm-resolver-metadata';
@@ -7,4 +7,6 @@ tslib_1.__exportStar(require("./bpm-auth.decorators"), exports);
7
7
  tslib_1.__exportStar(require("./bpm-auth.guard"), exports);
8
8
  tslib_1.__exportStar(require("./bpm-auth.module"), exports);
9
9
  tslib_1.__exportStar(require("./bpm-auth.options"), exports);
10
+ tslib_1.__exportStar(require("./bpm-resolver-access.decorator"), exports);
11
+ tslib_1.__exportStar(require("./bpm-resolver-metadata"), exports);
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/bpm-auth/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,mEAAyC;AACzC,gEAAsC;AACtC,2DAAiC;AACjC,4DAAkC;AAClC,6DAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/bpm-auth/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,mEAAyC;AACzC,gEAAsC;AACtC,2DAAiC;AACjC,4DAAkC;AAClC,6DAAmC;AACnC,0EAAgD;AAChD,kEAAwC"}
@@ -3,7 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConditionService = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@nestjs/common");
6
- const cel_js_1 = require("cel-js");
6
+ let celEngine = null;
7
+ /**
8
+ * Loads `cel-js` on first use rather than when this module is imported.
9
+ *
10
+ * `cel-js` is ESM-only and its `chevrotain` dependency ships an exports map
11
+ * that `jest-resolve` cannot follow. While the import sat at the top of this
12
+ * file, the package root pulled it in through
13
+ * `index → bpm-root → delegation → condition`, so *any* consumer test that
14
+ * imported anything from `@rytass/bpm-core-nestjs-module` failed to load with
15
+ * `Cannot find module 'chevrotain'` — pointing deep into `node_modules`, far
16
+ * from the code under test. Hosts had to stub `cel-js` before they could write
17
+ * a single test.
18
+ *
19
+ * Deferring the load means a host that never evaluates a CEL expression never
20
+ * resolves the package at all. `require` (not `await import`) keeps every
21
+ * caller in this file synchronous.
22
+ */
23
+ function loadCelEngine() {
24
+ if (celEngine === null) {
25
+ try {
26
+ celEngine = require('cel-js');
27
+ }
28
+ catch (error) {
29
+ // Deferring the load also defers this failure: it used to surface at
30
+ // boot as a bare ERR_REQUIRE_ESM, and would now surface as a 500 on
31
+ // whichever request first evaluated a condition. Name the cause where it
32
+ // is thrown.
33
+ if (isRequireEsmError(error)) {
34
+ throw new Error(`[@rytass/bpm-core-nestjs-module] This Node version cannot require the ESM-only 'cel-js'. BPM needs Node >=20.19 or >=22.12 to evaluate CEL conditions. Original error: ${error instanceof Error ? error.message : String(error)}`);
35
+ }
36
+ throw error;
37
+ }
38
+ }
39
+ return celEngine;
40
+ }
41
+ function isRequireEsmError(error) {
42
+ return (typeof error === 'object' &&
43
+ error !== null &&
44
+ 'code' in error &&
45
+ error.code === 'ERR_REQUIRE_ESM');
46
+ }
7
47
  const DEFAULT_MAX_EXPRESSION_LENGTH = 2000;
8
48
  // `has` and `size` are CEL macros, not context identifiers; the root-identifier
9
49
  // lint must not report them as unknown. `size` is required by the table field
@@ -25,7 +65,7 @@ let ConditionService = class ConditionService {
25
65
  if (trimmedExpression.length > maxExpressionLength) {
26
66
  return [`${label} must be ${maxExpressionLength} characters or fewer`];
27
67
  }
28
- const parseResult = (0, cel_js_1.parse)(trimmedExpression);
68
+ const parseResult = loadCelEngine().parse(trimmedExpression);
29
69
  if (isParseFailure(parseResult)) {
30
70
  return parseResult.errors.map((error) => `${label}: ${error}`);
31
71
  }
@@ -47,12 +87,13 @@ let ConditionService = class ConditionService {
47
87
  if (lengthErrors.length) {
48
88
  throw new common_1.BadRequestException(lengthErrors.join('; '));
49
89
  }
50
- const parseResult = (0, cel_js_1.parse)(trimmedExpression);
90
+ const engine = loadCelEngine();
91
+ const parseResult = engine.parse(trimmedExpression);
51
92
  if (isParseFailure(parseResult)) {
52
93
  throw new common_1.BadRequestException(parseResult.errors.map((error) => `${label}: ${error}`).join('; '));
53
94
  }
54
95
  try {
55
- return (0, cel_js_1.evaluate)(parseResult.cst, { ...context });
96
+ return engine.evaluate(parseResult.cst, { ...context });
56
97
  }
57
98
  catch (error) {
58
99
  throw new common_1.BadRequestException(error instanceof Error ? `${label}: ${error.message}` : label);
@@ -1 +1 @@
1
- {"version":3,"file":"condition.service.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/condition/condition.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAiE;AACjE,mCAAyE;AAczE,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAC3C,gFAAgF;AAChF,8EAA8E;AAC9E,kDAAkD;AAClD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAGtE,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,eAAe,CACb,WAA2C,EAC3C,UAAgC,EAAE;QAElC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,CACnD,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAChD,CAAC;IACJ,CAAC;IAED,cAAc,CACZ,UAAqC,EACrC,KAAa,EACb,UAAgC,EAAE;QAElC,IAAI,OAAO,UAAU,KAAK,WAAW,IAAI,UAAU,KAAK,IAAI,EAA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ACZ,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,sBAAsB,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC;IACtE,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAC5B,mBAAmB,CAAC,QAAQ,CAC1B,8CAA8C,CAC/C,CACF,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,kBAAkB,GAAG;QACzB,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;KACzE,CAAC;IAEF,OAAO,kBAAkB,CAAC,GAAG,CAC3B,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,KAAK,sCAAsC,UAAU,EAAE,CAC3E,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAkB;IAC7C,OAAO,UAAU,CAAC,OAAO,CAAC,mCAAmC,EAAE,IAAI,CAAC,CAAC;AACvE,CAAC"}
1
+ {"version":3,"file":"condition.service.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/condition/condition.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAiE;AAcjE,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,SAAS,aAAa;IACpB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC;YACH,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAc,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,qEAAqE;YACrE,oEAAoE;YACpE,yEAAyE;YACzE,aAAa;YACb,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7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,UAAU,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAC5B,mBAAmB,CAAC,QAAQ,CAC1B,8CAA8C,CAC/C,CACF,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,kBAAkB,GAAG;QACzB,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;KACzE,CAAC;IAEF,OAAO,kBAAkB,CAAC,GAAG,CAC3B,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,KAAK,sCAAsC,UAAU,EAAE,CAC3E,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAkB;IAC7C,OAAO,UAAU,CAAC,OAAO,CAAC,mCAAmC,EAAE,IAAI,CAAC,CAAC;AACvE,CAAC"}
@@ -4,6 +4,22 @@ export interface BPMRootIdentityOptions {
4
4
  * Member metadata cache lifetime in milliseconds.
5
5
  */
6
6
  readonly identityMemberMetadataCacheTtlMs?: number;
7
+ /**
8
+ * Whether BPM registers `IdentityQueries` — the `member`, `members`,
9
+ * `memberCount`, `searchMembers`, and `cachedMembers` GraphQL queries.
10
+ * Defaults to `true`.
11
+ *
12
+ * Those are common names. A host that already publishes its own member API
13
+ * gets `MultipleFieldsWithSameNameError` from `@nestjs/graphql` the moment
14
+ * `BPMRootModule` is mounted, and the application never starts. Set this to
15
+ * `false` to keep `IdentityService` (and everything in BPM that depends on
16
+ * it) while leaving the GraphQL surface entirely to the host.
17
+ *
18
+ * Read at module wiring time, not from a `forRootAsync` factory: Nest
19
+ * collects resolver providers while building the schema, before any async
20
+ * factory has run.
21
+ */
22
+ readonly identityRegisterResolvers?: boolean;
7
23
  }
8
24
  export interface BPMResolvedIdentityOptions {
9
25
  readonly memberMetadataCacheTtlMs: number;
@@ -1 +1 @@
1
- {"version":3,"file":"identity-options.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/identity/identity-options.ts"],"names":[],"mappings":";;;AAoBA,8DASC;AAhBY,QAAA,oBAAoB,GAC/B,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEpB,QAAA,4BAA4B,GAA+B;IACtE,wBAAwB,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;CACxC,CAAC;AAEF,SAAgB,yBAAyB,CACvC,UAAkC,EAAE;IAEpC,OAAO;QACL,wBAAwB,EAAE,wBAAwB,CAChD,OAAO,CAAC,gCAAgC,EACxC,oCAA4B,CAAC,wBAAwB,CACtD;KACF,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAC/B,KAAyB,EACzB,QAAgB;IAEhB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACxE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"identity-options.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/identity/identity-options.ts"],"names":[],"mappings":";;;AAqCA,8DASC;AAhBY,QAAA,oBAAoB,GAC/B,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEpB,QAAA,4BAA4B,GAA+B;IACtE,wBAAwB,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;CACxC,CAAC;AAEF,SAAgB,yBAAyB,CACvC,UAAkC,EAAE;IAEpC,OAAO;QACL,wBAAwB,EAAE,wBAAwB,CAChD,OAAO,CAAC,gCAAgC,EACxC,oCAA4B,CAAC,wBAAwB,CACtD;KACF,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAC/B,KAAyB,EACzB,QAAgB;IAEhB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACxE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -7,6 +7,12 @@ export interface IdentityModuleOptions extends BPMRootIdentityOptions {
7
7
  readonly memberResolverProvider: Provider<BPMMemberResolver>;
8
8
  }
9
9
  export interface IdentityModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
10
+ /**
11
+ * See `BPMRootIdentityOptions.identityRegisterResolvers`. Read here rather
12
+ * than from `useFactory` because Nest collects resolver providers before any
13
+ * async factory runs.
14
+ */
15
+ readonly identityRegisterResolvers?: boolean;
10
16
  readonly inject?: readonly InjectionToken[];
11
17
  readonly memberResolverProvider: Provider<BPMMemberResolver>;
12
18
  readonly useFactory: (...args: readonly unknown[]) => BPMRootIdentityOptions | Promise<BPMRootIdentityOptions>;
@@ -20,7 +20,7 @@ let IdentityModule = IdentityModule_1 = class IdentityModule {
20
20
  ],
21
21
  module: IdentityModule_1,
22
22
  providers: [
23
- identity_queries_1.IdentityQueries,
23
+ ...createIdentityGraphQLProviders(options.identityRegisterResolvers),
24
24
  identity_service_1.IdentityService,
25
25
  ...resolverProviders,
26
26
  createIdentityOptionsProvider(options),
@@ -37,7 +37,7 @@ let IdentityModule = IdentityModule_1 = class IdentityModule {
37
37
  ],
38
38
  module: IdentityModule_1,
39
39
  providers: [
40
- identity_queries_1.IdentityQueries,
40
+ ...createIdentityGraphQLProviders(options.identityRegisterResolvers),
41
41
  identity_service_1.IdentityService,
42
42
  ...resolverProviders,
43
43
  {
@@ -53,6 +53,13 @@ exports.IdentityModule = IdentityModule;
53
53
  exports.IdentityModule = IdentityModule = IdentityModule_1 = tslib_1.__decorate([
54
54
  (0, common_1.Module)({})
55
55
  ], IdentityModule);
56
+ /**
57
+ * `IdentityQueries` is a provider like any other, so leaving it out of the
58
+ * providers list is what keeps its fields out of the generated schema.
59
+ */
60
+ function createIdentityGraphQLProviders(registerResolvers) {
61
+ return registerResolvers === false ? [] : [identity_queries_1.IdentityQueries];
62
+ }
56
63
  function createMemberResolverProviders(options) {
57
64
  return [options.memberResolverProvider];
58
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"identity.module.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/identity/identity.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAKwB;AAExB,6CAAgD;AAChD,yDAAqD;AACrD,yDAAqD;AACrD,iFAA2E;AAE3E,yDAI4B;AAmBrB,IAAM,cAAc,sBAApB,MAAM,cAAc;IACzB,MAAM,CAAC,OAAO,CAAC,OAA8B;QAC3C,MAAM,iBAAiB,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAEjE,OAAO;YACL,OAAO,EAAE,CAAC,kCAAe,CAAC;YAC1B,OAAO,EAAE;gBACP,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC1B,uBAAa,CAAC,UAAU,CAAC,CAAC,wDAAyB,CAAC,CAAC;aACtD;YACD,MAAM,EAAE,gBAAc;YACtB,SAAS,EAAE;gBACT,kCAAe;gBACf,kCAAe;gBACf,GAAG,iBAAiB;gBACpB,6BAA6B,CAAC,OAAO,CAAC;aACvC;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAAmC;QACrD,MAAM,iBAAiB,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAEjE,OAAO;YACL,OAAO,EAAE,CAAC,kCAAe,CAAC;YAC1B,OAAO,EAAE;gBACP,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC1B,uBAAa,CAAC,UAAU,CAAC,CAAC,wDAAyB,CAAC,CAAC;aACtD;YACD,MAAM,EAAE,gBAAc;YACtB,SAAS,EAAE;gBACT,kCAAe;gBACf,kCAAe;gBACf,GAAG,iBAAiB;gBACpB;oBACE,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;oBACnC,OAAO,EAAE,uCAAoB;oBAC7B,UAAU,EAAE,KAAK,EACf,GAAG,IAAwB,EAC4B,EAAE,CACzD,IAAA,4CAAyB,EAAC,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;iBAC/D;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA7CY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CA6C1B;AAED,SAAS,6BAA6B,CACpC,OAA8B;IAE9B,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,6BAA6B,CACpC,UAAkC,EAAE;IAEpC,OAAO;QACL,OAAO,EAAE,uCAAoB;QAC7B,QAAQ,EAAE,IAAA,4CAAyB,EAAC,OAAO,CAAC;KAC7C,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"identity.module.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/identity/identity.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAKwB;AAExB,6CAAgD;AAChD,yDAAqD;AACrD,yDAAqD;AACrD,iFAA2E;AAE3E,yDAI4B;AAyBrB,IAAM,cAAc,sBAApB,MAAM,cAAc;IACzB,MAAM,CAAC,OAAO,CAAC,OAA8B;QAC3C,MAAM,iBAAiB,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAEjE,OAAO;YACL,OAAO,EAAE,CAAC,kCAAe,CAAC;YAC1B,OAAO,EAAE;gBACP,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC1B,uBAAa,CAAC,UAAU,CAAC,CAAC,wDAAyB,CAAC,CAAC;aACtD;YACD,MAAM,EAAE,gBAAc;YACtB,SAAS,EAAE;gBACT,GAAG,8BAA8B,CAAC,OAAO,CAAC,yBAAyB,CAAC;gBACpE,kCAAe;gBACf,GAAG,iBAAiB;gBACpB,6BAA6B,CAAC,O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CAAC;AACJ,CAAC"}
@@ -2,5 +2,13 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
2
2
  export declare class EnablePostgresExtensions0000000000001 implements MigrationInterface {
3
3
  readonly name = "EnablePostgresExtensions0000000000001";
4
4
  up(queryRunner: QueryRunner): Promise<void>;
5
- down(queryRunner: QueryRunner): Promise<void>;
5
+ /**
6
+ * Intentionally a no-op.
7
+ *
8
+ * Extensions are a one-time, database-wide prerequisite that a privileged
9
+ * role may well have installed before BPM ever ran — and other schemas in
10
+ * the same database may depend on them. Dropping `ltree` on the way down
11
+ * would take something this migration did not necessarily create.
12
+ */
13
+ down(): Promise<void>;
6
14
  }
@@ -1,17 +1,68 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EnablePostgresExtensions0000000000001 = void 0;
4
+ const INSUFFICIENT_PRIVILEGE = '42501';
5
+ /**
6
+ * PostgreSQL extensions every later BPM migration depends on: `uuid-ossp` for
7
+ * `uuid_generate_v4()` defaults, `ltree` for the org unit `path` column and its
8
+ * ancestor/descendant operators.
9
+ */
10
+ const REQUIRED_EXTENSIONS = ['uuid-ossp', 'ltree'];
4
11
  class EnablePostgresExtensions0000000000001 {
5
12
  constructor() {
6
13
  this.name = 'EnablePostgresExtensions0000000000001';
7
14
  }
8
15
  async up(queryRunner) {
9
- await queryRunner.query('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"');
10
- await queryRunner.query('CREATE EXTENSION IF NOT EXISTS "ltree"');
16
+ for (const extension of REQUIRED_EXTENSIONS) {
17
+ // PostgreSQL already returns early from `CREATE EXTENSION IF NOT
18
+ // EXISTS` when the extension is present, before it checks privileges, so
19
+ // this probe is not what makes a least-privilege role work — it makes
20
+ // the intent explicit and keeps the branch below reachable only in the
21
+ // case that actually needs explaining.
22
+ if (await isExtensionInstalled(queryRunner, extension)) {
23
+ continue;
24
+ }
25
+ try {
26
+ await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "${extension}"`);
27
+ }
28
+ catch (error) {
29
+ if (!isInsufficientPrivilegeError(error)) {
30
+ throw error;
31
+ }
32
+ throw new Error([
33
+ `[@rytass/bpm-core-nestjs-module] Cannot create the required PostgreSQL extension "${extension}": the migration role has no CREATE privilege on this database.`,
34
+ 'This is a one-time prerequisite, not something the application role can fix at runtime. Ask a role with sufficient privilege (a superuser, the database owner, or rds_superuser) to run:',
35
+ ...REQUIRED_EXTENSIONS.map((name) => ` CREATE EXTENSION IF NOT EXISTS "${name}";`),
36
+ 'against the BPM database, then run the migrations again. See the package README, "Database prerequisites".',
37
+ `Original error: ${readErrorMessage(error)}`,
38
+ ].join('\n'));
39
+ }
40
+ }
11
41
  }
12
- async down(queryRunner) {
13
- await queryRunner.query('DROP EXTENSION IF EXISTS "ltree"');
42
+ /**
43
+ * Intentionally a no-op.
44
+ *
45
+ * Extensions are a one-time, database-wide prerequisite that a privileged
46
+ * role may well have installed before BPM ever ran — and other schemas in
47
+ * the same database may depend on them. Dropping `ltree` on the way down
48
+ * would take something this migration did not necessarily create.
49
+ */
50
+ async down() {
51
+ return;
14
52
  }
15
53
  }
16
54
  exports.EnablePostgresExtensions0000000000001 = EnablePostgresExtensions0000000000001;
55
+ async function isExtensionInstalled(queryRunner, extension) {
56
+ const rows = await queryRunner.query('SELECT 1 FROM pg_extension WHERE extname = $1', [extension]);
57
+ return rows.length > 0;
58
+ }
59
+ function readErrorMessage(error) {
60
+ return error instanceof Error ? error.message : String(error);
61
+ }
62
+ function isInsufficientPrivilegeError(error) {
63
+ return (typeof error === 'object' &&
64
+ error !== null &&
65
+ 'code' in error &&
66
+ error.code === INSUFFICIENT_PRIVILEGE);
67
+ }
17
68
  //# sourceMappingURL=0000000000001-enable-postgres-extensions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"0000000000001-enable-postgres-extensions.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/migrations/0000000000001-enable-postgres-extensions.ts"],"names":[],"mappings":";;;AAEA,MAAa,qCAAqC;IAAlD;QACW,SAAI,GAAG,uCAAuC,CAAC;IAU1D,CAAC;IARC,KAAK,CAAC,EAAE,CAAC,WAAwB;QAC/B,MAAM,WAAW,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QACtE,MAAM,WAAW,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,WAAwB;QACjC,MAAM,WAAW,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC9D,CAAC;CACF;AAXD,sFAWC"}
1
+ {"version":3,"file":"0000000000001-enable-postgres-extensions.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/migrations/0000000000001-enable-postgres-extensions.ts"],"names":[],"mappings":";;;AAEA,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAEvC;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,CAAC,WAAW,EAAE,OAAO,CAAU,CAAC;AAE5D,MAAa,qCAAqC;IAAlD;QACW,SAAI,GAAG,uCAAuC,CAAC;IAgD1D,CAAC;IA9CC,KAAK,CAAC,EAAE,CAAC,WAAwB;QAC/B,KAAK,MAAM,SAAS,IAAI,mBAAmB,EAAE,CAAC;YAC5C,iEAAiE;YACjE,yEAAyE;YACzE,sEAAsE;YACtE,uEAAuE;YACvE,uCAAuC;YACvC,IAAI,MAAM,oBAAoB,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,CAAC;gBACvD,SAAS;YACX,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,WAAW,CAAC,KAAK,CACrB,mCAAmC,SAAS,GAAG,CAChD,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzC,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,MAAM,IAAI,KAAK,CACb;oBACE,qFAAqF,SAAS,iEAAiE;oBAC/J,0LAA0L;oBAC1L,GAAG,mBAAmB,CAAC,GAAG,CACxB,CAAC,IAAI,EAAU,EAAE,CAAC,uCAAuC,IAAI,IAAI,CAClE;oBACD,4GAA4G;oBAC5G,mBAAmB,gBAAgB,CAAC,KAAK,CAAC,EAAE;iBAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI;QACR,OAAO;IACT,CAAC;CACF;AAjDD,sFAiDC;AAED,KAAK,UAAU,oBAAoB,CACjC,WAAwB,EACxB,SAAiB;IAEjB,MAAM,IAAI,GAAuB,MAAM,WAAW,CAAC,KAAK,CACtD,+CAA+C,EAC/C,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAc;IAClD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACd,KAAqC,CAAC,IAAI,KAAK,sBAAsB,CACvE,CAAC;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from './dto/notification-preference.input';
1
2
  export * from './notification-delivery.service';
2
3
  export * from './notification-dispatcher.token';
3
4
  export * from './notification-observer.token';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./dto/notification-preference.input"), exports);
4
5
  tslib_1.__exportStar(require("./notification-delivery.service"), exports);
5
6
  tslib_1.__exportStar(require("./notification-dispatcher.token"), exports);
6
7
  tslib_1.__exportStar(require("./notification-observer.token"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/notification/index.ts"],"names":[],"mappings":";;;AAAA,0EAAgD;AAChD,0EAAgD;AAChD,wEAA8C;AAC9C,2EAAiD;AACjD,kEAAwC;AACxC,gEAAsC;AACtC,+DAAqC;AACrC,iEAAuC;AACvC,wEAA8C;AAC9C,gEAAsC;AACtC,iEAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core/src/lib/notification/index.ts"],"names":[],"mappings":";;;AAAA,8EAAoD;AACpD,0EAAgD;AAChD,0EAAgD;AAChD,wEAA8C;AAC9C,2EAAiD;AACjD,kEAAwC;AACxC,gEAAsC;AACtC,+DAAqC;AACrC,iEAAuC;AACvC,wEAA8C;AAC9C,gEAAsC;AACtC,iEAAuC"}
@@ -5,14 +5,14 @@ export declare class CreateManagerResolutionInput {
5
5
  managerMemberId: string;
6
6
  priority: number;
7
7
  effectiveFrom: string;
8
- effectiveTo: string | null;
8
+ effectiveTo?: string | null;
9
9
  }
10
10
  export declare class UpdateManagerResolutionInput {
11
11
  id: string;
12
- scopeType: ManagerResolutionScopeTypeEnum | null;
13
- scopeId: string | null;
14
- managerMemberId: string | null;
15
- priority: number | null;
16
- effectiveFrom: string | null;
17
- effectiveTo: string | null;
12
+ scopeType?: ManagerResolutionScopeTypeEnum | null;
13
+ scopeId?: string | null;
14
+ managerMemberId?: string | null;
15
+ priority?: number | null;
16
+ effectiveFrom?: string | null;
17
+ effectiveTo?: string | null;
18
18
  }
@@ -1,16 +1,16 @@
1
1
  export declare class CreateMembershipInput {
2
2
  memberId: string;
3
3
  orgUnitId: string;
4
- positionId: string | null;
4
+ positionId?: string | null;
5
5
  isPrimary: boolean;
6
6
  effectiveFrom: string;
7
- effectiveTo: string | null;
7
+ effectiveTo?: string | null;
8
8
  }
9
9
  export declare class UpdateMembershipInput {
10
10
  id: string;
11
- orgUnitId: string | null;
12
- positionId: string | null;
13
- isPrimary: boolean | null;
14
- effectiveFrom: string | null;
15
- effectiveTo: string | null;
11
+ orgUnitId?: string | null;
12
+ positionId?: string | null;
13
+ isPrimary?: boolean | null;
14
+ effectiveFrom?: string | null;
15
+ effectiveTo?: string | null;
16
16
  }