@forge/realtime 0.1.1 → 0.2.0-next.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @forge/realtime
2
2
 
3
+ ## 0.2.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 8e77d28: Add contextOverrides property to Realtime channel options
8
+
9
+ ## 0.1.2-next.0
10
+
11
+ ### Patch Changes
12
+
13
+ - 8ef80d7: Add npmignore file
14
+
3
15
  ## 0.1.1
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,7 @@
1
+ export declare enum Jira {
2
+ Board = "board",
3
+ Issue = "issue",
4
+ Project = "project"
5
+ }
6
+ export declare type ProductContext = Jira;
7
+ //# sourceMappingURL=productContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productContext.d.ts","sourceRoot":"","sources":["../src/productContext.ts"],"names":[],"mappings":"AAGA,oBAAY,IAAI;IACd,KAAK,UAAU;IACf,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,oBAAY,cAAc,GAAG,IAAI,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Jira = void 0;
4
+ var Jira;
5
+ (function (Jira) {
6
+ Jira["Board"] = "board";
7
+ Jira["Issue"] = "issue";
8
+ Jira["Project"] = "project";
9
+ })(Jira = exports.Jira || (exports.Jira = {}));
package/out/publish.d.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import { ProductContext } from './productContext';
1
2
  interface PublishOptions {
2
3
  token?: string;
4
+ contextOverrides?: ProductContext[];
3
5
  }
