@things-factory/calendar 10.1.203 → 10.1.206

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 (114) hide show
  1. package/dist-client/pages/calendar/calendar-list-page.d.ts +1 -9
  2. package/dist-client/pages/calendar/calendar-list-page.js +2 -27
  3. package/dist-client/pages/calendar/calendar-list-page.js.map +1 -1
  4. package/dist-client/pages/event/event-list-page.d.ts +5 -28
  5. package/dist-client/pages/event/event-list-page.js +65 -177
  6. package/dist-client/pages/event/event-list-page.js.map +1 -1
  7. package/dist-client/route.d.ts +1 -1
  8. package/dist-client/route.js +0 -3
  9. package/dist-client/route.js.map +1 -1
  10. package/dist-client/tsconfig.tsbuildinfo +1 -1
  11. package/dist-server/index.d.ts +1 -0
  12. package/dist-server/index.js +5 -0
  13. package/dist-server/index.js.map +1 -1
  14. package/dist-server/role-tasks.d.ts +2 -0
  15. package/dist-server/role-tasks.js +16 -0
  16. package/dist-server/role-tasks.js.map +1 -0
  17. package/dist-server/service/attendee/attendee-query.d.ts +7 -4
  18. package/dist-server/service/attendee/attendee-query.js +34 -25
  19. package/dist-server/service/attendee/attendee-query.js.map +1 -1
  20. package/dist-server/service/attendee/attendee-service.d.ts +41 -0
  21. package/dist-server/service/attendee/attendee-service.js +90 -0
  22. package/dist-server/service/attendee/attendee-service.js.map +1 -0
  23. package/dist-server/service/attendee/attendee-type.d.ts +3 -15
  24. package/dist-server/service/attendee/attendee-type.js +12 -53
  25. package/dist-server/service/attendee/attendee-type.js.map +1 -1
  26. package/dist-server/service/attendee/attendee.d.ts +24 -7
  27. package/dist-server/service/attendee/attendee.js +99 -23
  28. package/dist-server/service/attendee/attendee.js.map +1 -1
  29. package/dist-server/service/attendee/index.d.ts +1 -2
  30. package/dist-server/service/attendee/index.js +1 -2
  31. package/dist-server/service/attendee/index.js.map +1 -1
  32. package/dist-server/service/calendar/calendar-mutation.d.ts +1 -3
  33. package/dist-server/service/calendar/calendar-mutation.js +21 -94
  34. package/dist-server/service/calendar/calendar-mutation.js.map +1 -1
  35. package/dist-server/service/calendar/calendar-query.d.ts +1 -1
  36. package/dist-server/service/calendar/calendar-query.js +15 -17
  37. package/dist-server/service/calendar/calendar-query.js.map +1 -1
  38. package/dist-server/service/calendar/calendar-service.d.ts +10 -0
  39. package/dist-server/service/calendar/calendar-service.js +58 -0
  40. package/dist-server/service/calendar/calendar-service.js.map +1 -0
  41. package/dist-server/service/calendar/calendar-type.d.ts +1 -4
  42. package/dist-server/service/calendar/calendar-type.js +13 -25
  43. package/dist-server/service/calendar/calendar-type.js.map +1 -1
  44. package/dist-server/service/calendar/calendar.d.ts +7 -8
  45. package/dist-server/service/calendar/calendar.js +23 -33
  46. package/dist-server/service/calendar/calendar.js.map +1 -1
  47. package/dist-server/service/event/event-mutation.d.ts +6 -4
  48. package/dist-server/service/event/event-mutation.js +60 -83
  49. package/dist-server/service/event/event-mutation.js.map +1 -1
  50. package/dist-server/service/event/event-query.d.ts +11 -1
  51. package/dist-server/service/event/event-query.js +106 -13
  52. package/dist-server/service/event/event-query.js.map +1 -1
  53. package/dist-server/service/event/event-rules.d.ts +10 -0
  54. package/dist-server/service/event/event-rules.js +38 -0
  55. package/dist-server/service/event/event-rules.js.map +1 -0
  56. package/dist-server/service/event/event-service.d.ts +42 -0
  57. package/dist-server/service/event/event-service.js +159 -0
  58. package/dist-server/service/event/event-service.js.map +1 -0
  59. package/dist-server/service/event/event-type.d.ts +10 -11
  60. package/dist-server/service/event/event-type.js +32 -36
  61. package/dist-server/service/event/event-type.js.map +1 -1
  62. package/dist-server/service/event/event.d.ts +25 -11
  63. package/dist-server/service/event/event.js +89 -36
  64. package/dist-server/service/event/event.js.map +1 -1
  65. package/dist-server/service/event-series/event-series-mutation.d.ts +11 -0
  66. package/dist-server/service/event-series/event-series-mutation.js +100 -0
  67. package/dist-server/service/event-series/event-series-mutation.js.map +1 -0
  68. package/dist-server/service/event-series/event-series-query.d.ts +16 -0
  69. package/dist-server/service/event-series/event-series-query.js +109 -0
  70. package/dist-server/service/event-series/event-series-query.js.map +1 -0
  71. package/dist-server/service/event-series/event-series-service.d.ts +40 -0
  72. package/dist-server/service/event-series/event-series-service.js +253 -0
  73. package/dist-server/service/event-series/event-series-service.js.map +1 -0
  74. package/dist-server/service/event-series/event-series-type.d.ts +41 -0
  75. package/dist-server/service/event-series/event-series-type.js +155 -0
  76. package/dist-server/service/event-series/event-series-type.js.map +1 -0
  77. package/dist-server/service/event-series/event-series.d.ts +32 -0
  78. package/dist-server/service/event-series/event-series.js +134 -0
  79. package/dist-server/service/event-series/event-series.js.map +1 -0
  80. package/dist-server/service/event-series/index.d.ts +6 -0
  81. package/dist-server/service/event-series/index.js +10 -0
  82. package/dist-server/service/event-series/index.js.map +1 -0
  83. package/dist-server/service/event-series/recurrence.d.ts +19 -0
  84. package/dist-server/service/event-series/recurrence.js +95 -0
  85. package/dist-server/service/event-series/recurrence.js.map +1 -0
  86. package/dist-server/service/index.d.ts +15 -4
  87. package/dist-server/service/index.js +29 -11
  88. package/dist-server/service/index.js.map +1 -1
  89. package/dist-server/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +8 -5
  91. package/tests/open-doors.test.ts +18 -21
  92. package/things-factory.config.js +0 -4
  93. package/translations/en.json +44 -1
  94. package/translations/es.json +44 -1
  95. package/translations/ja.json +44 -1
  96. package/translations/ko.json +44 -1
  97. package/translations/ms.json +44 -1
  98. package/translations/zh.json +44 -1
  99. package/concept.md +0 -31
  100. package/dist-client/pages/attendee/attendee-importer.d.ts +0 -23
  101. package/dist-client/pages/attendee/attendee-importer.js +0 -93
  102. package/dist-client/pages/attendee/attendee-importer.js.map +0 -1
  103. package/dist-client/pages/attendee/attendee-list-page.d.ts +0 -56
  104. package/dist-client/pages/attendee/attendee-list-page.js +0 -263
  105. package/dist-client/pages/attendee/attendee-list-page.js.map +0 -1
  106. package/dist-client/pages/calendar/calendar-importer.d.ts +0 -23
  107. package/dist-client/pages/calendar/calendar-importer.js +0 -93
  108. package/dist-client/pages/calendar/calendar-importer.js.map +0 -1
  109. package/dist-client/pages/event/event-importer.d.ts +0 -23
  110. package/dist-client/pages/event/event-importer.js +0 -93
  111. package/dist-client/pages/event/event-importer.js.map +0 -1
  112. package/dist-server/service/attendee/attendee-mutation.d.ts +0 -10
  113. package/dist-server/service/attendee/attendee-mutation.js +0 -140
  114. package/dist-server/service/attendee/attendee-mutation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"attendee.js","sourceRoot":"","sources":["../../../server/service/attendee/attendee.ts"],"names":[],"mappings":";;;;AAAA,qCAA8F;AAC9F,+CAA2E;AAC3E,qDAAqD;AAErD,0CAAsC;AAEtC,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;AACvB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAA,+BAAgB,EAAC,cAAc,EAAE;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,iCAAiC;CAC/C,CAAC,CAAA;AAKK,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAiBpB,CAAA;AAjBY,4BAAQ;AAGV;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;oCACC;AAInB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCACb;AAIb;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,qCAAmB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCAC1C;AAKb;IAHC,IAAA,oBAAU,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC;IACvB,IAAA,mBAAS,GAAE;IACX,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,aAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAC5B;mBAhBJ,QAAQ;IAHpB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,eAAe,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACnF,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;GACtC,QAAQ,CAiBpB","sourcesContent":["import { Entity, Index, Column, ManyToMany, JoinTable, PrimaryGeneratedColumn } from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { Event } from '../event/event'\n\nexport enum AttendeeStatus {\n STATUS_A = 'STATUS_A',\n STATUS_B = 'STATUS_B'\n}\n\nregisterEnumType(AttendeeStatus, {\n name: 'AttendeeStatus',\n description: 'state enumeration of a attendee'\n})\n\n@Entity()\n@Index('ix_attendee_0', (attendee: Attendee) => [attendee.email], { unique: false })\n@ObjectType({ description: 'Entity for Attendee' })\nexport class Attendee {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column()\n @Field({ nullable: true })\n name?: string\n\n @Column()\n @Field(type => GraphQLEmailAddress, { nullable: true })\n email: string\n\n @ManyToMany(() => Event)\n @JoinTable()\n @Field(type => [Event], { nullable: true })\n events: Event[]\n}\n"]}
