jourycms-sdk 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. package/dist/base.app-container.d.ts +7 -0
  2. package/dist/base.app-container.d.ts.map +1 -0
  3. package/dist/base.app-container.js +10 -0
  4. package/dist/base.client.d.ts +10 -0
  5. package/dist/base.client.d.ts.map +1 -0
  6. package/dist/base.client.js +16 -0
  7. package/dist/base.service-container.d.ts +8 -0
  8. package/dist/base.service-container.d.ts.map +1 -0
  9. package/dist/base.service-container.js +12 -0
  10. package/dist/containers/auth/clients/api-keys.client.d.ts +13 -0
  11. package/dist/containers/auth/clients/api-keys.client.d.ts.map +1 -0
  12. package/dist/containers/auth/clients/api-keys.client.js +48 -0
  13. package/dist/containers/auth/clients/auth.client.d.ts +12 -0
  14. package/dist/containers/auth/clients/auth.client.d.ts.map +1 -0
  15. package/dist/containers/auth/clients/auth.client.js +39 -0
  16. package/dist/containers/auth/clients/permission-groups.client.d.ts +12 -0
  17. package/dist/containers/auth/clients/permission-groups.client.d.ts.map +1 -0
  18. package/dist/containers/auth/clients/permission-groups.client.js +42 -0
  19. package/dist/containers/auth/clients/permissions.client.d.ts +13 -0
  20. package/dist/containers/auth/clients/permissions.client.d.ts.map +1 -0
  21. package/dist/containers/auth/clients/permissions.client.js +48 -0
  22. package/dist/containers/auth/clients/roles.client.d.ts +17 -0
  23. package/dist/containers/auth/clients/roles.client.d.ts.map +1 -0
  24. package/dist/containers/auth/clients/roles.client.js +72 -0
  25. package/dist/containers/auth/clients/users.client.d.ts +26 -0
  26. package/dist/containers/auth/clients/users.client.d.ts.map +1 -0
  27. package/dist/containers/auth/clients/users.client.js +128 -0
  28. package/dist/containers/auth/service-container.d.ts +23 -0
  29. package/dist/containers/auth/service-container.d.ts.map +1 -0
  30. package/dist/containers/auth/service-container.js +48 -0
  31. package/dist/containers/content/clients/article-types.client.d.ts +15 -0
  32. package/dist/containers/content/clients/article-types.client.d.ts.map +1 -0
  33. package/dist/containers/content/clients/article-types.client.js +60 -0
  34. package/dist/containers/content/clients/articles.client.d.ts +15 -0
  35. package/dist/containers/content/clients/articles.client.d.ts.map +1 -0
  36. package/dist/containers/content/clients/articles.client.js +60 -0
  37. package/dist/containers/content/clients/comments.client.d.ts +15 -0
  38. package/dist/containers/content/clients/comments.client.d.ts.map +1 -0
  39. package/dist/containers/content/clients/comments.client.js +60 -0
  40. package/dist/containers/content/clients/reviews.client.d.ts +15 -0
  41. package/dist/containers/content/clients/reviews.client.d.ts.map +1 -0
  42. package/dist/containers/content/clients/reviews.client.js +60 -0
  43. package/dist/containers/content/clients/taxonomies.client.d.ts +15 -0
  44. package/dist/containers/content/clients/taxonomies.client.d.ts.map +1 -0
  45. package/dist/containers/content/clients/taxonomies.client.js +60 -0
  46. package/dist/containers/content/clients/terms.client.d.ts +15 -0
  47. package/dist/containers/content/clients/terms.client.d.ts.map +1 -0
  48. package/dist/containers/content/clients/terms.client.js +60 -0
  49. package/dist/containers/content/clients/translation.items.client.d.ts +16 -0
  50. package/dist/containers/content/clients/translation.items.client.d.ts.map +1 -0
  51. package/dist/containers/content/clients/translation.items.client.js +66 -0
  52. package/dist/containers/content/clients/translation.namespaces.client.d.ts +16 -0
  53. package/dist/containers/content/clients/translation.namespaces.client.d.ts.map +1 -0
  54. package/dist/containers/content/clients/translation.namespaces.client.js +66 -0
  55. package/dist/containers/content/clients/translation.projects.client.d.ts +16 -0
  56. package/dist/containers/content/clients/translation.projects.client.d.ts.map +1 -0
  57. package/dist/containers/content/clients/translation.projects.client.js +66 -0
  58. package/dist/containers/content/service-container.d.ts +29 -0
  59. package/dist/containers/content/service-container.d.ts.map +1 -0
  60. package/dist/containers/content/service-container.js +66 -0
  61. package/dist/containers/storage/clients/files.client.d.ts +13 -0
  62. package/dist/containers/storage/clients/files.client.d.ts.map +1 -0
  63. package/dist/containers/storage/clients/files.client.js +48 -0
  64. package/dist/containers/storage/clients/uploader.client.d.ts +6 -0
  65. package/dist/containers/storage/clients/uploader.client.d.ts.map +1 -0
  66. package/dist/containers/storage/clients/uploader.client.js +12 -0
  67. package/dist/containers/storage/clients/utils.client.d.ts +15 -0
  68. package/dist/containers/storage/clients/utils.client.d.ts.map +1 -0
  69. package/dist/containers/storage/clients/utils.client.js +45 -0
  70. package/dist/containers/storage/service-container.d.ts +31 -0
  71. package/dist/containers/storage/service-container.d.ts.map +1 -0
  72. package/dist/containers/storage/service-container.js +63 -0
  73. package/dist/containers/system/clients/apps.client.d.ts +16 -0
  74. package/dist/containers/system/clients/apps.client.d.ts.map +1 -0
  75. package/dist/containers/system/clients/apps.client.js +66 -0
  76. package/dist/containers/system/service-container.d.ts +13 -0
  77. package/dist/containers/system/service-container.d.ts.map +1 -0
  78. package/dist/containers/system/service-container.js +18 -0
  79. package/dist/exceptions/api-response.exception.d.ts +15 -0
  80. package/dist/exceptions/api-response.exception.d.ts.map +1 -0
  81. package/dist/exceptions/api-response.exception.js +26 -0
  82. package/dist/http-client.d.ts +20 -0
  83. package/dist/http-client.d.ts.map +1 -0
  84. package/dist/http-client.js +187 -0
  85. package/dist/index.d.ts +37 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +237 -0
  88. package/dist/init-sdk.d.ts +21 -0
  89. package/dist/init-sdk.d.ts.map +1 -0
  90. package/dist/init-sdk.js +17 -0
  91. package/dist/sdk.test.d.ts +1 -0
  92. package/dist/sdk.test.d.ts.map +1 -0
  93. package/dist/sdk.test.js +1 -0
  94. package/dist/utils/helpers.d.ts +5 -0
  95. package/dist/utils/helpers.d.ts.map +1 -0
  96. package/dist/utils/helpers.js +13 -0
  97. package/dist/utils/logger.d.ts +133 -0
  98. package/dist/utils/logger.d.ts.map +1 -0
  99. package/dist/utils/logger.js +176 -0
  100. package/package.json +49 -0
  101. package/typings/index.d.ts +1 -0
  102. package/typings/v1/cache-manager/class.d.ts +0 -0
  103. package/typings/v1/cache-manager/entity.d.ts +83 -0
  104. package/typings/v1/cache-manager/index.d.ts +5 -0
  105. package/typings/v1/cache-manager/store.d.ts +35 -0
  106. package/typings/v1/events/index.d.ts +3 -0
  107. package/typings/v1/events/payloads.d.ts +339 -0
  108. package/typings/v1/index.d.ts +8 -0
  109. package/typings/v1/lib/execution-scenario/index.d.ts +27 -0
  110. package/typings/v1/lib/index.d.ts +4 -0
  111. package/typings/v1/lib/logger/index.d.ts +3 -0
  112. package/typings/v1/lib/logger/logger.d.ts +53 -0
  113. package/typings/v1/modules/express/express.d.ts +40 -0
  114. package/typings/v1/modules/express/index.d.ts +3 -0
  115. package/typings/v1/modules/index.d.ts +4 -0
  116. package/typings/v1/modules/mongoose/index.d.ts +3 -0
  117. package/typings/v1/modules/mongoose/mongoose.d.ts +48 -0
  118. package/typings/v1/sdk/index.d.ts +3 -0
  119. package/typings/v1/sdk/sdk.d.ts +158 -0
  120. package/typings/v1/security/auth-data.d.ts +36 -0
  121. package/typings/v1/security/index.d.ts +4 -0
  122. package/typings/v1/security/jwt.d.ts +36 -0
  123. package/typings/v1/services/auth/api/api-key.d.ts +144 -0
  124. package/typings/v1/services/auth/api/auth.d.ts +168 -0
  125. package/typings/v1/services/auth/api/index.d.ts +9 -0
  126. package/typings/v1/services/auth/api/permission-group.d.ts +95 -0
  127. package/typings/v1/services/auth/api/permission.d.ts +128 -0
  128. package/typings/v1/services/auth/api/role.d.ts +193 -0
  129. package/typings/v1/services/auth/api/tools.d.ts +33 -0
  130. package/typings/v1/services/auth/api/user.d.ts +391 -0
  131. package/typings/v1/services/auth/entities/_shared.d.ts +11 -0
  132. package/typings/v1/services/auth/entities/api-key.d.ts +29 -0
  133. package/typings/v1/services/auth/entities/federated-credential.d.ts +22 -0
  134. package/typings/v1/services/auth/entities/index.d.ts +9 -0
  135. package/typings/v1/services/auth/entities/permission-group.d.ts +20 -0
  136. package/typings/v1/services/auth/entities/permission.d.ts +24 -0
  137. package/typings/v1/services/auth/entities/role.d.ts +25 -0
  138. package/typings/v1/services/auth/entities/user.d.ts +153 -0
  139. package/typings/v1/services/auth/index.d.ts +5 -0
  140. package/typings/v1/services/auth/models/.DS_Store +0 -0
  141. package/typings/v1/services/auth/models/api-key.d.ts +19 -0
  142. package/typings/v1/services/auth/models/api-key.model.d.ts +3 -0
  143. package/typings/v1/services/auth/models/federated-credential.d.ts +24 -0
  144. package/typings/v1/services/auth/models/index.d.ts +9 -0
  145. package/typings/v1/services/auth/models/permission-group.d.ts +24 -0
  146. package/typings/v1/services/auth/models/permission.d.ts +22 -0
  147. package/typings/v1/services/auth/models/role.d.ts +22 -0
  148. package/typings/v1/services/auth/models/user.d.ts +22 -0
  149. package/typings/v1/services/content/api/article-type.d.ts +160 -0
  150. package/typings/v1/services/content/api/article.d.ts +108 -0
  151. package/typings/v1/services/content/api/comment.d.ts +106 -0
  152. package/typings/v1/services/content/api/index.d.ts +12 -0
  153. package/typings/v1/services/content/api/review.d.ts +105 -0
  154. package/typings/v1/services/content/api/taxonomy.d.ts +101 -0
  155. package/typings/v1/services/content/api/term.d.ts +101 -0
  156. package/typings/v1/services/content/api/translation.item.d.ts +195 -0
  157. package/typings/v1/services/content/api/translation.namespace.d.ts +135 -0
  158. package/typings/v1/services/content/api/translation.project.d.ts +196 -0
  159. package/typings/v1/services/content/api/translation.tools.d.ts +85 -0
  160. package/typings/v1/services/content/entities/article-type.d.ts +51 -0
  161. package/typings/v1/services/content/entities/article.d.ts +53 -0
  162. package/typings/v1/services/content/entities/comment.d.ts +34 -0
  163. package/typings/v1/services/content/entities/index.d.ts +11 -0
  164. package/typings/v1/services/content/entities/review.d.ts +35 -0
  165. package/typings/v1/services/content/entities/taxonomy.d.ts +40 -0
  166. package/typings/v1/services/content/entities/term.d.ts +43 -0
  167. package/typings/v1/services/content/entities/translation.item.d.ts +48 -0
  168. package/typings/v1/services/content/entities/translation.namespace.d.ts +29 -0
  169. package/typings/v1/services/content/entities/translation.project.d.ts +98 -0
  170. package/typings/v1/services/content/index.d.ts +5 -0
  171. package/typings/v1/services/content/models/article-type.d.ts +19 -0
  172. package/typings/v1/services/content/models/article.d.ts +19 -0
  173. package/typings/v1/services/content/models/comment.d.ts +19 -0
  174. package/typings/v1/services/content/models/index.d.ts +11 -0
  175. package/typings/v1/services/content/models/review.d.ts +19 -0
  176. package/typings/v1/services/content/models/taxonomy.d.ts +19 -0
  177. package/typings/v1/services/content/models/term.d.ts +19 -0
  178. package/typings/v1/services/content/models/translation.item.d.ts +21 -0
  179. package/typings/v1/services/content/models/translation.namespace.d.ts +22 -0
  180. package/typings/v1/services/content/models/translation.project.d.ts +21 -0
  181. package/typings/v1/services/index.d.ts +4 -0
  182. package/typings/v1/services/storage/api/index.d.ts +3 -0
  183. package/typings/v1/services/storage/api/uploaded-file.d.ts +166 -0
  184. package/typings/v1/services/storage/entities/index.d.ts +3 -0
  185. package/typings/v1/services/storage/entities/uploaded-file.d.ts +49 -0
  186. package/typings/v1/services/storage/index.d.ts +5 -0
  187. package/typings/v1/services/storage/models/index.d.ts +3 -0
  188. package/typings/v1/services/storage/models/uploaded-file.d.ts +19 -0
  189. package/typings/v1/services/system/api/app.d.ts +130 -0
  190. package/typings/v1/services/system/api/index.d.ts +3 -0
  191. package/typings/v1/services/system/entities/app.d.ts +97 -0
  192. package/typings/v1/services/system/entities/index.d.ts +3 -0
  193. package/typings/v1/services/system/index.d.ts +5 -0
  194. package/typings/v1/services/system/models/app.d.ts +19 -0
  195. package/typings/v1/services/system/models/index.d.ts +3 -0
  196. package/typings/v1/ui/admin/index.d.ts +1 -0
  197. package/typings/v1/ui/forms/article/custom-fieds/custom-field.d.ts +189 -0
  198. package/typings/v1/ui/forms/article/custom-fieds/fields/article_object.custom-field.d.ts +29 -0
  199. package/typings/v1/ui/forms/article/custom-fieds/fields/boolean.custom-field.d.ts +24 -0
  200. package/typings/v1/ui/forms/article/custom-fieds/fields/checkbox.custom-field.d.ts +26 -0
  201. package/typings/v1/ui/forms/article/custom-fieds/fields/date.custom-field.d.ts +23 -0
  202. package/typings/v1/ui/forms/article/custom-fieds/fields/date_range.custom-field.d.ts +26 -0
  203. package/typings/v1/ui/forms/article/custom-fieds/fields/file.custom-field.d.ts +26 -0
  204. package/typings/v1/ui/forms/article/custom-fieds/fields/image.custom-field.d.ts +25 -0
  205. package/typings/v1/ui/forms/article/custom-fieds/fields/index.d.ts +11 -0
  206. package/typings/v1/ui/forms/article/custom-fieds/fields/number.custom-field.d.ts +26 -0
  207. package/typings/v1/ui/forms/article/custom-fieds/fields/radiobox.custom-field.d.ts +27 -0
  208. package/typings/v1/ui/forms/article/custom-fieds/fields/select.custom-field.d.ts +27 -0
  209. package/typings/v1/ui/forms/article/custom-fieds/fields/text.custom-field.d.ts +26 -0
  210. package/typings/v1/ui/forms/article/custom-fieds/fields/time.custom-field.d.ts +24 -0
  211. package/typings/v1/ui/forms/article/custom-fieds/index.d.ts +1 -0
  212. package/typings/v1/ui/forms/article/index.d.ts +1 -0
  213. package/typings/v1/ui/forms/index.d.ts +1 -0
  214. package/typings/v1/ui/index.d.ts +3 -0
  215. package/typings/v1/ui/routes/index.d.ts +1 -0
  216. package/typings/v1/ui/routes/routes.d.ts +73 -0
  217. package/typings/v1/utils/api/index.d.ts +4 -0
  218. package/typings/v1/utils/api/request.d.ts +215 -0
  219. package/typings/v1/utils/api/response.d.ts +188 -0
  220. package/typings/v1/utils/common/common.d.ts +53 -0
  221. package/typings/v1/utils/common/index.d.ts +3 -0
  222. package/typings/v1/utils/dev/config.d.ts +135 -0
  223. package/typings/v1/utils/dev/index.d.ts +4 -0
  224. package/typings/v1/utils/dev/instrumentation.d.ts +41 -0
  225. package/typings/v1/utils/entities/entities.d.ts +66 -0
  226. package/typings/v1/utils/entities/index.d.ts +4 -0
  227. package/typings/v1/utils/entities/snapshots.d.ts +69 -0
  228. package/typings/v1/utils/index.d.ts +10 -0
  229. package/typings/v1/utils/models/index.d.ts +3 -0
  230. package/typings/v1/utils/models/models.d.ts +50 -0
  231. package/typings/v1/utils/seed/index.d.ts +3 -0
  232. package/typings/v1/utils/seed/locations.d.ts +41 -0
  233. package/typings/v1/utils/system/microservice.d.ts +11 -0
  234. package/typings/v1/utils/system/models.d.ts +21 -0
  235. package/typings/v1/utils/utils.d.ts +171 -0
