@webiny/api-record-locking 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.e9333b3f0b

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 (164) hide show
  1. package/RecordLockingAppFeature.d.ts +11 -0
  2. package/RecordLockingAppFeature.js +20 -0
  3. package/RecordLockingAppFeature.js.map +1 -0
  4. package/domain/LockRecord.js +63 -70
  5. package/domain/LockRecord.js.map +1 -1
  6. package/domain/RecordLockingModel.js +27 -23
  7. package/domain/RecordLockingModel.js.map +1 -1
  8. package/domain/abstractions.d.ts +9 -3
  9. package/domain/abstractions.js +3 -7
  10. package/domain/abstractions.js.map +1 -1
  11. package/domain/calculateExpiresOn.js +5 -6
  12. package/domain/calculateExpiresOn.js.map +1 -1
  13. package/domain/errors.js +71 -81
  14. package/domain/errors.js.map +1 -1
  15. package/domain/index.js +0 -2
  16. package/domain/types.js +6 -9
  17. package/domain/types.js.map +1 -1
  18. package/features/GetLockRecord/GetLockRecordRepository.d.ts +4 -3
  19. package/features/GetLockRecord/GetLockRecordRepository.js +33 -25
  20. package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -1
  21. package/features/GetLockRecord/GetLockRecordUseCase.js +13 -10
  22. package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -1
  23. package/features/GetLockRecord/abstractions.js +3 -14
  24. package/features/GetLockRecord/abstractions.js.map +1 -1
  25. package/features/GetLockRecord/feature.js +7 -6
  26. package/features/GetLockRecord/feature.js.map +1 -1
  27. package/features/GetLockRecord/index.js +0 -2
  28. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +19 -28
  29. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
  30. package/features/GetLockedEntryLockRecord/abstractions.js +2 -10
  31. package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -1
  32. package/features/GetLockedEntryLockRecord/feature.js +6 -5
  33. package/features/GetLockedEntryLockRecord/feature.js.map +1 -1
  34. package/features/GetLockedEntryLockRecord/index.js +0 -2
  35. package/features/IsEntryLocked/IsEntryLockedUseCase.js +22 -28
  36. package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
  37. package/features/IsEntryLocked/abstractions.js +2 -9
  38. package/features/IsEntryLocked/abstractions.js.map +1 -1
  39. package/features/IsEntryLocked/feature.js +6 -5
  40. package/features/IsEntryLocked/feature.js.map +1 -1
  41. package/features/IsEntryLocked/index.js +0 -2
  42. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +3 -3
  43. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +27 -33
  44. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
  45. package/features/KickOutCurrentUser/abstractions.js +2 -6
  46. package/features/KickOutCurrentUser/abstractions.js.map +1 -1
  47. package/features/KickOutCurrentUser/feature.js +6 -5
  48. package/features/KickOutCurrentUser/feature.js.map +1 -1
  49. package/features/KickOutCurrentUser/index.js +0 -2
  50. package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +5 -3
  51. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +39 -32
  52. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -1
  53. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +13 -10
  54. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -1
  55. package/features/ListAllLockRecords/abstractions.js +3 -14
  56. package/features/ListAllLockRecords/abstractions.js.map +1 -1
  57. package/features/ListAllLockRecords/feature.js +7 -6
  58. package/features/ListAllLockRecords/feature.js.map +1 -1
  59. package/features/ListAllLockRecords/index.js +0 -2
  60. package/features/ListLockRecords/ListLockRecordsRepository.d.ts +6 -3
  61. package/features/ListLockRecords/ListLockRecordsRepository.js +39 -32
  62. package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -1
  63. package/features/ListLockRecords/ListLockRecordsUseCase.js +26 -23
  64. package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
  65. package/features/ListLockRecords/abstractions.js +3 -14
  66. package/features/ListLockRecords/abstractions.js.map +1 -1
  67. package/features/ListLockRecords/feature.js +7 -6
  68. package/features/ListLockRecords/feature.js.map +1 -1
  69. package/features/ListLockRecords/index.js +0 -2
  70. package/features/LockEntry/LockEntryEventsDecorator.js +31 -31
  71. package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
  72. package/features/LockEntry/LockEntryRepository.d.ts +4 -3
  73. package/features/LockEntry/LockEntryRepository.js +35 -31
  74. package/features/LockEntry/LockEntryRepository.js.map +1 -1
  75. package/features/LockEntry/LockEntryUseCase.js +21 -26
  76. package/features/LockEntry/LockEntryUseCase.js.map +1 -1
  77. package/features/LockEntry/abstractions.js +3 -14
  78. package/features/LockEntry/abstractions.js.map +1 -1
  79. package/features/LockEntry/events.js +25 -33
  80. package/features/LockEntry/events.js.map +1 -1
  81. package/features/LockEntry/feature.js +8 -7
  82. package/features/LockEntry/feature.js.map +1 -1
  83. package/features/LockEntry/index.js +0 -2
  84. package/features/RecordLockingFeature.d.ts +0 -5
  85. package/features/RecordLockingFeature.js +21 -22
  86. package/features/RecordLockingFeature.js.map +1 -1
  87. package/features/RecordLockingModelProvider.d.ts +18 -0
  88. package/features/RecordLockingModelProvider.js +22 -0
  89. package/features/RecordLockingModelProvider.js.map +1 -0
  90. package/features/UnlockEntry/UnlockEntryEventsDecorator.js +32 -32
  91. package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
  92. package/features/UnlockEntry/UnlockEntryRepository.d.ts +3 -3
  93. package/features/UnlockEntry/UnlockEntryRepository.js +31 -28
  94. package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -1
  95. package/features/UnlockEntry/UnlockEntryUseCase.js +53 -69
  96. package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
  97. package/features/UnlockEntry/abstractions.js +3 -14
  98. package/features/UnlockEntry/abstractions.js.map +1 -1
  99. package/features/UnlockEntry/events.js +25 -33
  100. package/features/UnlockEntry/events.js.map +1 -1
  101. package/features/UnlockEntry/feature.js +8 -7
  102. package/features/UnlockEntry/feature.js.map +1 -1
  103. package/features/UnlockEntry/hasFullAccessPermission.js +6 -7
  104. package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
  105. package/features/UnlockEntry/index.js +0 -2
  106. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +31 -31
  107. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
  108. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +3 -3
  109. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +33 -31
  110. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
  111. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +62 -79
  112. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
  113. package/features/UnlockEntryRequest/abstractions.js +3 -14
  114. package/features/UnlockEntryRequest/abstractions.js.map +1 -1
  115. package/features/UnlockEntryRequest/events.js +25 -33
  116. package/features/UnlockEntryRequest/events.js.map +1 -1
  117. package/features/UnlockEntryRequest/feature.js +8 -7
  118. package/features/UnlockEntryRequest/feature.js.map +1 -1
  119. package/features/UnlockEntryRequest/index.js +0 -2
  120. package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +4 -3
  121. package/features/UpdateEntryLock/UpdateEntryLockRepository.js +47 -49
  122. package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
  123. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +40 -51
  124. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
  125. package/features/UpdateEntryLock/abstractions.js +3 -14
  126. package/features/UpdateEntryLock/abstractions.js.map +1 -1
  127. package/features/UpdateEntryLock/feature.js +7 -6
  128. package/features/UpdateEntryLock/feature.js.map +1 -1
  129. package/features/UpdateEntryLock/index.js +0 -2
  130. package/graphql/RecordLockingGraphQLSchema.d.ts +25 -0
  131. package/graphql/RecordLockingGraphQLSchema.js +390 -0
  132. package/graphql/RecordLockingGraphQLSchema.js.map +1 -0
  133. package/graphql/checkPermissions.d.ts +3 -3
  134. package/graphql/checkPermissions.js +4 -10
  135. package/graphql/checkPermissions.js.map +1 -1
  136. package/graphql/resolve.d.ts +1 -1
  137. package/graphql/resolve.js +16 -18
  138. package/graphql/resolve.js.map +1 -1
  139. package/index.d.ts +2 -9
  140. package/index.js +1 -63
  141. package/package.json +23 -21
  142. package/types.js +6 -9
  143. package/types.js.map +1 -1
  144. package/utils/convertWhereCondition.js +20 -32
  145. package/utils/convertWhereCondition.js.map +1 -1
  146. package/utils/getTimeout.js +8 -15
  147. package/utils/getTimeout.js.map +1 -1
  148. package/utils/lockRecordDatabaseId.js +6 -11
  149. package/utils/lockRecordDatabaseId.js.map +1 -1
  150. package/domain/index.js.map +0 -1
  151. package/features/GetLockRecord/index.js.map +0 -1
  152. package/features/GetLockedEntryLockRecord/index.js.map +0 -1
  153. package/features/IsEntryLocked/index.js.map +0 -1
  154. package/features/KickOutCurrentUser/index.js.map +0 -1
  155. package/features/ListAllLockRecords/index.js.map +0 -1
  156. package/features/ListLockRecords/index.js.map +0 -1
  157. package/features/LockEntry/index.js.map +0 -1
  158. package/features/UnlockEntry/index.js.map +0 -1
  159. package/features/UnlockEntryRequest/index.js.map +0 -1
  160. package/features/UpdateEntryLock/index.js.map +0 -1
  161. package/graphql/schema.d.ts +0 -11
  162. package/graphql/schema.js +0 -315
  163. package/graphql/schema.js.map +0 -1
  164. package/index.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-record-locking",
