@forge/realtime 0.1.1 → 0.1.2-next.0
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 +6 -0
- package/package.json +1 -1
- package/out/__test__/publish.test.d.ts +0 -2
- package/out/__test__/publish.test.d.ts.map +0 -1
- package/out/__test__/publish.test.js +0 -157
- package/out/__test__/runtime.test.d.ts +0 -2
- package/out/__test__/runtime.test.d.ts.map +0 -1
- package/out/__test__/runtime.test.js +0 -12
- package/out/__test__/signRealtimeToken.test.d.ts +0 -2
- package/out/__test__/signRealtimeToken.test.d.ts.map +0 -1
- package/out/__test__/signRealtimeToken.test.js +0 -80
- package/out/__test__/utils.d.ts +0 -3
- package/out/__test__/utils.d.ts.map +0 -1
- package/out/__test__/utils.js +0 -34
- package/src/__test__/__snapshots__/publish.test.ts.snap +0 -157
- package/src/__test__/__snapshots__/signRealtimeToken.test.ts.snap +0 -58
- package/src/__test__/publish.test.ts +0 -203
- package/src/__test__/runtime.test.ts +0 -13
- package/src/__test__/signRealtimeToken.test.ts +0 -96
- package/src/__test__/utils.ts +0 -33
- package/src/index.ts +0 -2
- package/src/publish.ts +0 -160
- package/src/runtime.ts +0 -9
- package/src/signRealtimeToken.ts +0 -90
- package/src/utils.ts +0 -12
- package/tsconfig.json +0 -18
- package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -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 +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 +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
|
-
});
|
package/out/__test__/utils.d.ts
DELETED
|
@@ -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"}
|
package/out/__test__/utils.js
DELETED
|
@@ -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
|
-
`;
|