@strapi/data-transfer 5.12.1 → 5.12.3

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 (213) hide show
  1. package/dist/engine/errors.js +39 -0
  2. package/dist/engine/errors.js.map +1 -0
  3. package/dist/engine/errors.mjs +34 -0
  4. package/dist/engine/errors.mjs.map +1 -0
  5. package/dist/engine/index.js +797 -0
  6. package/dist/engine/index.js.map +1 -0
  7. package/dist/engine/index.mjs +792 -0
  8. package/dist/engine/index.mjs.map +1 -0
  9. package/dist/engine/validation/provider.js +19 -0
  10. package/dist/engine/validation/provider.js.map +1 -0
  11. package/dist/engine/validation/provider.mjs +17 -0
  12. package/dist/engine/validation/provider.mjs.map +1 -0
  13. package/dist/engine/validation/schemas/index.js +57 -0
  14. package/dist/engine/validation/schemas/index.js.map +1 -0
  15. package/dist/engine/validation/schemas/index.mjs +55 -0
  16. package/dist/engine/validation/schemas/index.mjs.map +1 -0
  17. package/dist/errors/base.js +13 -0
  18. package/dist/errors/base.js.map +1 -0
  19. package/dist/errors/base.mjs +11 -0
  20. package/dist/errors/base.mjs.map +1 -0
  21. package/dist/errors/constants.js +10 -0
  22. package/dist/errors/constants.js.map +1 -0
  23. package/dist/errors/constants.mjs +8 -0
  24. package/dist/errors/constants.mjs.map +1 -0
  25. package/dist/errors/providers.js +41 -0
  26. package/dist/errors/providers.js.map +1 -0
  27. package/dist/errors/providers.mjs +36 -0
  28. package/dist/errors/providers.mjs.map +1 -0
  29. package/dist/file/index.js +8 -0
  30. package/dist/file/index.js.map +1 -0
  31. package/dist/file/index.mjs +3 -0
  32. package/dist/file/index.mjs.map +1 -0
  33. package/dist/file/providers/destination/index.js +248 -0
  34. package/dist/file/providers/destination/index.js.map +1 -0
  35. package/dist/file/providers/destination/index.mjs +246 -0
  36. package/dist/file/providers/destination/index.mjs.map +1 -0
  37. package/dist/file/providers/destination/utils.js +63 -0
  38. package/dist/file/providers/destination/utils.js.map +1 -0
  39. package/dist/file/providers/destination/utils.mjs +60 -0
  40. package/dist/file/providers/destination/utils.mjs.map +1 -0
  41. package/dist/file/providers/index.js +10 -0
  42. package/dist/file/providers/index.js.map +1 -0
  43. package/dist/file/providers/index.mjs +3 -0
  44. package/dist/file/providers/index.mjs.map +1 -0
  45. package/dist/file/providers/source/index.js +288 -0
  46. package/dist/file/providers/source/index.js.map +1 -0
  47. package/dist/file/providers/source/index.mjs +286 -0
  48. package/dist/file/providers/source/index.mjs.map +1 -0
  49. package/dist/file/providers/source/utils.js +56 -0
  50. package/dist/file/providers/source/utils.js.map +1 -0
  51. package/dist/file/providers/source/utils.mjs +52 -0
  52. package/dist/file/providers/source/utils.mjs.map +1 -0
  53. package/dist/index.js +8 -5692
  54. package/dist/index.js.map +1 -1
  55. package/dist/index.mjs +8 -5674
  56. package/dist/index.mjs.map +1 -1
  57. package/dist/strapi/index.js +12 -0
  58. package/dist/strapi/index.js.map +1 -0
  59. package/dist/strapi/index.mjs +7 -0
  60. package/dist/strapi/index.mjs.map +1 -0
  61. package/dist/strapi/providers/index.js +16 -0
  62. package/dist/strapi/providers/index.js.map +1 -0
  63. package/dist/strapi/providers/index.mjs +7 -0
  64. package/dist/strapi/providers/index.mjs.map +1 -0
  65. package/dist/strapi/providers/local-destination/index.js +419 -0
  66. package/dist/strapi/providers/local-destination/index.js.map +1 -0
  67. package/dist/strapi/providers/local-destination/index.mjs +396 -0
  68. package/dist/strapi/providers/local-destination/index.mjs.map +1 -0
  69. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +52 -0
  70. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
  71. package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs +49 -0
  72. package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs.map +1 -0
  73. package/dist/strapi/providers/local-destination/strategies/restore/entities.js +64 -0
  74. package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
  75. package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs +62 -0
  76. package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs.map +1 -0
  77. package/dist/strapi/providers/local-destination/strategies/restore/index.js +126 -0
  78. package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
  79. package/dist/strapi/providers/local-destination/strategies/restore/index.mjs +122 -0
  80. package/dist/strapi/providers/local-destination/strategies/restore/index.mjs.map +1 -0
  81. package/dist/strapi/providers/local-destination/strategies/restore/links.js +60 -0
  82. package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
  83. package/dist/strapi/providers/local-destination/strategies/restore/links.mjs +58 -0
  84. package/dist/strapi/providers/local-destination/strategies/restore/links.mjs.map +1 -0
  85. package/dist/strapi/providers/local-source/assets.js +123 -0
  86. package/dist/strapi/providers/local-source/assets.js.map +1 -0
  87. package/dist/strapi/providers/local-source/assets.mjs +121 -0
  88. package/dist/strapi/providers/local-source/assets.mjs.map +1 -0
  89. package/dist/strapi/providers/local-source/configuration.js +39 -0
  90. package/dist/strapi/providers/local-source/configuration.js.map +1 -0
  91. package/dist/strapi/providers/local-source/configuration.mjs +37 -0
  92. package/dist/strapi/providers/local-source/configuration.mjs.map +1 -0
  93. package/dist/strapi/providers/local-source/entities.js +62 -0
  94. package/dist/strapi/providers/local-source/entities.js.map +1 -0
  95. package/dist/strapi/providers/local-source/entities.mjs +59 -0
  96. package/dist/strapi/providers/local-source/entities.mjs.map +1 -0
  97. package/dist/strapi/providers/local-source/index.js +154 -0
  98. package/dist/strapi/providers/local-source/index.js.map +1 -0
  99. package/dist/strapi/providers/local-source/index.mjs +152 -0
  100. package/dist/strapi/providers/local-source/index.mjs.map +1 -0
  101. package/dist/strapi/providers/local-source/links.js +26 -0
  102. package/dist/strapi/providers/local-source/links.js.map +1 -0
  103. package/dist/strapi/providers/local-source/links.mjs +24 -0
  104. package/dist/strapi/providers/local-source/links.mjs.map +1 -0
  105. package/dist/strapi/providers/remote-destination/index.js +392 -0
  106. package/dist/strapi/providers/remote-destination/index.js.map +1 -0
  107. package/dist/strapi/providers/remote-destination/index.mjs +390 -0
  108. package/dist/strapi/providers/remote-destination/index.mjs.map +1 -0
  109. package/dist/strapi/providers/remote-source/index.js +405 -0
  110. package/dist/strapi/providers/remote-source/index.js.map +1 -0
  111. package/dist/strapi/providers/remote-source/index.mjs +403 -0
  112. package/dist/strapi/providers/remote-source/index.mjs.map +1 -0
  113. package/dist/strapi/providers/utils.js +173 -0
  114. package/dist/strapi/providers/utils.js.map +1 -0
  115. package/dist/strapi/providers/utils.mjs +169 -0
  116. package/dist/strapi/providers/utils.mjs.map +1 -0
  117. package/dist/strapi/queries/entity.js +125 -0
  118. package/dist/strapi/queries/entity.js.map +1 -0
  119. package/dist/strapi/queries/entity.mjs +123 -0
  120. package/dist/strapi/queries/entity.mjs.map +1 -0
  121. package/dist/strapi/queries/index.js +10 -0
  122. package/dist/strapi/queries/index.js.map +1 -0
  123. package/dist/strapi/queries/index.mjs +5 -0
  124. package/dist/strapi/queries/index.mjs.map +1 -0
  125. package/dist/strapi/queries/link.js +298 -0
  126. package/dist/strapi/queries/link.js.map +1 -0
  127. package/dist/strapi/queries/link.mjs +295 -0
  128. package/dist/strapi/queries/link.mjs.map +1 -0
  129. package/dist/strapi/remote/constants.js +11 -0
  130. package/dist/strapi/remote/constants.js.map +1 -0
  131. package/dist/strapi/remote/constants.mjs +8 -0
  132. package/dist/strapi/remote/constants.mjs.map +1 -0
  133. package/dist/strapi/remote/flows/default.js +43 -0
  134. package/dist/strapi/remote/flows/default.js.map +1 -0
  135. package/dist/strapi/remote/flows/default.mjs +41 -0
  136. package/dist/strapi/remote/flows/default.mjs.map +1 -0
  137. package/dist/strapi/remote/flows/index.js +54 -0
  138. package/dist/strapi/remote/flows/index.js.map +1 -0
  139. package/dist/strapi/remote/flows/index.mjs +52 -0
  140. package/dist/strapi/remote/flows/index.mjs.map +1 -0
  141. package/dist/strapi/remote/handlers/constants.js +10 -0
  142. package/dist/strapi/remote/handlers/constants.js.map +1 -0
  143. package/dist/strapi/remote/handlers/constants.mjs +8 -0
  144. package/dist/strapi/remote/handlers/constants.mjs.map +1 -0
  145. package/dist/strapi/remote/handlers/index.js +12 -0
  146. package/dist/strapi/remote/handlers/index.js.map +1 -0
  147. package/dist/strapi/remote/handlers/index.mjs +4 -0
  148. package/dist/strapi/remote/handlers/index.mjs.map +1 -0
  149. package/dist/strapi/remote/handlers/pull.js +348 -0
  150. package/dist/strapi/remote/handlers/pull.js.map +1 -0
  151. package/dist/strapi/remote/handlers/pull.mjs +346 -0
  152. package/dist/strapi/remote/handlers/pull.mjs.map +1 -0
  153. package/dist/strapi/remote/handlers/push.js +400 -0
  154. package/dist/strapi/remote/handlers/push.js.map +1 -0
  155. package/dist/strapi/remote/handlers/push.mjs +398 -0
  156. package/dist/strapi/remote/handlers/push.mjs.map +1 -0
  157. package/dist/strapi/remote/handlers/utils.js +316 -0
  158. package/dist/strapi/remote/handlers/utils.js.map +1 -0
  159. package/dist/strapi/remote/handlers/utils.mjs +310 -0
  160. package/dist/strapi/remote/handlers/utils.mjs.map +1 -0
  161. package/dist/strapi/remote/index.js +10 -0
  162. package/dist/strapi/remote/index.js.map +1 -0
  163. package/dist/strapi/remote/index.mjs +5 -0
  164. package/dist/strapi/remote/index.mjs.map +1 -0
  165. package/dist/utils/components.js +178 -0
  166. package/dist/utils/components.js.map +1 -0
  167. package/dist/utils/components.mjs +171 -0
  168. package/dist/utils/components.mjs.map +1 -0
  169. package/dist/utils/diagnostic.js +51 -0
  170. package/dist/utils/diagnostic.js.map +1 -0
  171. package/dist/utils/diagnostic.mjs +49 -0
  172. package/dist/utils/diagnostic.mjs.map +1 -0
  173. package/dist/utils/encryption/decrypt.js +47 -0
  174. package/dist/utils/encryption/decrypt.js.map +1 -0
  175. package/dist/utils/encryption/decrypt.mjs +45 -0
  176. package/dist/utils/encryption/decrypt.mjs.map +1 -0
  177. package/dist/utils/encryption/encrypt.js +47 -0
  178. package/dist/utils/encryption/encrypt.js.map +1 -0
  179. package/dist/utils/encryption/encrypt.mjs +45 -0
  180. package/dist/utils/encryption/encrypt.mjs.map +1 -0
  181. package/dist/utils/encryption/index.js +10 -0
  182. package/dist/utils/encryption/index.js.map +1 -0
  183. package/dist/utils/encryption/index.mjs +3 -0
  184. package/dist/utils/encryption/index.mjs.map +1 -0
  185. package/dist/utils/index.js +20 -0
  186. package/dist/utils/index.js.map +1 -0
  187. package/dist/utils/index.mjs +15 -0
  188. package/dist/utils/index.mjs.map +1 -0
  189. package/dist/utils/json.js +96 -0
  190. package/dist/utils/json.js.map +1 -0
  191. package/dist/utils/json.mjs +94 -0
  192. package/dist/utils/json.mjs.map +1 -0
  193. package/dist/utils/middleware.js +14 -0
  194. package/dist/utils/middleware.js.map +1 -0
  195. package/dist/utils/middleware.mjs +12 -0
  196. package/dist/utils/middleware.mjs.map +1 -0
  197. package/dist/utils/providers.js +12 -0
  198. package/dist/utils/providers.js.map +1 -0
  199. package/dist/utils/providers.mjs +10 -0
  200. package/dist/utils/providers.mjs.map +1 -0
  201. package/dist/utils/schema.js +32 -0
  202. package/dist/utils/schema.js.map +1 -0
  203. package/dist/utils/schema.mjs +29 -0
  204. package/dist/utils/schema.mjs.map +1 -0
  205. package/dist/utils/stream.js +59 -0
  206. package/dist/utils/stream.js.map +1 -0
  207. package/dist/utils/stream.mjs +55 -0
  208. package/dist/utils/stream.mjs.map +1 -0
  209. package/dist/utils/transaction.js +93 -0
  210. package/dist/utils/transaction.js.map +1 -0
  211. package/dist/utils/transaction.mjs +91 -0
  212. package/dist/utils/transaction.mjs.map +1 -0
  213. package/package.json +5 -5