3
- "version": "0.0.0-unstable.e6f0dc8ca7",
3
+ "version": "0.0.0-unstable.e9333b3f0b",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -16,30 +16,32 @@
16
16
  ],
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@webiny/api": "0.0.0-unstable.e6f0dc8ca7",
20
- "@webiny/api-headless-cms": "0.0.0-unstable.e6f0dc8ca7",
21
- "@webiny/api-websockets": "0.0.0-unstable.e6f0dc8ca7",
22
- "@webiny/feature": "0.0.0-unstable.e6f0dc8ca7",
23
- "@webiny/handler": "0.0.0-unstable.e6f0dc8ca7",
24
- "@webiny/handler-aws": "0.0.0-unstable.e6f0dc8ca7",
25
- "@webiny/handler-graphql": "0.0.0-unstable.e6f0dc8ca7",
26
- "@webiny/plugins": "0.0.0-unstable.e6f0dc8ca7",
27
- "@webiny/utils": "0.0.0-unstable.e6f0dc8ca7"
19
+ "@webiny/api": "0.0.0-unstable.e9333b3f0b",
20
+ "@webiny/api-graphql": "0.0.0-unstable.e9333b3f0b",
21
+ "@webiny/api-headless-cms": "0.0.0-unstable.e9333b3f0b",
22
+ "@webiny/api-websockets": "0.0.0-unstable.e9333b3f0b",
23
+ "@webiny/feature": "0.0.0-unstable.e9333b3f0b",
24
+ "@webiny/handler": "0.0.0-unstable.e9333b3f0b",
25
+ "@webiny/utils": "0.0.0-unstable.e9333b3f0b"
28
26
  },
29
27
  "devDependencies": {
30
- "@webiny/api-core": "0.0.0-unstable.e6f0dc8ca7",
31
- "@webiny/build-tools": "0.0.0-unstable.e6f0dc8ca7",
32
- "@webiny/project-utils": "0.0.0-unstable.e6f0dc8ca7",
33
- "@webiny/wcp": "0.0.0-unstable.e6f0dc8ca7",
34
- "graphql": "16.14.0",
28
+ "@webiny/api-core": "0.0.0-unstable.e9333b3f0b",
29
+ "@webiny/api-core-testing": "0.0.0-unstable.e9333b3f0b",
30
+ "@webiny/build-tools": "0.0.0-unstable.e9333b3f0b",
31
+ "@webiny/di": "1.1.0",
32
+ "@webiny/event-handler-core": "0.0.0-unstable.e9333b3f0b",
33
+ "@webiny/wcp": "0.0.0-unstable.e9333b3f0b",
34
+ "graphql": "16.14.2",
35
35
  "rimraf": "6.1.3",
36
- "type-fest": "5.6.0",
37
- "typescript": "6.0.3",
38
- "vitest": "4.1.5"
36
+ "type-fest": "5.8.0",
37
+ "typescript": "7.0.2",
38
+ "vitest": "4.1.11"
39
39
  },