4
6
  export declare const publish: (channelName: string, eventPayload: string, options?: PublishOptions) => Promise<{
5
7
  eventId: null;
@@ -1 +1 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAwBA,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,OAAO,gBAAuB,MAAM,gBAAgB,MAAM,YAAY,cAAc;;;;;;;;EAiEhG,CAAC;AAEF,eAAO,MAAM,aAAa,gBAAuB,MAAM,gBAAgB,MAAM,YAAY,cAAc;;;;;;;;EAgEtG,CAAC"}
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2BlD,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,OAAO,gBAAuB,MAAM,gBAAgB,MAAM,YAAY,cAAc;;;;;;;;EA6EhG,CAAC;AAEF,eAAO,MAAM,aAAa,gBAAuB,MAAM,gBAAgB,MAAM,YAAY,cAAc;;;;;;;;EAgEtG,CAAC"}
package/out/publish.js CHANGED
@@ -7,6 +7,7 @@ const graphqlBody = `mutation publishRealtimeChannel(
7
7
  $installationId: ID!
8
8
  $name: String!
9
9
  $payload: String!
10
+ $context: String
10
11
  $isGlobal: Boolean
11
12
  $token: String
12
13
  ){
@@ -15,6 +16,7 @@ const graphqlBody = `mutation publishRealtimeChannel(
15
16
  installationId: $installationId
16
17
  name: $name
17
18
  payload: $payload
19
+ context: $context
18
20
  isGlobal: $isGlobal
19
21
  token: $token
20
22
  ) {
@@ -28,6 +30,15 @@ const publish = async (channelName, eventPayload, options) => {
28
30
  if (appContext?.environmentType === 'PRODUCTION') {
29
31
  throw new Error(utils_1.prodEnvErrorMessage);
30
32
  }
33
+ const { token, contextOverrides } = options || {};
34
+ if (contextOverrides && !Array.isArray(contextOverrides)) {
35
+ throw new Error('Invalid value for contextOverrides. Please provide an array of valid context properties.');
36
+ }
37
+ const channelContext = contextOverrides
38
+ ? JSON.stringify({
39
+ contextOverrides
40
+ })
41
+ : undefined;
31
42
  const response = await global.__forge_fetch__({
32
43
  type: 'realtime'
33
44
  }, '/', {
@@ -37,9 +48,10 @@ const publish = async (channelName, eventPayload, options) => {
37
48
  variables: {
38
49
  installationId: appContext.installationId,
39
50
  name: channelName,
51
+ context: channelContext,
40
52
  payload: eventPayload,
41
53
  isGlobal: false,
42
- token: options?.token
54
+ token: token
43
55
  }
44
56
  }),
45
57
  errors: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/realtime",
3
- "version": "0.1.1",
3
+ "version": "0.2.0-next.1",
4
4
  "description": "Forge realtime",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=publish.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publish.test.d.ts","sourceRoot":"","sources":["../../src/__test__/publish.test.ts"],"names":[],"mappings":""}
@@ -1,157 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const runtime = tslib_1.__importStar(require("../runtime"));
5
- const publish_1 = require("../publish");
6
- const utils_1 = require("./utils");
7
- const TEST_EVENT_ID = 'event-id';
8
- const TEST_EVENT_TIMESTAMP = '1234567890';
9
- const MOCK_CHANNEL = 'my-channel';
10
- const MOCK_PUBLISH_OPTIONS = { token: 'my-token' };
11
- const MOCK_EVENT_PAYLOAD_STRING = 'this is an event payload';
12
- const MOCK_EVENT_PAYLOAD_OBJECT = { value: 'this is a test payload', funLevel: 100 };
13
- const MOCK_FETCH_RESPONSE = {
14
- errors: [],
15
- data: {
16
- ecosystem: {
17
- publishRealtimeChannel: {
18
- eventId: TEST_EVENT_ID,
19
- eventTimestamp: TEST_EVENT_TIMESTAMP
20
- },
21
- success: true
22
- }
23
- }
24
- };
25
- const MOCK_ERRORS = [
26
- {
27
- message: 'Error message',
28
- extensions: {
29
- errorType: 'Error type',
30
- statusCode: 500
31
- }
32
- }
33
- ];
34
- describe('publish', () => {
35
- beforeEach(() => {
36
- jest.restoreAllMocks();
37
- jest.resetAllMocks();
38
- });
39
- it('should publish an event with FCT in header', async () => {
40
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
41
- const mockForgeFetch = jest.fn().mockResolvedValue({
42
- json: jest.fn().mockResolvedValue(MOCK_FETCH_RESPONSE),
43
- status: 200,
44
- headers: { get: jest.fn().mockReturnValue(undefined) }
45
- });
46
- global.__forge_fetch__ = mockForgeFetch;
47
- const response = await (0, publish_1.publish)(MOCK_CHANNEL, MOCK_EVENT_PAYLOAD_STRING, MOCK_PUBLISH_OPTIONS);
48
- expect(response).toEqual({ eventId: TEST_EVENT_ID, eventTimestamp: TEST_EVENT_TIMESTAMP });
49
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
50
- });
51
- it('should publish an event when the payload is an object', async () => {
52
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
53
- const mockForgeFetch = jest.fn().mockResolvedValue({
54
- json: jest.fn().mockResolvedValue(MOCK_FETCH_RESPONSE),
55
- status: 200,
56
- headers: { get: jest.fn().mockReturnValue(undefined) }
57
- });
58
- global.__forge_fetch__ = mockForgeFetch;
59
- const response = await (0, publish_1.publish)(MOCK_CHANNEL, JSON.stringify(MOCK_EVENT_PAYLOAD_OBJECT), MOCK_PUBLISH_OPTIONS);
60
- expect(response).toEqual({ eventId: TEST_EVENT_ID, eventTimestamp: TEST_EVENT_TIMESTAMP });
61
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
62
- });
63
- it('should throw an error when Forge Outbound Proxy returns an error', async () => {
64
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
65
- const mockForgeFetch = jest.fn().mockResolvedValue({
66
- text: jest.fn().mockResolvedValue('Error occurred'),
67
- status: 502,
68
- headers: { get: jest.fn().mockReturnValue('UPSTREAM_FAILURE') }
69
- });
70
- global.__forge_fetch__ = mockForgeFetch;
71
- const response = (0, publish_1.publish)(MOCK_CHANNEL, JSON.stringify(MOCK_EVENT_PAYLOAD_OBJECT), MOCK_PUBLISH_OPTIONS);
72
- await expect(response).rejects.toThrow('Forge platform failed to process runtime HTTP request - 502 - UPSTREAM_FAILURE');
73
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
74
- });
75
- it('should return null eventId and eventTimestamp when the response has errors', async () => {
76
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
77
- const mockForgeFetch = jest.fn().mockResolvedValue({
78
- json: jest.fn().mockResolvedValue({
79
- errors: MOCK_ERRORS,
80
- data: {
81
- ecosystem: {
82
- publishRealtimeChannel: null,
83
- }
84
- }
85
- }),
86
- status: 200,
87
- headers: { get: jest.fn().mockReturnValue(undefined) }
88
- });
89
- global.__forge_fetch__ = mockForgeFetch;
90
- const payload = { value: 'this is a test payload', funLevel: 100 };
91
- const response = await (0, publish_1.publish)('my-channel', JSON.stringify(payload));
92
- expect(response).toEqual({ eventId: null, eventTimestamp: null, errors: MOCK_ERRORS });
93
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
94
- });
95
- });
96
- describe('publishGlobal', () => {
97
- beforeEach(() => {
98
- jest.restoreAllMocks();
99
- jest.resetAllMocks();
100
- });
101
- it('should publish an event', async () => {
102
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
103
- const mockForgeFetch = jest.fn().mockResolvedValue({
104
- json: jest.fn().mockResolvedValue(MOCK_FETCH_RESPONSE),
105
- status: 200,
106
- headers: { get: jest.fn().mockReturnValue(undefined) }
107
- });
108
- global.__forge_fetch__ = mockForgeFetch;
109
- const response = await (0, publish_1.publishGlobal)(MOCK_CHANNEL, MOCK_EVENT_PAYLOAD_STRING, MOCK_PUBLISH_OPTIONS);
110
- expect(response).toEqual({ eventId: TEST_EVENT_ID, eventTimestamp: TEST_EVENT_TIMESTAMP });
111
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
112
- });
113
- it('should publish an event when the payload is an object', async () => {
114
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
115
- const mockForgeFetch = jest.fn().mockResolvedValue({
116
- json: jest.fn().mockResolvedValue(MOCK_FETCH_RESPONSE),
117
- status: 200,
118
- headers: { get: jest.fn().mockReturnValue(undefined) }
119
- });
120
- global.__forge_fetch__ = mockForgeFetch;
121
- const response = await (0, publish_1.publishGlobal)(MOCK_CHANNEL, JSON.stringify(MOCK_EVENT_PAYLOAD_OBJECT), MOCK_PUBLISH_OPTIONS);
122
- expect(response).toEqual({ eventId: TEST_EVENT_ID, eventTimestamp: TEST_EVENT_TIMESTAMP });
123
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
124
- });
125
- it('should throw an error when Forge Outbound Proxy returns an error', async () => {
126
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
127
- const mockForgeFetch = jest.fn().mockResolvedValue({
128
- text: jest.fn().mockResolvedValue('Error occurred'),
129
- status: 502,
130
- headers: { get: jest.fn().mockReturnValue('UPSTREAM_FAILURE') }
131
- });
132
- global.__forge_fetch__ = mockForgeFetch;
133
- const response = (0, publish_1.publishGlobal)(MOCK_CHANNEL, JSON.stringify(MOCK_EVENT_PAYLOAD_OBJECT), MOCK_PUBLISH_OPTIONS);
134
- await expect(response).rejects.toThrow('Forge platform failed to process runtime HTTP request - 502 - UPSTREAM_FAILURE');
135
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
136
- });
137
- it('should return null eventId and eventTimestamp when the response has errors', async () => {
138
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
139
- const mockForgeFetch = jest.fn().mockResolvedValue({
140
- json: jest.fn().mockResolvedValue({
141
- errors: MOCK_ERRORS,
142
- data: {
143
- ecosystem: {
144
- publishRealtimeChannel: null,
145
- }
146
- }
147
- }),
148
- status: 200,
149
- headers: { get: jest.fn().mockReturnValue(undefined) }
150
- });
151
- global.__forge_fetch__ = mockForgeFetch;
152
- const payload = { value: 'this is a test payload', funLevel: 100 };
153
- const response = await (0, publish_1.publishGlobal)('my-channel', JSON.stringify(payload));
154
- expect(response).toEqual({ eventId: null, eventTimestamp: null, errors: MOCK_ERRORS });
155
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
156
- });
157
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=runtime.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.test.d.ts","sourceRoot":"","sources":["../../src/__test__/runtime.test.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const runtime_1 = require("../runtime");
4
- const utils_1 = require("./utils");
5
- describe('__getRuntime', () => {
6
- it('should return the runtime object', async () => {
7
- global.__forge_runtime__ = utils_1.FORGE_RUNTIME;
8
- const runtime = (0, runtime_1.__getRuntime)();
9
- expect(runtime.appContext.appId).toBe('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa');
10
- expect(runtime.contextAri).toBe('ari:cloud:jira::site/ffffffff-ffff-ffff-ffff-ffffffffffff');
11
- });
12
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=signRealtimeToken.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signRealtimeToken.test.d.ts","sourceRoot":"","sources":["../../src/__test__/signRealtimeToken.test.ts"],"names":[],"mappings":""}
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const runtime = tslib_1.__importStar(require("../runtime"));
5
- const signRealtimeToken_1 = require("../signRealtimeToken");
6
- const utils_1 = require("./utils");
7
- const TEST_TOKEN = 'jwt-token';
8
- const TEST_EXPIRES_AT = '1234567890';
9
- const MOCK_ERRORS = [
10
- {
11
- message: 'Error message',
12
- extensions: {
13
- errorType: 'Error type',
14
- statusCode: 500
15
- }
16
- }
17
- ];
18
- describe('signRealtimeToken', () => {
19
- beforeEach(() => {
20
- jest.restoreAllMocks();
21
- jest.resetAllMocks();
22
- });
23
- it('should send a signRealtimeToken request and recieve a jwt and expiresAt', async () => {
24
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
25
- const mockForgeFetch = jest.fn().mockResolvedValue({
26
- json: jest.fn().mockResolvedValue({
27
- errors: [],
28
- data: {
29
- ecosystem: {
30
- signRealtimeToken: {
31
- errors: [],
32
- forgeRealtimeToken: {
33
- jwt: TEST_TOKEN,
34
- expiresAt: TEST_EXPIRES_AT
35
- },
36
- success: true
37
- }
38
- }
39
- }
40
- }),
41
- status: 200,
42
- headers: { get: jest.fn().mockReturnValue(undefined) }
43
- });
44
- global.__forge_fetch__ = mockForgeFetch;
45
- const response = await (0, signRealtimeToken_1.signRealtimeToken)('my-channel', { 'test-key': 'test-value' });
46
- expect(response).toEqual({ token: TEST_TOKEN, expiresAt: TEST_EXPIRES_AT });
47
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
48
- });
49
- it('should throw an error when Forge Outbound Proxy returns an error', async () => {
50
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
51
- const mockForgeFetch = jest.fn().mockResolvedValue({
52
- text: jest.fn().mockResolvedValue('Error occurred'),
53
- status: 502,
54
- headers: { get: jest.fn().mockReturnValue('UPSTREAM_FAILURE') }
55
- });
56
- global.__forge_fetch__ = mockForgeFetch;
57
- const response = (0, signRealtimeToken_1.signRealtimeToken)('my-channel', { 'test-key': 'test-value' });
58
- await expect(response).rejects.toThrow('Forge platform failed to process runtime HTTP request - 502 - UPSTREAM_FAILURE');
59
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
60
- });
61
- it('should send generic error when errors are returned', async () => {
62
- jest.spyOn(runtime, '__getRuntime').mockReturnValue(utils_1.FORGE_RUNTIME);
63
- const mockForgeFetch = jest.fn().mockResolvedValue({
64
- json: jest.fn().mockResolvedValue({
65
- errors: MOCK_ERRORS,
66
- data: {
67
- ecosystem: {
68
- signRealtimeToken: null,
69
- }
70
- }
71
- }),
72
- status: 200,
73
- headers: { get: jest.fn().mockReturnValue(undefined) }
74
- });
75
- global.__forge_fetch__ = mockForgeFetch;
76
- const response = await (0, signRealtimeToken_1.signRealtimeToken)('my-channel', { 'test-key': 'test-value' });
77
- expect(response).toEqual({ token: null, expiresAt: null, errors: MOCK_ERRORS });
78
- expect(mockForgeFetch.mock.calls).toMatchSnapshot();
79
- });
80
- });
@@ -1,3 +0,0 @@
1
- import type { ForgeRuntime } from '@forge/api';
2
- export declare const FORGE_RUNTIME: ForgeRuntime;
3
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/__test__/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,eAAO,MAAM,aAAa,EAAE,YA6B3B,CAAC"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FORGE_RUNTIME = void 0;
4
- const metrics_interface_1 = require("@atlassian/metrics-interface");
5
- exports.FORGE_RUNTIME = {
6
- container: { runtime: 'node', region: 'us-west-2' },
7
- proxy: { url: 'https://foo', token: 'token' },
8
- contextAri: 'ari:cloud:jira::site/ffffffff-ffff-ffff-ffff-ffffffffffff',
9
- appContext: {
10
- appId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
11
- environmentId: 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
12
- environmentType: 'DEVELOPMENT',
13
- invocationId: '33333',
14
- installationId: 'iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii',
15
- appVersion: '1.2.3',
16
- functionKey: 'functionKey',
17
- moduleType: 'moduleType',
18
- moduleKey: 'moduleKey',
19
- license: { isActive: true }
20
- },
21
- tracing: {
22
- traceId: 'traceId',
23
- spanId: 'spanId'
24
- },
25
- lambdaContext: {
26
- awsRequestId: '123',
27
- getRemainingTimeInMillis: jest.fn()
28
- },
29
- metrics: new metrics_interface_1.NoMetrics(),
30
- realtime: {
31
- contextToken: 'my.context.token'
32
- },
33
- featureFlags: jest.fn()
34
- };
@@ -1,157 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`publish should publish an event when the payload is an object 1`] = `
4
- [
5
- [
6
- {
7
- "type": "realtime",
8
- },
9
- "/",
10
- {
11
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"{\\"value\\":\\"this is a test payload\\",\\"funLevel\\":100}","isGlobal":false,"token":"my-token"}}",
12
- "errors": [],
13
- "headers": {
14
- "Content-Type": "application/json",
15
- "x-forge-context-token": "my.context.token",
16
- },
17
- "method": "POST",
18
- },
19
- ],
20
- ]
21
- `;
22
-
23
- exports[`publish should publish an event with FCT in header 1`] = `
24
- [
25
- [
26
- {
27
- "type": "realtime",
28
- },
29
- "/",
30
- {
31
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"this is an event payload","isGlobal":false,"token":"my-token"}}",
32
- "errors": [],
33
- "headers": {
34
- "Content-Type": "application/json",
35
- "x-forge-context-token": "my.context.token",
36
- },
37
- "method": "POST",
38
- },
39
- ],
40
- ]
41
- `;
42
-
43
- exports[`publish should return null eventId and eventTimestamp when the response has errors 1`] = `
44
- [
45
- [
46
- {
47
- "type": "realtime",
48
- },
49
- "/",
50
- {
51
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"{\\"value\\":\\"this is a test payload\\",\\"funLevel\\":100}","isGlobal":false}}",
52
- "errors": [],
53
- "headers": {
54
- "Content-Type": "application/json",
55
- "x-forge-context-token": "my.context.token",
56
- },
57
- "method": "POST",
58
- },
59
- ],
60
- ]
61
- `;
62
-
63
- exports[`publish should throw an error when Forge Outbound Proxy returns an error 1`] = `
64
- [
65
- [
66
- {
67
- "type": "realtime",
68
- },
69
- "/",
70
- {
71
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"{\\"value\\":\\"this is a test payload\\",\\"funLevel\\":100}","isGlobal":false,"token":"my-token"}}",
72
- "errors": [],
73
- "headers": {
74
- "Content-Type": "application/json",
75
- "x-forge-context-token": "my.context.token",
76
- },
77
- "method": "POST",
78
- },
79
- ],
80
- ]
81
- `;
82
-
83
- exports[`publishGlobal should publish an event 1`] = `
84
- [
85
- [
86
- {
87
- "type": "realtime",
88
- },
89
- "/",
90
- {
91
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"this is an event payload","isGlobal":true,"token":"my-token"}}",
92
- "errors": [],
93
- "headers": {
94
- "Content-Type": "application/json",
95
- },
96
- "method": "POST",
97
- },
98
- ],
99
- ]
100
- `;
101
-
102
- exports[`publishGlobal should publish an event when the payload is an object 1`] = `
103
- [
104
- [
105
- {
106
- "type": "realtime",
107
- },
108
- "/",
109
- {
110
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"{\\"value\\":\\"this is a test payload\\",\\"funLevel\\":100}","isGlobal":true,"token":"my-token"}}",
111
- "errors": [],
112
- "headers": {
113
- "Content-Type": "application/json",
114
- },
115
- "method": "POST",
116
- },
117
- ],
118
- ]
119
- `;
120
-
121
- exports[`publishGlobal should return null eventId and eventTimestamp when the response has errors 1`] = `
122
- [
123
- [
124
- {
125
- "type": "realtime",
126
- },
127
- "/",
128
- {
129
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"{\\"value\\":\\"this is a test payload\\",\\"funLevel\\":100}","isGlobal":true}}",
130
- "errors": [],
131
- "headers": {
132
- "Content-Type": "application/json",
133
- },
134
- "method": "POST",
135
- },
136
- ],
137
- ]
138
- `;
139
-
140
- exports[`publishGlobal should throw an error when Forge Outbound Proxy returns an error 1`] = `
141
- [
142
- [
143
- {
144
- "type": "realtime",
145
- },
146
- "/",
147
- {
148
- "body": "{"query":"mutation publishRealtimeChannel(\\n $installationId: ID!\\n $name: String!\\n $payload: String!\\n $isGlobal: Boolean\\n $token: String\\n){\\n ecosystem {\\n publishRealtimeChannel(\\n installationId: $installationId\\n name: $name\\n payload: $payload\\n isGlobal: $isGlobal\\n token: $token\\n ) {\\n eventId,\\n eventTimestamp\\n }\\n }\\n}","variables":{"installationId":"iiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii","name":"my-channel","payload":"{\\"value\\":\\"this is a test payload\\",\\"funLevel\\":100}","isGlobal":true,"token":"my-token"}}",
149
- "errors": [],
150
- "headers": {
151
- "Content-Type": "application/json",
152
- },
153
- "method": "POST",
154
- },
155
- ],
156
- ]
157
- `;
@@ -1,58 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`signRealtimeToken should send a signRealtimeToken request and recieve a jwt and expiresAt 1`] = `
4
- [
5
- [
6
- {
7
- "type": "realtime",
8
- },
9
- "/",
10
- {
11
- "body": "{"query":"mutation signRealtimeToken(\\n $channelName: String!\\n $claims: JSON!\\n){\\n ecosystem {\\n signRealtimeToken(\\n channelName: $channelName\\n claims: $claims\\n ) {\\n errors {\\n message\\n extensions {\\n errorType\\n statusCode\\n }\\n }\\n forgeRealtimeToken {\\n jwt\\n expiresAt\\n }\\n success\\n }\\n }\\n}","variables":{"channelName":"my-channel","claims":{"test-key":"test-value"}}}",
12
- "errors": [],
13
- "headers": {
14
- "Content-Type": "application/json",
15
- },
16
- "method": "POST",
17
- },
18
- ],
19
- ]
20
- `;
21
-
22
- exports[`signRealtimeToken should send generic error when errors are returned 1`] = `
23
- [
24
- [
25
- {
26
- "type": "realtime",
27
- },
28
- "/",
29
- {
30
- "body": "{"query":"mutation signRealtimeToken(\\n $channelName: String!\\n $claims: JSON!\\n){\\n ecosystem {\\n signRealtimeToken(\\n channelName: $channelName\\n claims: $claims\\n ) {\\n errors {\\n message\\n extensions {\\n errorType\\n statusCode\\n }\\n }\\n forgeRealtimeToken {\\n jwt\\n expiresAt\\n }\\n success\\n }\\n }\\n}","variables":{"channelName":"my-channel","claims":{"test-key":"test-value"}}}",
31
- "errors": [],
32
- "headers": {
33
- "Content-Type": "application/json",
34
- },
35
- "method": "POST",
36
- },
37
- ],
38
- ]
39
- `;
40
-
41
- exports[`signRealtimeToken should throw an error when Forge Outbound Proxy returns an error 1`] = `
42
- [
43
- [
44
- {
45
- "type": "realtime",
46
- },
47
- "/",
48
- {
49
- "body": "{"query":"mutation signRealtimeToken(\\n $channelName: String!\\n $claims: JSON!\\n){\\n ecosystem {\\n signRealtimeToken(\\n channelName: $channelName\\n claims: $claims\\n ) {\\n errors {\\n message\\n extensions {\\n errorType\\n statusCode\\n }\\n }\\n forgeRealtimeToken {\\n jwt\\n expiresAt\\n }\\n success\\n }\\n }\\n}","variables":{"channelName":"my-channel","claims":{"test-key":"test-value"}}}",
50
- "errors": [],
51
- "headers": {
52
- "Content-Type": "application/json",
53
- },
54
- "method": "POST",
55
- },
56
- ],
57
- ]
58
- `;