@@ -0,0 +1,21 @@
1
+ import JouryCMSSdk from ".";
2
+ export type LevelupClientAppApiCallHeaders = Partial<{
3
+ Authorization: string;
4
+ 'X-App-Id': string;
5
+ }>;
6
+ export type LevelupInternalAppApiCallHeaders = Partial<{
7
+ Authorization: string;
8
+ 'X-App-Id': string;
9
+ }> & {
10
+ 'X-Service-Secret': string;
11
+ 'X-Service-Name': string;
12
+ };
13
+ export declare function initSdk<Client extends 'backend' | 'frontend'>(client: Client, config: {
14
+ baseURL: string;
15
+ appId: string;
16
+ appSecret: string;
17
+ debug: boolean;
18
+ headersInjector: Client extends 'frontend' ? () => LevelupClientAppApiCallHeaders | PromiseLike<LevelupClientAppApiCallHeaders> : () => LevelupInternalAppApiCallHeaders | PromiseLike<LevelupInternalAppApiCallHeaders>;
19
+ refreshTokenHandler?: (sdk: Levelup.CMS.V1.SDK.ISdk) => Promise<void>;
20
+ }, id?: string): JouryCMSSdk;
21
+ //# sourceMappingURL=init-sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-sdk.d.ts","sourceRoot":"","sources":["../src/init-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,GAAG,CAAC;AAE5B,MAAM,MAAM,8BAA8B,GAAG,OAAO,CAAC;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAAA;AAEF,MAAM,MAAM,gCAAgC,GAAG,OAAO,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,GAAG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAA;AAKD,wBAAgB,OAAO,CAAC,MAAM,SAAS,SAAS,GAAG,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IACrF,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,eAAe,EAAE,MAAM,SAAS,UAAU,GAAG,MAAM,8BAA8B,GAAG,WAAW,CAAC,8BAA8B,CAAC,GAAG,MAAM,gCAAgC,GAAG,WAAW,CAAC,gCAAgC,CAAC,CAAA;IACxN,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE,EAAE,EAAE,GAAE,MAAkB,eASxB"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initSdk = initSdk;
7
+ const _1 = __importDefault(require("."));
8
+ function initSdk(client, config, id = 'DEFAULT') {
9
+ return _1.default.getInstance({
10
+ baseURL: config.baseURL,
11
+ appId: config.appId,
12
+ appSecret: config.appSecret,
13
+ headers: config.headersInjector,
14
+ refreshTokenHandler: config.refreshTokenHandler,
15
+ debug: config.debug
16
+ }, id);
17
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=sdk.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.test.d.ts","sourceRoot":"","sources":["../src/sdk.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,5 @@
1
+ export default class JouryCMSSdkHelpers {
2
+ getEdge: <Edge extends Levelup.CMS.V1.Utils.Api.Response.TResponseEdge, E extends keyof Edge>(edge: Partial<Edge> | undefined, entity: E, _id?: string | null) => Edge[E][keyof Edge[E]] | undefined;
3
+ isValidId(id: string | null | undefined): boolean;
4
+ }
5
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAC9B,OAAO,EAAE,CACd,IAAI,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,EAC5D,CAAC,SAAS,MAAM,IAAI,EAEpB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,EAC/B,MAAM,EAAE,CAAC,EACT,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,KAChB,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAGrC;IAEK,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;CAGzD"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class JouryCMSSdkHelpers {
4
+ getEdge = (edge, entity, _id) => {
5
+ if (!_id)
6
+ return undefined;
7
+ return ((edge ?? {})[entity] ?? {})[_id];
8
+ };
9
+ isValidId(id) {
10
+ return !!id && id.length === 24;
11
+ }
12
+ }
13
+ exports.default = JouryCMSSdkHelpers;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @generator Levelup
3
+ * @author dr. Salmi <reevosolutions@gmail.com>
4
+ * @since 24-02-2024 20:47:22
5
+ */
6
+ type InstanceContext = 'SDK' | 'CLIENT' | 'CACHE' | 'HTTP_CLIENT';
7
+ /**
8
+ * Represents a logger service.
9
+ */
10
+ export declare class LoggerService {
11
+ private context;
12
+ private contextId;
13
+ private static muted;
14
+ /**
15
+ * Returns an instance of the LoggerService.
16
+ * @param context The context of the logger instance.
17
+ * @param contextId The context ID of the logger instance.
18
+ * @param config The configuration of the logger instance.
19
+ * @returns An instance of the LoggerService.
20
+ */
21
+ static getInstance(context?: InstanceContext, contextId?: string): LoggerService;
22
+ /**
23
+ * Mutes the logger instance.
24
+ * @param context The context of the logger instance.
25
+ * @param contextId The context ID of the logger instance.
26
+ */
27
+ static mute(context?: InstanceContext, contextId?: string): void;
28
+ /**
29
+ * Unmutes the logger instance.
30
+ * @param context The context of the logger instance.
31
+ * @param contextId The context ID of the logger instance.
32
+ */
33
+ static unmute(context?: InstanceContext, contextId?: string): void;
34
+ /**
35
+ * Constructs a new instance of the LoggerService.
36
+ * @param context The context of the logger instance.
37
+ * @param contextId The context ID of the logger instance.
38
+ * @param config The configuration of the logger instance.
39
+ */
40
+ constructor(context: InstanceContext, contextId: string);
41
+ /**
42
+ * Logs a message with the specified log type.
43
+ * @param type The log type.
44
+ * @param message The log message.
45
+ * @param args Additional arguments to be logged.
46
+ */
47
+ log(type: Levelup.CMS.V1.Lib.Logger.LogType, message: string, ...args: any[]): void;
48
+ /**
49
+ * Logs a warning message.
50
+ * @param message The warning message.
51
+ * @param args Additional arguments to be logged.
52
+ */
53
+ warn(message: string, ...args: any[]): void;
54
+ /**
55
+ * Logs an error message.
56
+ * @param message The error message.
57
+ * @param args Additional arguments to be logged.
58
+ */
59
+ error(message: string, ...args: any[]): void;
60
+ /**
61
+ * Logs an info message.
62
+ * @param message The info message.
63
+ * @param args Additional arguments to be logged.
64
+ */
65
+ info(message: string, ...args: any[]): void;
66
+ /**
67
+ * Logs a debug message.
68
+ * @param message The debug message.
69
+ * @param args Additional arguments to be logged.
70
+ */
71
+ debug(message: string, ...args: any[]): void;
72
+ /**
73
+ * Logs a success message.
74
+ * @param message The success message.
75
+ * @param args Additional arguments to be logged.
76
+ */
77
+ success(message: string, ...args: any[]): void;
78
+ /**
79
+ * Logs a silly message.
80
+ * @param message The silly message.
81
+ * @param args Additional arguments to be logged.
82
+ */
83
+ silly(message: string, ...args: any[]): void;
84
+ /**
85
+ * Logs an HTTP message.
86
+ * @param message The HTTP message.
87
+ * @param args Additional arguments to be logged.
88
+ */
89
+ http(message: string, ...args: any[]): void;
90
+ /**
91
+ * Logs an event message.
92
+ * @param message The event message.
93
+ * @param args Additional arguments to be logged.
94
+ */
95
+ event(message: string, ...args: any[]): void;
96
+ /**
97
+ * Logs a value message.
98
+ * @param message The value message.
99
+ * @param args Additional arguments to be logged.
100
+ */
101
+ value(message: string, ...args: any[]): void;
102
+ }
103
+ /**
104
+ * Represents a log item type.
105
+ */
106
+ export type LogItemType = "event" | "debug" | "http" | "warn" | "error";
107
+ /**
108
+ * Represents a log item severity.
109
+ */
110
+ export type LogItemSeverity = "success" | "info" | "debug" | "trace" | "notice" | "warn" | "error" | "alert" | "critical" | "emergency" | "fatal";
111
+ /**
112
+ * Represents a log item.
113
+ */
114
+ export type ILogItem = {
115
+ name: string;
116
+ payload: {
117
+ related_to?: string;
118
+ [key: string]: any;
119
+ };
120
+ service?: string;
121
+ severity?: LogItemSeverity;
122
+ related_to?: string;
123
+ };
124
+ /**
125
+ * Initializes a logger instance. it will log the initialization of the logger instance automatically.
126
+ * @param context The context of the logger instance.
127
+ * @param contextId The context ID of the logger instance.
128
+ * @param config The configuration of the logger instance.
129
+ * @returns The initialized logger instance.
130
+ */
131
+ declare const initLogger: (context: InstanceContext | undefined, contextId: string) => LoggerService;
132
+ export default initLogger;
133
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,KAAK,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;AAClE;;GAEG;AACH,qBAAa,aAAa;IAExB,OAAO,CAAC,OAAO,CAA6C;IAC5D,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAOhB;IAEJ;;;;;;OAMG;WACW,WAAW,CAAC,OAAO,GAAE,eAAuB,EAAE,SAAS,GAAE,MAAW,GAAG,aAAa;IAIlG;;;;OAIG;WACW,IAAI,CAAC,OAAO,GAAE,eAAuB,EAAE,SAAS,GAAE,MAAW;IAI3E;;;;OAIG;WACW,MAAM,CAAC,OAAO,GAAE,eAAuB,EAAE,SAAS,GAAE,MAAW;IAI7E;;;;;OAKG;gBACS,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM;IAKvD;;;;;OAKG;IACI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAwBnF;;;;OAIG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI3C;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI5C;;;;OAIG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI3C;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI5C;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI9C;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI5C;;;;OAIG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI3C;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAI5C;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;CAI7C;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACrB,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,eAAe,GACzB,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,MAAM,GACN,OAAO,GACP,OAAO,GACP,UAAU,GACV,WAAW,GACX,OAAO,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA;AAGD;;;;;;GAMG;AACH,QAAA,MAAM,UAAU,YAAa,eAAe,yBAAqB,MAAM,kBAItE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ /**
3
+ * @generator Levelup
4
+ * @author dr. Salmi <reevosolutions@gmail.com>
5
+ * @since 24-02-2024 20:47:22
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.LoggerService = void 0;
12
+ const colors_1 = __importDefault(require("colors"));
13
+ const moment_1 = __importDefault(require("moment"));
14
+ /**
15
+ * Represents a logger service.
16
+ */
17
+ class LoggerService {
18
+ context;
19
+ contextId;
20
+ static muted = {
21
+ SDK: {},
22
+ CLIENT: {},
23
+ HTTP_CLIENT: {},
24
+ CACHE: {},
25
+ };
26
+ /**
27
+ * Returns an instance of the LoggerService.
28
+ * @param context The context of the logger instance.
29
+ * @param contextId The context ID of the logger instance.
30
+ * @param config The configuration of the logger instance.
31
+ * @returns An instance of the LoggerService.
32
+ */
33
+ static getInstance(context = "SDK", contextId = "") {
34
+ return new LoggerService(context, contextId);
35
+ }
36
+ /**
37
+ * Mutes the logger instance.
38
+ * @param context The context of the logger instance.
39
+ * @param contextId The context ID of the logger instance.
40
+ */
41
+ static mute(context = "SDK", contextId = "") {
42
+ this.muted[context][contextId] = true;
43
+ }
44
+ /**
45
+ * Unmutes the logger instance.
46
+ * @param context The context of the logger instance.
47
+ * @param contextId The context ID of the logger instance.
48
+ */
49
+ static unmute(context = "SDK", contextId = "") {
50
+ this.muted[context][contextId] = false;
51
+ }
52
+ /**
53
+ * Constructs a new instance of the LoggerService.
54
+ * @param context The context of the logger instance.
55
+ * @param contextId The context ID of the logger instance.
56
+ * @param config The configuration of the logger instance.
57
+ */
58
+ constructor(context, contextId) {
59
+ this.context = context;
60
+ this.contextId = contextId;
61
+ }
62
+ /**
63
+ * Logs a message with the specified log type.
64
+ * @param type The log type.
65
+ * @param message The log message.
66
+ * @param args Additional arguments to be logged.
67
+ */
68
+ log(type, message, ...args) {
69
+ if (LoggerService.muted[this.context][this.contextId] || LoggerService.muted[this.context]["all"])
70
+ return;
71
+ const label = `${colors_1.default.grey((0, moment_1.default)().format('HH:mm:ss,SSS'))} ${colors_1.default.bold.gray(`[${this.context}:${this.contextId}]`)} ${type === "DEBUG"
72
+ ? colors_1.default.bold.cyan(message)
73
+ : type === "WARN"
74
+ ? colors_1.default.bold.yellow(message)
75
+ : type === "ERROR"
76
+ ? colors_1.default.bold.red(message)
77
+ : type === "SUCCESS"
78
+ ? colors_1.default.bold.green(message)
79
+ : type === "HTTP"
80
+ ? colors_1.default.bold.blue(message)
81
+ : type === "EVENT"
82
+ ? colors_1.default.gray(message)
83
+ : type === "INFO"
84
+ ? colors_1.default.bold.cyan(message)
85
+ : type === "VALUE"
86
+ ? colors_1.default.bold.magenta(message)
87
+ : colors_1.default.bold.gray(message)}`;
88
+ console.log(label, ...args);
89
+ }
90
+ /**
91
+ * Logs a warning message.
92
+ * @param message The warning message.
93
+ * @param args Additional arguments to be logged.
94
+ */
95
+ warn(message, ...args) {
96
+ this.log("WARN", message, ...args);
97
+ }
98
+ /**
99
+ * Logs an error message.
100
+ * @param message The error message.
101
+ * @param args Additional arguments to be logged.
102
+ */
103
+ error(message, ...args) {
104
+ this.log("ERROR", message, ...args);
105
+ }
106
+ /**
107
+ * Logs an info message.
108
+ * @param message The info message.
109
+ * @param args Additional arguments to be logged.
110
+ */
111
+ info(message, ...args) {
112
+ this.log("INFO", message, ...args);
113
+ }
114
+ /**
115
+ * Logs a debug message.
116
+ * @param message The debug message.
117
+ * @param args Additional arguments to be logged.
118
+ */
119
+ debug(message, ...args) {
120
+ this.log("DEBUG", message, ...args);
121
+ }
122
+ /**
123
+ * Logs a success message.
124
+ * @param message The success message.
125
+ * @param args Additional arguments to be logged.
126
+ */
127
+ success(message, ...args) {
128
+ this.log("SUCCESS", message, ...args);
129
+ }
130
+ /**
131
+ * Logs a silly message.
132
+ * @param message The silly message.
133
+ * @param args Additional arguments to be logged.
134
+ */
135
+ silly(message, ...args) {
136
+ this.log("SILLY", message, ...args);
137
+ }
138
+ /**
139
+ * Logs an HTTP message.
140
+ * @param message The HTTP message.
141
+ * @param args Additional arguments to be logged.
142
+ */
143
+ http(message, ...args) {
144
+ this.log("HTTP", message, ...args);
145
+ }
146
+ /**
147
+ * Logs an event message.
148
+ * @param message The event message.
149
+ * @param args Additional arguments to be logged.
150
+ */
151
+ event(message, ...args) {
152
+ this.log("EVENT", message, ...args);
153
+ }
154
+ /**
155
+ * Logs a value message.
156
+ * @param message The value message.
157
+ * @param args Additional arguments to be logged.
158
+ */
159
+ value(message, ...args) {
160
+ this.log("VALUE", message, ...args);
161
+ }
162
+ }
163
+ exports.LoggerService = LoggerService;
164
+ /**
165
+ * Initializes a logger instance. it will log the initialization of the logger instance automatically.
166
+ * @param context The context of the logger instance.
167
+ * @param contextId The context ID of the logger instance.
168
+ * @param config The configuration of the logger instance.
169
+ * @returns The initialized logger instance.
170
+ */
171
+ const initLogger = (context = "SDK", contextId) => {
172
+ const logger = LoggerService.getInstance(context, contextId);
173
+ logger.event('...Initialized', contextId);
174
+ return logger;
175
+ };
176
+ exports.default = initLogger;
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "jourycms-sdk",
3
+ "version": "1.0.1",
4
+ "description": "Sdk for Joury CMS",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/**/*",
8
+ "typings/**/*"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/reevosolutions/jourycms-project"
13
+ },
14
+ "keywords": [
15
+ "levelup",
16
+ "sdk"
17
+ ],
18
+ "author": "salmigroup@gmail.com",
19
+ "license": "ISC",
20
+ "scripts": {
21
+ "test": "echo \"Error: no test specified\" && exit 1",
22
+ "build": "tsc",
23
+ "lint:src": "eslint 'src/**/*.ts'",
24
+ "lint:typing": "eslint 'typings/**/*.d.ts'",
25
+ "lint": "yarn lint:src && yarn lint:typing",
26
+ "lint:fix": "eslint ./src --fix",
27
+ "push": "git add . && git commit -m 'update' && git push",
28
+ "publish": "npm publish",
29
+ "pub": "yarn build && yarn push && yarn publish"
30
+ },
31
+ "dependencies": {
32
+ "axios": "^1.7.7",
33
+ "colors": "^1.4.0",
34
+ "moment": "^2.30.1",
35
+ "qs": "^6.13.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/mongoose": "^5.11.96",
39
+ "@types/qs": "^6.9.16",
40
+ "@typescript-eslint/eslint-plugin": "^8.13.0",
41
+ "@typescript-eslint/parser": "^8.13.0",
42
+ "eslint": "^9.14.0",
43
+ "globals": "^15.12.0",
44
+ "ts-node": "^10.9.2",
45
+ "typescript": "^5.6.3",
46
+ "typescript-eslint": "^8.13.0",
47
+ "utility-types": "^3.11.0"
48
+ }
49
+ }
@@ -0,0 +1 @@
1
+ export * from "./v1/index.d.ts";
File without changes
@@ -0,0 +1,83 @@
1
+ declare module Levelup {
2
+ namespace CMS {
3
+ namespace V1 {
4
+ /**
5
+ * @description Service CacheManager
6
+ */
7
+ namespace CacheManager {
8
+ export interface EntityCacheManager<E extends TEntity> {
9
+ get(
10
+ id: string,
11
+ config?: {
12
+ expiration?: number;
13
+ force_load_from_db?: boolean;
14
+ company?: string | null;
15
+ }
16
+ ): Promise<Levelup.V2.CacheManager.EntityType<E>>;
17
+
18
+ getMany(
19
+ ids: string[],
20
+ config?: {
21
+ expiration?: number;
22
+ force_load_from_db?: boolean;
23
+ company?: string | null;
24
+ }
25
+ ): Promise<Levelup.V2.CacheManager.EntityType<E>[]>;
26
+
27
+ list(config?: {
28
+ query: Levelup.V2.CacheManager.TListQueryParams<E>;
29
+ force_load_from_db?: boolean;
30
+ company?: string | null;
31
+ }): Promise<Levelup.V2.CacheManager.EntityType<E>[]>;
32
+
33
+ set(
34
+ id: string,
35
+ value: Levelup.V2.CacheManager.EntityType<E>,
36
+ company?: string | null
37
+ ): Promise<void>;
38
+
39
+ unset(id: string, company?: string | null): Promise<void>;
40
+
41
+ unsetAll(company?: string | null): Promise<void>;
42
+ }
43
+
44
+ export type TLevelupEntity =
45
+ // auth
46
+ | "user"
47
+ | "apiKey"
48
+ | "role"
49
+ | "permission"
50
+ | "permissionGroup"
51
+ // system
52
+ | "app"
53
+ ;
54
+
55
+ export type TLevelupListQueryParams<E extends TEntity> =
56
+ // auth
57
+ E extends "user"
58
+ ? Users.Api.Users.List.Request
59
+ : E extends "permission"
60
+ ? Auth.Api.Permissions.List.Request
61
+ : E extends "permissionGroup"
62
+ ? Auth.Api.PermissionGroups.List.Request
63
+ : E extends "role"
64
+ ? Auth.Api.Roles.List.Request
65
+ : E extends "apiKey"
66
+ ? Auth.Api.ApiKeys.List.Request
67
+ : // system
68
+ E extends "app"
69
+ ? System.Api.Apps.List.Request
70
+ : never;
71
+
72
+
73
+
74
+ export type TEntity = TLevelupEntity;
75
+
76
+ export type TListQueryParams<E extends TEntity> =
77
+ E extends Levelup.V2.CacheManager.TLevelupEntity
78
+ ? Levelup.V2.CacheManager.TLevelupListQueryParams<E>
79
+ : never;
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,5 @@
1
+ 'generated by levelup';
2
+
3
+ export * from "./store.d.ts";
4
+ export * from "./entity.d.ts";
5
+ export * from "./class.d.ts";
@@ -0,0 +1,35 @@
1
+
2
+ declare module Levelup {
3
+ namespace CMS {
4
+ namespace V1 {
5
+
6
+ /**
7
+ * @description Service CacheManager
8
+ */
9
+ namespace CacheManager {
10
+ namespace Store {
11
+ export type TStoredLevelupObject<E extends TEntity> = {
12
+ value: EntityType<E>;
13
+ last_updated: Date
14
+ }
15
+ export type TStoredForeignObject<Obj> = {
16
+ value: Obj;
17
+ last_updated: Date
18
+ }
19
+
20
+
21
+ export namespace Firebase {
22
+
23
+ export type FCMTokenObjectOnRedis = {
24
+ fcm_token: string;
25
+ user: Utils.Common.ID;
26
+ app: Utils.Common.ID | null;
27
+ role: string | null;
28
+ }
29
+ }
30
+
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,3 @@
1
+ 'generated by levelup';
2
+
3
+ export * from "./payloads.d.ts";