40
40
  "publishConfig": {
41
- "access": "public",
42
- "directory": "dist"
41
+ "access": "public"
43
42
  },
44
- "gitHead": "e6f0dc8ca741c1fcc3fec9a5b9e86fdd49544641"
43
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
44
+ "webiny": {
45
+ "publishFrom": "dist"
46
+ }
45
47
  }
package/types.js CHANGED
@@ -1,12 +1,9 @@
1
- export let RecordLockingLockRecordActionType = /*#__PURE__*/function (RecordLockingLockRecordActionType) {
2
- RecordLockingLockRecordActionType["requested"] = "requested";
3
- RecordLockingLockRecordActionType["approved"] = "approved";
4
- RecordLockingLockRecordActionType["denied"] = "denied";
5
- return RecordLockingLockRecordActionType;
1
+ var types_RecordLockingLockRecordActionType = /*#__PURE__*/ function(RecordLockingLockRecordActionType) {
2
+ RecordLockingLockRecordActionType["requested"] = "requested";
3
+ RecordLockingLockRecordActionType["approved"] = "approved";
4
+ RecordLockingLockRecordActionType["denied"] = "denied";
5
+ return RecordLockingLockRecordActionType;
6
6
  }({});
7
-
8
- /**
9
- * Do not use any special chars other than #, as we use this to create lock record IDs.
10
- */
7
+ export { types_RecordLockingLockRecordActionType as RecordLockingLockRecordActionType };
11
8
 
12
9
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["RecordLockingLockRecordActionType"],"sources":["types.ts"],"sourcesContent":["import type {\n CmsEntryListParams,\n CmsEntryMeta,\n CmsIdentity\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntry, CmsError } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport type { CmsError, CmsEntry };\n\nexport type IRecordLockingIdentity = CmsIdentity;\n\nexport type IRecordLockingMeta = CmsEntryMeta;\n\nexport enum RecordLockingLockRecordActionType {\n requested = \"requested\",\n approved = \"approved\",\n denied = \"denied\"\n}\n\nexport interface IRecordLockingLockRecordRequestedAction {\n type: RecordLockingLockRecordActionType.requested;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport interface IRecordLockingLockRecordApprovedAction {\n type: RecordLockingLockRecordActionType.approved;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport interface IRecordLockingLockRecordDeniedAction {\n type: RecordLockingLockRecordActionType.denied;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport type IRecordLockingLockRecordAction =\n | IRecordLockingLockRecordRequestedAction\n | IRecordLockingLockRecordApprovedAction\n | IRecordLockingLockRecordDeniedAction;\n\nexport interface IRecordLockingLockRecordObject {\n id: string;\n targetId: string;\n type: IRecordLockingLockRecordEntryType;\n lockedBy: IRecordLockingIdentity;\n lockedOn: Date;\n updatedOn: Date;\n expiresOn: Date;\n actions?: IRecordLockingLockRecordAction[];\n}\n\nexport interface IRecordLockingLockRecord extends IRecordLockingLockRecordObject {\n toObject(): IRecordLockingLockRecordObject;\n addAction(action: IRecordLockingLockRecordAction): void;\n getUnlockRequested(): IRecordLockingLockRecordRequestedAction | undefined;\n getUnlockApproved(): IRecordLockingLockRecordApprovedAction | undefined;\n getUnlockDenied(): IRecordLockingLockRecordDeniedAction | undefined;\n isExpired(): boolean;\n}\n\n/**\n * Do not use any special chars other than #, as we use this to create lock record IDs.\n */\nexport type IRecordLockingLockRecordEntryType = string;\n\nexport type IRecordLockingListAllLockRecordsParams = Pick<\n CmsEntryListParams,\n \"where\" | \"limit\" | \"sort\" | \"after\"\n>;\n\nexport type IRecordLockingListLockRecordsParams = IRecordLockingListAllLockRecordsParams;\n"],"mappings":"AAaA,WAAYA,iCAAiC,0BAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAA,OAAjCA,iCAAiC;AAAA;;AAoD7C;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n CmsEntryListParams,\n CmsEntryMeta,\n CmsIdentity\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntry, CmsError } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport type { CmsError, CmsEntry };\n\nexport type IRecordLockingIdentity = CmsIdentity;\n\nexport type IRecordLockingMeta = CmsEntryMeta;\n\nexport enum RecordLockingLockRecordActionType {\n requested = \"requested\",\n approved = \"approved\",\n denied = \"denied\"\n}\n\nexport interface IRecordLockingLockRecordRequestedAction {\n type: RecordLockingLockRecordActionType.requested;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport interface IRecordLockingLockRecordApprovedAction {\n type: RecordLockingLockRecordActionType.approved;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport interface IRecordLockingLockRecordDeniedAction {\n type: RecordLockingLockRecordActionType.denied;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport type IRecordLockingLockRecordAction =\n | IRecordLockingLockRecordRequestedAction\n | IRecordLockingLockRecordApprovedAction\n | IRecordLockingLockRecordDeniedAction;\n\nexport interface IRecordLockingLockRecordObject {\n id: string;\n targetId: string;\n type: IRecordLockingLockRecordEntryType;\n lockedBy: IRecordLockingIdentity;\n lockedOn: Date;\n updatedOn: Date;\n expiresOn: Date;\n actions?: IRecordLockingLockRecordAction[];\n}\n\nexport interface IRecordLockingLockRecord extends IRecordLockingLockRecordObject {\n toObject(): IRecordLockingLockRecordObject;\n addAction(action: IRecordLockingLockRecordAction): void;\n getUnlockRequested(): IRecordLockingLockRecordRequestedAction | undefined;\n getUnlockApproved(): IRecordLockingLockRecordApprovedAction | undefined;\n getUnlockDenied(): IRecordLockingLockRecordDeniedAction | undefined;\n isExpired(): boolean;\n}\n\n/**\n * Do not use any special chars other than #, as we use this to create lock record IDs.\n */\nexport type IRecordLockingLockRecordEntryType = string;\n\nexport type IRecordLockingListAllLockRecordsParams = Pick<\n CmsEntryListParams,\n \"where\" | \"limit\" | \"sort\" | \"after\"\n>;\n\nexport type IRecordLockingListLockRecordsParams = IRecordLockingListAllLockRecordsParams;\n"],"names":["RecordLockingLockRecordActionType"],"mappings":"AAaO,IAAKA,0CAAiCA,WAAAA,GAAAA,SAAjCA,iCAAiC;;;;WAAjCA"}
@@ -1,38 +1,26 @@
1
1
  import { createLockRecordDatabaseId } from "./lockRecordDatabaseId.js";