@@ -0,0 +1,171 @@
1
+ import _ from 'lodash';
2
+ import { get, has, pipe, omit, assign } from 'lodash/fp';
3
+ import { contentTypes, async } from '@strapi/utils';
4
+
5
+ const isDialectMySQL = ()=>strapi.db?.dialect.client === 'mysql';
6
+ function omitComponentData(contentType, data) {
7
+ const { attributes } = contentType;
8
+ const componentAttributes = Object.keys(attributes).filter((attributeName)=>contentTypes.isComponentAttribute(attributes[attributeName]));
9
+ return omit(componentAttributes, data);
10
+ }
11
+ // NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
12
+ const createComponents = async (uid, data)=>{
13
+ const { attributes = {} } = strapi.getModel(uid);
14
+ const componentBody = {};
15
+ const attributeNames = Object.keys(attributes);
16
+ for (const attributeName of attributeNames){
17
+ const attribute = attributes[attributeName];
18
+ if (!has(attributeName, data) || !contentTypes.isComponentAttribute(attribute)) {
19
+ continue;
20
+ }
21
+ if (attribute.type === 'component') {
22
+ const { component: componentUID, repeatable = false } = attribute;
23
+ const componentValue = data[attributeName];
24
+ if (componentValue === null) {
25
+ continue;
26
+ }
27
+ if (repeatable === true) {
28
+ if (!Array.isArray(componentValue)) {
29
+ throw new Error('Expected an array to create repeatable component');
30
+ }
31
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
32
+ const components = await async.map(componentValue, (value)=>createComponent(componentUID, value), {
33
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
34
+ });
35
+ componentBody[attributeName] = components.map(({ id })=>{
36
+ return {
37
+ id,
38
+ __pivot: {
39
+ field: attributeName,
40
+ component_type: componentUID
41
+ }
42
+ };
43
+ });
44
+ } else {
45
+ const component = await createComponent(componentUID, componentValue);
46
+ componentBody[attributeName] = {
47
+ id: component.id,
48
+ __pivot: {
49
+ field: attributeName,
50
+ component_type: componentUID
51
+ }
52
+ };
53
+ }
54
+ continue;
55
+ }
56
+ if (attribute.type === 'dynamiczone') {
57
+ const dynamiczoneValues = data[attributeName];
58
+ if (!Array.isArray(dynamiczoneValues)) {
59
+ throw new Error('Expected an array to create repeatable component');
60
+ }
61
+ const createDynamicZoneComponents = async (value)=>{
62
+ const { id } = await createComponent(value.__component, value);
63
+ return {
64
+ id,
65
+ __component: value.__component,
66
+ __pivot: {
67
+ field: attributeName
68
+ }
69
+ };
70
+ };
71
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
72
+ componentBody[attributeName] = await async.map(dynamiczoneValues, createDynamicZoneComponents, {
73
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
74
+ });
75
+ continue;
76
+ }
77
+ }
78
+ return componentBody;
79
+ };
80
+ const getComponents = async (uid, entity)=>{
81
+ const componentAttributes = contentTypes.getComponentAttributes(strapi.getModel(uid));
82
+ if (_.isEmpty(componentAttributes)) {
83
+ return {};
84
+ }
85
+ return strapi.db.query(uid).load(entity, componentAttributes);
86
+ };
87
+ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {})=>{
88
+ const { attributes = {} } = strapi.getModel(uid);
89
+ const attributeNames = Object.keys(attributes);
90
+ for (const attributeName of attributeNames){
91
+ const attribute = attributes[attributeName];
92
+ if (attribute.type === 'component' || attribute.type === 'dynamiczone') {
93
+ let value;
94
+ if (loadComponents) {
95
+ value = await strapi.db.query(uid).load(entityToDelete, attributeName);
96
+ } else {
97
+ value = entityToDelete[attributeName];
98
+ }
99
+ if (!value) {
100
+ continue;
101
+ }
102
+ if (attribute.type === 'component') {
103
+ const { component: componentUID } = attribute;
104
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
105
+ await async.map(_.castArray(value), (subValue)=>deleteComponent(componentUID, subValue), {
106
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
107
+ });
108
+ } else {
109
+ // delete dynamic zone components
110
+ // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1
111
+ await async.map(_.castArray(value), (subValue)=>deleteComponent(subValue.__component, subValue), {
112
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
113
+ });
114
+ }
115
+ continue;
116
+ }
117
+ }
118
+ };
119
+ /** *************************
120
+ Component queries
121
+ ************************** */ // components can have nested compos so this must be recursive
122
+ const createComponent = async (uid, data)=>{
123
+ const model = strapi.getModel(uid);
124
+ const componentData = await createComponents(uid, data);
125
+ const transform = pipe(// Make sure we don't save the component with a pre-defined ID
126
+ omit('id'), // Remove the component data from the original data object ...
127
+ (payload)=>omitComponentData(model, payload), // ... and assign the newly created component instead
128
+ assign(componentData));
129
+ return strapi.db.query(uid).create({
130
+ data: transform(data)
131
+ });
132
+ };
133
+ const deleteComponent = async (uid, componentToDelete)=>{
134
+ await deleteComponents(uid, componentToDelete);
135
+ await strapi.db.query(uid).delete({
136
+ where: {
137
+ id: componentToDelete.id
138
+ }
139
+ });
140
+ };
141
+ /**
142
+ * Resolve the component UID of an entity's attribute based
143
+ * on a given path (components & dynamic zones only)
144
+ */ const resolveComponentUID = ({ paths, strapi: strapi1, data, contentType })=>{
145
+ let value = data;
146
+ let cType = contentType;
147
+ for (const path of paths){
148
+ value = get(path, value);
149
+ // Needed when the value of cType should be computed
150
+ // based on the next value (eg: dynamic zones)
151
+ if (typeof cType === 'function') {
152
+ cType = cType(value);
153
+ }
154
+ if (path in cType.attributes) {
155
+ const attribute = cType.attributes[path];
156
+ if (attribute.type === 'component') {
157
+ cType = strapi1.getModel(attribute.component);
158
+ }
159
+ if (attribute.type === 'dynamiczone') {
160
+ cType = ({ __component })=>strapi1.getModel(__component);
161
+ }
162
+ }
163
+ }
164
+ if ('uid' in cType) {
165
+ return cType.uid;
166
+ }
167
+ return undefined;
168
+ };
169
+
170
+ export { createComponents, deleteComponent, deleteComponents, getComponents, omitComponentData, resolveComponentUID };
171
+ //# sourceMappingURL=components.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.mjs","sources":["../../src/utils/components.ts"],"sourcesContent":["import _ from 'lodash';\nimport { get, has, omit, pipe, assign } from 'lodash/fp';\n\nimport { contentTypes as contentTypesUtils, async, errors } from '@strapi/utils';\nimport type { Modules, UID, Data, Utils, Schema, Core } from '@strapi/types';\n\ntype LoadedComponents<TUID extends UID.Schema> = Data.Entity<\n TUID,\n Schema.AttributeNamesByType<TUID, 'component' | 'dynamiczone'>\n>;\n\ntype ComponentValue = Schema.Attribute.Value<\n Schema.Attribute.Component<UID.Component, false> | Schema.Attribute.Component<UID.Component, true>\n>;\n\ntype ComponentBody = {\n [key: string]: Schema.Attribute.Value<\n | Schema.Attribute.Component<UID.Component, false>\n | Schema.Attribute.Component<UID.Component, true>\n | Schema.Attribute.DynamicZone\n >;\n};\n\nconst isDialectMySQL = () => strapi.db?.dialect.client === 'mysql';\n\nfunction omitComponentData(\n contentType: Schema.ContentType,\n data: Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>\n): Partial<Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>>;\nfunction omitComponentData(\n contentType: Schema.Component,\n data: Modules.EntityService.Params.Data.Input<Schema.Component['uid']>\n): Partial<Modules.EntityService.Params.Data.Input<Schema.Component['uid']>>;\nfunction omitComponentData(\n contentType: Schema.ContentType | Schema.Component,\n data: Modules.EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n): Partial<\n Modules.EntityService.Params.Data.Input<Schema.ContentType['uid'] | Schema.Component['uid']>\n> {\n const { attributes } = contentType;\n const componentAttributes = Object.keys(attributes).filter((attributeName) =>\n contentTypesUtils.isComponentAttribute(attributes[attributeName])\n );\n\n return omit(componentAttributes, data);\n}\n\n// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer\nconst createComponents = async <\n TUID extends UID.Schema,\n TData extends Modules.EntityService.Params.Data.Input<TUID>,\n>(\n uid: TUID,\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[attributeName as keyof TData];\n\n if (componentValue === null) {\n continue;\n }\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => createComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n\n componentBody[attributeName] = components.map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await createComponent(\n componentUID,\n componentValue as Modules.EntityService.Params.Data.Input<UID.Component>\n );\n componentBody[attributeName] = {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Modules.EntityService.Params.Attribute.GetValue<Schema.Attribute.DynamicZone>;\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n const createDynamicZoneComponents = async (\n value: Utils.Array.Values<typeof dynamiczoneValues>\n ) => {\n const { id } = await createComponent(value.__component, value);\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n };\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n createDynamicZoneComponents,\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst getComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entity: { id: Modules.EntityService.Params.Attribute.ID }\n): Promise<LoadedComponents<TUID>> => {\n const componentAttributes = contentTypesUtils.getComponentAttributes(strapi.getModel(uid));\n\n if (_.isEmpty(componentAttributes)) {\n return {} as LoadedComponents<TUID>;\n }\n\n return strapi.db.query(uid).load(entity, componentAttributes) as Promise<LoadedComponents<TUID>>;\n};\n\n/*\n delete old components\n create or update\n*/\nconst updateComponents = async <\n TUID extends UID.Schema,\n TData extends Partial<Modules.EntityService.Params.Data.Input<TUID>>,\n>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: TData\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const componentBody: ComponentBody = {};\n\n for (const attributeName of Object.keys(attributes)) {\n const attribute = attributes[attributeName];\n\n if (!has(attributeName, data)) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID, repeatable = false } = attribute;\n\n const componentValue = data[\n attributeName as keyof TData\n ] as Schema.Attribute.Value<Schema.Attribute.Component>;\n\n await deleteOldComponents(uid, componentUID, entityToUpdate, attributeName, componentValue);\n\n if (repeatable === true) {\n if (!Array.isArray(componentValue)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n const components = (await async.map(\n componentValue,\n (value: any) => updateOrCreateComponent(componentUID, value),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n )) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n\n componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {\n return {\n id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n });\n } else {\n const component = await updateOrCreateComponent(componentUID, componentValue);\n componentBody[attributeName] = component && {\n id: component.id,\n __pivot: {\n field: attributeName,\n component_type: componentUID,\n },\n };\n }\n\n continue;\n }\n\n if (attribute.type === 'dynamiczone') {\n const dynamiczoneValues = data[\n attributeName as keyof TData\n ] as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n await deleteOldDZComponents(uid, entityToUpdate, attributeName, dynamiczoneValues);\n\n if (!Array.isArray(dynamiczoneValues)) {\n throw new Error('Expected an array to create repeatable component');\n }\n\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n componentBody[attributeName] = await async.map(\n dynamiczoneValues,\n async (value: any) => {\n const { id } = await updateOrCreateComponent(value.__component, value);\n\n return {\n id,\n __component: value.__component,\n __pivot: {\n field: attributeName,\n },\n };\n },\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n\n continue;\n }\n }\n\n return componentBody;\n};\n\nconst pickStringifiedId = ({\n id,\n}: {\n id: Modules.EntityService.Params.Attribute.ID;\n}): Modules.EntityService.Params.Attribute.ID & string => {\n if (typeof id === 'string') {\n return id;\n }\n\n return `${id}`;\n};\n\nconst deleteOldComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n componentUID: UID.Component,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n componentValue: Schema.Attribute.Value<Schema.Attribute.Component>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as ComponentValue;\n\n const idsToKeep = _.castArray(componentValue).filter(has('id')).map(pickStringifiedId);\n const allIds = _.castArray(previousValue).filter(has('id')).map(pickStringifiedId);\n\n idsToKeep.forEach((id) => {\n if (!allIds.includes(id)) {\n throw new errors.ApplicationError(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n }\n });\n\n const idsToDelete = _.difference(allIds, idsToKeep);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n await deleteComponent(componentUID, { id: idToDelete });\n }\n }\n};\n\nconst deleteOldDZComponents = async <TUID extends UID.Schema>(\n uid: TUID,\n entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n attributeName: string,\n dynamiczoneValues: Schema.Attribute.Value<Schema.Attribute.DynamicZone>\n) => {\n const previousValue = (await strapi.db\n .query(uid)\n .load(entityToUpdate, attributeName)) as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n const idsToKeep = _.castArray(dynamiczoneValues)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n const allIds = _.castArray(previousValue)\n .filter(has('id'))\n .map((v) => ({\n id: pickStringifiedId(v),\n __component: v.__component,\n }));\n\n idsToKeep.forEach(({ id, __component }) => {\n if (!allIds.find((el) => el.id === id && el.__component === __component)) {\n const err = new Error(\n `Some of the provided components in ${attributeName} are not related to the entity`\n );\n\n Object.assign(err, { status: 400 });\n throw err;\n }\n });\n\n type IdsToDelete = Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n const idsToDelete = allIds.reduce((acc, { id, __component }) => {\n if (!idsToKeep.find((el) => el.id === id && el.__component === __component)) {\n acc.push({ id, __component });\n }\n\n return acc;\n }, [] as IdsToDelete);\n\n if (idsToDelete.length > 0) {\n for (const idToDelete of idsToDelete) {\n const { id, __component } = idToDelete;\n await deleteComponent(__component, { id });\n }\n }\n};\n\nconst deleteComponents = async <TUID extends UID.Schema, TEntity extends Data.Entity<TUID>>(\n uid: TUID,\n entityToDelete: TEntity,\n { loadComponents = true } = {}\n) => {\n const { attributes = {} } = strapi.getModel(uid);\n\n const attributeNames = Object.keys(attributes);\n\n for (const attributeName of attributeNames) {\n const attribute = attributes[attributeName];\n\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n let value;\n if (loadComponents) {\n value = await strapi.db.query(uid).load(entityToDelete, attributeName);\n } else {\n value = entityToDelete[attributeName as keyof TEntity];\n }\n\n if (!value) {\n continue;\n }\n\n if (attribute.type === 'component') {\n const { component: componentUID } = attribute;\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(componentUID, subValue),\n {\n concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity,\n }\n );\n } else {\n // delete dynamic zone components\n // MySQL/MariaDB can cause deadlocks here if concurrency higher than 1\n await async.map(\n _.castArray(value),\n (subValue: any) => deleteComponent(subValue.__component, subValue),\n { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }\n );\n }\n\n continue;\n }\n }\n};\n\n/** *************************\n Component queries\n************************** */\n\n// components can have nested compos so this must be recursive\nconst createComponent = async <TUID extends UID.Component = UID.Component>(\n uid: TUID,\n data: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid) as Schema.Component;\n\n const componentData = await createComponents(uid, data);\n const transform = pipe(\n // Make sure we don't save the component with a pre-defined ID\n omit('id'),\n // Remove the component data from the original data object ...\n (payload) => omitComponentData(model, payload),\n // ... and assign the newly created component instead\n assign(componentData)\n );\n\n return strapi.db.query(uid).create({ data: transform(data) });\n};\n\n// components can have nested compos so this must be recursive\nconst updateComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToUpdate: { id: Modules.EntityService.Params.Attribute.ID },\n data: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n const model = strapi.getModel(uid) as Schema.Component;\n\n const componentData = await updateComponents(uid, componentToUpdate, data);\n\n return strapi.db.query(uid).update({\n where: {\n id: componentToUpdate.id,\n },\n data: Object.assign(omitComponentData(model, data), componentData),\n });\n};\n\nconst updateOrCreateComponent = <TUID extends UID.Component>(\n componentUID: TUID,\n value: Modules.EntityService.Params.Data.Input<TUID>\n) => {\n if (value === null) {\n return null;\n }\n\n // update\n if ('id' in value && typeof value.id !== 'undefined') {\n // TODO: verify the compo is associated with the entity\n return updateComponent(componentUID, { id: value.id }, value);\n }\n\n // create\n return createComponent(componentUID, value);\n};\n\nconst deleteComponent = async <TUID extends UID.Component>(\n uid: TUID,\n componentToDelete: Data.Component<TUID>\n) => {\n await deleteComponents(uid, componentToDelete);\n await strapi.db.query(uid).delete({ where: { id: componentToDelete.id } });\n};\n\n/**\n * Resolve the component UID of an entity's attribute based\n * on a given path (components & dynamic zones only)\n */\nconst resolveComponentUID = ({\n paths,\n strapi,\n data,\n contentType,\n}: {\n paths: string[];\n strapi: Core.Strapi;\n data: any;\n contentType: Schema.ContentType;\n}): UID.Schema | undefined => {\n let value: unknown = data;\n let cType:\n | Schema.ContentType\n | Schema.Component\n | ((...opts: any[]) => Schema.ContentType | Schema.Component) = contentType;\n for (const path of paths) {\n value = get(path, value);\n\n // Needed when the value of cType should be computed\n // based on the next value (eg: dynamic zones)\n if (typeof cType === 'function') {\n cType = cType(value);\n }\n\n if (path in cType.attributes) {\n const attribute: Schema.Attribute.AnyAttribute = cType.attributes[path];\n\n if (attribute.type === 'component') {\n cType = strapi.getModel(attribute.component);\n }\n\n if (attribute.type === 'dynamiczone') {\n cType = ({ __component }: { __component: UID.Component }) => strapi.getModel(__component);\n }\n }\n }\n\n if ('uid' in cType) {\n return cType.uid;\n }\n\n return undefined;\n};\n\nexport {\n omitComponentData,\n getComponents,\n createComponents,\n updateComponents,\n deleteComponents,\n deleteComponent,\n resolveComponentUID,\n};\n"],"names":["isDialectMySQL","strapi","db","dialect","client","omitComponentData","contentType","data","attributes","componentAttributes","Object","keys","filter","attributeName","contentTypesUtils","isComponentAttribute","omit","createComponents","uid","getModel","componentBody","attributeNames","attribute","has","type","component","componentUID","repeatable","componentValue","Array","isArray","Error","components","async","map","value","createComponent","concurrency","inTransaction","Infinity","id","__pivot","field","component_type","dynamiczoneValues","createDynamicZoneComponents","__component","getComponents","entity","getComponentAttributes","_","isEmpty","query","load","deleteComponents","entityToDelete","loadComponents","castArray","subValue","deleteComponent","model","componentData","transform","pipe","payload","assign","create","componentToDelete","delete","where","resolveComponentUID","paths","cType","path","get","undefined"],"mappings":";;;;AAuBA,MAAMA,iBAAiB,IAAMC,MAAAA,CAAOC,EAAE,EAAEC,QAAQC,MAAW,KAAA,OAAA;AAU3D,SAASC,iBAAAA,CACPC,WAAkD,EAClDC,IAAkG,EAAA;IAIlG,MAAM,EAAEC,UAAU,EAAE,GAAGF,WAAAA;AACvB,IAAA,MAAMG,mBAAsBC,GAAAA,MAAAA,CAAOC,IAAI,CAACH,YAAYI,MAAM,CAAC,CAACC,aAAAA,GAC1DC,YAAkBC,CAAAA,oBAAoB,CAACP,UAAU,CAACK,aAAc,CAAA,CAAA,CAAA;AAGlE,IAAA,OAAOG,KAAKP,mBAAqBF,EAAAA,IAAAA,CAAAA;AACnC;AAEA;AACMU,MAAAA,gBAAAA,GAAmB,OAIvBC,GACAX,EAAAA,IAAAA,GAAAA;IAEA,MA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B,QAAA,OAAOA,MAAMtD,GAAG;AAClB;IAEA,OAAOyD,SAAAA;AACT;;;;"}
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var events = require('events');
4
+
5
+ const createDiagnosticReporter = (options = {})=>{
6
+ const { stackSize = -1 } = options;
7
+ const emitter = new events.EventEmitter();
8
+ const stack = [];
9
+ const addListener = (event, listener)=>{
10
+ emitter.on(event, listener);
11
+ };
12
+ const isDiagnosticValid = (diagnostic)=>{
13
+ if (!diagnostic.kind || !diagnostic.details || !diagnostic.details.message) {
14
+ return false;
15
+ }
16
+ return true;
17
+ };
18
+ return {
19
+ stack: {
20
+ get size () {
21
+ return stack.length;
22
+ },
23
+ get items () {
24
+ return stack;
25
+ }
26
+ },
27
+ report (diagnostic) {
28
+ if (!isDiagnosticValid(diagnostic)) {
29
+ return this;
30
+ }
31
+ emitter.emit('diagnostic', diagnostic);
32
+ emitter.emit(`diagnostic.${diagnostic.kind}`, diagnostic);
33
+ if (stackSize !== -1 && stack.length >= stackSize) {
34
+ stack.shift();
35
+ }
36
+ stack.push(diagnostic);
37
+ return this;
38
+ },
39
+ onDiagnostic (listener) {
40
+ addListener('diagnostic', listener);
41
+ return this;
42
+ },
43
+ on (kind, listener) {
44
+ addListener(`diagnostic.${kind}`, listener);
45
+ return this;
46
+ }
47
+ };
48
+ };
49
+
50
+ exports.createDiagnosticReporter = createDiagnosticReporter;
51
+ //# sourceMappingURL=diagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.js","sources":["../../src/utils/diagnostic.ts"],"sourcesContent":["import { EventEmitter } from 'events';\n\nexport interface IDiagnosticReporterOptions {\n stackSize?: number;\n}\n\nexport type GenericDiagnostic<K extends DiagnosticKind, T = unknown> = {\n kind: K;\n details: {\n message: string;\n createdAt: Date;\n } & T;\n};\n\nexport type DiagnosticKind = 'error' | 'warning' | 'info';\n\nexport type DiagnosticListener<T extends DiagnosticKind = DiagnosticKind> = (\n diagnostic: { kind: T } & Diagnostic extends infer U ? U : never\n) => void | Promise<void>;\n\nexport type DiagnosticEvent = 'diagnostic' | `diagnostic.${DiagnosticKind}`;\n\nexport type GetEventListener<E extends DiagnosticEvent> = E extends 'diagnostic'\n ? DiagnosticListener\n : E extends `diagnostic.${infer K}`\n ? K extends DiagnosticKind\n ? DiagnosticListener<K>\n : never\n : never;\n\nexport type Diagnostic = ErrorDiagnostic | WarningDiagnostic | InfoDiagnostic;\n\nexport type ErrorDiagnosticSeverity = 'fatal' | 'error' | 'silly';\n\nexport type ErrorDiagnostic = GenericDiagnostic<\n 'error',\n {\n name: string;\n severity: ErrorDiagnosticSeverity;\n error: Error;\n }\n>;\n\nexport type WarningDiagnostic = GenericDiagnostic<\n 'warning',\n {\n origin?: string;\n }\n>;\n\nexport type InfoDiagnostic<T = unknown> = GenericDiagnostic<\n 'info',\n {\n origin?: string;\n params?: T;\n }\n>;\n\nexport interface IDiagnosticReporter {\n stack: {\n readonly size: number;\n readonly items: Diagnostic[];\n };\n\n report(diagnostic: Diagnostic): IDiagnosticReporter;\n onDiagnostic(listener: DiagnosticListener): IDiagnosticReporter;\n on<T extends DiagnosticKind>(kind: T, listener: DiagnosticListener<T>): IDiagnosticReporter;\n}\n\nconst createDiagnosticReporter = (\n options: IDiagnosticReporterOptions = {}\n): IDiagnosticReporter => {\n const { stackSize = -1 } = options;\n\n const emitter = new EventEmitter();\n const stack: Diagnostic[] = [];\n\n const addListener = <T extends DiagnosticEvent>(event: T, listener: GetEventListener<T>) => {\n emitter.on(event, listener);\n };\n\n const isDiagnosticValid = (diagnostic: Diagnostic) => {\n if (!diagnostic.kind || !diagnostic.details || !diagnostic.details.message) {\n return false;\n }\n return true;\n };\n\n return {\n stack: {\n get size() {\n return stack.length;\n },\n\n get items() {\n return stack;\n },\n },\n\n report(diagnostic: Diagnostic) {\n if (!isDiagnosticValid(diagnostic)) {\n return this;\n }\n\n emitter.emit('diagnostic', diagnostic);\n emitter.emit(`diagnostic.${diagnostic.kind}`, diagnostic);\n\n if (stackSize !== -1 && stack.length >= stackSize) {\n stack.shift();\n }\n\n stack.push(diagnostic);\n\n return this;\n },\n\n onDiagnostic(listener: DiagnosticListener) {\n addListener('diagnostic', listener);\n\n return this;\n },\n\n on<T extends DiagnosticKind>(kind: T, listener: DiagnosticListener<T>) {\n addListener(`diagnostic.${kind}`, listener as never);\n\n return this;\n },\n };\n};\n\nexport { createDiagnosticReporter };\n"],"names":["createDiagnosticReporter","options","stackSize","emitter","EventEmitter","stack","addListener","event","listener","on","isDiagnosticValid","diagnostic","kind","details","message","size","length","items","report","emit","shift","push","onDiagnostic"],"mappings":";;;;AAqEA,MAAMA,wBAA2B,GAAA,CAC/BC,OAAsC,GAAA,EAAE,GAAA;AAExC,IAAA,MAAM,EAAEC,SAAAA,GAAY,CAAC,CAAC,EAAE,GAAGD,OAAAA;AAE3B,IAAA,MAAME,UAAU,IAAIC,mBAAAA,EAAAA;AACpB,IAAA,MAAMC,QAAsB,EAAE;IAE9B,MAAMC,WAAAA,GAAc,CAA4BC,KAAUC,EAAAA,QAAAA,GAAAA;QACxDL,OAAQM,CAAAA,EAAE,CAACF,KAAOC,EAAAA,QAAAA,CAAAA;AACpB,KAAA;AAEA,IAAA,MAAME,oBAAoB,CAACC,UAAAA,GAAAA;AACzB,QAAA,IAAI,CAACA,UAAAA,CAAWC,IAAI,IAAI,CAACD,UAAAA,CAAWE,OAAO,IAAI,CAACF,UAAAA,CAAWE,OAAO,CAACC,OAAO,EAAE;YAC1E,OAAO,KAAA;AACT;QACA,OAAO,IAAA;AACT,KAAA;IAEA,OAAO;QACLT,KAAO,EAAA;AACL,YAAA,IAAIU,IAAO,CAAA,GAAA;AACT,gBAAA,OAAOV,MAAMW,MAAM;AACrB,aAAA;AAEA,YAAA,IAAIC,KAAQ,CAAA,GAAA;gBACV,OAAOZ,KAAAA;AACT;AACF,SAAA;AAEAa,QAAAA,MAAAA,CAAAA,CAAOP,UAAsB,EAAA;YAC3B,IAAI,CAACD,kBAAkBC,UAAa,CAAA,EAAA;AAClC,gBAAA,OAAO,IAAI;AACb;YAEAR,OAAQgB,CAAAA,IAAI,CAAC,YAAcR,EAAAA,UAAAA,CAAAA;YAC3BR,OAAQgB,CAAAA,IAAI,CAAC,CAAC,WAAW,EAAER,UAAWC,CAAAA,IAAI,CAAC,CAAC,EAAED,UAAAA,CAAAA;AAE9C,YAAA,IAAIT,cAAc,CAAC,CAAA,IAAKG,KAAMW,CAAAA,MAAM,IAAId,SAAW,EAAA;AACjDG,gBAAAA,KAAAA,CAAMe,KAAK,EAAA;AACb;AAEAf,YAAAA,KAAAA,CAAMgB,IAAI,CAACV,UAAAA,CAAAA;AAEX,YAAA,OAAO,IAAI;AACb,SAAA;AAEAW,QAAAA,YAAAA,CAAAA,CAAad,QAA4B,EAAA;AACvCF,YAAAA,WAAAA,CAAY,YAAcE,EAAAA,QAAAA,CAAAA;AAE1B,YAAA,OAAO,IAAI;AACb,SAAA;QAEAC,EAA6BG,CAAAA,CAAAA,IAAO,EAAEJ,QAA+B,EAAA;AACnEF,YAAAA,WAAAA,CAAY,CAAC,WAAW,EAAEM,IAAAA,CAAK,CAAC,EAAEJ,QAAAA,CAAAA;AAElC,YAAA,OAAO,IAAI;AACb;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,49 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ const createDiagnosticReporter = (options = {})=>{
4
+ const { stackSize = -1 } = options;
5
+ const emitter = new EventEmitter();
6
+ const stack = [];
7
+ const addListener = (event, listener)=>{
8
+ emitter.on(event, listener);
9
+ };
10
+ const isDiagnosticValid = (diagnostic)=>{
11
+ if (!diagnostic.kind || !diagnostic.details || !diagnostic.details.message) {
12
+ return false;
13
+ }
14
+ return true;
15
+ };
16
+ return {
17
+ stack: {
18
+ get size () {
19
+ return stack.length;
20
+ },
21
+ get items () {
22
+ return stack;
23
+ }
24
+ },
25
+ report (diagnostic) {
26
+ if (!isDiagnosticValid(diagnostic)) {
27
+ return this;
28
+ }
29
+ emitter.emit('diagnostic', diagnostic);
30
+ emitter.emit(`diagnostic.${diagnostic.kind}`, diagnostic);
31
+ if (stackSize !== -1 && stack.length >= stackSize) {
32
+ stack.shift();
33
+ }
34
+ stack.push(diagnostic);
35
+ return this;
36
+ },
37
+ onDiagnostic (listener) {
38
+ addListener('diagnostic', listener);
39
+ return this;
40
+ },
41
+ on (kind, listener) {
42
+ addListener(`diagnostic.${kind}`, listener);
43
+ return this;
44
+ }
45
+ };
46
+ };
47
+
48
+ export { createDiagnosticReporter };
49
+ //# sourceMappingURL=diagnostic.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.mjs","sources":["../../src/utils/diagnostic.ts"],"sourcesContent":["import { EventEmitter } from 'events';\n\nexport interface IDiagnosticReporterOptions {\n stackSize?: number;\n}\n\nexport type GenericDiagnostic<K extends DiagnosticKind, T = unknown> = {\n kind: K;\n details: {\n message: string;\n createdAt: Date;\n } & T;\n};\n\nexport type DiagnosticKind = 'error' | 'warning' | 'info';\n\nexport type DiagnosticListener<T extends DiagnosticKind = DiagnosticKind> = (\n diagnostic: { kind: T } & Diagnostic extends infer U ? U : never\n) => void | Promise<void>;\n\nexport type DiagnosticEvent = 'diagnostic' | `diagnostic.${DiagnosticKind}`;\n\nexport type GetEventListener<E extends DiagnosticEvent> = E extends 'diagnostic'\n ? DiagnosticListener\n : E extends `diagnostic.${infer K}`\n ? K extends DiagnosticKind\n ? DiagnosticListener<K>\n : never\n : never;\n\nexport type Diagnostic = ErrorDiagnostic | WarningDiagnostic | InfoDiagnostic;\n\nexport type ErrorDiagnosticSeverity = 'fatal' | 'error' | 'silly';\n\nexport type ErrorDiagnostic = GenericDiagnostic<\n 'error',\n {\n name: string;\n severity: ErrorDiagnosticSeverity;\n error: Error;\n }\n>;\n\nexport type WarningDiagnostic = GenericDiagnostic<\n 'warning',\n {\n origin?: string;\n }\n>;\n\nexport type InfoDiagnostic<T = unknown> = GenericDiagnostic<\n 'info',\n {\n origin?: string;\n params?: T;\n }\n>;\n\nexport interface IDiagnosticReporter {\n stack: {\n readonly size: number;\n readonly items: Diagnostic[];\n };\n\n report(diagnostic: Diagnostic): IDiagnosticReporter;\n onDiagnostic(listener: DiagnosticListener): IDiagnosticReporter;\n on<T extends DiagnosticKind>(kind: T, listener: DiagnosticListener<T>): IDiagnosticReporter;\n}\n\nconst createDiagnosticReporter = (\n options: IDiagnosticReporterOptions = {}\n): IDiagnosticReporter => {\n const { stackSize = -1 } = options;\n\n const emitter = new EventEmitter();\n const stack: Diagnostic[] = [];\n\n const addListener = <T extends DiagnosticEvent>(event: T, listener: GetEventListener<T>) => {\n emitter.on(event, listener);\n };\n\n const isDiagnosticValid = (diagnostic: Diagnostic) => {\n if (!diagnostic.kind || !diagnostic.details || !diagnostic.details.message) {\n return false;\n }\n return true;\n };\n\n return {\n stack: {\n get size() {\n return stack.length;\n },\n\n get items() {\n return stack;\n },\n },\n\n report(diagnostic: Diagnostic) {\n if (!isDiagnosticValid(diagnostic)) {\n return this;\n }\n\n emitter.emit('diagnostic', diagnostic);\n emitter.emit(`diagnostic.${diagnostic.kind}`, diagnostic);\n\n if (stackSize !== -1 && stack.length >= stackSize) {\n stack.shift();\n }\n\n stack.push(diagnostic);\n\n return this;\n },\n\n onDiagnostic(listener: DiagnosticListener) {\n addListener('diagnostic', listener);\n\n return this;\n },\n\n on<T extends DiagnosticKind>(kind: T, listener: DiagnosticListener<T>) {\n addListener(`diagnostic.${kind}`, listener as never);\n\n return this;\n },\n };\n};\n\nexport { createDiagnosticReporter };\n"],"names":["createDiagnosticReporter","options","stackSize","emitter","EventEmitter","stack","addListener","event","listener","on","isDiagnosticValid","diagnostic","kind","details","message","size","length","items","report","emit","shift","push","onDiagnostic"],"mappings":";;AAqEA,MAAMA,wBAA2B,GAAA,CAC/BC,OAAsC,GAAA,EAAE,GAAA;AAExC,IAAA,MAAM,EAAEC,SAAAA,GAAY,CAAC,CAAC,EAAE,GAAGD,OAAAA;AAE3B,IAAA,MAAME,UA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A;AAE1B,YAAA,OAAO,IAAI;AACb,SAAA;QAEAC,EAA6BG,CAAAA,CAAAA,IAAO,EAAEJ,QAA+B,EAAA;AACnEF,YAAAA,WAAAA,CAAY,CAAC,WAAW,EAAEM,IAAAA,CAAK,CAAC,EAAEJ,QAAAA,CAAAA;AAElC,YAAA,OAAO,IAAI;AACb;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+
5
+ // different key values depending on algorithm chosen
6
+ const getDecryptionStrategy = (algorithm)=>{
7
+ const strategies = {
8
+ 'aes-128-ecb' (key) {
9
+ const hashedKey = crypto.scryptSync(key, '', 16);
10
+ const initVector = null;
11
+ const securityKey = hashedKey;
12
+ return crypto.createDecipheriv(algorithm, securityKey, initVector);
13
+ },
14
+ aes128 (key) {
15
+ const hashedKey = crypto.scryptSync(key, '', 32);
16
+ const initVector = hashedKey.slice(16);
17
+ const securityKey = hashedKey.slice(0, 16);
18
+ return crypto.createDecipheriv(algorithm, securityKey, initVector);
19
+ },
20
+ aes192 (key) {
21
+ const hashedKey = crypto.scryptSync(key, '', 40);
22
+ const initVector = hashedKey.slice(24);
23
+ const securityKey = hashedKey.slice(0, 24);
24
+ return crypto.createDecipheriv(algorithm, securityKey, initVector);
25
+ },
26
+ aes256 (key) {
27
+ const hashedKey = crypto.scryptSync(key, '', 48);
28
+ const initVector = hashedKey.slice(32);
29
+ const securityKey = hashedKey.slice(0, 32);
30
+ return crypto.createDecipheriv(algorithm, securityKey, initVector);
31
+ }
32
+ };
33
+ return strategies[algorithm];
34
+ };
35
+ /**
36
+ * It creates a cipher instance used for decryption
37
+ *
38
+ * @param key - The decryption key
39
+ * @param algorithm - The algorithm to use to create the Cipher
40
+ *
41
+ * @returns A {@link Cipher} instance created with the given key & algorithm
42
+ */ const createDecryptionCipher = (key, algorithm = 'aes-128-ecb')=>{
43
+ return getDecryptionStrategy(algorithm)(key);
44
+ };
45
+
46
+ exports.createDecryptionCipher = createDecryptionCipher;
47
+ //# sourceMappingURL=decrypt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decrypt.js","sources":["../../../src/utils/encryption/decrypt.ts"],"sourcesContent":["import { Cipher, scryptSync, CipherKey, BinaryLike, createDecipheriv } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getDecryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.slice(16);\n const securityKey: CipherKey = hashedKey.slice(0, 16);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.slice(24);\n const securityKey: CipherKey = hashedKey.slice(0, 24);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.slice(32);\n const securityKey: CipherKey = hashedKey.slice(0, 32);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for decryption\n *\n * @param key - The decryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipher} instance created with the given key & algorithm\n */\nexport const createDecryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipher => {\n return getDecryptionStrategy(algorithm)(key);\n};\n"],"names":["getDecryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createDecipheriv","aes128","slice","aes192","aes256","createDecryptionCipher"],"mappings":";;;;AAGA;AACA,MAAM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AAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,uBAAAA,CAAiBP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAClD;AACF,KAAA;IAEA,OAAOJ,UAAU,CAACD,SAAU,CAAA;AAC9B,CAAA;AAEA;;;;;;;AAOC,IACYY,MAAAA,sBAAAA,GAAyB,CACpCV,GAAAA,EACAF,YAAuB,aAAa,GAAA;AAEpC,IAAA,OAAOD,sBAAsBC,SAAWE,CAAAA,CAAAA,GAAAA,CAAAA;AAC1C;;;;"}
@@ -0,0 +1,45 @@
1
+ import { scryptSync, createDecipheriv } from 'crypto';
2
+
3
+ // different key values depending on algorithm chosen
4
+ const getDecryptionStrategy = (algorithm)=>{
5
+ const strategies = {
6
+ 'aes-128-ecb' (key) {
7
+ const hashedKey = scryptSync(key, '', 16);
8
+ const initVector = null;
9
+ const securityKey = hashedKey;
10
+ return createDecipheriv(algorithm, securityKey, initVector);
11
+ },
12
+ aes128 (key) {
13
+ const hashedKey = scryptSync(key, '', 32);
14
+ const initVector = hashedKey.slice(16);
15
+ const securityKey = hashedKey.slice(0, 16);
16
+ return createDecipheriv(algorithm, securityKey, initVector);
17
+ },
18
+ aes192 (key) {
19
+ const hashedKey = scryptSync(key, '', 40);
20
+ const initVector = hashedKey.slice(24);
21
+ const securityKey = hashedKey.slice(0, 24);
22
+ return createDecipheriv(algorithm, securityKey, initVector);
23
+ },
24
+ aes256 (key) {
25
+ const hashedKey = scryptSync(key, '', 48);
26
+ const initVector = hashedKey.slice(32);
27
+ const securityKey = hashedKey.slice(0, 32);
28
+ return createDecipheriv(algorithm, securityKey, initVector);
29
+ }
30
+ };
31
+ return strategies[algorithm];
32
+ };
33
+ /**
34
+ * It creates a cipher instance used for decryption
35
+ *
36
+ * @param key - The decryption key
37
+ * @param algorithm - The algorithm to use to create the Cipher
38
+ *
39
+ * @returns A {@link Cipher} instance created with the given key & algorithm
40
+ */ const createDecryptionCipher = (key, algorithm = 'aes-128-ecb')=>{
41
+ return getDecryptionStrategy(algorithm)(key);
42
+ };
43
+
44
+ export { createDecryptionCipher };
45
+ //# sourceMappingURL=decrypt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decrypt.mjs","sources":["../../../src/utils/encryption/decrypt.ts"],"sourcesContent":["import { Cipher, scryptSync, CipherKey, BinaryLike, createDecipheriv } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getDecryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.slice(16);\n const securityKey: CipherKey = hashedKey.slice(0, 16);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.slice(24);\n const securityKey: CipherKey = hashedKey.slice(0, 24);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.slice(32);\n const securityKey: CipherKey = hashedKey.slice(0, 32);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for decryption\n *\n * @param key - The decryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipher} instance created with the given key & algorithm\n */\nexport const createDecryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipher => {\n return getDecryptionStrategy(algorithm)(key);\n};\n"],"names":["getDecryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createDecipheriv","aes128","slice","aes192","aes256","createDecryptionCipher"],"mappings":";;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,UAAyB,GAAA;AAC7B,QAAA,aAAA,CAAA,CAAcC,GAAW,EAAA;YACvB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;AACtC,YAAA,MAAMG,UAAgC,GAAA,IAAA;AACtC,YAAA,MAAMC,WAAyBH,GAAAA,SAAAA;YAC/B,OAAOI,gBAAAA,CAAiBP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAClD,SAAA;AACAG,QAAAA,MAAAA,CAAAA,CAAON,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,gBAAAA,CAAiBP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAClD,SAAA;AACAK,QAAAA,MAAAA,CAAAA,CAAOR,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,gBAAAA,CAAiBP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAClD,SAAA;AACAM,QAAAA,MAAAA,CAAAA,CAAOT,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,gBAAAA,CAAiBP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAClD;AACF,KAAA;IAEA,OAAOJ,UAAU,CAACD,SAAU,CAAA;AAC9B,CAAA;AAEA;;;;;;;AAOC,IACYY,MAAAA,sBAAAA,GAAyB,CACpCV,GAAAA,EACAF,YAAuB,aAAa,GAAA;AAEpC,IAAA,OAAOD,sBAAsBC,SAAWE,CAAAA,CAAAA,GAAAA,CAAAA;AAC1C;;;;"}
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+
5
+ // different key values depending on algorithm chosen
6
+ const getEncryptionStrategy = (algorithm)=>{
7
+ const strategies = {
8
+ 'aes-128-ecb' (key) {
9
+ const hashedKey = crypto.scryptSync(key, '', 16);
10
+ const initVector = null;
11
+ const securityKey = hashedKey;
12
+ return crypto.createCipheriv(algorithm, securityKey, initVector);
13
+ },
14
+ aes128 (key) {
15
+ const hashedKey = crypto.scryptSync(key, '', 32);
16
+ const initVector = hashedKey.slice(16);
17
+ const securityKey = hashedKey.slice(0, 16);
18
+ return crypto.createCipheriv(algorithm, securityKey, initVector);
19
+ },
20
+ aes192 (key) {
21
+ const hashedKey = crypto.scryptSync(key, '', 40);
22
+ const initVector = hashedKey.slice(24);
23
+ const securityKey = hashedKey.slice(0, 24);
24
+ return crypto.createCipheriv(algorithm, securityKey, initVector);
25
+ },
26
+ aes256 (key) {
27
+ const hashedKey = crypto.scryptSync(key, '', 48);
28
+ const initVector = hashedKey.slice(32);
29
+ const securityKey = hashedKey.slice(0, 32);
30
+ return crypto.createCipheriv(algorithm, securityKey, initVector);
31
+ }
32
+ };
33
+ return strategies[algorithm];
34
+ };
35
+ /**
36
+ * It creates a cipher instance used for encryption
37
+ *
38
+ * @param key - The encryption key
39
+ * @param algorithm - The algorithm to use to create the Cipher
40
+ *
41
+ * @returns A {@link Cipher} instance created with the given key & algorithm
42
+ */ const createEncryptionCipher = (key, algorithm = 'aes-128-ecb')=>{
43
+ return getEncryptionStrategy(algorithm)(key);
44
+ };
45
+
46
+ exports.createEncryptionCipher = createEncryptionCipher;
47
+ //# sourceMappingURL=encrypt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt.js","sources":["../../../src/utils/encryption/encrypt.ts"],"sourcesContent":["import { createCipheriv, Cipher, scryptSync, CipherKey, BinaryLike } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getEncryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.slice(16);\n const securityKey: CipherKey = hashedKey.slice(0, 16);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.slice(24);\n const securityKey: CipherKey = hashedKey.slice(0, 24);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.slice(32);\n const securityKey: CipherKey = hashedKey.slice(0, 32);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for encryption\n *\n * @param key - The encryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipher} instance created with the given key & algorithm\n */\nexport const createEncryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipher => {\n return getEncryptionStrategy(algorithm)(key);\n};\n"],"names":["getEncryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createCipheriv","aes128","slice","aes192","aes256","createEncryptionCipher"],"mappings":";;;;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,UAAyB,GAAA;AAC7B,QAAA,aAAA,CAAA,CAAcC,GAAW,EAAA;YACvB,MAAMC,SAAAA,GAAYC,iBAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;AACtC,YAAA,MAAMG,UAAgC,GAAA,IAAA;AACtC,YAAA,MAAMC,WAAyBH,GAAAA,SAAAA;YAC/B,OAAOI,qBAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD,SAAA;AACAG,QAAAA,MAAAA,CAAAA,CAAON,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,iBAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,qBAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD,SAAA;AACAK,QAAAA,MAAAA,CAAAA,CAAOR,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,iBAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,qBAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD,SAAA;AACAM,QAAAA,MAAAA,CAAAA,CAAOT,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,iBAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,qBAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD;AACF,KAAA;IAEA,OAAOJ,UAAU,CAACD,SAAU,CAAA;AAC9B,CAAA;AAEA;;;;;;;AAOC,IACYY,MAAAA,sBAAAA,GAAyB,CACpCV,GAAAA,EACAF,YAAuB,aAAa,GAAA;AAEpC,IAAA,OAAOD,sBAAsBC,SAAWE,CAAAA,CAAAA,GAAAA,CAAAA;AAC1C;;;;"}
@@ -0,0 +1,45 @@
1
+ import { scryptSync, createCipheriv } from 'crypto';
2
+
3
+ // different key values depending on algorithm chosen
4
+ const getEncryptionStrategy = (algorithm)=>{
5
+ const strategies = {
6
+ 'aes-128-ecb' (key) {
7
+ const hashedKey = scryptSync(key, '', 16);
8
+ const initVector = null;
9
+ const securityKey = hashedKey;
10
+ return createCipheriv(algorithm, securityKey, initVector);
11
+ },
12
+ aes128 (key) {
13
+ const hashedKey = scryptSync(key, '', 32);
14
+ const initVector = hashedKey.slice(16);
15
+ const securityKey = hashedKey.slice(0, 16);
16
+ return createCipheriv(algorithm, securityKey, initVector);
17
+ },
18
+ aes192 (key) {
19
+ const hashedKey = scryptSync(key, '', 40);
20
+ const initVector = hashedKey.slice(24);
21
+ const securityKey = hashedKey.slice(0, 24);
22
+ return createCipheriv(algorithm, securityKey, initVector);
23
+ },
24
+ aes256 (key) {
25
+ const hashedKey = scryptSync(key, '', 48);
26
+ const initVector = hashedKey.slice(32);
27
+ const securityKey = hashedKey.slice(0, 32);
28
+ return createCipheriv(algorithm, securityKey, initVector);
29
+ }
30
+ };
31
+ return strategies[algorithm];
32
+ };
33
+ /**
34
+ * It creates a cipher instance used for encryption
35
+ *
36
+ * @param key - The encryption key
37
+ * @param algorithm - The algorithm to use to create the Cipher
38
+ *
39
+ * @returns A {@link Cipher} instance created with the given key & algorithm
40
+ */ const createEncryptionCipher = (key, algorithm = 'aes-128-ecb')=>{
41
+ return getEncryptionStrategy(algorithm)(key);
42
+ };
43
+
44
+ export { createEncryptionCipher };
45
+ //# sourceMappingURL=encrypt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt.mjs","sources":["../../../src/utils/encryption/encrypt.ts"],"sourcesContent":["import { createCipheriv, Cipher, scryptSync, CipherKey, BinaryLike } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getEncryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.slice(16);\n const securityKey: CipherKey = hashedKey.slice(0, 16);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.slice(24);\n const securityKey: CipherKey = hashedKey.slice(0, 24);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipher {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.slice(32);\n const securityKey: CipherKey = hashedKey.slice(0, 32);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for encryption\n *\n * @param key - The encryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipher} instance created with the given key & algorithm\n */\nexport const createEncryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipher => {\n return getEncryptionStrategy(algorithm)(key);\n};\n"],"names":["getEncryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createCipheriv","aes128","slice","aes192","aes256","createEncryptionCipher"],"mappings":";;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,UAAyB,GAAA;AAC7B,QAAA,aAAA,CAAA,CAAcC,GAAW,EAAA;YACvB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;AACtC,YAAA,MAAMG,UAAgC,GAAA,IAAA;AACtC,YAAA,MAAMC,WAAyBH,GAAAA,SAAAA;YAC/B,OAAOI,cAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD,SAAA;AACAG,QAAAA,MAAAA,CAAAA,CAAON,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,cAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD,SAAA;AACAK,QAAAA,MAAAA,CAAAA,CAAOR,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,cAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD,SAAA;AACAM,QAAAA,MAAAA,CAAAA,CAAOT,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAWF,CAAAA,GAAAA,EAAK,EAAI,EAAA,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAUM,CAAAA,KAAK,CAAC,EAAA,CAAA;AACtD,YAAA,MAAMH,WAAyBH,GAAAA,SAAAA,CAAUM,KAAK,CAAC,CAAG,EAAA,EAAA,CAAA;YAClD,OAAOF,cAAAA,CAAeP,WAAWM,WAAaD,EAAAA,UAAAA,CAAAA;AAChD;AACF,KAAA;IAEA,OAAOJ,UAAU,CAACD,SAAU,CAAA;AAC9B,CAAA;AAEA;;;;;;;AAOC,IACYY,MAAAA,sBAAAA,GAAyB,CACpCV,GAAAA,EACAF,YAAuB,aAAa,GAAA;AAEpC,IAAA,OAAOD,sBAAsBC,SAAWE,CAAAA,CAAAA,GAAAA,CAAAA;AAC1C;;;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var encrypt = require('./encrypt.js');
4
+ var decrypt = require('./decrypt.js');
5
+
6
+
7
+
8
+ exports.createEncryptionCipher = encrypt.createEncryptionCipher;
9
+ exports.createDecryptionCipher = decrypt.createDecryptionCipher;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ export { createEncryptionCipher } from './encrypt.mjs';
2
+ export { createDecryptionCipher } from './decrypt.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var index = require('./encryption/index.js');
4
+ var stream = require('./stream.js');
5
+ var json = require('./json.js');
6
+ var schema = require('./schema.js');
7
+ var transaction = require('./transaction.js');
8
+ var middleware = require('./middleware.js');
9
+ var diagnostic = require('./diagnostic.js');
10
+
11
+
12
+
13
+ exports.encryption = index;
14
+ exports.stream = stream;
15
+ exports.json = json;
16
+ exports.schema = schema;
17
+ exports.transaction = transaction;
18
+ exports.middleware = middleware;
19
+ exports.diagnostics = diagnostic;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}