@things-factory/saas 10.1.248 → 10.1.249

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 (66) hide show
  1. package/dist-client/bootstrap.d.ts +1 -0
  2. package/dist-client/bootstrap.js +5 -0
  3. package/dist-client/bootstrap.js.map +1 -0
  4. package/dist-client/entity360/saas-account-360.d.ts +11 -0
  5. package/dist-client/entity360/saas-account-360.js +178 -0
  6. package/dist-client/entity360/saas-account-360.js.map +1 -0
  7. package/dist-client/index.d.ts +1 -0
  8. package/dist-client/index.js +2 -0
  9. package/dist-client/index.js.map +1 -0
  10. package/dist-client/pages/saas-account-list.d.ts +57 -0
  11. package/dist-client/pages/saas-account-list.js +169 -0
  12. package/dist-client/pages/saas-account-list.js.map +1 -0
  13. package/dist-client/pages/saas-account-page.d.ts +52 -0
  14. package/dist-client/pages/saas-account-page.js +332 -0
  15. package/dist-client/pages/saas-account-page.js.map +1 -0
  16. package/dist-client/route.d.ts +1 -0
  17. package/dist-client/route.js +13 -0
  18. package/dist-client/route.js.map +1 -0
  19. package/dist-client/tsconfig.tsbuildinfo +1 -0
  20. package/dist-client/words.d.ts +34 -0
  21. package/dist-client/words.js +22 -0
  22. package/dist-client/words.js.map +1 -0
  23. package/dist-server/index.d.ts +1 -0
  24. package/dist-server/index.js +9 -0
  25. package/dist-server/index.js.map +1 -0
  26. package/dist-server/role-tasks.d.ts +2 -0
  27. package/dist-server/role-tasks.js +18 -0
  28. package/dist-server/role-tasks.js.map +1 -0
  29. package/dist-server/service/checks.d.ts +27 -0
  30. package/dist-server/service/checks.js +70 -0
  31. package/dist-server/service/checks.js.map +1 -0
  32. package/dist-server/service/index.d.ts +18 -0
  33. package/dist-server/service/index.js +34 -0
  34. package/dist-server/service/index.js.map +1 -0
  35. package/dist-server/service/saas-access.d.ts +20 -0
  36. package/dist-server/service/saas-access.js +36 -0
  37. package/dist-server/service/saas-access.js.map +1 -0
  38. package/dist-server/service/saas-account.d.ts +39 -0
  39. package/dist-server/service/saas-account.js +151 -0
  40. package/dist-server/service/saas-account.js.map +1 -0
  41. package/dist-server/service/saas-mutation.d.ts +10 -0
  42. package/dist-server/service/saas-mutation.js +87 -0
  43. package/dist-server/service/saas-mutation.js.map +1 -0
  44. package/dist-server/service/saas-query.d.ts +21 -0
  45. package/dist-server/service/saas-query.js +168 -0
  46. package/dist-server/service/saas-query.js.map +1 -0
  47. package/dist-server/service/saas-rules.d.ts +41 -0
  48. package/dist-server/service/saas-rules.js +62 -0
  49. package/dist-server/service/saas-rules.js.map +1 -0
  50. package/dist-server/service/saas-seat.d.ts +26 -0
  51. package/dist-server/service/saas-seat.js +110 -0
  52. package/dist-server/service/saas-seat.js.map +1 -0
  53. package/dist-server/service/saas-service.d.ts +19 -0
  54. package/dist-server/service/saas-service.js +223 -0
  55. package/dist-server/service/saas-service.js.map +1 -0
  56. package/dist-server/service/saas-subscription.d.ts +45 -0
  57. package/dist-server/service/saas-subscription.js +174 -0
  58. package/dist-server/service/saas-subscription.js.map +1 -0
  59. package/dist-server/service/saas-sync.d.ts +34 -0
  60. package/dist-server/service/saas-sync.js +106 -0
  61. package/dist-server/service/saas-sync.js.map +1 -0
  62. package/dist-server/service/saas-type.d.ts +89 -0
  63. package/dist-server/service/saas-type.js +338 -0
  64. package/dist-server/service/saas-type.js.map +1 -0
  65. package/dist-server/tsconfig.tsbuildinfo +1 -0
  66. package/package.json +4 -4
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SaasAccountQuery = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const accounting_1 = require("@things-factory/accounting");
6
+ const auth_base_1 = require("@things-factory/auth-base");
7
+ const biz_base_1 = require("@things-factory/biz-base");
8
+ const shell_1 = require("@things-factory/shell");
9
+ const type_graphql_1 = require("type-graphql");
10
+ const typeorm_1 = require("typeorm");
11
+ const saas_access_1 = require("./saas-access");
12
+ const saas_account_1 = require("./saas-account");
13
+ const saas_service_1 = require("./saas-service");
14
+ const saas_seat_1 = require("./saas-seat");
15
+ const saas_subscription_1 = require("./saas-subscription");
16
+ const saas_type_1 = require("./saas-type");
17
+ const today = () => new Date().toISOString().slice(0, 10);
18
+ /** The accounts with their admins - the list's relation in one read. */
19
+ async function withAdmins(tx, state, items) {
20
+ if (!items.length)
21
+ return items;
22
+ const rows = await tx.getRepository(saas_account_1.SaasAccount).find({ where: { id: (0, typeorm_1.In)(items.map(one => one.id)) }, relations: ['admins'] });
23
+ for (const one of items)
24
+ one.admins = rows.find(row => row.id === one.id)?.admins ?? [];
25
+ return items;
26
+ }
27
+ let SaasAccountQuery = class SaasAccountQuery {
28
+ async saasAccounts(params, context) {
29
+ const query = (0, shell_1.getQueryBuilderFromListParams)({ domain: context.state.domain, params, repository: (0, shell_1.getRepository)(saas_account_1.SaasAccount), searchables: ['name', 'identifier', 'purpose', 'billingEmail', 'description'] });
30
+ const [items, total] = await query.getManyAndCount();
31
+ return { items: await withAdmins((0, shell_1.getRepository)(saas_account_1.SaasAccount).manager, context.state, items), total };
32
+ }
33
+ async mySaasAccounts(context) {
34
+ const { domain, user } = context.state;
35
+ const manager = (0, shell_1.getRepository)(saas_account_1.SaasAccount).manager;
36
+ const ids = await (0, saas_access_1.administeredBy)(manager, domain, user?.id);
37
+ if (!ids.length)
38
+ return [];
39
+ return withAdmins(manager, context.state, await (0, shell_1.getRepository)(saas_account_1.SaasAccount).find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(ids) }, order: { name: 'ASC' } }));
40
+ }
41
+ async saasAccount(id, context) {
42
+ const manager = (0, shell_1.getRepository)(saas_account_1.SaasAccount).manager;
43
+ const account = await (0, saas_access_1.accountIn)(manager, context.state.domain, await (0, saas_access_1.scopeOf)(context.state, 'query', manager), id);
44
+ return (await withAdmins(manager, context.state, [account]))[0];
45
+ }
46
+ async saasSubscriptions(accountId, context) {
47
+ const manager = (0, shell_1.getRepository)(saas_account_1.SaasAccount).manager;
48
+ return (0, saas_service_1.saasSubscriptionsOf)(manager, context.state.domain, await (0, saas_access_1.scopeOf)(context.state, 'query', manager), accountId, today());
49
+ }
50
+ async saasSeats(subscriptionId, context) {
51
+ const manager = (0, shell_1.getRepository)(saas_account_1.SaasAccount).manager;
52
+ return (0, saas_service_1.saasSeatsOf)(manager, context.state.domain, await (0, saas_access_1.scopeOf)(context.state, 'query', manager), subscriptionId);
53
+ }
54
+ async saasChanges(accountId, context) {
55
+ const manager = (0, shell_1.getRepository)(saas_account_1.SaasAccount).manager;
56
+ const rows = await (0, saas_service_1.saasChangesOf)(manager, context.state.domain, await (0, saas_access_1.scopeOf)(context.state, 'query', manager), accountId);
57
+ return rows.map((one) => ({ subject: one.subject, factKind: one.factKind, field: one.field, fromValue: one.fromValue, toValue: one.toValue, at: one.at, changedBy: one.changedBy?.name }));
58
+ }
59
+ counterparty(row) {
60
+ return row.counterparty ?? (row.counterpartyId ? (0, shell_1.getRepository)(biz_base_1.Counterparty).findOneBy({ id: row.counterpartyId }) : undefined);
61
+ }
62
+ parent(row) {
63
+ return row.parent ?? (row.parentId ? (0, shell_1.getRepository)(saas_account_1.SaasAccount).findOneBy({ id: row.parentId }) : undefined);
64
+ }
65
+ paymentAccount(row) {
66
+ return row.paymentAccount ?? (row.paymentAccountId ? (0, shell_1.getRepository)(accounting_1.BankAccount).findOneBy({ id: row.paymentAccountId }) : undefined);
67
+ }
68
+ domain(row) {
69
+ return row.domain ?? (row.domainId ? (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: row.domainId }) : undefined);
70
+ }
71
+ updater(row) {
72
+ return row.updater ?? (row.updaterId ? (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: row.updaterId }) : undefined);
73
+ }
74
+ };
75
+ exports.SaasAccountQuery = SaasAccountQuery;
76
+ tslib_1.__decorate([
77
+ (0, type_graphql_1.Directive)('@privilege(category: "saas", privilege: "query", domainOwnerGranted: true)'),
78
+ (0, type_graphql_1.Query)(type => saas_type_1.SaasAccountList, { description: 'To fetch a page of the accounts the domain holds with vendors' }),
79
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
80
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
81
+ tslib_1.__metadata("design:type", Function),
82
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
83
+ tslib_1.__metadata("design:returntype", Promise)
84
+ ], SaasAccountQuery.prototype, "saasAccounts", null);
85
+ tslib_1.__decorate([
86
+ (0, type_graphql_1.Directive)('@privilege(category: "saas-self", privilege: "query", domainOwnerGranted: true)'),
87
+ (0, type_graphql_1.Query)(type => [saas_account_1.SaasAccount], { description: 'The accounts the signed-in person is named an admin of' }),
88
+ tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
89
+ tslib_1.__metadata("design:type", Function),
90
+ tslib_1.__metadata("design:paramtypes", [Object]),
91
+ tslib_1.__metadata("design:returntype", Promise)
92
+ ], SaasAccountQuery.prototype, "mySaasAccounts", null);
93
+ tslib_1.__decorate([
94
+ (0, type_graphql_1.Directive)('@privilege(category: "saas-self", privilege: "query", domainOwnerGranted: true)'),
95
+ (0, type_graphql_1.Query)(type => saas_account_1.SaasAccount, { description: 'To fetch an account - a reader’s any, an admin’s own' }),
96
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
97
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
98
+ tslib_1.__metadata("design:type", Function),
99
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
100
+ tslib_1.__metadata("design:returntype", Promise)
101
+ ], SaasAccountQuery.prototype, "saasAccount", null);
102
+ tslib_1.__decorate([
103
+ (0, type_graphql_1.Directive)('@privilege(category: "saas-self", privilege: "query", domainOwnerGranted: true)'),
104
+ (0, type_graphql_1.Query)(type => [saas_subscription_1.SaasSubscription], { description: 'The subscriptions of an account, with the seats held today' }),
105
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('accountId')),
106
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
107
+ tslib_1.__metadata("design:type", Function),
108
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
109
+ tslib_1.__metadata("design:returntype", Promise)
110
+ ], SaasAccountQuery.prototype, "saasSubscriptions", null);
111
+ tslib_1.__decorate([
112
+ (0, type_graphql_1.Directive)('@privilege(category: "saas-self", privilege: "query", domainOwnerGranted: true)'),
113
+ (0, type_graphql_1.Query)(type => [saas_seat_1.SaasSeat], { description: 'The seats of a subscription' }),
114
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('subscriptionId')),
115
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
116
+ tslib_1.__metadata("design:type", Function),
117
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
118
+ tslib_1.__metadata("design:returntype", Promise)
119
+ ], SaasAccountQuery.prototype, "saasSeats", null);
120
+ tslib_1.__decorate([
121
+ (0, type_graphql_1.Directive)('@privilege(category: "saas-self", privilege: "query", domainOwnerGranted: true)'),
122
+ (0, type_graphql_1.Query)(type => [saas_type_1.SaasChange], { description: 'What moved on an account and its subscriptions, newest first' }),
123
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('accountId')),
124
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
125
+ tslib_1.__metadata("design:type", Function),
126
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
127
+ tslib_1.__metadata("design:returntype", Promise)
128
+ ], SaasAccountQuery.prototype, "saasChanges", null);
129
+ tslib_1.__decorate([
130
+ (0, type_graphql_1.FieldResolver)(type => biz_base_1.Counterparty, { nullable: true }),
131
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
132
+ tslib_1.__metadata("design:type", Function),
133
+ tslib_1.__metadata("design:paramtypes", [saas_account_1.SaasAccount]),
134
+ tslib_1.__metadata("design:returntype", void 0)
135
+ ], SaasAccountQuery.prototype, "counterparty", null);
136
+ tslib_1.__decorate([
137
+ (0, type_graphql_1.FieldResolver)(type => saas_account_1.SaasAccount, { nullable: true }),
138
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
139
+ tslib_1.__metadata("design:type", Function),
140
+ tslib_1.__metadata("design:paramtypes", [saas_account_1.SaasAccount]),
141
+ tslib_1.__metadata("design:returntype", void 0)
142
+ ], SaasAccountQuery.prototype, "parent", null);
143
+ tslib_1.__decorate([
144
+ (0, type_graphql_1.FieldResolver)(type => accounting_1.BankAccount, { nullable: true }),
145
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
146
+ tslib_1.__metadata("design:type", Function),
147
+ tslib_1.__metadata("design:paramtypes", [saas_account_1.SaasAccount]),
148
+ tslib_1.__metadata("design:returntype", void 0)
149
+ ], SaasAccountQuery.prototype, "paymentAccount", null);
150
+ tslib_1.__decorate([
151
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain, { nullable: true }),
152
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
153
+ tslib_1.__metadata("design:type", Function),
154
+ tslib_1.__metadata("design:paramtypes", [saas_account_1.SaasAccount]),
155
+ tslib_1.__metadata("design:returntype", void 0)
156
+ ], SaasAccountQuery.prototype, "domain", null);
157
+ tslib_1.__decorate([
158
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
159
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
160
+ tslib_1.__metadata("design:type", Function),
161
+ tslib_1.__metadata("design:paramtypes", [saas_account_1.SaasAccount]),
162
+ tslib_1.__metadata("design:returntype", void 0)
163
+ ], SaasAccountQuery.prototype, "updater", null);
164
+ exports.SaasAccountQuery = SaasAccountQuery = tslib_1.__decorate([
165
+ (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
166
+ (0, type_graphql_1.Resolver)(saas_account_1.SaasAccount)
167
+ ], SaasAccountQuery);
168
+ //# sourceMappingURL=saas-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saas-query.js","sourceRoot":"","sources":["../../server/service/saas-query.ts"],"names":[],"mappings":";;;;AAAA,2DAAwD;AACxD,yDAAgD;A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BAAW;;sDAEtC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,0BAAW;;8CAE9B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,0BAAW;;+CAE/B;2BAxEU,gBAAgB;IAF5B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,0BAAW,CAAC;GACT,gBAAgB,CAyE5B","sourcesContent":["import { BankAccount } from '@things-factory/accounting'\nimport { User } from '@things-factory/auth-base'\nimport { Counterparty } from '@things-factory/biz-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam, SpeakRefusals } from '@things-factory/shell'\nimport { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root, UseMiddleware } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { accountIn, administeredBy, scopeOf } from './saas-access'\nimport { SaasAccount } from './saas-account'\nimport { saasChangesOf, saasSeatsOf, saasSubscriptionsOf } from './saas-service'\nimport { SaasSeat } from './saas-seat'\nimport { SaasSubscription } from './saas-subscription'\nimport { SaasAccountList, SaasChange } from './saas-type'\n\nconst today = () => new Date().toISOString().slice(0, 10)\n\n/** The accounts with their admins - the list's relation in one read. */\nasync function withAdmins(tx: any, state: any, items: SaasAccount[]) {\n if (!items.length) return items\n const rows = await tx.getRepository(SaasAccount).find({ where: { id: In(items.map(one => one.id)) }, relations: ['admins'] })\n for (const one of items) one.admins = rows.find(row => row.id === one.id)?.admins ?? []\n return items\n}\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(SaasAccount)\nexport class SaasAccountQuery {\n @Directive('@privilege(category: \"saas\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => SaasAccountList, { description: 'To fetch a page of the accounts the domain holds with vendors' })\n async saasAccounts(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<SaasAccountList> {\n const query = getQueryBuilderFromListParams({ domain: context.state.domain, params, repository: getRepository(SaasAccount), searchables: ['name', 'identifier', 'purpose', 'billingEmail', 'description'] })\n const [items, total] = await query.getManyAndCount()\n return { items: await withAdmins(getRepository(SaasAccount).manager, context.state, items), total }\n }\n\n @Directive('@privilege(category: \"saas-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [SaasAccount], { description: 'The accounts the signed-in person is named an admin of' })\n async mySaasAccounts(@Ctx() context: ResolverContext): Promise<SaasAccount[]> {\n const { domain, user } = context.state\n const manager = getRepository(SaasAccount).manager\n const ids = await administeredBy(manager, domain, user?.id)\n if (!ids.length) return []\n return withAdmins(manager, context.state, await getRepository(SaasAccount).find({ where: { domain: { id: domain.id }, id: In(ids) } as any, order: { name: 'ASC' } as any }))\n }\n\n @Directive('@privilege(category: \"saas-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => SaasAccount, { description: 'To fetch an account - a reader’s any, an admin’s own' })\n async saasAccount(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<SaasAccount> {\n const manager = getRepository(SaasAccount).manager\n const account = await accountIn(manager, context.state.domain, await scopeOf(context.state, 'query', manager), id)\n return (await withAdmins(manager, context.state, [account]))[0]\n }\n\n @Directive('@privilege(category: \"saas-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [SaasSubscription], { description: 'The subscriptions of an account, with the seats held today' })\n async saasSubscriptions(@Arg('accountId') accountId: string, @Ctx() context: ResolverContext): Promise<SaasSubscription[]> {\n const manager = getRepository(SaasAccount).manager\n return saasSubscriptionsOf(manager, context.state.domain, await scopeOf(context.state, 'query', manager), accountId, today())\n }\n\n @Directive('@privilege(category: \"saas-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [SaasSeat], { description: 'The seats of a subscription' })\n async saasSeats(@Arg('subscriptionId') subscriptionId: string, @Ctx() context: ResolverContext): Promise<SaasSeat[]> {\n const manager = getRepository(SaasAccount).manager\n return saasSeatsOf(manager, context.state.domain, await scopeOf(context.state, 'query', manager), subscriptionId)\n }\n\n @Directive('@privilege(category: \"saas-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(type => [SaasChange], { description: 'What moved on an account and its subscriptions, newest first' })\n async saasChanges(@Arg('accountId') accountId: string, @Ctx() context: ResolverContext): Promise<SaasChange[]> {\n const manager = getRepository(SaasAccount).manager\n const rows = await saasChangesOf(manager, context.state.domain, await scopeOf(context.state, 'query', manager), accountId)\n return rows.map((one: any) => ({ subject: one.subject, factKind: one.factKind, field: one.field, fromValue: one.fromValue, toValue: one.toValue, at: one.at, changedBy: one.changedBy?.name }))\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n counterparty(@Root() row: SaasAccount) {\n return row.counterparty ?? (row.counterpartyId ? getRepository(Counterparty).findOneBy({ id: row.counterpartyId }) : undefined)\n }\n\n @FieldResolver(type => SaasAccount, { nullable: true })\n parent(@Root() row: SaasAccount) {\n return row.parent ?? (row.parentId ? getRepository(SaasAccount).findOneBy({ id: row.parentId }) : undefined)\n }\n\n @FieldResolver(type => BankAccount, { nullable: true })\n paymentAccount(@Root() row: SaasAccount) {\n return row.paymentAccount ?? (row.paymentAccountId ? getRepository(BankAccount).findOneBy({ id: row.paymentAccountId }) : undefined)\n }\n\n @FieldResolver(type => Domain, { nullable: true })\n domain(@Root() row: SaasAccount) {\n return row.domain ?? (row.domainId ? getRepository(Domain).findOneBy({ id: row.domainId }) : undefined)\n }\n\n @FieldResolver(type => User, { nullable: true })\n updater(@Root() row: SaasAccount) {\n return row.updater ?? (row.updaterId ? getRepository(User).findOneBy({ id: row.updaterId }) : undefined)\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ export declare enum SaasAccountStatus {
2
+ ACTIVE = "ACTIVE",
3
+ CLOSED = "CLOSED"
4
+ }
5
+ export declare enum SaasBilling {
6
+ SEAT = "SEAT",
7
+ FIXED = "FIXED",
8
+ USAGE = "USAGE",
9
+ COMMITMENT = "COMMITMENT",
10
+ OWNED = "OWNED"
11
+ }
12
+ export declare enum SaasSubscriptionStatus {
13
+ ACTIVE = "ACTIVE",
14
+ CANCELLING = "CANCELLING",
15
+ CANCELLED = "CANCELLED"
16
+ }
17
+ export declare const DATE: RegExp;
18
+ export interface SubscriptionFacts {
19
+ id: string;
20
+ billing: SaasBilling | string;
21
+ quantity?: number | null;
22
+ unitPrice?: number | null;
23
+ startOn: string;
24
+ renewalOn?: string | null;
25
+ endedOn?: string | null;
26
+ status: SaasSubscriptionStatus | string;
27
+ }
28
+ /**
29
+ * What its quantity and unit price make - a reference a person compares with the recurring item's actual (개정 7-3):
30
+ * seats or units times the price, a fee with no quantity once. Null when no price is written; an owned license none.
31
+ */
32
+ export declare function referenceAmountOf(sub: SubscriptionFacts): number | null;
33
+ /** Whether its renewal is near: from so many days before its renewal day (none - the day itself) to the day, while in use. */
34
+ export declare function renewalDue(sub: SubscriptionFacts & {
35
+ noticeDays?: number | null;
36
+ }, today: string): boolean;
37
+ /** Whether a seat is held on a day. */
38
+ export declare const seatHeld: (seat: {
39
+ fromOn?: string | null;
40
+ untilOn?: string | null;
41
+ }, today: string) => boolean;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.seatHeld = exports.DATE = exports.SaasSubscriptionStatus = exports.SaasBilling = exports.SaasAccountStatus = void 0;
4
+ exports.referenceAmountOf = referenceAmountOf;
5
+ exports.renewalDue = renewalDue;
6
+ const type_graphql_1 = require("type-graphql");
7
+ /*
8
+ * The subscriptions' rules (ADR-0177) - their renewals, their seats and the reference a quantity and a unit price make.
9
+ * The money is the recurring items' (accounting, 개정 7). Apart from the entities, so the screens' words and the tests
10
+ * read them without a type-graphql class. Pure.
11
+ */
12
+ var SaasAccountStatus;
13
+ (function (SaasAccountStatus) {
14
+ SaasAccountStatus["ACTIVE"] = "ACTIVE";
15
+ SaasAccountStatus["CLOSED"] = "CLOSED";
16
+ })(SaasAccountStatus || (exports.SaasAccountStatus = SaasAccountStatus = {}));
17
+ (0, type_graphql_1.registerEnumType)(SaasAccountStatus, { name: 'SaasAccountStatus', description: 'Whether an account is in use or closed' });
18
+ var SaasBilling;
19
+ (function (SaasBilling) {
20
+ SaasBilling["SEAT"] = "SEAT";
21
+ SaasBilling["FIXED"] = "FIXED";
22
+ SaasBilling["USAGE"] = "USAGE";
23
+ SaasBilling["COMMITMENT"] = "COMMITMENT";
24
+ SaasBilling["OWNED"] = "OWNED";
25
+ })(SaasBilling || (exports.SaasBilling = SaasBilling = {}));
26
+ (0, type_graphql_1.registerEnumType)(SaasBilling, {
27
+ name: 'SaasBilling',
28
+ description: 'How a subscription is paid for - seats times a unit price, a fixed fee, metered usage, a commitment for a term, or a license owned (the asset register carries its cost)'
29
+ });
30
+ var SaasSubscriptionStatus;
31
+ (function (SaasSubscriptionStatus) {
32
+ SaasSubscriptionStatus["ACTIVE"] = "ACTIVE";
33
+ SaasSubscriptionStatus["CANCELLING"] = "CANCELLING";
34
+ SaasSubscriptionStatus["CANCELLED"] = "CANCELLED";
35
+ })(SaasSubscriptionStatus || (exports.SaasSubscriptionStatus = SaasSubscriptionStatus = {}));
36
+ (0, type_graphql_1.registerEnumType)(SaasSubscriptionStatus, {
37
+ name: 'SaasSubscriptionStatus',
38
+ description: 'In use, not to be renewed (it ends on its renewal day) or ended'
39
+ });
40
+ exports.DATE = /^\d{4}-\d{2}-\d{2}$/;
41
+ const num = (value) => (value === null || value === undefined || value === '' ? 0 : Number(value) || 0);
42
+ /**
43
+ * What its quantity and unit price make - a reference a person compares with the recurring item's actual (개정 7-3):
44
+ * seats or units times the price, a fee with no quantity once. Null when no price is written; an owned license none.
45
+ */
46
+ function referenceAmountOf(sub) {
47
+ if (sub.billing === SaasBilling.OWNED || sub.unitPrice === null || sub.unitPrice === undefined)
48
+ return null;
49
+ return (sub.quantity === null || sub.quantity === undefined ? 1 : num(sub.quantity)) * num(sub.unitPrice);
50
+ }
51
+ /** Whether its renewal is near: from so many days before its renewal day (none - the day itself) to the day, while in use. */
52
+ function renewalDue(sub, today) {
53
+ if (sub.status !== SaasSubscriptionStatus.ACTIVE || !sub.renewalOn || sub.billing === SaasBilling.OWNED)
54
+ return false;
55
+ const from = new Date(`${sub.renewalOn}T00:00:00Z`);
56
+ from.setUTCDate(from.getUTCDate() - Math.max(0, num(sub.noticeDays)));
57
+ return today >= from.toISOString().slice(0, 10) && today <= sub.renewalOn;
58
+ }
59
+ /** Whether a seat is held on a day. */
60
+ const seatHeld = (seat, today) => (!seat.fromOn || seat.fromOn <= today) && (!seat.untilOn || seat.untilOn >= today);
61
+ exports.seatHeld = seatHeld;
62
+ //# sourceMappingURL=saas-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saas-rules.js","sourceRoot":"","sources":["../../server/service/saas-rules.ts"],"names":[],"mappings":";;;AAuDA,8CAGC;AAGD,gCAKC;AAlED,+CAA+C;AAE/C;;;;GAIG;AAEH,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,sCAAiB,CAAA;AACnB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AACD,IAAA,+BAAgB,EAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC,CAAA;AAEzH,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,8BAAe,CAAA;AACjB,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AACD,IAAA,+BAAgB,EAAC,WAAW,EAAE;IAC5B,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,0KAA0K;CACxL,CAAC,CAAA;AAEF,IAAY,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,CAAC,CAAA;IACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IACrE,OAAO,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,SAAS,CAAA;AAC3E,CAAC;AAED,uCAAuC;AAChC,MAAM,QAAQ,GAAG,CAAC,IAAyD,EAAE,KAAa,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,CAAA;AAA3K,QAAA,QAAQ,YAAmK","sourcesContent":["import { registerEnumType } from 'type-graphql'\n\n/*\n * The subscriptions' rules (ADR-0177) - their renewals, their seats and the reference a quantity and a unit price make.\n * The money is the recurring items' (accounting, 개정 7). Apart from the entities, so the screens' words and the tests\n * read them without a type-graphql class. Pure.\n */\n\nexport enum SaasAccountStatus {\n ACTIVE = 'ACTIVE',\n CLOSED = 'CLOSED'\n}\nregisterEnumType(SaasAccountStatus, { name: 'SaasAccountStatus', description: 'Whether an account is in use or closed' })\n\nexport enum SaasBilling {\n SEAT = 'SEAT',\n FIXED = 'FIXED',\n USAGE = 'USAGE',\n COMMITMENT = 'COMMITMENT',\n OWNED = 'OWNED'\n}\nregisterEnumType(SaasBilling, {\n name: 'SaasBilling',\n description: 'How a subscription is paid for - seats times a unit price, a fixed fee, metered usage, a commitment for a term, or a license owned (the asset register carries its cost)'\n})\n\nexport enum SaasSubscriptionStatus {\n ACTIVE = 'ACTIVE',\n CANCELLING = 'CANCELLING',\n CANCELLED = 'CANCELLED'\n}\nregisterEnumType(SaasSubscriptionStatus, {\n name: 'SaasSubscriptionStatus',\n description: 'In use, not to be renewed (it ends on its renewal day) or ended'\n})\n\nexport const DATE = /^\\d{4}-\\d{2}-\\d{2}$/\n\nexport interface SubscriptionFacts {\n id: string\n billing: SaasBilling | string\n quantity?: number | null\n unitPrice?: number | null\n startOn: string\n renewalOn?: string | null\n endedOn?: string | null\n status: SaasSubscriptionStatus | string\n}\n\nconst num = (value: any) => (value === null || value === undefined || value === '' ? 0 : Number(value) || 0)\n\n/**\n * What its quantity and unit price make - a reference a person compares with the recurring item's actual (개정 7-3):\n * seats or units times the price, a fee with no quantity once. Null when no price is written; an owned license none.\n */\nexport function referenceAmountOf(sub: SubscriptionFacts): number | null {\n if (sub.billing === SaasBilling.OWNED || sub.unitPrice === null || sub.unitPrice === undefined) return null\n return (sub.quantity === null || sub.quantity === undefined ? 1 : num(sub.quantity)) * num(sub.unitPrice)\n}\n\n/** Whether its renewal is near: from so many days before its renewal day (none - the day itself) to the day, while in use. */\nexport function renewalDue(sub: SubscriptionFacts & { noticeDays?: number | null }, today: string): boolean {\n if (sub.status !== SaasSubscriptionStatus.ACTIVE || !sub.renewalOn || sub.billing === SaasBilling.OWNED) return false\n const from = new Date(`${sub.renewalOn}T00:00:00Z`)\n from.setUTCDate(from.getUTCDate() - Math.max(0, num(sub.noticeDays)))\n return today >= from.toISOString().slice(0, 10) && today <= sub.renewalOn\n}\n\n/** Whether a seat is held on a day. */\nexport const seatHeld = (seat: { fromOn?: string | null; untilOn?: string | null }, today: string) => (!seat.fromOn || seat.fromOn <= today) && (!seat.untilOn || seat.untilOn >= today)\n"]}
@@ -0,0 +1,26 @@
1
+ import { User } from '@things-factory/auth-base';
2
+ import { Employee } from '@things-factory/organization';
3
+ import { Domain } from '@things-factory/shell';
4
+ import { SaasSubscription } from './saas-subscription';
5
+ /** Who holds one place of a subscription, and from when to when (ADR-0177 decision 6) - an employee, or a name. */
6
+ export declare class SaasSeat {
7
+ readonly id: string;
8
+ domain?: Domain;
9
+ domainId?: string;
10
+ subscription?: SaasSubscription;
11
+ subscriptionId?: string;
12
+ employee?: Employee;
13
+ employeeId?: string;
14
+ holder?: string;
15
+ login?: string;
16
+ fromOn?: string;
17
+ untilOn?: string;
18
+ description?: string;
19
+ createdAt?: Date;
20
+ updatedAt?: Date;
21
+ deletedAt?: Date;
22
+ creator?: User;
23
+ creatorId?: string;
24
+ updater?: User;
25
+ updaterId?: string;
26
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SaasSeat = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const auth_base_1 = require("@things-factory/auth-base");
6
+ const organization_1 = require("@things-factory/organization");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const type_graphql_1 = require("type-graphql");
9
+ const typeorm_1 = require("typeorm");
10
+ const saas_subscription_1 = require("./saas-subscription");
11
+ /** Who holds one place of a subscription, and from when to when (ADR-0177 decision 6) - an employee, or a name. */
12
+ let SaasSeat = class SaasSeat {
13
+ };
14
+ exports.SaasSeat = SaasSeat;
15
+ tslib_1.__decorate([
16
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
17
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier of the seat' }),
18
+ tslib_1.__metadata("design:type", String)
19
+ ], SaasSeat.prototype, "id", void 0);
20
+ tslib_1.__decorate([
21
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
22
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain the seat belongs to' }),
23
+ tslib_1.__metadata("design:type", shell_1.Domain)
24
+ ], SaasSeat.prototype, "domain", void 0);
25
+ tslib_1.__decorate([
26
+ (0, typeorm_1.RelationId)((seat) => seat.domain),
27
+ tslib_1.__metadata("design:type", String)
28
+ ], SaasSeat.prototype, "domainId", void 0);
29
+ tslib_1.__decorate([
30
+ (0, typeorm_1.ManyToOne)(type => saas_subscription_1.SaasSubscription, { onDelete: 'CASCADE' }),
31
+ (0, type_graphql_1.Field)(type => saas_subscription_1.SaasSubscription, { nullable: true, description: 'The subscription it is a place of' }),
32
+ tslib_1.__metadata("design:type", saas_subscription_1.SaasSubscription)
33
+ ], SaasSeat.prototype, "subscription", void 0);
34
+ tslib_1.__decorate([
35
+ (0, typeorm_1.RelationId)((seat) => seat.subscription),
36
+ tslib_1.__metadata("design:type", String)
37
+ ], SaasSeat.prototype, "subscriptionId", void 0);
38
+ tslib_1.__decorate([
39
+ (0, typeorm_1.ManyToOne)(type => organization_1.Employee, { nullable: true, onDelete: 'SET NULL' }),
40
+ (0, type_graphql_1.Field)(type => organization_1.Employee, { nullable: true, description: 'The employee who holds it' }),
41
+ tslib_1.__metadata("design:type", organization_1.Employee)
42
+ ], SaasSeat.prototype, "employee", void 0);
43
+ tslib_1.__decorate([
44
+ (0, typeorm_1.RelationId)((seat) => seat.employee),
45
+ tslib_1.__metadata("design:type", String)
46
+ ], SaasSeat.prototype, "employeeId", void 0);
47
+ tslib_1.__decorate([
48
+ (0, typeorm_1.Column)({ nullable: true }),
49
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Who holds it when it is no employee - a contractor, a shared mailbox' }),
50
+ tslib_1.__metadata("design:type", String)
51
+ ], SaasSeat.prototype, "holder", void 0);
52
+ tslib_1.__decorate([
53
+ (0, typeorm_1.Column)({ nullable: true }),
54
+ (0, type_graphql_1.Field)({ nullable: true, description: "The login it is held by at the vendor - a Microsoft 365 user name; set by a sync, which opens and closes it" }),
55
+ tslib_1.__metadata("design:type", String)
56
+ ], SaasSeat.prototype, "login", void 0);
57
+ tslib_1.__decorate([
58
+ (0, typeorm_1.Column)({ nullable: true }),
59
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day it was given - YYYY-MM-DD' }),
60
+ tslib_1.__metadata("design:type", String)
61
+ ], SaasSeat.prototype, "fromOn", void 0);
62
+ tslib_1.__decorate([
63
+ (0, typeorm_1.Column)({ nullable: true }),
64
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The day it was taken back - YYYY-MM-DD' }),
65
+ tslib_1.__metadata("design:type", String)
66
+ ], SaasSeat.prototype, "untilOn", void 0);
67
+ tslib_1.__decorate([
68
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
69
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Notes - the login it uses' }),
70
+ tslib_1.__metadata("design:type", String)
71
+ ], SaasSeat.prototype, "description", void 0);
72
+ tslib_1.__decorate([
73
+ (0, typeorm_1.CreateDateColumn)(),
74
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the seat was registered' }),
75
+ tslib_1.__metadata("design:type", Date)
76
+ ], SaasSeat.prototype, "createdAt", void 0);
77
+ tslib_1.__decorate([
78
+ (0, typeorm_1.UpdateDateColumn)(),
79
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the seat last changed' }),
80
+ tslib_1.__metadata("design:type", Date)
81
+ ], SaasSeat.prototype, "updatedAt", void 0);
82
+ tslib_1.__decorate([
83
+ (0, typeorm_1.DeleteDateColumn)(),
84
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When the seat was deleted' }),
85
+ tslib_1.__metadata("design:type", Date)
86
+ ], SaasSeat.prototype, "deletedAt", void 0);
87
+ tslib_1.__decorate([
88
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
89
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who registered it' }),
90
+ tslib_1.__metadata("design:type", auth_base_1.User)
91
+ ], SaasSeat.prototype, "creator", void 0);
92
+ tslib_1.__decorate([
93
+ (0, typeorm_1.RelationId)((seat) => seat.creator),
94
+ tslib_1.__metadata("design:type", String)
95
+ ], SaasSeat.prototype, "creatorId", void 0);
96
+ tslib_1.__decorate([
97
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
98
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who last changed it' }),
99
+ tslib_1.__metadata("design:type", auth_base_1.User)
100
+ ], SaasSeat.prototype, "updater", void 0);
101
+ tslib_1.__decorate([
102
+ (0, typeorm_1.RelationId)((seat) => seat.updater),
103
+ tslib_1.__metadata("design:type", String)
104
+ ], SaasSeat.prototype, "updaterId", void 0);
105
+ exports.SaasSeat = SaasSeat = tslib_1.__decorate([
106
+ (0, typeorm_1.Entity)(),
107
+ (0, typeorm_1.Index)('ix_saas_seat_0', (seat) => [seat.domain, seat.subscription]),
108
+ (0, type_graphql_1.ObjectType)({ description: 'Entity for SaasSeat — who holds one place of a subscription' })
109
+ ], SaasSeat);
110
+ //# sourceMappingURL=saas-seat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saas-seat.js","sourceRoot":"","sources":["../../server/service/saas-seat.ts"],"names":[],"mappings":";;;;AAAA,yDAAgD;AAChD,+DAAuD;AACvD,iDAA8C;AAC9C,+CAAoD;AACpD,qCAAoJ;AAEpJ,2DAAsD;AAEtD,mHAAmH;AAI5G,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAuEpB,CAAA;AAvEY,4BAAQ;AAGV;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;oCACjD;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;sCAChF,cAAM;wCAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;;0CAC3B;AAIjB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,oCAAgB,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC5D,IAAA,oBAAK,EAAC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B,EAAE,CAAC;sCAClE,gBAAI;yCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;2CAC3B;mBAtEP,QAAQ;IAHpB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,IAAc,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7E,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,6DAA6D,EAAE,CAAC;GAC9E,QAAQ,CAuEpB","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Employee } from '@things-factory/organization'\nimport { Domain } from '@things-factory/shell'\nimport { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\n\nimport { SaasSubscription } from './saas-subscription'\n\n/** Who holds one place of a subscription, and from when to when (ADR-0177 decision 6) - an employee, or a name. */\n@Entity()\n@Index('ix_saas_seat_0', (seat: SaasSeat) => [seat.domain, seat.subscription])\n@ObjectType({ description: 'Entity for SaasSeat — who holds one place of a subscription' })\nexport class SaasSeat {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier of the seat' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain the seat belongs to' })\n domain?: Domain\n\n @RelationId((seat: SaasSeat) => seat.domain)\n domainId?: string\n\n @ManyToOne(type => SaasSubscription, { onDelete: 'CASCADE' })\n @Field(type => SaasSubscription, { nullable: true, description: 'The subscription it is a place of' })\n subscription?: SaasSubscription\n\n @RelationId((seat: SaasSeat) => seat.subscription)\n subscriptionId?: string\n\n @ManyToOne(type => Employee, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Employee, { nullable: true, description: 'The employee who holds it' })\n employee?: Employee\n\n @RelationId((seat: SaasSeat) => seat.employee)\n employeeId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Who holds it when it is no employee - a contractor, a shared mailbox' })\n holder?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: \"The login it is held by at the vendor - a Microsoft 365 user name; set by a sync, which opens and closes it\" })\n login?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The day it was given - YYYY-MM-DD' })\n fromOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The day it was taken back - YYYY-MM-DD' })\n untilOn?: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes - the login it uses' })\n description?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When the seat was registered' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When the seat last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When the seat was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who registered it' })\n creator?: User\n\n @RelationId((seat: SaasSeat) => seat.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((seat: SaasSeat) => seat.updater)\n updaterId?: string\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { Patch } from '@things-factory/asset';
2
+ import { Domain } from '@things-factory/shell';
3
+ import { EntityManager } from 'typeorm';
4
+ import { SaasScope } from './saas-access';
5
+ import { SaasAccount } from './saas-account';
6
+ import { SaasSeat } from './saas-seat';
7
+ import { SaasSubscription } from './saas-subscription';
8
+ export declare const SAAS_ACCOUNT_FACT = "saas-account";
9
+ export declare const SAAS_SUBSCRIPTION_FACT = "saas-subscription";
10
+ export declare function saveSaasAccounts(tx: EntityManager, domain: Domain, user: any, patches: Patch[]): Promise<SaasAccount[]>;
11
+ export declare function saveSaasSubscriptions(tx: EntityManager, domain: Domain, user: any, scope: SaasScope, accountId: string, patches: Patch[]): Promise<SaasSubscription[]>;
12
+ /** The subscriptions of an account, with the seats held today and the reference each makes. */
13
+ export declare function saasSubscriptionsOf(tx: EntityManager, domain: Domain, scope: SaasScope, accountId: string, today: string): Promise<SaasSubscription[]>;
14
+ export declare function saveSaasSeats(tx: EntityManager, domain: Domain, user: any, scope: SaasScope, subscriptionId: string, patches: Patch[]): Promise<SaasSeat[]>;
15
+ export declare function saasSeatsOf(tx: EntityManager, domain: Domain, scope: SaasScope, subscriptionId: string): Promise<SaasSeat[]>;
16
+ /** What moved on an account and on each of its subscriptions, newest first. */
17
+ export declare function saasChangesOf(tx: EntityManager, domain: Domain, scope: SaasScope, accountId: string): Promise<(import("@things-factory/fact-change").FactChange & {
18
+ subject: string;
19
+ })[]>;