2
- const attachPrefix = value => {
3
- if (Array.isArray(value)) {
4
- return value.map(createLockRecordDatabaseId);
5
- }
6
- return createLockRecordDatabaseId(value);
2
+ const attachPrefix = (value)=>{
3
+ if (Array.isArray(value)) return value.map(createLockRecordDatabaseId);
4
+ return createLockRecordDatabaseId(value);
7
5
  };
8
- export const convertWhereCondition = where => {
9
- if (!where) {
10
- return where;
11
- }
12
- for (const key in where) {
13
- if (key.startsWith("AND") || key.startsWith("OR")) {
14
- const value = where[key];
15
- if (!value) {
16
- continue;
17
- }
18
- for (const subKey in value) {
19
- value[subKey] = convertWhereCondition(value[subKey]);
20
- }
21
- continue;
22
- } else if (key.startsWith("id") === false) {
23
- continue;
24
- }
25
- const value = where[key];
26
- if (!value) {
27
- continue;
6
+ const convertWhereCondition = (where)=>{
7
+ if (!where) return where;
8
+ for(const key in where){
9
+ if (key.startsWith("AND") || key.startsWith("OR")) {
10
+ const value = where[key];
11
+ if (!value) continue;
12
+ for(const subKey in value)value[subKey] = convertWhereCondition(value[subKey]);
13
+ continue;
14
+ }
15
+ if (false === key.startsWith("id")) continue;
16
+ const value = where[key];
17
+ if (!value) continue;
18
+ const newKey = key.replace("id", "entryId");
19
+ where[newKey] = attachPrefix(where[key]);
20
+ delete where[key];
28
21
  }
29
- const newKey = key.replace("id", "entryId");
30
- // @ts-expect-error
31
- where[newKey] = attachPrefix(where[key]);
32
- // @ts-expect-error
33
- delete where[key];
34
- }
35
- return where;
22
+ return where;
36
23
  };
24
+ export { convertWhereCondition };
37
25
 
38
26
  //# sourceMappingURL=convertWhereCondition.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createLockRecordDatabaseId","attachPrefix","value","Array","isArray","map","convertWhereCondition","where","key","startsWith","subKey","newKey","replace"],"sources":["convertWhereCondition.ts"],"sourcesContent":["import type { IRecordLockingListLockRecordsParams } from \"~/types.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\ntype IWhere = IRecordLockingListLockRecordsParams[\"where\"] | undefined;\n\nconst attachPrefix = (value: string | string[]) => {\n if (Array.isArray(value)) {\n return value.map(createLockRecordDatabaseId);\n }\n return createLockRecordDatabaseId(value);\n};\n\nexport const convertWhereCondition = (where: IWhere): IWhere => {\n if (!where) {\n return where;\n }\n for (const key in where) {\n if (key.startsWith(\"AND\") || key.startsWith(\"OR\")) {\n const value = where[key as keyof typeof where] as IWhere[] | undefined;\n if (!value) {\n continue;\n }\n for (const subKey in value) {\n value[subKey] = convertWhereCondition(value[subKey]);\n }\n continue;\n } else if (key.startsWith(\"id\") === false) {\n continue;\n }\n const value = where[key as keyof typeof where];\n if (!value) {\n continue;\n }\n\n const newKey = key.replace(\"id\", \"entryId\") as keyof typeof where;\n // @ts-expect-error\n where[newKey] = attachPrefix(where[key]);\n // @ts-expect-error\n delete where[key];\n }\n return where;\n};\n"],"mappings":"AACA,SAASA,0BAA0B;AAInC,MAAMC,YAAY,GAAIC,KAAwB,IAAK;EAC/C,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACG,GAAG,CAACL,0BAA0B,CAAC;EAChD;EACA,OAAOA,0BAA0B,CAACE,KAAK,CAAC;AAC5C,CAAC;AAED,OAAO,MAAMI,qBAAqB,GAAIC,KAAa,IAAa;EAC5D,IAAI,CAACA,KAAK,EAAE;IACR,OAAOA,KAAK;EAChB;EACA,KAAK,MAAMC,GAAG,IAAID,KAAK,EAAE;IACrB,IAAIC,GAAG,CAACC,UAAU,CAAC,KAAK,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE;MAC/C,MAAMP,KAAK,GAAGK,KAAK,CAACC,GAAG,CAA+C;MACtE,IAAI,CAACN,KAAK,EAAE;QACR;MACJ;MACA,KAAK,MAAMQ,MAAM,IAAIR,KAAK,EAAE;QACxBA,KAAK,CAACQ,MAAM,CAAC,GAAGJ,qBAAqB,CAACJ,KAAK,CAACQ,MAAM,CAAC,CAAC;MACxD;MACA;IACJ,CAAC,MAAM,IAAIF,GAAG,CAACC,UAAU,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE;MACvC;IACJ;IACA,MAAMP,KAAK,GAAGK,KAAK,CAACC,GAAG,CAAuB;IAC9C,IAAI,CAACN,KAAK,EAAE;MACR;IACJ;IAEA,MAAMS,MAAM,GAAGH,GAAG,CAACI,OAAO,CAAC,IAAI,EAAE,SAAS,CAAuB;IACjE;IACAL,KAAK,CAACI,MAAM,CAAC,GAAGV,YAAY,CAACM,KAAK,CAACC,GAAG,CAAC,CAAC;IACxC;IACA,OAAOD,KAAK,CAACC,GAAG,CAAC;EACrB;EACA,OAAOD,KAAK;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/convertWhereCondition.js","sources":["../../src/utils/convertWhereCondition.ts"],"sourcesContent":["import type { IRecordLockingListLockRecordsParams } from \"~/types.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\ntype IWhere = IRecordLockingListLockRecordsParams[\"where\"] | undefined;\n\nconst attachPrefix = (value: string | string[]) => {\n if (Array.isArray(value)) {\n return value.map(createLockRecordDatabaseId);\n }\n return createLockRecordDatabaseId(value);\n};\n\nexport const convertWhereCondition = (where: IWhere): IWhere => {\n if (!where) {\n return where;\n }\n for (const key in where) {\n if (key.startsWith(\"AND\") || key.startsWith(\"OR\")) {\n const value = where[key as keyof typeof where] as IWhere[] | undefined;\n if (!value) {\n continue;\n }\n for (const subKey in value) {\n value[subKey] = convertWhereCondition(value[subKey]);\n }\n continue;\n } else if (key.startsWith(\"id\") === false) {\n continue;\n }\n const value = where[key as keyof typeof where];\n if (!value) {\n continue;\n }\n\n const newKey = key.replace(\"id\", \"entryId\") as keyof typeof where;\n // @ts-expect-error\n where[newKey] = attachPrefix(where[key]);\n // @ts-expect-error\n delete where[key];\n }\n return where;\n};\n"],"names":["attachPrefix","value","Array","createLockRecordDatabaseId","convertWhereCondition","where","key","subKey","newKey"],"mappings":";AAKA,MAAMA,eAAe,CAACC;IAClB,IAAIC,MAAM,OAAO,CAACD,QACd,OAAOA,MAAM,GAAG,CAACE;IAErB,OAAOA,2BAA2BF;AACtC;AAEO,MAAMG,wBAAwB,CAACC;IAClC,IAAI,CAACA,OACD,OAAOA;IAEX,IAAK,MAAMC,OAAOD,MAAO;QACrB,IAAIC,IAAI,UAAU,CAAC,UAAUA,IAAI,UAAU,CAAC,OAAO;YAC/C,MAAML,QAAQI,KAAK,CAACC,IAA0B;YAC9C,IAAI,CAACL,OACD;YAEJ,IAAK,MAAMM,UAAUN,MACjBA,KAAK,CAACM,OAAO,GAAGH,sBAAsBH,KAAK,CAACM,OAAO;YAEvD;QACJ;QAAO,IAAID,AAAyB,UAAzBA,IAAI,UAAU,CAAC,OACtB;QAEJ,MAAML,QAAQI,KAAK,CAACC,IAA0B;QAC9C,IAAI,CAACL,OACD;QAGJ,MAAMO,SAASF,IAAI,OAAO,CAAC,MAAM;QAEjCD,KAAK,CAACG,OAAO,GAAGR,aAAaK,KAAK,CAACC,IAAI;QAEvC,OAAOD,KAAK,CAACC,IAAI;IACrB;IACA,OAAOD;AACX"}
@@ -1,21 +1,14 @@
1
1
  const minTimeoutInSeconds = 30;
2
2
  const defaultTimeoutInSeconds = 60;
3
- /**
4
- * Input is in seconds.
5
- * Output is milliseconds.
6
- */
7
- export const getTimeout = input => {
8
- if (input && input > 0) {
9
- if (input < minTimeoutInSeconds) {
10
- return minTimeoutInSeconds * 1000;
3
+ const getTimeout = (input)=>{
4
+ if (input && input > 0) {
5
+ if (input < minTimeoutInSeconds) return 1000 * minTimeoutInSeconds;
6
+ return 1000 * input;
11
7
  }
12
- return input * 1000;
13
- }
14
- const userDefined = process.env.WEBINY_RECORD_LOCK_TIMEOUT ? parseInt(process.env.WEBINY_RECORD_LOCK_TIMEOUT) : undefined;
15
- if (!userDefined || isNaN(userDefined) || userDefined <= 0) {
16
- return defaultTimeoutInSeconds * 1000;
17
- }
18
- return userDefined * 1000;
8
+ const userDefined = process.env.WEBINY_RECORD_LOCK_TIMEOUT ? parseInt(process.env.WEBINY_RECORD_LOCK_TIMEOUT) : void 0;
9
+ if (!userDefined || isNaN(userDefined) || userDefined <= 0) return 1000 * defaultTimeoutInSeconds;
10
+ return 1000 * userDefined;
19
11
  };
12
+ export { getTimeout };
20
13
 
21
14
  //# sourceMappingURL=getTimeout.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["minTimeoutInSeconds","defaultTimeoutInSeconds","getTimeout","input","userDefined","process","env","WEBINY_RECORD_LOCK_TIMEOUT","parseInt","undefined","isNaN"],"sources":["getTimeout.ts"],"sourcesContent":["const minTimeoutInSeconds = 30;\nconst defaultTimeoutInSeconds = 60;\n/**\n * Input is in seconds.\n * Output is milliseconds.\n */\nexport const getTimeout = (input: number | undefined) => {\n if (input && input > 0) {\n if (input < minTimeoutInSeconds) {\n return minTimeoutInSeconds * 1000;\n }\n return input * 1000;\n }\n const userDefined = process.env.WEBINY_RECORD_LOCK_TIMEOUT\n ? parseInt(process.env.WEBINY_RECORD_LOCK_TIMEOUT)\n : undefined;\n if (!userDefined || isNaN(userDefined) || userDefined <= 0) {\n return defaultTimeoutInSeconds * 1000;\n }\n return userDefined * 1000;\n};\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,uBAAuB,GAAG,EAAE;AAClC;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAIC,KAAyB,IAAK;EACrD,IAAIA,KAAK,IAAIA,KAAK,GAAG,CAAC,EAAE;IACpB,IAAIA,KAAK,GAAGH,mBAAmB,EAAE;MAC7B,OAAOA,mBAAmB,GAAG,IAAI;IACrC;IACA,OAAOG,KAAK,GAAG,IAAI;EACvB;EACA,MAAMC,WAAW,GAAGC,OAAO,CAACC,GAAG,CAACC,0BAA0B,GACpDC,QAAQ,CAACH,OAAO,CAACC,GAAG,CAACC,0BAA0B,CAAC,GAChDE,SAAS;EACf,IAAI,CAACL,WAAW,IAAIM,KAAK,CAACN,WAAW,CAAC,IAAIA,WAAW,IAAI,CAAC,EAAE;IACxD,OAAOH,uBAAuB,GAAG,IAAI;EACzC;EACA,OAAOG,WAAW,GAAG,IAAI;AAC7B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/getTimeout.js","sources":["../../src/utils/getTimeout.ts"],"sourcesContent":["const minTimeoutInSeconds = 30;\nconst defaultTimeoutInSeconds = 60;\n/**\n * Input is in seconds.\n * Output is milliseconds.\n */\nexport const getTimeout = (input: number | undefined) => {\n if (input && input > 0) {\n if (input < minTimeoutInSeconds) {\n return minTimeoutInSeconds * 1000;\n }\n return input * 1000;\n }\n const userDefined = process.env.WEBINY_RECORD_LOCK_TIMEOUT\n ? parseInt(process.env.WEBINY_RECORD_LOCK_TIMEOUT)\n : undefined;\n if (!userDefined || isNaN(userDefined) || userDefined <= 0) {\n return defaultTimeoutInSeconds * 1000;\n }\n return userDefined * 1000;\n};\n"],"names":["minTimeoutInSeconds","defaultTimeoutInSeconds","getTimeout","input","userDefined","process","parseInt","undefined","isNaN"],"mappings":"AAAA,MAAMA,sBAAsB;AAC5B,MAAMC,0BAA0B;AAKzB,MAAMC,aAAa,CAACC;IACvB,IAAIA,SAASA,QAAQ,GAAG;QACpB,IAAIA,QAAQH,qBACR,OAAOA,AAAsB,OAAtBA;QAEX,OAAOG,AAAQ,OAARA;IACX;IACA,MAAMC,cAAcC,QAAQ,GAAG,CAAC,0BAA0B,GACpDC,SAASD,QAAQ,GAAG,CAAC,0BAA0B,IAC/CE;IACN,IAAI,CAACH,eAAeI,MAAMJ,gBAAgBA,eAAe,GACrD,OAAOH,AAA0B,OAA1BA;IAEX,OAAOG,AAAc,OAAdA;AACX"}
@@ -1,16 +1,11 @@
1
1
  import { parseIdentifier } from "@webiny/utils";
2
2
  const WBY_LM_PREFIX = "wby-lm-";
3
- export const createLockRecordDatabaseId = input => {
4
- const {
5
- id
6
- } = parseIdentifier(input);
7
- if (id.startsWith(WBY_LM_PREFIX)) {
8
- return id;
9
- }
10
- return `${WBY_LM_PREFIX}${id}`;
11
- };
12
- export const removeLockRecordDatabasePrefix = id => {
13
- return id.replace(WBY_LM_PREFIX, "");
3
+ const createLockRecordDatabaseId = (input)=>{
4
+ const { id } = parseIdentifier(input);
5
+ if (id.startsWith(WBY_LM_PREFIX)) return id;
6
+ return `${WBY_LM_PREFIX}${id}`;
14
7
  };
8
+ const removeLockRecordDatabasePrefix = (id)=>id.replace(WBY_LM_PREFIX, "");
9
+ export { createLockRecordDatabaseId, removeLockRecordDatabasePrefix };
15
10
 
16
11
  //# sourceMappingURL=lockRecordDatabaseId.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["parseIdentifier","WBY_LM_PREFIX","createLockRecordDatabaseId","input","id","startsWith","removeLockRecordDatabasePrefix","replace"],"sources":["lockRecordDatabaseId.ts"],"sourcesContent":["import { parseIdentifier } from \"@webiny/utils\";\n\nconst WBY_LM_PREFIX = \"wby-lm-\";\n\nexport const createLockRecordDatabaseId = (input: string): string => {\n const { id } = parseIdentifier(input);\n if (id.startsWith(WBY_LM_PREFIX)) {\n return id;\n }\n return `${WBY_LM_PREFIX}${id}`;\n};\n\nexport const removeLockRecordDatabasePrefix = (id: string) => {\n return id.replace(WBY_LM_PREFIX, \"\");\n};\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,eAAe;AAE/C,MAAMC,aAAa,GAAG,SAAS;AAE/B,OAAO,MAAMC,0BAA0B,GAAIC,KAAa,IAAa;EACjE,MAAM;IAAEC;EAAG,CAAC,GAAGJ,eAAe,CAACG,KAAK,CAAC;EACrC,IAAIC,EAAE,CAACC,UAAU,CAACJ,aAAa,CAAC,EAAE;IAC9B,OAAOG,EAAE;EACb;EACA,OAAO,GAAGH,aAAa,GAAGG,EAAE,EAAE;AAClC,CAAC;AAED,OAAO,MAAME,8BAA8B,GAAIF,EAAU,IAAK;EAC1D,OAAOA,EAAE,CAACG,OAAO,CAACN,aAAa,EAAE,EAAE,CAAC;AACxC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/lockRecordDatabaseId.js","sources":["../../src/utils/lockRecordDatabaseId.ts"],"sourcesContent":["import { parseIdentifier } from \"@webiny/utils\";\n\nconst WBY_LM_PREFIX = \"wby-lm-\";\n\nexport const createLockRecordDatabaseId = (input: string): string => {\n const { id } = parseIdentifier(input);\n if (id.startsWith(WBY_LM_PREFIX)) {\n return id;\n }\n return `${WBY_LM_PREFIX}${id}`;\n};\n\nexport const removeLockRecordDatabasePrefix = (id: string) => {\n return id.replace(WBY_LM_PREFIX, \"\");\n};\n"],"names":["WBY_LM_PREFIX","createLockRecordDatabaseId","input","id","parseIdentifier","removeLockRecordDatabasePrefix"],"mappings":";AAEA,MAAMA,gBAAgB;AAEf,MAAMC,6BAA6B,CAACC;IACvC,MAAM,EAAEC,EAAE,EAAE,GAAGC,gBAAgBF;IAC/B,IAAIC,GAAG,UAAU,CAACH,gBACd,OAAOG;IAEX,OAAO,GAAGH,gBAAgBG,IAAI;AAClC;AAEO,MAAME,iCAAiC,CAACF,KACpCA,GAAG,OAAO,CAACH,eAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./errors.js\";\nexport * from \"./LockRecord.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["GetLockRecordFeature"],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport { GetLockRecordFeature } from \"./feature.js\";\n"],"mappings":"AAAA;AACA,SAASA,oBAAoB","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./feature.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./feature.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./events.js\";\nexport * from \"./feature.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- import type { IGraphQLSchemaPlugin } from "@webiny/handler-graphql";
2
- import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
3
- import { CmsModel } from "@webiny/api-headless-cms/types/model.js";
4
- import type { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
5
- interface Params {
6
- model: CmsModel;
7
- models: CmsModel[];
8
- fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
9
- }
10
- export declare const createGraphQLSchema: (params: Params) => Promise<IGraphQLSchemaPlugin<ApiCoreContext>>;
11
- export {};
package/graphql/schema.js DELETED
@@ -1,315 +0,0 @@
1
- import { resolve, resolveList } from "./resolve.js";
2
- import { createGraphQLSchemaPlugin } from "@webiny/handler-graphql";
3
- import { renderFields } from "@webiny/api-headless-cms/utils/renderFields.js";
4
- import { renderListFilterFields } from "@webiny/api-headless-cms/utils/renderListFilterFields.js";
5
- import { renderSortEnum } from "@webiny/api-headless-cms/utils/renderSortEnum.js";
6
- import { checkPermissions } from "./checkPermissions.js";
7
- import { IsEntryLockedUseCase } from "../features/IsEntryLocked/abstractions.js";
8
- import { GetLockRecordUseCase } from "../features/GetLockRecord/abstractions.js";
9
- import { GetLockedEntryLockRecordUseCase } from "../features/GetLockedEntryLockRecord/abstractions.js";
10
- import { ListLockRecordsUseCase } from "../features/ListLockRecords/abstractions.js";
11
- import { ListAllLockRecordsUseCase } from "../features/ListAllLockRecords/abstractions.js";
12
- import { LockEntryUseCase } from "../features/LockEntry/abstractions.js";
13
- import { UpdateEntryLockUseCase } from "../features/UpdateEntryLock/abstractions.js";
14
- import { UnlockEntryUseCase } from "../features/UnlockEntry/abstractions.js";
15
- import { UnlockEntryRequestUseCase } from "../features/UnlockEntryRequest/abstractions.js";
16
- export const createGraphQLSchema = async params => {
17
- const model = params.model;
18
- const models = params.models.filter(model => {
19
- return model.fields.length > 0;
20
- });
21
- const fieldRegistry = params.fieldRegistry;
22
- const recordLockingFields = renderFields({
23
- models,
24
- model,
25
- fields: model.fields,
26
- type: "manage",
27
- fieldRegistry
28
- });
29
- const listFilterFieldsRender = renderListFilterFields({
30
- model,
31
- fields: model.fields,
32
- type: "manage",
33
- fieldRegistry,
34
- excludeFields: ["entryId"]
35
- });
36
- const sortEnumRender = renderSortEnum({
37
- model,
38
- fields: model.fields,
39
- fieldRegistry,
40
- sorters: []
41
- });
42
- const plugin = createGraphQLSchemaPlugin({
43
- typeDefs: /* GraphQL */`
44
- ${recordLockingFields.map(f => f.typeDefs).join("\n")}
45
-
46
- type RecordLockingError {
47
- message: String
48
- code: String
49
- data: JSON
50
- stack: String
51
- }
52
-
53
- enum RecordLockingRecordActionType {
54
- requested
55
- approved
56
- denied
57
- }
58
-
59
- type RecordLockingIdentity {
60
- id: String!
61
- displayName: String
62
- type: String
63
- }
64
-
65
- type RecordLockingRecordAction {
66
- id: ID!
67
- type: RecordLockingRecordActionType!
68
- message: String
69
- createdBy: RecordLockingIdentity!
70
- createdOn: DateTime!
71
- }
72
-
73
- type RecordLockingRecord {
74
- id: ID!
75
- lockedBy: RecordLockingIdentity!
76
- lockedOn: DateTime!
77
- updatedOn: DateTime!
78
- expiresOn: DateTime!
79
- ${recordLockingFields.map(f => f.fields).join("\n")}
80
- }
81
-
82
- type RecordLockingIsEntryLockedResponse {
83
- data: Boolean
84
- error: RecordLockingError
85
- }
86
-
87
- type RecordLockingGetLockRecordResponse {
88
- data: RecordLockingRecord
89
- error: RecordLockingError
90
- }
91
-
92
- type RecordLockingGetLockedEntryLockRecordResponse {
93
- data: RecordLockingRecord
94
- error: RecordLockingError
95
- }
96
-
97
- type RecordLockingListLockRecordsResponse {
98
- data: [RecordLockingRecord!]
99
- error: RecordLockingError
100
- }
101
-
102
- type RecordLockingLockEntryResponse {
103
- data: RecordLockingRecord
104
- error: RecordLockingError
105
- }
106
-
107
- type RecordLockingUpdateLockResponse {
108
- data: RecordLockingRecord
109
- error: RecordLockingError
110
- }
111
-
112
- type RecordLockingUnlockEntryResponse {
113
- data: RecordLockingRecord
114
- error: RecordLockingError
115
- }
116
-
117
- type RecordLockingUnlockEntryRequestResponse {
118
- data: RecordLockingRecord
119
- error: RecordLockingError
120
- }
121
-
122
- input RecordLockingListWhereInput {
123
- ${listFilterFieldsRender.allFiltersAsString()}
124
- }
125
-
126
- enum RecordLockingListSorter {
127
- ${sortEnumRender}
128
- }
129
-
130
- type RecordLockingQuery {
131
- _empty: String
132
- }
133
-
134
- type RecordLockingMutation {
135
- _empty: String
136
- }
137
-
138
- extend type RecordLockingQuery {
139
- isEntryLocked(id: ID!, type: String!): RecordLockingIsEntryLockedResponse!
140
- getLockRecord(id: ID!, type: String!): RecordLockingGetLockRecordResponse!
141
- # Returns lock record or null - if entry is locked in context of the current user, does not throw an error like getLockRecord if no record in the DB
142
- getLockedEntryLockRecord(id: ID!, type: String!): RecordLockingGetLockedEntryLockRecordResponse!
143
- listAllLockRecords(
144
- where: RecordLockingListWhereInput
145
- sort: [RecordLockingListSorter!]
146
- limit: Int
147
- after: String
148
- ): RecordLockingListLockRecordsResponse!
149
- # Basically same as listAllLockRecords except this one will filter out records with expired lock.
150
- listLockRecords(
151
- where: RecordLockingListWhereInput
152
- sort: [RecordLockingListSorter!]
153
- limit: Int
154
- after: String
155
- ): RecordLockingListLockRecordsResponse!
156
- }
157
-
158
- extend type RecordLockingMutation {
159
- lockEntry(id: ID!, type: String!): RecordLockingLockEntryResponse!
160
- updateEntryLock(id: ID!, type: String!): RecordLockingUpdateLockResponse!
161
- unlockEntry(id: ID!, type: String!, force: Boolean): RecordLockingUnlockEntryResponse!
162
- unlockEntryRequest(
163
- id: ID!
164
- type: String!
165
- ): RecordLockingUnlockEntryRequestResponse!
166
- }
167
-
168
- extend type Query {
169
- recordLocking: RecordLockingQuery
170
- }
171
-
172
- extend type Mutation {
173
- recordLocking: RecordLockingMutation
174
- }
175
- `,
176
- resolvers: {
177
- Query: {
178
- recordLocking: async () => ({})
179
- },
180
- Mutation: {
181
- recordLocking: async () => ({})
182
- },
183
- RecordLockingQuery: {
184
- async isEntryLocked(_, args, context) {
185
- return resolve(async () => {
186
- await checkPermissions(context);
187
- const useCase = context.container.resolve(IsEntryLockedUseCase);
188
- const result = await useCase.execute({
189
- id: args.id,
190
- type: args.type
191
- });
192
- if (result.isFail()) {
193
- throw result.error;
194
- }
195
- return result.value;
196
- });
197
- },
198
- async getLockRecord(_, args, context) {
199
- return resolve(async () => {
200
- await checkPermissions(context);
201
- const useCase = context.container.resolve(GetLockRecordUseCase);
202
- const result = await useCase.execute({
203
- id: args.id,
204
- type: args.type
205
- });
206
- if (result.isFail()) {
207
- throw result.error;
208
- }
209
- return result.value;
210
- });
211
- },
212
- async getLockedEntryLockRecord(_, args, context) {
213
- return resolve(async () => {
214
- await checkPermissions(context);
215
- const useCase = context.container.resolve(GetLockedEntryLockRecordUseCase);
216
- const result = await useCase.execute({
217
- id: args.id,
218
- type: args.type
219
- });
220
- // Returns null if not found/expired/locked by current user
221
- if (result.isFail()) {
222
- return null;
223
- }
224
- return result.value;
225
- });
226
- },
227
- async listLockRecords(_, args, context) {
228
- return resolveList(async () => {
229
- await checkPermissions(context);
230
- const useCase = context.container.resolve(ListLockRecordsUseCase);
231
- const result = await useCase.execute(args);
232
- if (result.isFail()) {
233
- throw result.error;
234
- }
235
- return result.value;
236
- });
237
- },
238
- listAllLockRecords(_, args, context) {
239
- return resolveList(async () => {
240
- await checkPermissions(context);
241
- const useCase = context.container.resolve(ListAllLockRecordsUseCase);
242
- const result = await useCase.execute(args);
243
- if (result.isFail()) {
244
- throw result.error;
245
- }
246
- return result.value;
247
- });
248
- }
249
- },
250
- RecordLockingMutation: {
251
- async lockEntry(_, args, context) {
252
- return resolve(async () => {
253
- await checkPermissions(context);
254
- const useCase = context.container.resolve(LockEntryUseCase);
255
- const result = await useCase.execute({
256
- id: args.id,
257
- type: args.type
258
- });
259
- if (result.isFail()) {
260
- throw result.error;
261
- }
262
- return result.value;
263
- });
264
- },
265
- async updateEntryLock(_, args, context) {
266
- return resolve(async () => {
267
- await checkPermissions(context);
268
- const useCase = context.container.resolve(UpdateEntryLockUseCase);
269
- const result = await useCase.execute({
270
- id: args.id,
271
- type: args.type
272
- });
273
- if (result.isFail()) {
274
- throw result.error;
275
- }
276
- return result.value;
277
- });
278
- },
279
- async unlockEntry(_, args, context) {
280
- return resolve(async () => {
281
- await checkPermissions(context);
282
- const useCase = context.container.resolve(UnlockEntryUseCase);
283
- const result = await useCase.execute({
284
- id: args.id,
285
- type: args.type,
286
- force: args.force
287
- });
288
- if (result.isFail()) {
289
- throw result.error;
290
- }
291
- return result.value;
292
- });
293
- },
294
- async unlockEntryRequest(_, args, context) {
295
- return resolve(async () => {
296
- await checkPermissions(context);
297
- const useCase = context.container.resolve(UnlockEntryRequestUseCase);
298
- const result = await useCase.execute({
299
- id: args.id,
300
- type: args.type
301
- });
302
- if (result.isFail()) {
303
- throw result.error;
304
- }
305
- return result.value;
306
- });
307
- }
308
- }
309
- }
310
- });
311
- plugin.name = "recordLocking.graphql.schema.locking";
312
- return plugin;
313
- };
314
-
315
- //# sourceMappingURL=schema.js.map