@abyss-project/reflex 6.0.3 → 6.0.5

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 (154) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/types/interface/models/reflex-completion-webhook.model.d.ts +9 -0
  5. package/dist/types/interface/models/reflex-completion-webhook.model.js +10 -1
  6. package/dist/types/interface/models/reflex-completion-webhook.model.js.map +1 -1
  7. package/dist/types/interface/models/reflex-service-limits.model.d.ts +5 -2
  8. package/jest.config.ts +11 -11
  9. package/package.json +1 -1
  10. package/src/api/alert-rule.api.test.ts +72 -72
  11. package/src/api/alert-rule.api.ts +57 -57
  12. package/src/api/application-insights.api.test.ts +42 -42
  13. package/src/api/application-insights.api.ts +38 -38
  14. package/src/api/application-run-settings.api.test.ts +51 -51
  15. package/src/api/application-run-settings.api.ts +30 -30
  16. package/src/api/function-access.api.ts +87 -87
  17. package/src/api/function-insights.api.test.ts +27 -27
  18. package/src/api/function-insights.api.ts +18 -18
  19. package/src/api/function-run.api.ts +38 -38
  20. package/src/api/function-settings.api.ts +74 -74
  21. package/src/api/function-template.api.test.ts +72 -72
  22. package/src/api/function-template.api.ts +52 -52
  23. package/src/api/function-test.api.ts +34 -34
  24. package/src/api/function-version.api.ts +66 -66
  25. package/src/api/function.api.ts +62 -62
  26. package/src/api/health.api.ts +10 -10
  27. package/src/api/route-stats.api.test.ts +45 -45
  28. package/src/api/route-stats.api.ts +36 -36
  29. package/src/api/service-completion-webhook.api.test.ts +10 -0
  30. package/src/api/service-configuration.api.ts +16 -16
  31. package/src/api/service-deployment.api.ts +79 -79
  32. package/src/api/service-discord-event.api.test.ts +106 -106
  33. package/src/api/service-discord-event.api.ts +78 -78
  34. package/src/api/service-insights.api.test.ts +36 -36
  35. package/src/api/service-insights.api.ts +42 -42
  36. package/src/api/service-task.api.test.ts +140 -140
  37. package/src/api/service-task.api.ts +141 -141
  38. package/src/api/service-version.api.ts +54 -54
  39. package/src/api/service.api.test.ts +215 -215
  40. package/src/api/service.api.ts +55 -55
  41. package/src/discord/discord-event-filter-cases.ts +261 -261
  42. package/src/discord/discord-event-filters.test.ts +91 -91
  43. package/src/discord/discord-event-filters.ts +95 -95
  44. package/src/discord/discord-event-intents.test.ts +112 -112
  45. package/src/discord/discord-event-intents.ts +55 -55
  46. package/src/discord/index.ts +3 -3
  47. package/src/insights/index.ts +1 -1
  48. package/src/insights/percentiles.test.ts +75 -75
  49. package/src/insights/percentiles.ts +37 -37
  50. package/src/types/enum/access-grant-status.enum.ts +12 -12
  51. package/src/types/enum/access-kind.enum.ts +7 -7
  52. package/src/types/enum/access-request-status.enum.ts +11 -11
  53. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  54. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  55. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  56. package/src/types/enum/discord-channel-type.enum.ts +11 -11
  57. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  58. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  59. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  60. package/src/types/enum/discord-event-status.enum.ts +13 -13
  61. package/src/types/enum/discord-event-type.enum.ts +7 -7
  62. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  63. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  64. package/src/types/enum/discord-host-action.enum.ts +35 -35
  65. package/src/types/enum/discord-locale.enum.ts +35 -35
  66. package/src/types/enum/discord-option-type.enum.ts +12 -12
  67. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  68. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  69. package/src/types/enum/discord-token-state.enum.ts +11 -11
  70. package/src/types/enum/execution-mode.enum.ts +9 -9
  71. package/src/types/enum/execution-profile.enum.ts +20 -20
  72. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  73. package/src/types/enum/health-status.enum.ts +4 -4
  74. package/src/types/enum/insights-period.enum.ts +8 -8
  75. package/src/types/enum/log-cap-mode.enum.ts +6 -6
  76. package/src/types/enum/log-drop-cause.enum.ts +8 -8
  77. package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
  78. package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
  79. package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
  80. package/src/types/enum/route-method.enum.ts +9 -9
  81. package/src/types/enum/run-log-level.enum.ts +6 -6
  82. package/src/types/enum/run-mode.enum.ts +11 -11
  83. package/src/types/enum/run-step-status.enum.ts +7 -7
  84. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  85. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  86. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  87. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  88. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  89. package/src/types/enum/service-type.enum.ts +9 -9
  90. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  91. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  92. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  93. package/src/types/enum/trigger-kind.enum.ts +8 -8
  94. package/src/types/enum/vault-value-source.enum.ts +12 -12
  95. package/src/types/enum/vault-visibility.enum.ts +5 -5
  96. package/src/types/index.ts +2 -2
  97. package/src/types/interface/api/index.ts +3 -3
  98. package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
  99. package/src/types/interface/api/requests/application-insights.request.ts +18 -18
  100. package/src/types/interface/api/requests/application-run-settings.request.ts +11 -11
  101. package/src/types/interface/api/requests/function-access.request.ts +51 -51
  102. package/src/types/interface/api/requests/function-settings.request.ts +34 -34
  103. package/src/types/interface/api/requests/function-template.request.ts +29 -29
  104. package/src/types/interface/api/requests/function-version.request.ts +38 -38
  105. package/src/types/interface/api/requests/function.request.ts +36 -36
  106. package/src/types/interface/api/requests/route-stats.request.ts +22 -22
  107. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  108. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  109. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  110. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  111. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  112. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  113. package/src/types/interface/api/requests/service.request.ts +46 -46
  114. package/src/types/interface/api/response.ts +4 -4
  115. package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
  116. package/src/types/interface/api/responses/application-insights.response.ts +11 -11
  117. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
  118. package/src/types/interface/api/responses/function-access.response.ts +45 -45
  119. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  120. package/src/types/interface/api/responses/function-template.response.ts +21 -21
  121. package/src/types/interface/api/responses/function-version.response.ts +42 -42
  122. package/src/types/interface/api/responses/function.response.ts +25 -25
  123. package/src/types/interface/api/responses/route-stats.response.ts +15 -15
  124. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  125. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  126. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  127. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  128. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  129. package/src/types/interface/api/responses/service-version.response.ts +112 -112
  130. package/src/types/interface/api/responses/service.response.ts +31 -31
  131. package/src/types/interface/health.response.ts +7 -7
  132. package/src/types/interface/index.ts +3 -3
  133. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  134. package/src/types/interface/models/reflex-access-request.model.ts +15 -15
  135. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
  136. package/src/types/interface/models/reflex-completion-webhook.model.ts +26 -0
  137. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  138. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  139. package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
  140. package/src/types/interface/models/reflex-discord.model.ts +196 -196
  141. package/src/types/interface/models/reflex-function-template.model.ts +18 -18
  142. package/src/types/interface/models/reflex-function-version.model.ts +19 -19
  143. package/src/types/interface/models/reflex-function.model.ts +30 -30
  144. package/src/types/interface/models/reflex-insights.model.ts +215 -215
  145. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  146. package/src/types/interface/models/reflex-run-settings.model.ts +28 -28
  147. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  148. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  149. package/src/types/interface/models/reflex-service-limits.model.ts +17 -8
  150. package/src/types/interface/models/reflex-service.model.ts +45 -45
  151. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  152. package/src/types/interface/models/reflex-task.model.ts +97 -97
  153. package/tsconfig.check.json +15 -15
  154. package/tsconfig.json +35 -35