1
+ {"version":3,"file":"attendee.js","sourceRoot":"","sources":["../../../server/service/attendee/attendee.ts"],"names":[],"mappings":";;;;AAAA,qCAAoJ;AACpJ,+CAAoD;AAEpD,iDAA8C;AAC9C,yDAAgD;AAEhD,0CAAsC;AACtC,+DAA0D;AAE1D;;;GAGG;AAmBI,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAmEpB,CAAA;AAnEY,4BAAQ;AAGV;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAA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AQ,CAAC,KAAK,CAAC,EAAE;QAClG,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,0EAA0E;KAClF,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;GAChF,QAAQ,CAmEpB","sourcesContent":["import { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\nimport { Field, ID, ObjectType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nimport { Event } from '../event/event'\nimport { EventSeries } from '../event-series/event-series'\n\n/**\n * A person named on an event or a series — a user who enters the domain, or someone known only by an e-mail address.\n * Naming a person grants nothing: no role, no privilege, no reading of the event.\n */\n@Entity()\n@Index('ix_attendee_0', (attendee: Attendee) => [attendee.domain, attendee.event, attendee.user], {\n unique: true,\n where: '\"deleted_at\" IS NULL AND \"event_id\" IS NOT NULL AND \"user_id\" IS NOT NULL'\n})\n@Index('ix_attendee_1', (attendee: Attendee) => [attendee.domain, attendee.event, attendee.email], {\n unique: true,\n where: '\"deleted_at\" IS NULL AND \"event_id\" IS NOT NULL AND \"email\" IS NOT NULL'\n})\n@Index('ix_attendee_2', (attendee: Attendee) => [attendee.domain, attendee.series, attendee.user], {\n unique: true,\n where: '\"deleted_at\" IS NULL AND \"series_id\" IS NOT NULL AND \"user_id\" IS NOT NULL'\n})\n@Index('ix_attendee_3', (attendee: Attendee) => [attendee.domain, attendee.series, attendee.email], {\n unique: true,\n where: '\"deleted_at\" IS NULL AND \"series_id\" IS NOT NULL AND \"email\" IS NOT NULL'\n})\n@ObjectType({ description: 'A person named on an event or a series; naming grants nothing' })\nexport class Attendee {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier of the attendee row' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain the attendee row belongs to' })\n domain?: Domain\n\n @RelationId((attendee: Attendee) => attendee.domain)\n domainId?: string\n\n @ManyToOne(type => Event, { nullable: true })\n event?: Event\n\n @RelationId((attendee: Attendee) => attendee.event)\n @Field({ nullable: true, description: 'Id of the event the person is named on' })\n eventId?: string\n\n @ManyToOne(type => EventSeries, { nullable: true })\n series?: EventSeries\n\n @RelationId((attendee: Attendee) => attendee.series)\n @Field({ nullable: true, description: 'Id of the series the person is named on' })\n seriesId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user, when the attendee signs in to the domain' })\n user?: User\n\n @RelationId((attendee: Attendee) => attendee.user)\n @Field({ nullable: true, description: 'Id of the user, when the attendee signs in to the domain' })\n userId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'E-mail address, when the attendee is not a user of the domain' })\n email?: string\n\n @Column()\n @Field({ description: 'Name shown for the attendee' })\n name: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Creation timestamp' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Last update timestamp' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'Soft delete timestamp' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who named the attendee' })\n creator?: User\n\n @RelationId((attendee: Attendee) => attendee.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed the attendee row' })\n updater?: User\n\n @RelationId((attendee: Attendee) => attendee.updater)\n updaterId?: string\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import { Attendee } from './attendee';
2
2
  import { AttendeeQuery } from './attendee-query';
3
- import { AttendeeMutation } from './attendee-mutation';
4
3
  export declare const entities: (typeof Attendee)[];
5
- export declare const resolvers: (typeof AttendeeQuery | typeof AttendeeMutation)[];
4
+ export declare const resolvers: (typeof AttendeeQuery)[];
6
5
  export declare const subscribers: any[];
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.subscribers = exports.resolvers = exports.entities = void 0;
4
4
  const attendee_1 = require("./attendee");
5
5
  const attendee_query_1 = require("./attendee-query");
6
- const attendee_mutation_1 = require("./attendee-mutation");
7
6
  exports.entities = [attendee_1.Attendee];
8
- exports.resolvers = [attendee_query_1.AttendeeQuery, attendee_mutation_1.AttendeeMutation];
7
+ exports.resolvers = [attendee_query_1.AttendeeQuery];
9
8
  exports.subscribers = [];
10
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/attendee/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAgD;AAChD,2DAAsD;AAEzC,QAAA,QAAQ,GAAG,CAAC,mBAAQ,CAAC,CAAA;AACrB,QAAA,SAAS,GAAG,CAAC,8BAAa,EAAE,oCAAgB,CAAC,CAAA;AAC7C,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { Attendee } from './attendee'\nimport { AttendeeQuery } from './attendee-query'\nimport { AttendeeMutation } from './attendee-mutation'\n\nexport const entities = [Attendee]\nexport const resolvers = [AttendeeQuery, AttendeeMutation]\nexport const subscribers = []\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/attendee/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAgD;AAEnC,QAAA,QAAQ,GAAG,CAAC,mBAAQ,CAAC,CAAA;AACrB,QAAA,SAAS,GAAG,CAAC,8BAAa,CAAC,CAAA;AAC3B,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { Attendee } from './attendee'\nimport { AttendeeQuery } from './attendee-query'\n\nexport const entities = [Attendee]\nexport const resolvers = [AttendeeQuery]\nexport const subscribers = []\n"]}
@@ -1,10 +1,8 @@
1
1
  import { Calendar } from './calendar';
2
- import { NewCalendar, CalendarPatch } from './calendar-type';
2
+ import { CalendarPatch, NewCalendar } from './calendar-type';
3
3
  export declare class CalendarMutation {
4
4
  createCalendar(calendar: NewCalendar, context: ResolverContext): Promise<Calendar>;
5
5
  updateCalendar(id: string, patch: CalendarPatch, context: ResolverContext): Promise<Calendar>;
6
6
  updateMultipleCalendar(patches: CalendarPatch[], context: ResolverContext): Promise<Calendar[]>;
7
- deleteCalendar(id: string, context: ResolverContext): Promise<boolean>;
8
7
  deleteCalendars(ids: string[], context: ResolverContext): Promise<boolean>;
9
- importCalendars(calendars: CalendarPatch[], context: ResolverContext): Promise<boolean>;
10
8
  }
@@ -3,95 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CalendarMutation = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
- const typeorm_1 = require("typeorm");
6
+ const shell_1 = require("@things-factory/shell");
7
7
  const calendar_1 = require("./calendar");
8
+ const calendar_service_1 = require("./calendar-service");
8
9
  const calendar_type_1 = require("./calendar-type");
9
10
  let CalendarMutation = class CalendarMutation {
10
- async createCalendar(calendar, context) {
11
+ createCalendar(calendar, context) {
11
12
  const { domain, user, tx } = context.state;
12
- const result = await tx.getRepository(calendar_1.Calendar).save({
13
- ...calendar,
14
- domain,
15
- creator: user,
16
- updater: user
17
- });
18
- return result;
13
+ return (0, calendar_service_1.createCalendar)(tx, domain, user, calendar);
19
14
  }
20
- async updateCalendar(id, patch, context) {
15
+ updateCalendar(id, patch, context) {
21
16
  const { domain, user, tx } = context.state;
22
- const repository = tx.getRepository(calendar_1.Calendar);
23
- const calendar = await repository.findOne({
24
- where: { domain: { id: domain.id }, id }
25
- });
26
- return await repository.save({
27
- ...calendar,
28
- ...patch,
29
- updater: user
30
- });
17
+ return (0, calendar_service_1.updateCalendar)(tx, domain, user, id, patch);
31
18
  }
32
19
  async updateMultipleCalendar(patches, context) {
33
20
  const { domain, user, tx } = context.state;
34
- let results = [];
35
- const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
36
- const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
37
- const calendarRepo = tx.getRepository(calendar_1.Calendar);
38
- if (_createRecords.length > 0) {
39
- for (let i = 0; i < _createRecords.length; i++) {
40
- const newRecord = _createRecords[i];
41
- const result = await calendarRepo.save({
42
- ...newRecord,
43
- domain,
44
- creator: user,
45
- updater: user
46
- });
47
- results.push({ ...result, cuFlag: '+' });
48
- }
49
- }
50
- if (_updateRecords.length > 0) {
51
- for (let i = 0; i < _updateRecords.length; i++) {
52
- const updateRecord = _updateRecords[i];
53
- const calendar = await calendarRepo.findOne({
54
- where: { domain: { id: domain.id }, id: updateRecord.id }
55
- });
56
- if (!calendar) {
57
- throw new Error(`failed to find calendar to update: ${updateRecord.id}`);
58
- }
59
- const result = await calendarRepo.save({
60
- ...calendar,
61
- ...updateRecord,
62
- updater: user
63
- });
64
- results.push({ ...result, cuFlag: 'M' });
65
- }
21
+ const results = [];
22
+ for (const patch of patches) {
23
+ const flag = patch.cuFlag?.toUpperCase();
24
+ if (flag === '+')
25
+ results.push({ ...(await (0, calendar_service_1.createCalendar)(tx, domain, user, patch)), cuFlag: '+' });
26
+ else if (flag === 'M')
27
+ results.push({ ...(await (0, calendar_service_1.updateCalendar)(tx, domain, user, (await (0, calendar_service_1.calendarInDomain)(tx, domain, patch.id)).id, patch)), cuFlag: 'M' });
66
28
  }
67
29
  return results;
68
30
  }
69
- async deleteCalendar(id, context) {
70
- const { domain, tx } = context.state;
71
- await tx.getRepository(calendar_1.Calendar).delete({ domain: { id: domain.id }, id });
72
- return true;
73
- }
74
- async deleteCalendars(ids, context) {
75
- const { domain, tx } = context.state;
76
- await tx.getRepository(calendar_1.Calendar).delete({
77
- domain: { id: domain.id },
78
- id: (0, typeorm_1.In)(ids)
79
- });
80
- return true;
81
- }
82
- async importCalendars(calendars, context) {
83
- const { domain, tx } = context.state;
84
- await Promise.all(calendars.map(async (calendar) => {
85
- const createdCalendar = await tx.getRepository(calendar_1.Calendar).save({ domain, ...calendar });
86
- }));
87
- return true;
31
+ deleteCalendars(ids, context) {
32
+ const { domain, user, tx } = context.state;
33
+ return (0, calendar_service_1.deleteCalendars)(tx, domain, user, ids);
88
34
  }
89
35
  };
90
36
  exports.CalendarMutation = CalendarMutation;
91
37
  tslib_1.__decorate([
92
38
  (0, type_graphql_1.Directive)('@transaction'),
93
39
  (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
94
- (0, type_graphql_1.Mutation)(returns => calendar_1.Calendar, { description: 'To create new Calendar' }),
40
+ (0, type_graphql_1.Mutation)(returns => calendar_1.Calendar, { description: 'To create a calendar' }),
95
41
  tslib_1.__param(0, (0, type_graphql_1.Arg)('calendar')),
96
42
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
97
43
  tslib_1.__metadata("design:type", Function),
@@ -101,7 +47,7 @@ tslib_1.__decorate([
101
47
  tslib_1.__decorate([
102
48
  (0, type_graphql_1.Directive)('@transaction'),
103
49
  (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
104
- (0, type_graphql_1.Mutation)(returns => calendar_1.Calendar, { description: 'To modify Calendar information' }),
50
+ (0, type_graphql_1.Mutation)(returns => calendar_1.Calendar, { description: 'To change a calendar' }),
105
51
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
106
52
  tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
107
53
  tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
@@ -112,7 +58,7 @@ tslib_1.__decorate([
112
58
  tslib_1.__decorate([
113
59
  (0, type_graphql_1.Directive)('@transaction'),
114
60
  (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
115
- (0, type_graphql_1.Mutation)(returns => [calendar_1.Calendar], { description: "To modify multiple Calendars' information" }),
61
+ (0, type_graphql_1.Mutation)(returns => [calendar_1.Calendar], { description: 'To create and change calendars from grid rows' }),
116
62
  tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [calendar_type_1.CalendarPatch])),
117
63
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
118
64
  tslib_1.__metadata("design:type", Function),
@@ -122,34 +68,15 @@ tslib_1.__decorate([
122
68
  tslib_1.__decorate([
123
69
  (0, type_graphql_1.Directive)('@transaction'),
124
70
  (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
125
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Calendar' }),
126
- tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
127
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
128
- tslib_1.__metadata("design:type", Function),
129
- tslib_1.__metadata("design:paramtypes", [String, Object]),
130
- tslib_1.__metadata("design:returntype", Promise)
131
- ], CalendarMutation.prototype, "deleteCalendar", null);
132
- tslib_1.__decorate([
133
- (0, type_graphql_1.Directive)('@transaction'),
134
- (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
135
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Calendars' }),
71
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete calendars that hold no events or series' }),
136
72
  tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
137
73
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
138
74
  tslib_1.__metadata("design:type", Function),
139
75
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
140
76
  tslib_1.__metadata("design:returntype", Promise)
141
77
  ], CalendarMutation.prototype, "deleteCalendars", null);
142
- tslib_1.__decorate([
143
- (0, type_graphql_1.Directive)('@transaction'),
144
- (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
145
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Calendars' }),
146
- tslib_1.__param(0, (0, type_graphql_1.Arg)('calendars', type => [calendar_type_1.CalendarPatch])),
147
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
148
- tslib_1.__metadata("design:type", Function),
149
- tslib_1.__metadata("design:paramtypes", [Array, Object]),
150
- tslib_1.__metadata("design:returntype", Promise)
151
- ], CalendarMutation.prototype, "importCalendars", null);
152
78
  exports.CalendarMutation = CalendarMutation = tslib_1.__decorate([
79
+ (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
153
80
  (0, type_graphql_1.Resolver)(calendar_1.Calendar)
154
81
  ], CalendarMutation);
155
82
  //# sourceMappingURL=calendar-mutation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"calendar-mutation.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,yCAAqC;AACrC,mDAA4D;AAGrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAIrB,AAAN,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,IAAI,CAAC;YACnD,GAAG,QAAQ;YACX,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAKK,AAAN,KAAK,CAAC,cAAc,CACP,EAAU,EACP,KAAoB,EAC3B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAA;QAC7C,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACxC,KAAK,EAAE,EAAE,M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C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE3E,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,6BAAa,CAAC,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAWP;2BAxIU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CAyI5B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { Calendar } from './calendar'\nimport { NewCalendar, CalendarPatch } from './calendar-type'\n\n@Resolver(Calendar)\nexport class CalendarMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Calendar, { description: 'To create new Calendar' })\n async createCalendar(@Arg('calendar') calendar: NewCalendar, @Ctx() context: ResolverContext): Promise<Calendar> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Calendar).save({\n ...calendar,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Calendar, { description: 'To modify Calendar information' })\n async updateCalendar(\n @Arg('id') id: string,\n @Arg('patch') patch: CalendarPatch,\n @Ctx() context: ResolverContext\n ): Promise<Calendar> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Calendar)\n const calendar = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n return await repository.save({\n ...calendar,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Calendar], { description: \"To modify multiple Calendars' information\" })\n async updateMultipleCalendar(\n @Arg('patches', type => [CalendarPatch]) patches: CalendarPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Calendar[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const calendarRepo = tx.getRepository(Calendar)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await calendarRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const calendar = await calendarRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!calendar) {\n throw new Error(`failed to find calendar to update: ${updateRecord.id}`)\n }\n\n const result = await calendarRepo.save({\n ...calendar,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete Calendar' })\n async deleteCalendar(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Calendar).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple Calendars' })\n async deleteCalendars(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Calendar).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple Calendars' })\n async importCalendars(\n @Arg('calendars', type => [CalendarPatch]) calendars: CalendarPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n calendars.map(async (calendar: CalendarPatch) => {\n const createdCalendar: Calendar = await tx.getRepository(Calendar).save({ domain, ...calendar })\n })\n )\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"calendar-mutation.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAqF;AAErF,iDAAqD;AAErD,yCAAqC;AACrC,yDAAsG;AACtG,mDAA4D;AAIrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAI3B,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QACpF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,OAAO,IAAA,iCAAc,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IACnD,CAAC;IAKD,cAAc,CAAY,EAAU,EAAgB,KAAoB,EAAS,OAAwB;QACvG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,OAAO,IAAA,iCAAc,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAA;IACpD,CAAC;IAKK,AAAN,KAAK,CAAC,sBAAsB,CAA0C,OAAwB,EAAS,OAAwB;QAC7H,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,OAAO,GAAG,EAAE,CAAA;QAClB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;YACxC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EAAE,CAAC,mBAAQ,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IAAwB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDAArB,6BAAa;;sDAGvE;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC;IACpE,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,6BAAa,CAAC,CAAC,CAAA;IAA4B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DASrG;AAKD;IAHC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;IAClF,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAGlE;2BArCU,gBAAgB;IAF5B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CAsC5B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { Calendar } from './calendar'\nimport { calendarInDomain, createCalendar, deleteCalendars, updateCalendar } from './calendar-service'\nimport { CalendarPatch, NewCalendar } from './calendar-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(Calendar)\nexport class CalendarMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Calendar, { description: 'To create a calendar' })\n createCalendar(@Arg('calendar') calendar: NewCalendar, @Ctx() context: ResolverContext): Promise<Calendar> {\n const { domain, user, tx } = context.state\n return createCalendar(tx, domain, user, calendar)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Calendar, { description: 'To change a calendar' })\n updateCalendar(@Arg('id') id: string, @Arg('patch') patch: CalendarPatch, @Ctx() context: ResolverContext): Promise<Calendar> {\n const { domain, user, tx } = context.state\n return updateCalendar(tx, domain, user, id, patch)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Calendar], { description: 'To create and change calendars from grid rows' })\n async updateMultipleCalendar(@Arg('patches', type => [CalendarPatch]) patches: CalendarPatch[], @Ctx() context: ResolverContext): Promise<Calendar[]> {\n const { domain, user, tx } = context.state\n const results = []\n for (const patch of patches) {\n const flag = patch.cuFlag?.toUpperCase()\n if (flag === '+') results.push({ ...(await createCalendar(tx, domain, user, patch as NewCalendar)), cuFlag: '+' })\n else if (flag === 'M') results.push({ ...(await updateCalendar(tx, domain, user, (await calendarInDomain(tx, domain, patch.id)).id, patch)), cuFlag: 'M' })\n }\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete calendars that hold no events or series' })\n deleteCalendars(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n return deleteCalendars(tx, domain, user, ids)\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { Domain, ListParam } from '@things-factory/shell';
2
1
  import { User } from '@things-factory/auth-base';
2
+ import { Domain, ListParam } from '@things-factory/shell';
3
3
  import { Calendar } from './calendar';
4
4
  import { CalendarList } from './calendar-type';
5
5
  export declare class CalendarQuery {
@@ -3,41 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CalendarQuery = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
- const shell_1 = require("@things-factory/shell");
7
6
  const auth_base_1 = require("@things-factory/auth-base");
7
+ const shell_1 = require("@things-factory/shell");
8
8
  const calendar_1 = require("./calendar");
9
9
  const calendar_type_1 = require("./calendar-type");
10
10
  let CalendarQuery = class CalendarQuery {
11
- async calendar(id, context) {
12
- const { domain } = context.state;
13
- return await (0, shell_1.getRepository)(calendar_1.Calendar).findOne({
14
- where: { domain: { id: domain.id }, id }
15
- });
11
+ calendar(id, context) {
12
+ return (0, shell_1.getRepository)(calendar_1.Calendar).findOne({ where: { domain: { id: context.state.domain.id }, id } });
16
13
  }
17
14
  async calendars(params, context) {
18
- const { domain } = context.state;
19
15
  const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
20
- domain,
16
+ domain: context.state.domain,
21
17
  params,
22
- repository: await (0, shell_1.getRepository)(calendar_1.Calendar),
18
+ repository: (0, shell_1.getRepository)(calendar_1.Calendar),
23
19
  searchables: ['name', 'description']
24
20
  });
25
21
  const [items, total] = await queryBuilder.getManyAndCount();
26
22
  return { items, total };
27
23
  }
28
- async domain(calendar) {
29
- return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: calendar.domainId });
24
+ domain(calendar) {
25
+ return (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: calendar.domainId });
30
26
  }
31
- async updater(calendar) {
32
- return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: calendar.updaterId });
27
+ updater(calendar) {
28
+ return calendar.updaterId ? (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: calendar.updaterId }) : null;
33
29
  }
34
- async creator(calendar) {
35
- return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: calendar.creatorId });
30
+ creator(calendar) {
31
+ return calendar.creatorId ? (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: calendar.creatorId }) : null;
36
32
  }
37
33
  };
38
34
  exports.CalendarQuery = CalendarQuery;
39
35
  tslib_1.__decorate([
40
- (0, type_graphql_1.Query)(returns => calendar_1.Calendar, { nullable: true, description: 'To fetch a Calendar' }),
36
+ (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "query", domainOwnerGranted: true)'),
37
+ (0, type_graphql_1.Query)(returns => calendar_1.Calendar, { nullable: true, description: 'To fetch a calendar' }),
41
38
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
42
39
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
43
40
  tslib_1.__metadata("design:type", Function),
@@ -45,7 +42,8 @@ tslib_1.__decorate([
45
42
  tslib_1.__metadata("design:returntype", Promise)
46
43
  ], CalendarQuery.prototype, "calendar", null);
47
44
  tslib_1.__decorate([
48
- (0, type_graphql_1.Query)(returns => calendar_type_1.CalendarList, { description: 'To fetch multiple Calendars' }),
45
+ (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "query", domainOwnerGranted: true)'),
46
+ (0, type_graphql_1.Query)(returns => calendar_type_1.CalendarList, { description: 'To fetch a page of calendars' }),
49
47
  tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
50
48
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
51
49
  tslib_1.__metadata("design:type", Function),
@@ -1 +1 @@
1
- {"version":3,"file":"calendar-query.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,iDAAuG;AACvG,yDAAgD;AAChD,yCAAqC;AACrC,mDAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;IAElB,AAAN,KAAK,CAAC,QAAQ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Q,CAAC,SAAS,EAAE,CAAC,CAAA;IACxE,CAAC;CACF,CAAA;AAxCY,sCAAa;AAElB;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACpE,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6CAM3C;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAY,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IAC9D,mBAAA,IAAA,mBAAI,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;8CAazD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;2CAEtC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;wBAvCU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CAwCzB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Calendar } from './calendar'\nimport { CalendarList } from './calendar-type'\n\n@Resolver(Calendar)\nexport class CalendarQuery {\n @Query(returns => Calendar!, { nullable: true, description: 'To fetch a Calendar' })\n async calendar(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Calendar> {\n const { domain } = context.state\n\n return await getRepository(Calendar).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => CalendarList, { description: 'To fetch multiple Calendars' })\n async calendars(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CalendarList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Calendar),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() calendar: Calendar): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: calendar.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() calendar: Calendar): Promise<User> {\n return await getRepository(User).findOneBy({ id: calendar.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() calendar: Calendar): Promise<User> {\n return await getRepository(User).findOneBy({ id: calendar.creatorId })\n }\n}\n"]}
1
+ {"version":3,"file":"calendar-query.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAAgD;AAChD,iDAAuG;AAEvG,yCAAqC;AACrC,mDAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;IAGxB,QAAQ,CAAY,EAAU,EAAS,OAAwB;QAC7D,OAAO,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACpG,CAAC;IAIK,AAAN,KAAK,CAAC,SAAS,CAA0B,MAAiB,EAAS,OAAwB;QACzF,MAAM,YAAY,GAAG,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ErC;AAIK;IAFL,IAAA,wBAAS,EAAC,gFAAgF,CAAC;IAC3F,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAY,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC/D,mBAAA,IAAA,mBAAI,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;8CASzD;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACtB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;2CAEhC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACnB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEjC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACnB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEjC;wBAjCU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CAkCzB","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Calendar } from './calendar'\nimport { CalendarList } from './calendar-type'\n\n@Resolver(Calendar)\nexport class CalendarQuery {\n @Directive('@privilege(category: \"calendar\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Calendar, { nullable: true, description: 'To fetch a calendar' })\n calendar(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Calendar> {\n return getRepository(Calendar).findOne({ where: { domain: { id: context.state.domain.id }, id } })\n }\n\n @Directive('@privilege(category: \"calendar\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => CalendarList, { description: 'To fetch a page of calendars' })\n async calendars(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CalendarList> {\n const queryBuilder = getQueryBuilderFromListParams({\n domain: context.state.domain,\n params,\n repository: getRepository(Calendar),\n searchables: ['name', 'description']\n })\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n domain(@Root() calendar: Calendar): Promise<Domain> {\n return getRepository(Domain).findOneBy({ id: calendar.domainId })\n }\n\n @FieldResolver(type => User)\n updater(@Root() calendar: Calendar): Promise<User> {\n return calendar.updaterId ? getRepository(User).findOneBy({ id: calendar.updaterId }) : null\n }\n\n @FieldResolver(type => User)\n creator(@Root() calendar: Calendar): Promise<User> {\n return calendar.creatorId ? getRepository(User).findOneBy({ id: calendar.creatorId }) : null\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { Domain } from '@things-factory/shell';
4
+ import { Calendar } from './calendar';
5
+ import { CalendarPatch, NewCalendar } from './calendar-type';
6
+ export declare function calendarInDomain(tx: EntityManager, domain: Domain, id: string): Promise<Calendar>;
7
+ export declare function createCalendar(tx: EntityManager, domain: Domain, user: User, input: NewCalendar): Promise<Calendar>;
8
+ export declare function updateCalendar(tx: EntityManager, domain: Domain, user: User, id: string, patch: CalendarPatch): Promise<Calendar>;
9
+ /** A calendar that still holds events or series is not deleted; they would lose their place. */
10
+ export declare function deleteCalendars(tx: EntityManager, domain: Domain, user: User, ids: string[]): Promise<boolean>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calendarInDomain = calendarInDomain;
4
+ exports.createCalendar = createCalendar;
5
+ exports.updateCalendar = updateCalendar;
6
+ exports.deleteCalendars = deleteCalendars;
7
+ const typeorm_1 = require("typeorm");
8
+ const shell_1 = require("@things-factory/shell");
9
+ const event_1 = require("../event/event");
10
+ const event_series_1 = require("../event-series/event-series");
11
+ const calendar_1 = require("./calendar");
12
+ async function calendarInDomain(tx, domain, id) {
13
+ const calendar = await tx.getRepository(calendar_1.Calendar).findOne({ where: { id, domain: { id: domain.id } } });
14
+ if (!calendar)
15
+ throw new shell_1.Refusal('calendar-not-found', {}, 'Choose a calendar of this domain');
16
+ return calendar;
17
+ }
18
+ async function checkCalendarName(tx, domain, name, id) {
19
+ const trimmed = name?.trim();
20
+ if (!trimmed)
21
+ throw new shell_1.Refusal('calendar-name-required', {}, 'Name the calendar');
22
+ const same = await tx.getRepository(calendar_1.Calendar).findOne({ where: { domain: { id: domain.id }, name: trimmed, ...(id ? { id: (0, typeorm_1.Not)(id) } : {}) } });
23
+ if (same)
24
+ throw new shell_1.Refusal('calendar-name-duplicate', { name: trimmed }, 'Another calendar of this domain has that name');
25
+ return trimmed;
26
+ }
27
+ async function createCalendar(tx, domain, user, input) {
28
+ const name = await checkCalendarName(tx, domain, input.name);
29
+ const repository = tx.getRepository(calendar_1.Calendar);
30
+ const saved = await repository.save(repository.create({ domain, name, description: input.description?.trim() || null, active: input.active ?? true, creator: user, updater: user }));
31
+ return calendarInDomain(tx, domain, saved.id);
32
+ }
33
+ async function updateCalendar(tx, domain, user, id, patch) {
34
+ const calendar = await calendarInDomain(tx, domain, id);
35
+ const change = { updater: user };
36
+ if (patch.name !== undefined)
37
+ change.name = await checkCalendarName(tx, domain, patch.name, calendar.id);
38
+ if (patch.description !== undefined)
39
+ change.description = patch.description?.trim() || null;
40
+ if (patch.active !== undefined && patch.active !== null)
41
+ change.active = patch.active;
42
+ await tx.getRepository(calendar_1.Calendar).update({ id: calendar.id }, change);
43
+ return calendarInDomain(tx, domain, id);
44
+ }
45
+ /** A calendar that still holds events or series is not deleted; they would lose their place. */
46
+ async function deleteCalendars(tx, domain, user, ids) {
47
+ const calendars = await tx.getRepository(calendar_1.Calendar).find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(ids) } });
48
+ if (calendars.length !== new Set(ids).size)
49
+ throw new shell_1.Refusal('calendar-not-found', {}, 'Choose a calendar of this domain');
50
+ const used = (await tx.getRepository(event_1.Event).count({ where: { domain: { id: domain.id }, calendar: { id: (0, typeorm_1.In)(ids) } } })) +
51
+ (await tx.getRepository(event_series_1.EventSeries).count({ where: { domain: { id: domain.id }, calendar: { id: (0, typeorm_1.In)(ids) } } }));
52
+ if (used)
53
+ throw new shell_1.Refusal('calendar-in-use', {}, 'Move or delete the events and series of the calendar first');
54
+ await tx.getRepository(calendar_1.Calendar).update({ id: (0, typeorm_1.In)(ids) }, { updater: user });
55
+ await tx.getRepository(calendar_1.Calendar).softDelete({ id: (0, typeorm_1.In)(ids) });
56
+ return true;
57
+ }
58
+ //# sourceMappingURL=calendar-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-service.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-service.ts"],"names":[],"mappings":";;AAUA,4CAIC;AAUD,wCAOC;AAED,wCAQC;AAGD,0CAUC;AAtDD,qCAAgD;AAGhD,iDAAuD;AAEvD,0CAAsC;AACtC,+DAA0D;AAC1D,yCAAqC;AAG9B,KAAK,UAAU,gBAAgB,CAAC,EAAiB,EAAE,MAAc,EAAE,EAAU;IAClF,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACvG,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,eAAO,CAAC,oBAAoB,EAAE,EAAE,EAAE,kCAAkC,CAAC,CAAA;IAC9F,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,EAAiB,EAAE,MAAc,EAAE,IAAwB,EAAE,EAAW;IACvG,MAAM,OAAO,GAAG,IAAI,EA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AAI,SAAS,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI;QAAE,MAAM,IAAI,eAAO,CAAC,oBAAoB,EAAE,EAAE,EAAE,kCAAkC,CAAC,CAAA;IAC3H,MAAM,IAAI,GACR,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,aAAK,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1G,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,0BAAW,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAClH,IAAI,IAAI;QAAE,MAAM,IAAI,eAAO,CAAC,iBAAiB,EAAE,EAAE,EAAE,4DAA4D,CAAC,CAAA;IAChH,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3E,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC5D,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { EntityManager, In, Not } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, Refusal } from '@things-factory/shell'\n\nimport { Event } from '../event/event'\nimport { EventSeries } from '../event-series/event-series'\nimport { Calendar } from './calendar'\nimport { CalendarPatch, NewCalendar } from './calendar-type'\n\nexport async function calendarInDomain(tx: EntityManager, domain: Domain, id: string): Promise<Calendar> {\n const calendar = await tx.getRepository(Calendar).findOne({ where: { id, domain: { id: domain.id } } })\n if (!calendar) throw new Refusal('calendar-not-found', {}, 'Choose a calendar of this domain')\n return calendar\n}\n\nasync function checkCalendarName(tx: EntityManager, domain: Domain, name: string | undefined, id?: string): Promise<string> {\n const trimmed = name?.trim()\n if (!trimmed) throw new Refusal('calendar-name-required', {}, 'Name the calendar')\n const same = await tx.getRepository(Calendar).findOne({ where: { domain: { id: domain.id }, name: trimmed, ...(id ? { id: Not(id) } : {}) } })\n if (same) throw new Refusal('calendar-name-duplicate', { name: trimmed }, 'Another calendar of this domain has that name')\n return trimmed\n}\n\nexport async function createCalendar(tx: EntityManager, domain: Domain, user: User, input: NewCalendar): Promise<Calendar> {\n const name = await checkCalendarName(tx, domain, input.name)\n const repository = tx.getRepository(Calendar)\n const saved = await repository.save(\n repository.create({ domain, name, description: input.description?.trim() || null, active: input.active ?? true, creator: user, updater: user })\n )\n return calendarInDomain(tx, domain, saved.id)\n}\n\nexport async function updateCalendar(tx: EntityManager, domain: Domain, user: User, id: string, patch: CalendarPatch): Promise<Calendar> {\n const calendar = await calendarInDomain(tx, domain, id)\n const change: Partial<Calendar> = { updater: user }\n if (patch.name !== undefined) change.name = await checkCalendarName(tx, domain, patch.name, calendar.id)\n if (patch.description !== undefined) change.description = patch.description?.trim() || null\n if (patch.active !== undefined && patch.active !== null) change.active = patch.active\n await tx.getRepository(Calendar).update({ id: calendar.id }, change)\n return calendarInDomain(tx, domain, id)\n}\n\n/** A calendar that still holds events or series is not deleted; they would lose their place. */\nexport async function deleteCalendars(tx: EntityManager, domain: Domain, user: User, ids: string[]): Promise<boolean> {\n const calendars = await tx.getRepository(Calendar).find({ where: { domain: { id: domain.id }, id: In(ids) } })\n if (calendars.length !== new Set(ids).size) throw new Refusal('calendar-not-found', {}, 'Choose a calendar of this domain')\n const used =\n (await tx.getRepository(Event).count({ where: { domain: { id: domain.id }, calendar: { id: In(ids) } } })) +\n (await tx.getRepository(EventSeries).count({ where: { domain: { id: domain.id }, calendar: { id: In(ids) } } }))\n if (used) throw new Refusal('calendar-in-use', {}, 'Move or delete the events and series of the calendar first')\n await tx.getRepository(Calendar).update({ id: In(ids) }, { updater: user })\n await tx.getRepository(Calendar).softDelete({ id: In(ids) })\n return true\n}\n"]}
@@ -1,16 +1,13 @@
1
- import { Calendar, CalendarStatus } from './calendar';
1
+ import { Calendar } from './calendar';
2
2
  export declare class NewCalendar {
3
3
  name: string;
4
4
  description?: string;
5
- state?: CalendarStatus;
6
5
  active?: boolean;
7
- params?: string;
8
6
  }
9
7
  export declare class CalendarPatch {
10
8
  id?: string;
11
9
  name?: string;
12
10
  description?: string;
13
- state?: CalendarStatus;
14
11
  active?: boolean;
15
12
  cuFlag?: string;
16
13
  }
@@ -8,70 +8,58 @@ let NewCalendar = class NewCalendar {
8
8
  };
9
9
  exports.NewCalendar = NewCalendar;
10
10
  tslib_1.__decorate([
11
- (0, type_graphql_1.Field)(),
11
+ (0, type_graphql_1.Field)({ description: 'Name of the calendar, unique in the domain' }),
12
12
  tslib_1.__metadata("design:type", String)
13
13
  ], NewCalendar.prototype, "name", void 0);
14
14
  tslib_1.__decorate([
15
- (0, type_graphql_1.Field)({ nullable: true }),
15
+ (0, type_graphql_1.Field)({ nullable: true, description: 'What the calendar is for' }),
16
16
  tslib_1.__metadata("design:type", String)
17
17
  ], NewCalendar.prototype, "description", void 0);
18
18
  tslib_1.__decorate([
19
- (0, type_graphql_1.Field)(type => calendar_1.CalendarStatus, { nullable: true }),
20
- tslib_1.__metadata("design:type", String)
21
- ], NewCalendar.prototype, "state", void 0);
22
- tslib_1.__decorate([
23
- (0, type_graphql_1.Field)({ nullable: true }),
19
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Whether the calendar is in use; true when empty' }),
24
20
  tslib_1.__metadata("design:type", Boolean)
25
21
  ], NewCalendar.prototype, "active", void 0);
26
- tslib_1.__decorate([
27
- (0, type_graphql_1.Field)({ nullable: true }),
28
- tslib_1.__metadata("design:type", String)
29
- ], NewCalendar.prototype, "params", void 0);
30
22
  exports.NewCalendar = NewCalendar = tslib_1.__decorate([
31
- (0, type_graphql_1.InputType)()
23
+ (0, type_graphql_1.InputType)({ description: 'A calendar to create' })
32
24
  ], NewCalendar);
33
25
  let CalendarPatch = class CalendarPatch {
34
26
  };
35
27
  exports.CalendarPatch = CalendarPatch;
36
28
  tslib_1.__decorate([
37
- (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
29
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'Id of the calendar, for a grid row' }),
38
30
  tslib_1.__metadata("design:type", String)
39
31
  ], CalendarPatch.prototype, "id", void 0);
40
32
  tslib_1.__decorate([
41
- (0, type_graphql_1.Field)({ nullable: true }),
33
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Name of the calendar, unique in the domain' }),
42
34
  tslib_1.__metadata("design:type", String)
43
35
  ], CalendarPatch.prototype, "name", void 0);
44
36
  tslib_1.__decorate([
45
- (0, type_graphql_1.Field)({ nullable: true }),
37
+ (0, type_graphql_1.Field)({ nullable: true, description: 'What the calendar is for' }),
46
38
  tslib_1.__metadata("design:type", String)
47
39
  ], CalendarPatch.prototype, "description", void 0);
48
40
  tslib_1.__decorate([
49
- (0, type_graphql_1.Field)(type => calendar_1.CalendarStatus, { nullable: true }),
50
- tslib_1.__metadata("design:type", String)
51
- ], CalendarPatch.prototype, "state", void 0);
52
- tslib_1.__decorate([
53
- (0, type_graphql_1.Field)({ nullable: true }),
41
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Whether the calendar is in use' }),
54
42
  tslib_1.__metadata("design:type", Boolean)
55
43
  ], CalendarPatch.prototype, "active", void 0);
56
44
  tslib_1.__decorate([
57
- (0, type_graphql_1.Field)({ nullable: true }),
45
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Grid row flag: + to create, M to modify' }),
58
46
  tslib_1.__metadata("design:type", String)
59
47
  ], CalendarPatch.prototype, "cuFlag", void 0);
60
48
  exports.CalendarPatch = CalendarPatch = tslib_1.__decorate([
61
- (0, type_graphql_1.InputType)()
49
+ (0, type_graphql_1.InputType)({ description: 'What changes on a calendar; a grid row carries its id and cuFlag' })
62
50
  ], CalendarPatch);
63
51
  let CalendarList = class CalendarList {
64
52
  };
65
53
  exports.CalendarList = CalendarList;
66
54
  tslib_1.__decorate([
67
- (0, type_graphql_1.Field)(type => [calendar_1.Calendar]),
55
+ (0, type_graphql_1.Field)(type => [calendar_1.Calendar], { description: 'The calendars on this page' }),
68
56
  tslib_1.__metadata("design:type", Array)
69
57
  ], CalendarList.prototype, "items", void 0);
70
58
  tslib_1.__decorate([
71
- (0, type_graphql_1.Field)(type => type_graphql_1.Int),
59
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'How many calendars match in all' }),
72
60
  tslib_1.__metadata("design:type", Number)
73
61
  ], CalendarList.prototype, "total", void 0);
74
62
  exports.CalendarList = CalendarList = tslib_1.__decorate([
75
- (0, type_graphql_1.ObjectType)()
63
+ (0, type_graphql_1.ObjectType)({ description: 'A page of calendars' })
76
64
  ], CalendarList);
77
65
  //# sourceMappingURL=calendar-type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"calendar-type.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-type.ts"],"names":[],"mappings":";;;;AAEA,+CAAsF;AAItF,yCAAqD;AAG9C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAevB,CAAA;AAfY,kCAAW;AAEtB;IADC,IAAA,oBAAK,GAAE;;yCACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,yBAAc,EAAE,EAAE,QAAQ,EAAE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LUpload from 'graphql-upload/GraphQLUpload.js'\nimport { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Calendar, CalendarStatus } from './calendar'\n\n@InputType()\nexport class NewCalendar {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => CalendarStatus, { nullable: true })\n state?: CalendarStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n}\n\n@InputType()\nexport class CalendarPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => CalendarStatus, { nullable: true })\n state?: CalendarStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class CalendarList {\n @Field(type => [Calendar])\n items: Calendar[]\n\n @Field(type => Int)\n total: number\n}\n"]}
1
+ {"version":3,"file":"calendar-type.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yCAAqC;AAG9B,IAAM,WAAW,GAAjB,MAAM,WAAW;CASvB,CAAA;AATY,kCAAW;AAEtB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;;yCACzD;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;;gDAC/C;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;;2CAC1E;sBARL,WAAW;IADvB,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;GACtC,WAAW,CASvB;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;CAezB,CAAA;AAfY,sCAAa;AAExB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;;yCAC9E;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;;2CACxE;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;;kDAC/C;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;6CACzD;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;6CACnE;wBAdJ,aAAa;IADzB,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,kEAAkE,EAAE,CAAC;GAClF,aAAa,CAezB;AAGM,IAAM,YAAY,GAAlB,MAAM,YAAY;CAMxB,CAAA;AANY,oCAAY;AAEvB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;;2CACxD;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE,CAAC;;2CAC1D;uBALF,YAAY;IADxB,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;GACtC,YAAY,CAMxB","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Calendar } from './calendar'\n\n@InputType({ description: 'A calendar to create' })\nexport class NewCalendar {\n @Field({ description: 'Name of the calendar, unique in the domain' })\n name: string\n\n @Field({ nullable: true, description: 'What the calendar is for' })\n description?: string\n\n @Field({ nullable: true, description: 'Whether the calendar is in use; true when empty' })\n active?: boolean\n}\n\n@InputType({ description: 'What changes on a calendar; a grid row carries its id and cuFlag' })\nexport class CalendarPatch {\n @Field(type => ID, { nullable: true, description: 'Id of the calendar, for a grid row' })\n id?: string\n\n @Field({ nullable: true, description: 'Name of the calendar, unique in the domain' })\n name?: string\n\n @Field({ nullable: true, description: 'What the calendar is for' })\n description?: string\n\n @Field({ nullable: true, description: 'Whether the calendar is in use' })\n active?: boolean\n\n @Field({ nullable: true, description: 'Grid row flag: + to create, M to modify' })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A page of calendars' })\nexport class CalendarList {\n @Field(type => [Calendar], { description: 'The calendars on this page' })\n items: Calendar[]\n\n @Field(type => Int, { description: 'How many calendars match in all' })\n total: number\n}\n"]}