package/.eslintrc.js CHANGED
@@ -1,32 +1,32 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- project: 'tsconfig.check.json',
5
- tsconfigRootDir: __dirname,
6
- sourceType: 'module',
7
- },
8
- plugins: ['@typescript-eslint/eslint-plugin', 'filenames-simple'],
9
- extends: [
10
- 'plugin:@typescript-eslint/recommended',
11
- 'plugin:prettier/recommended',
12
- ],
13
- root: true,
14
- env: {
15
- node: true,
16
- jest: true,
17
- },
18
- ignorePatterns: ['.eslintrc.js', 'jest.config.ts'],
19
- rules: {
20
- '@typescript-eslint/explicit-function-return-type': 'off',
21
- '@typescript-eslint/explicit-module-boundary-types': 'off',
22
- '@typescript-eslint/no-explicit-any': 'off',
23
- "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
24
- 'filenames-simple/naming-convention': [
25
- 'error',
26
- {
27
- rule: '^([a-z0-9]*)(-[a-z0-9]+)*$',
28
- },
29
- ],
30
- },
31
- overrides: [],
32
- };
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ project: 'tsconfig.check.json',
5
+ tsconfigRootDir: __dirname,
6
+ sourceType: 'module',
7
+ },
8
+ plugins: ['@typescript-eslint/eslint-plugin', 'filenames-simple'],
9
+ extends: [
10
+ 'plugin:@typescript-eslint/recommended',
11
+ 'plugin:prettier/recommended',
12
+ ],
13
+ root: true,
14
+ env: {
15
+ node: true,
16
+ jest: true,
17
+ },
18
+ ignorePatterns: ['.eslintrc.js', 'jest.config.ts'],
19
+ rules: {
20
+ '@typescript-eslint/explicit-function-return-type': 'off',
21
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
22
+ '@typescript-eslint/no-explicit-any': 'off',
23
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
24
+ 'filenames-simple/naming-convention': [
25
+ 'error',
26
+ {
27
+ rule: '^([a-z0-9]*)(-[a-z0-9]+)*$',
28
+ },
29
+ ],
30
+ },
31
+ overrides: [],
32
+ };
package/.prettierrc CHANGED
@@ -1,5 +1,5 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all",
4
- "printWidth": 100
5
- }
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "printWidth": 100
5
+ }
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
- # @abyss-project/reflex
2
-
3
- SDK of the AbyssReflex service.
4
-
5
- Not published yet: the first publication comes with its first consumer (the Console, J1).
6
-
7
- ## Liens
8
-
9
- - **Documentation** : [https://docs.abyss-project.fr](https://docs.abyss-project.fr)
10
- - **Application Abyss** : [app.abyss-project.fr](https://app.abyss-project.fr)
11
- - **Statut des services** : [status.abyss-project.fr](https://status.abyss-project.fr)
12
-
13
- ## Support
14
-
15
- Pour toute demande, ouvrir un ticket depuis [l'application Abyss](https://app.abyss-project.fr/dashboard/account/tickets/create).
1
+ # @abyss-project/reflex
2
+
3
+ SDK of the AbyssReflex service.
4
+
5
+ Not published yet: the first publication comes with its first consumer (the Console, J1).
6
+
7
+ ## Liens
8
+
9
+ - **Documentation** : [https://docs.abyss-project.fr](https://docs.abyss-project.fr)
10
+ - **Application Abyss** : [app.abyss-project.fr](https://app.abyss-project.fr)
11
+ - **Statut des services** : [status.abyss-project.fr](https://status.abyss-project.fr)
12
+
13
+ ## Support
14
+
15
+ Pour toute demande, ouvrir un ticket depuis [l'application Abyss](https://app.abyss-project.fr/dashboard/account/tickets/create).
@@ -7,6 +7,15 @@ export declare const REFLEX_COMPLETION_WEBHOOK_LIMITS: {
7
7
  readonly sendTimeoutMs: 10000;
8
8
  readonly outputMaxBytes: 65536;
9
9
  };
10
+ export declare const REFLEX_COMPLETION_DELIVERY_ERRORS: {
11
+ readonly refusedAddress: "The URL is not https, or reaches an address the edge may not reach";
12
+ readonly noSigningSecret: "No signing secret for the Service in the environment";
13
+ readonly invalidUrl: "The URL is not valid";
14
+ readonly receiverTimeoutPrefix: "The receiver did not answer within";
15
+ readonly requestFailedPrefix: "The request failed";
16
+ readonly httpPrefix: "HTTP";
17
+ readonly redirectsNotFollowed: "redirects are not followed";
18
+ };
10
19
  export interface IReflexCompletionWebhookPayload {
11
20
  executionId: string;
12
21
  functionId: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REFLEX_COMPLETION_WEBHOOK_LIMITS = exports.RESERVED_EXECUTIONS_SEGMENT = exports.COMPLETION_DELIVERY_ID_HEADER = void 0;
3
+ exports.REFLEX_COMPLETION_DELIVERY_ERRORS = exports.REFLEX_COMPLETION_WEBHOOK_LIMITS = exports.RESERVED_EXECUTIONS_SEGMENT = exports.COMPLETION_DELIVERY_ID_HEADER = void 0;
4
4
  exports.COMPLETION_DELIVERY_ID_HEADER = 'x-abyss-delivery-id';
5
5
  exports.RESERVED_EXECUTIONS_SEGMENT = '_executions';
6
6
  exports.REFLEX_COMPLETION_WEBHOOK_LIMITS = {
@@ -9,4 +9,13 @@ exports.REFLEX_COMPLETION_WEBHOOK_LIMITS = {
9
9
  sendTimeoutMs: 10_000,
10
10
  outputMaxBytes: 65_536,
11
11
  };
12
+ exports.REFLEX_COMPLETION_DELIVERY_ERRORS = {
13
+ refusedAddress: 'The URL is not https, or reaches an address the edge may not reach',
14
+ noSigningSecret: 'No signing secret for the Service in the environment',
15
+ invalidUrl: 'The URL is not valid',
16
+ receiverTimeoutPrefix: 'The receiver did not answer within',
17
+ requestFailedPrefix: 'The request failed',
18
+ httpPrefix: 'HTTP',
19
+ redirectsNotFollowed: 'redirects are not followed',
20
+ };
12
21
  //# sourceMappingURL=reflex-completion-webhook.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflex-completion-webhook.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-completion-webhook.model.ts"],"names":[],"mappings":";;;AAGa,QAAA,6BAA6B,GAAG,qBAAqB,CAAC;AAMtD,QAAA,2BAA2B,GAAG,aAAa,CAAC;AAG5C,QAAA,gCAAgC,GAAG;IAE9C,YAAY,EAAE,IAAI;IAElB,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAEtC,aAAa,EAAE,MAAM;IAErB,cAAc,EAAE,MAAM;CACd,CAAC"}
1
+ {"version":3,"file":"reflex-completion-webhook.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-completion-webhook.model.ts"],"names":[],"mappings":";;;AAGa,QAAA,6BAA6B,GAAG,qBAAqB,CAAC;AAMtD,QAAA,2BAA2B,GAAG,aAAa,CAAC;AAG5C,QAAA,gCAAgC,GAAG;IAE9C,YAAY,EAAE,IAAI;IAElB,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAEtC,aAAa,EAAE,MAAM;IAErB,cAAc,EAAE,MAAM;CACd,CAAC;AAWE,QAAA,iCAAiC,GAAG;IAE/C,cAAc,EAAE,oEAAoE;IAEpF,eAAe,EAAE,sDAAsD;IAEvE,UAAU,EAAE,sBAAsB;IAElC,qBAAqB,EAAE,oCAAoC;IAE3D,mBAAmB,EAAE,oBAAoB;IAEzC,UAAU,EAAE,MAAM;IAElB,oBAAoB,EAAE,4BAA4B;CAC1C,CAAC"}
@@ -13,11 +13,14 @@ export interface IReflexServiceMonthlySpendCap {
13
13
  spentCents: number;
14
14
  usedPercent: number;
15
15
  }
16
+ export interface IReflexOrganizationCredits {
17
+ includedMillicredits: number | null;
18
+ consumedMillicredits: number;
19
+ }
16
20
  export interface IReflexServiceCredits {
17
21
  month: string;
18
22
  consumedMillicredits: number;
19
- organizationConsumedMillicredits: number;
20
- includedMillicredits: number | null;
23
+ organizationCredits: IReflexOrganizationCredits | null;
21
24
  overageEnabled: boolean;
22
25
  overageAllowedByOrganization: boolean;
23
26
  }
package/jest.config.ts CHANGED
@@ -1,11 +1,11 @@
1
- import type { Config } from '@jest/types';
2
-
3
- const config: Config.InitialOptions = {
4
- testEnvironment: 'node',
5
- transform: {
6
- '^.+\\.tsx?$': ['ts-jest', { isolatedModules: true }],
7
- },
8
- modulePathIgnorePatterns: ['dist'],
9
- };
10
-
11
- export default config;
1
+ import type { Config } from '@jest/types';
2
+
3
+ const config: Config.InitialOptions = {
4
+ testEnvironment: 'node',
5
+ transform: {
6
+ '^.+\\.tsx?$': ['ts-jest', { isolatedModules: true }],
7
+ },
8
+ modulePathIgnorePatterns: ['dist'],
9
+ };
10
+
11
+ export default config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/reflex",
3
- "version": "6.0.3",
3
+ "version": "6.0.5",
4
4
  "description": "Core package to interact with AbyssReflex",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,72 +1,72 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, ReflexAlertMetric, ReflexAlertScope } from '..';
3
-
4
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
- data: { data: {} },
6
- status: 200,
7
- statusText: '',
8
- headers: {},
9
- config,
10
- }));
11
-
12
- beforeAll(() => {
13
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
- AbyssReflexCore.axios.defaults.adapter = adapter;
15
- });
16
-
17
- beforeEach(() => adapter.mockClear());
18
-
19
- const APP = { applicationId: 'app-1' };
20
-
21
- describe('AbyssReflexCore alert rule routes', () => {
22
- it('alertRule.list calls GET .../alert-rule, filtered by environment when given', async () => {
23
- await AbyssReflexCore.sdk.application.alertRule.list(APP, { environmentId: 'e-1' });
24
-
25
- const config = adapter.mock.calls[0][0];
26
- expect(config.method).toBe('get');
27
- expect(config.url).toBe('api/application/app-1/alert-rule');
28
- expect(config.params).toEqual({ environmentId: 'e-1' });
29
- });
30
-
31
- it('alertRule.list works without a query', async () => {
32
- await AbyssReflexCore.sdk.application.alertRule.list(APP);
33
-
34
- expect(adapter.mock.calls[0][0].params).toEqual({});
35
- });
36
-
37
- it('alertRule.create calls POST .../alert-rule with the rule', async () => {
38
- const body = {
39
- environmentId: 'e-1',
40
- scope: ReflexAlertScope.SERVICE,
41
- serviceId: 'svc-1',
42
- metric: ReflexAlertMetric.ERROR_RATE,
43
- threshold: 5,
44
- windowMinutes: 15,
45
- name: 'Errors',
46
- };
47
- await AbyssReflexCore.sdk.application.alertRule.create(APP, body);
48
-
49
- const config = adapter.mock.calls[0][0];
50
- expect(config.method).toBe('post');
51
- expect(config.url).toBe('api/application/app-1/alert-rule');
52
- expect(JSON.parse(config.data)).toEqual(body);
53
- });
54
-
55
- it('alertRule.update calls PUT .../alert-rule/:ruleId with the editable values', async () => {
56
- const body = { threshold: 10, windowMinutes: 30, minRuns: 20, enabled: false, name: 'Errors' };
57
- await AbyssReflexCore.sdk.application.alertRule.update({ ...APP, ruleId: 'rule-1' }, body);
58
-
59
- const config = adapter.mock.calls[0][0];
60
- expect(config.method).toBe('put');
61
- expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
62
- expect(JSON.parse(config.data)).toEqual(body);
63
- });
64
-
65
- it('alertRule.delete calls DELETE .../alert-rule/:ruleId', async () => {
66
- await AbyssReflexCore.sdk.application.alertRule.delete({ ...APP, ruleId: 'rule-1' });
67
-
68
- const config = adapter.mock.calls[0][0];
69
- expect(config.method).toBe('delete');
70
- expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
71
- });
72
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, ReflexAlertMetric, ReflexAlertScope } from '..';
3
+
4
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
+ data: { data: {} },
6
+ status: 200,
7
+ statusText: '',
8
+ headers: {},
9
+ config,
10
+ }));
11
+
12
+ beforeAll(() => {
13
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
+ AbyssReflexCore.axios.defaults.adapter = adapter;
15
+ });
16
+
17
+ beforeEach(() => adapter.mockClear());
18
+
19
+ const APP = { applicationId: 'app-1' };
20
+
21
+ describe('AbyssReflexCore alert rule routes', () => {
22
+ it('alertRule.list calls GET .../alert-rule, filtered by environment when given', async () => {
23
+ await AbyssReflexCore.sdk.application.alertRule.list(APP, { environmentId: 'e-1' });
24
+
25
+ const config = adapter.mock.calls[0][0];
26
+ expect(config.method).toBe('get');
27
+ expect(config.url).toBe('api/application/app-1/alert-rule');
28
+ expect(config.params).toEqual({ environmentId: 'e-1' });
29
+ });
30
+
31
+ it('alertRule.list works without a query', async () => {
32
+ await AbyssReflexCore.sdk.application.alertRule.list(APP);
33
+
34
+ expect(adapter.mock.calls[0][0].params).toEqual({});
35
+ });
36
+
37
+ it('alertRule.create calls POST .../alert-rule with the rule', async () => {
38
+ const body = {
39
+ environmentId: 'e-1',
40
+ scope: ReflexAlertScope.SERVICE,
41
+ serviceId: 'svc-1',
42
+ metric: ReflexAlertMetric.ERROR_RATE,
43
+ threshold: 5,
44
+ windowMinutes: 15,
45
+ name: 'Errors',
46
+ };
47
+ await AbyssReflexCore.sdk.application.alertRule.create(APP, body);
48
+
49
+ const config = adapter.mock.calls[0][0];
50
+ expect(config.method).toBe('post');
51
+ expect(config.url).toBe('api/application/app-1/alert-rule');
52
+ expect(JSON.parse(config.data)).toEqual(body);
53
+ });
54
+
55
+ it('alertRule.update calls PUT .../alert-rule/:ruleId with the editable values', async () => {
56
+ const body = { threshold: 10, windowMinutes: 30, minRuns: 20, enabled: false, name: 'Errors' };
57
+ await AbyssReflexCore.sdk.application.alertRule.update({ ...APP, ruleId: 'rule-1' }, body);
58
+
59
+ const config = adapter.mock.calls[0][0];
60
+ expect(config.method).toBe('put');
61
+ expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
62
+ expect(JSON.parse(config.data)).toEqual(body);
63
+ });
64
+
65
+ it('alertRule.delete calls DELETE .../alert-rule/:ruleId', async () => {
66
+ await AbyssReflexCore.sdk.application.alertRule.delete({ ...APP, ruleId: 'rule-1' });
67
+
68
+ const config = adapter.mock.calls[0][0];
69
+ expect(config.method).toBe('delete');
70
+ expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
71
+ });
72
+ });
@@ -1,57 +1,57 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- ICreateAlertRuleBody,
4
- ICreateAlertRuleParams,
5
- ICreateAlertRuleResponse,
6
- IDeleteAlertRuleParams,
7
- IDeleteAlertRuleResponse,
8
- IListAlertRuleParams,
9
- IListAlertRuleQuery,
10
- IListAlertRuleResponse,
11
- IUpdateAlertRuleBody,
12
- IUpdateAlertRuleParams,
13
- IUpdateAlertRuleResponse,
14
- } from '../types';
15
-
16
- const alertRuleUrl = (params: { applicationId: string }): string =>
17
- `api/application/${params.applicationId}/alert-rule`;
18
-
19
- /** `GET .../alert-rule`: the rules of the application and the state of their last evaluation. Needs REFLEX_READ. */
20
- export const listAlertRule = async (
21
- params: IListAlertRuleParams,
22
- query: IListAlertRuleQuery = {},
23
- ): Promise<IListAlertRuleResponse> =>
24
- (
25
- await AbyssReflexCore.axios.get<IListAlertRuleResponse>(alertRuleUrl(params), {
26
- params: query,
27
- })
28
- ).data;
29
-
30
- /** `POST .../alert-rule`: creates a rule. Needs REFLEX_FUNCTION_UPDATE. */
31
- export const createAlertRule = async (
32
- params: ICreateAlertRuleParams,
33
- body: ICreateAlertRuleBody,
34
- ): Promise<ICreateAlertRuleResponse> =>
35
- (await AbyssReflexCore.axios.post<ICreateAlertRuleResponse>(alertRuleUrl(params), body)).data;
36
-
37
- /** `PUT .../alert-rule/:ruleId`: changes the threshold, window, minimum of runs, name and switch of a rule. Needs REFLEX_FUNCTION_UPDATE. */
38
- export const updateAlertRule = async (
39
- params: IUpdateAlertRuleParams,
40
- body: IUpdateAlertRuleBody,
41
- ): Promise<IUpdateAlertRuleResponse> =>
42
- (
43
- await AbyssReflexCore.axios.put<IUpdateAlertRuleResponse>(
44
- `${alertRuleUrl(params)}/${params.ruleId}`,
45
- body,
46
- )
47
- ).data;
48
-
49
- /** `DELETE .../alert-rule/:ruleId`: deletes a rule and its state. Needs REFLEX_FUNCTION_UPDATE. */
50
- export const deleteAlertRule = async (
51
- params: IDeleteAlertRuleParams,
52
- ): Promise<IDeleteAlertRuleResponse> =>
53
- (
54
- await AbyssReflexCore.axios.delete<IDeleteAlertRuleResponse>(
55
- `${alertRuleUrl(params)}/${params.ruleId}`,
56
- )
57
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ ICreateAlertRuleBody,
4
+ ICreateAlertRuleParams,
5
+ ICreateAlertRuleResponse,
6
+ IDeleteAlertRuleParams,
7
+ IDeleteAlertRuleResponse,
8
+ IListAlertRuleParams,
9
+ IListAlertRuleQuery,
10
+ IListAlertRuleResponse,
11
+ IUpdateAlertRuleBody,
12
+ IUpdateAlertRuleParams,
13
+ IUpdateAlertRuleResponse,
14
+ } from '../types';
15
+
16
+ const alertRuleUrl = (params: { applicationId: string }): string =>
17
+ `api/application/${params.applicationId}/alert-rule`;
18
+
19
+ /** `GET .../alert-rule`: the rules of the application and the state of their last evaluation. Needs REFLEX_READ. */
20
+ export const listAlertRule = async (
21
+ params: IListAlertRuleParams,
22
+ query: IListAlertRuleQuery = {},
23
+ ): Promise<IListAlertRuleResponse> =>
24
+ (
25
+ await AbyssReflexCore.axios.get<IListAlertRuleResponse>(alertRuleUrl(params), {
26
+ params: query,
27
+ })
28
+ ).data;
29
+
30
+ /** `POST .../alert-rule`: creates a rule. Needs REFLEX_FUNCTION_UPDATE. */
31
+ export const createAlertRule = async (
32
+ params: ICreateAlertRuleParams,
33
+ body: ICreateAlertRuleBody,
34
+ ): Promise<ICreateAlertRuleResponse> =>
35
+ (await AbyssReflexCore.axios.post<ICreateAlertRuleResponse>(alertRuleUrl(params), body)).data;
36
+
37
+ /** `PUT .../alert-rule/:ruleId`: changes the threshold, window, minimum of runs, name and switch of a rule. Needs REFLEX_FUNCTION_UPDATE. */
38
+ export const updateAlertRule = async (
39
+ params: IUpdateAlertRuleParams,
40
+ body: IUpdateAlertRuleBody,
41
+ ): Promise<IUpdateAlertRuleResponse> =>
42
+ (
43
+ await AbyssReflexCore.axios.put<IUpdateAlertRuleResponse>(
44
+ `${alertRuleUrl(params)}/${params.ruleId}`,
45
+ body,
46
+ )
47
+ ).data;
48
+
49
+ /** `DELETE .../alert-rule/:ruleId`: deletes a rule and its state. Needs REFLEX_FUNCTION_UPDATE. */
50
+ export const deleteAlertRule = async (
51
+ params: IDeleteAlertRuleParams,
52
+ ): Promise<IDeleteAlertRuleResponse> =>
53
+ (
54
+ await AbyssReflexCore.axios.delete<IDeleteAlertRuleResponse>(
55
+ `${alertRuleUrl(params)}/${params.ruleId}`,
56
+ )
57
+ ).data;
@@ -1,42 +1,42 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, InsightsPeriod } from '..';
3
-
4
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
- data: { data: {} },
6
- status: 200,
7
- statusText: '',
8
- headers: {},
9
- config,
10
- }));
11
-
12
- beforeAll(() => {
13
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
- AbyssReflexCore.axios.defaults.adapter = adapter;
15
- });
16
-
17
- beforeEach(() => adapter.mockClear());
18
-
19
- const QUERY = { environmentId: 'e-1', period: InsightsPeriod.DAYS_7 };
20
-
21
- describe('AbyssReflexCore application insights routes', () => {
22
- it('insights.get calls GET .../insights with the environment and the period', async () => {
23
- await AbyssReflexCore.sdk.application.insights.get({ applicationId: 'app-1' }, QUERY);
24
-
25
- const config = adapter.mock.calls[0][0];
26
- expect(config.method).toBe('get');
27
- expect(config.url).toBe('api/application/app-1/insights');
28
- expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
29
- });
30
-
31
- it('insights.calendar calls GET .../insights/calendar with the environment only', async () => {
32
- await AbyssReflexCore.sdk.application.insights.calendar(
33
- { applicationId: 'app-1' },
34
- { environmentId: 'e-1' },
35
- );
36
-
37
- const config = adapter.mock.calls[0][0];
38
- expect(config.method).toBe('get');
39
- expect(config.url).toBe('api/application/app-1/insights/calendar');
40
- expect(config.params).toEqual({ environmentId: 'e-1' });
41
- });
42
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, InsightsPeriod } from '..';
3
+
4
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
+ data: { data: {} },
6
+ status: 200,
7
+ statusText: '',
8
+ headers: {},
9
+ config,
10
+ }));
11
+
12
+ beforeAll(() => {
13
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
+ AbyssReflexCore.axios.defaults.adapter = adapter;
15
+ });
16
+
17
+ beforeEach(() => adapter.mockClear());
18
+
19
+ const QUERY = { environmentId: 'e-1', period: InsightsPeriod.DAYS_7 };
20
+
21
+ describe('AbyssReflexCore application insights routes', () => {
22
+ it('insights.get calls GET .../insights with the environment and the period', async () => {
23
+ await AbyssReflexCore.sdk.application.insights.get({ applicationId: 'app-1' }, QUERY);
24
+
25
+ const config = adapter.mock.calls[0][0];
26
+ expect(config.method).toBe('get');
27
+ expect(config.url).toBe('api/application/app-1/insights');
28
+ expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
29
+ });
30
+
31
+ it('insights.calendar calls GET .../insights/calendar with the environment only', async () => {
32
+ await AbyssReflexCore.sdk.application.insights.calendar(
33
+ { applicationId: 'app-1' },
34
+ { environmentId: 'e-1' },
35
+ );
36
+
37
+ const config = adapter.mock.calls[0][0];
38
+ expect(config.method).toBe('get');
39
+ expect(config.url).toBe('api/application/app-1/insights/calendar');
40
+ expect(config.params).toEqual({ environmentId: 'e-1' });
41
+ });
42
+ });
@@ -1,38 +1,38 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetApplicationCalendarParams,
4
- IGetApplicationCalendarQuery,
5
- IGetApplicationCalendarResponse,
6
- IGetApplicationInsightsParams,
7
- IGetApplicationInsightsQuery,
8
- IGetApplicationInsightsResponse,
9
- } from '../types';
10
-
11
- const insightsUrl = (params: { applicationId: string }): string =>
12
- `api/application/${params.applicationId}/insights`;
13
-
14
- /**
15
- * `GET .../insights`: the overview of an application in one environment over a period: tiles, series, share by
16
- * Service, ranking of the triggers. Needs REFLEX_READ.
17
- */
18
- export const getApplicationInsights = async (
19
- params: IGetApplicationInsightsParams,
20
- query: IGetApplicationInsightsQuery,
21
- ): Promise<IGetApplicationInsightsResponse> =>
22
- (
23
- await AbyssReflexCore.axios.get<IGetApplicationInsightsResponse>(insightsUrl(params), {
24
- params: query,
25
- })
26
- ).data;
27
-
28
- /** `GET .../insights/calendar`: runs, failures and credits of each of the last 365 days. Needs REFLEX_READ. */
29
- export const getApplicationCalendar = async (
30
- params: IGetApplicationCalendarParams,
31
- query: IGetApplicationCalendarQuery,
32
- ): Promise<IGetApplicationCalendarResponse> =>
33
- (
34
- await AbyssReflexCore.axios.get<IGetApplicationCalendarResponse>(
35
- `${insightsUrl(params)}/calendar`,
36
- { params: query },
37
- )
38
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetApplicationCalendarParams,
4
+ IGetApplicationCalendarQuery,
5
+ IGetApplicationCalendarResponse,
6
+ IGetApplicationInsightsParams,
7
+ IGetApplicationInsightsQuery,
8
+ IGetApplicationInsightsResponse,
9
+ } from '../types';
10
+
11
+ const insightsUrl = (params: { applicationId: string }): string =>
12
+ `api/application/${params.applicationId}/insights`;
13
+
14
+ /**
15
+ * `GET .../insights`: the overview of an application in one environment over a period: tiles, series, share by
16
+ * Service, ranking of the triggers. Needs REFLEX_READ.
17
+ */
18
+ export const getApplicationInsights = async (
19
+ params: IGetApplicationInsightsParams,
20
+ query: IGetApplicationInsightsQuery,
21
+ ): Promise<IGetApplicationInsightsResponse> =>
22
+ (
23
+ await AbyssReflexCore.axios.get<IGetApplicationInsightsResponse>(insightsUrl(params), {
24
+ params: query,
25
+ })
26
+ ).data;
27
+
28
+ /** `GET .../insights/calendar`: runs, failures and credits of each of the last 365 days. Needs REFLEX_READ. */
29
+ export const getApplicationCalendar = async (
30
+ params: IGetApplicationCalendarParams,
31
+ query: IGetApplicationCalendarQuery,
32
+ ): Promise<IGetApplicationCalendarResponse> =>
33
+ (
34
+ await AbyssReflexCore.axios.get<IGetApplicationCalendarResponse>(
35
+ `${insightsUrl(params)}/calendar`,
36
+ { params: query },
37
+ )
38
+ ).data;