seatsio 72.3.0 → 72.6.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/.github/workflows/release.yml +42 -0
- package/README.md +25 -0
- package/package.json +5 -5
- package/release.mjs +92 -0
- package/src/Charts/Charts.js +5 -0
- package/src/Events/Events.js +67 -1
- package/tests/charts/manageCategories.test.js +12 -0
- package/tests/events/createEvents.test.js +134 -0
- package/tests/subaccounts/filterSubaccounts.test.js +2 -2
- package/tests/testUtils.js +3 -3
- package/.github/workflows/publish.yml +0 -19
- package/releasing.md +0 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Very important!
|
|
2
|
+
# Make sure that the github token has read AND WRITE access on github.
|
|
3
|
+
# 1. hit https://github.com/seatsio/[REPO]/settings/actions
|
|
4
|
+
# 2. under "Workflow permissions", make sure "Read and write permissions" is checked instead of the (default?) read only.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
name: Release
|
|
8
|
+
run-name: Release ${{ github.repository }}
|
|
9
|
+
on:
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
inputs:
|
|
12
|
+
versionToBump:
|
|
13
|
+
description: 'The version to bump. Major for incompatible API changes, minor for adding BC features'
|
|
14
|
+
required: true
|
|
15
|
+
type: choice
|
|
16
|
+
options:
|
|
17
|
+
- minor
|
|
18
|
+
- major
|
|
19
|
+
jobs:
|
|
20
|
+
release:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v3
|
|
24
|
+
- uses: fregante/setup-git-user@v2
|
|
25
|
+
- id: install-zx
|
|
26
|
+
run: npm i -g zx
|
|
27
|
+
- id: install-semver-tool
|
|
28
|
+
run: |
|
|
29
|
+
wget -O /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
|
|
30
|
+
chmod +x /usr/local/bin/semver
|
|
31
|
+
- run: zx ./release.mjs -v $VERSION_TO_BUMP
|
|
32
|
+
env:
|
|
33
|
+
VERSION_TO_BUMP: ${{ inputs.versionToBump }}
|
|
34
|
+
GH_TOKEN: ${{ github.token }}
|
|
35
|
+
- uses: actions/setup-node@v1
|
|
36
|
+
with:
|
|
37
|
+
node-version: 18
|
|
38
|
+
registry-url: https://registry.npmjs.org/
|
|
39
|
+
- run: yarn install
|
|
40
|
+
- run: yarn publish
|
|
41
|
+
env:
|
|
42
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/README.md
CHANGED
|
@@ -56,6 +56,19 @@ let event = await client.events.create(chart.key)
|
|
|
56
56
|
console.log(`Created a chart with key ${chart.key} and an event with key: ${event.key}`)
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### Creating multiple events
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import { SeatsioClient, Region, Events } from 'seatsio'
|
|
63
|
+
|
|
64
|
+
let client = new SeatsioClient(Region.EU(), <WORKSPACE SECRET KEY>)
|
|
65
|
+
let chart = await client.charts.create()
|
|
66
|
+
let events = await client.events.createMultiple(chart.key, [ Events.eventCreationParams(), Events.eventCreationParams('aSpecificEventKey') ])
|
|
67
|
+
for (const event of events) {
|
|
68
|
+
console.log(`Created an event with key: ${event.key}`)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
59
72
|
### Booking objects
|
|
60
73
|
|
|
61
74
|
Booking an object changes its status to `booked`. Booked seats are not selectable on a rendered chart.
|
|
@@ -256,6 +269,18 @@ let event = await client.events.create(chart.key)
|
|
|
256
269
|
console.log(`Created a chart with key ${chart.key} and an event with key: ${event.key}`)
|
|
257
270
|
```
|
|
258
271
|
|
|
272
|
+
### Listing categories
|
|
273
|
+
|
|
274
|
+
```js
|
|
275
|
+
import { SeatsioClient, Region } from 'seatsio'
|
|
276
|
+
|
|
277
|
+
let client = new SeatsioClient(Region.EU(), <COMPANY ADMIN KEY>, <WORKSPACE PUBLIC KEY>)
|
|
278
|
+
let categories = await client.charts.listCategories("the chart key")
|
|
279
|
+
for (const category of categoryList) {
|
|
280
|
+
console.log(category.label)
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
259
284
|
## Error Handling
|
|
260
285
|
When an API call results in an error, a rejected promise is returned with a value that looks like
|
|
261
286
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seatsio",
|
|
3
|
-
"version": "72.
|
|
3
|
+
"version": "72.6.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Official JavaScript and Node.JS client library for the Seats.io REST API",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"url": "https://github.com/seatsio/seatsio-js"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"axios": "1.3.
|
|
16
|
+
"axios": "1.3.4"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"eslint": "8.
|
|
19
|
+
"eslint": "8.35.0",
|
|
20
20
|
"eslint-config-standard": "17.0.0",
|
|
21
21
|
"eslint-plugin-import": "2.27.5",
|
|
22
22
|
"eslint-plugin-n": "15.6.1",
|
|
23
23
|
"eslint-plugin-promise": "6.1.1",
|
|
24
|
-
"jest": "29.4.
|
|
25
|
-
"jest-cli": "29.4.
|
|
24
|
+
"jest": "29.4.3",
|
|
25
|
+
"jest-cli": "29.4.3",
|
|
26
26
|
"uuid": "9.0.0"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/release.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env zx
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Script to release the seats.io java lib.
|
|
5
|
+
* - changes the version number in README.md
|
|
6
|
+
* - changes the version number in build.gradle
|
|
7
|
+
* - creates the release in Gihub (using gh cli)
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* Prerequisites:
|
|
11
|
+
* - zx installed (https://github.com/google/zx)
|
|
12
|
+
* - gh cli installed (https://cli.github.com/)
|
|
13
|
+
* - semver cli installed (https://github.com/fsaintjacques/semver-tool)
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* zx ./release.mjs -v major/minor -n "release notes"
|
|
17
|
+
* */
|
|
18
|
+
|
|
19
|
+
// don't output the commands themselves
|
|
20
|
+
$.verbose = false
|
|
21
|
+
|
|
22
|
+
const versionToBump = getVersionToBump()
|
|
23
|
+
const latestVersion = await fetchLatestReleasedVersionNumber()
|
|
24
|
+
const nextVersion = await determineNextVersionNumber(latestVersion)
|
|
25
|
+
|
|
26
|
+
await pullLastVersion()
|
|
27
|
+
.then(bumpVersionInFiles)
|
|
28
|
+
.then(commitAndPush)
|
|
29
|
+
.then(release)
|
|
30
|
+
|
|
31
|
+
function getVersionToBump() {
|
|
32
|
+
if (!argv.v || !(argv.v === 'minor' || argv.v === 'major')) {
|
|
33
|
+
throw new Error ("Please specify -v major/minor")
|
|
34
|
+
}
|
|
35
|
+
return argv.v
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function removeLeadingV(tagName) {
|
|
39
|
+
if (tagName.startsWith('v')) {
|
|
40
|
+
return tagName.substring(1)
|
|
41
|
+
}
|
|
42
|
+
return tagName
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function fetchLatestReleasedVersionNumber() {
|
|
46
|
+
let result = await $`gh release view --json tagName`
|
|
47
|
+
let tagName = JSON.parse(result).tagName
|
|
48
|
+
return removeLeadingV(tagName)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function determineNextVersionNumber(previous) {
|
|
52
|
+
return (await $`semver bump ${versionToBump} ${previous}`).stdout.trim()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function bumpVersionInFiles() {
|
|
56
|
+
await replaceInFile("package.json", `"version": "${latestVersion}",`, `"version": "${nextVersion}",`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function replaceInFile(filename, latestVersion, nextVersion) {
|
|
60
|
+
return await fs.readFile(filename, 'utf8')
|
|
61
|
+
.then(text => {
|
|
62
|
+
if (text.indexOf(latestVersion) < 0) {
|
|
63
|
+
throw new Error('Not the correct version. Could not find ' + latestVersion + ' in ' + filename)
|
|
64
|
+
}
|
|
65
|
+
return text
|
|
66
|
+
})
|
|
67
|
+
.then(text => text.replace(latestVersion, nextVersion))
|
|
68
|
+
.then(text => fs.writeFileSync(filename, text))
|
|
69
|
+
.then(() => gitAdd(filename))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function pullLastVersion() {
|
|
73
|
+
await $`git checkout master`
|
|
74
|
+
await $`git pull origin master`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function gitAdd(filename) {
|
|
78
|
+
return await $`git add ${filename}`
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function commitAndPush() {
|
|
82
|
+
await $`git commit -m "version bump"`
|
|
83
|
+
await $`git push origin master`
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function release() {
|
|
87
|
+
const newTag = 'v' + nextVersion
|
|
88
|
+
return await $`gh release create ${newTag} --generate-notes`.catch(error => {
|
|
89
|
+
console.error('something went wrong while creating the release. Please revert the version change!')
|
|
90
|
+
throw error
|
|
91
|
+
})
|
|
92
|
+
}
|
package/src/Charts/Charts.js
CHANGED
|
@@ -68,6 +68,11 @@ class Charts {
|
|
|
68
68
|
return this.client.delete(`/charts/${chartKey}/categories/${categoryKey}`)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
listCategories (key) {
|
|
72
|
+
return this.client.get(`/charts/${key}/categories`)
|
|
73
|
+
.then((res) => res.data.categories)
|
|
74
|
+
}
|
|
75
|
+
|
|
71
76
|
/**
|
|
72
77
|
* @param {string} key
|
|
73
78
|
* @returns {object}
|
package/src/Events/Events.js
CHANGED
|
@@ -16,7 +16,6 @@ class Events {
|
|
|
16
16
|
this.channels = new Channels(this.client)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/* @return Event */
|
|
20
19
|
/**
|
|
21
20
|
* @param {string} chartKey
|
|
22
21
|
* @param {?string} eventKey
|
|
@@ -55,6 +54,73 @@ class Events {
|
|
|
55
54
|
.then((res) => new EventDeserializer().fromJson(res.data))
|
|
56
55
|
}
|
|
57
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @param {?string} eventKey
|
|
59
|
+
* @param {?TableBookingConfig} tableBookingConfig
|
|
60
|
+
* @param {?string} socialDistancingRulesetKey
|
|
61
|
+
* @param {?object} objectCategories
|
|
62
|
+
* @param {?array} categories
|
|
63
|
+
* @returns an object containing the necessary data for event creation
|
|
64
|
+
* @static
|
|
65
|
+
*/
|
|
66
|
+
static eventCreationParams (eventKey = null, tableBookingConfig = null, socialDistancingRulesetKey = null, objectCategories = null, categories = null) {
|
|
67
|
+
const eventDefinition = {}
|
|
68
|
+
eventDefinition.eventKey = eventKey
|
|
69
|
+
eventDefinition.tableBookingConfig = tableBookingConfig
|
|
70
|
+
eventDefinition.socialDistancingRulesetKey = socialDistancingRulesetKey
|
|
71
|
+
eventDefinition.objectCategories = objectCategories
|
|
72
|
+
eventDefinition.categories = categories
|
|
73
|
+
return eventDefinition
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} chartKey
|
|
78
|
+
* @param {object[]} events use {@link Events.eventCreationParams()} as a convenience function to create these objects
|
|
79
|
+
* @returns {Promise<Event[]>}
|
|
80
|
+
*/
|
|
81
|
+
createMultiple (chartKey, events) {
|
|
82
|
+
const requestParameters = {}
|
|
83
|
+
|
|
84
|
+
requestParameters.chartKey = chartKey
|
|
85
|
+
requestParameters.events = []
|
|
86
|
+
|
|
87
|
+
if (events) {
|
|
88
|
+
for (let i = 0; i < events.length; i++) {
|
|
89
|
+
const event = {}
|
|
90
|
+
if (events[i].eventKey !== null) {
|
|
91
|
+
event.eventKey = events[i].eventKey
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (events[i].tableBookingConfig !== null) {
|
|
95
|
+
event.tableBookingConfig = events[i].tableBookingConfig
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (events[i].socialDistancingRulesetKey !== null) {
|
|
99
|
+
event.socialDistancingRulesetKey = events[i].socialDistancingRulesetKey
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (events[i].objectCategories !== null) {
|
|
103
|
+
event.objectCategories = events[i].objectCategories
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (events[i].categories != null) {
|
|
107
|
+
event.categories = events[i].categories
|
|
108
|
+
}
|
|
109
|
+
requestParameters.events.push(event)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return this.client.post('/events/actions/create-multiple', requestParameters)
|
|
114
|
+
.then((res) => {
|
|
115
|
+
const result = []
|
|
116
|
+
const deserializer = new EventDeserializer()
|
|
117
|
+
for (const event of res.data.events) {
|
|
118
|
+
result.push(deserializer.fromJson(event))
|
|
119
|
+
}
|
|
120
|
+
return result
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
58
124
|
/**
|
|
59
125
|
* @param {string} eventKey
|
|
60
126
|
* @returns {Promise<Event>}
|
|
@@ -30,3 +30,15 @@ test('should remove a category', async () => {
|
|
|
30
30
|
const retrievedChart = await client.charts.retrievePublishedVersion(chart.key)
|
|
31
31
|
expect(retrievedChart.categories.list).toEqual([{ key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false }])
|
|
32
32
|
})
|
|
33
|
+
|
|
34
|
+
test('should retrieve the categories of a chart', async () => {
|
|
35
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
36
|
+
const categories = [
|
|
37
|
+
{ key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false },
|
|
38
|
+
{ key: 'cat2', label: 'Category 2', color: '#bbbbbb', accessible: true }
|
|
39
|
+
]
|
|
40
|
+
const chart = await client.charts.create('aChart', null, categories)
|
|
41
|
+
|
|
42
|
+
const categoryList = await client.charts.listCategories(chart.key)
|
|
43
|
+
expect(categoryList).toEqual(categories)
|
|
44
|
+
})
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
const SocialDistancingRuleset = require('../../src/Charts/SocialDistancingRuleset.js')
|
|
3
|
+
const TableBookingConfig = require('../../src/Events/TableBookingConfig')
|
|
4
|
+
const Category = require('../../src/Charts/Category')
|
|
5
|
+
const Events = require('../../src/Events/Events')
|
|
6
|
+
|
|
7
|
+
test('should check that a minimum of one event is required', async () => {
|
|
8
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
9
|
+
const chartKey = testUtils.getChartKey()
|
|
10
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
await client.events.createMultiple(chartKey)
|
|
14
|
+
} catch (e) {
|
|
15
|
+
expect(e.errors.length).toEqual(1)
|
|
16
|
+
expect(e.errors[0].code).toBe('GENERAL_ERROR')
|
|
17
|
+
expect(e.errors[0].message).toBe('#/events: expected minimum item count: 1, found: 0')
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('should check that an empty object is a valid event definition', async () => {
|
|
22
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
23
|
+
const chartKey = testUtils.getChartKey()
|
|
24
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
25
|
+
|
|
26
|
+
const events = await client.events.createMultiple(chartKey, [{}])
|
|
27
|
+
|
|
28
|
+
expect(events).toHaveLength(1)
|
|
29
|
+
expect(events[0].key).toBeTruthy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('should create a single event', async () => {
|
|
33
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
34
|
+
const chart = await client.charts.create()
|
|
35
|
+
|
|
36
|
+
const events = await client.events.createMultiple(chart.key, [
|
|
37
|
+
Events.eventCreationParams('eventKey')
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
expect(events).toHaveLength(1)
|
|
41
|
+
expect(events[0].key).toEqual('eventKey')
|
|
42
|
+
|
|
43
|
+
const retrievedEvent = await client.events.retrieve('eventKey')
|
|
44
|
+
expect(retrievedEvent.key).toEqual('eventKey')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('should create multiple events', async () => {
|
|
48
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
49
|
+
const chart = await client.charts.create()
|
|
50
|
+
|
|
51
|
+
const events = [
|
|
52
|
+
Events.eventCreationParams('eventKey1'),
|
|
53
|
+
Events.eventCreationParams('eventKey2')
|
|
54
|
+
]
|
|
55
|
+
const createdEvents = await client.events.createMultiple(chart.key, events)
|
|
56
|
+
|
|
57
|
+
expect(createdEvents).toHaveLength(2)
|
|
58
|
+
expect(createdEvents[0].key).toEqual('eventKey1')
|
|
59
|
+
expect(createdEvents[1].key).toEqual('eventKey2')
|
|
60
|
+
|
|
61
|
+
for (const event of events) {
|
|
62
|
+
const retrievedEvent = await client.events.retrieve(event.eventKey)
|
|
63
|
+
expect(retrievedEvent.key).toEqual(event.eventKey)
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('supports tableBookingConfig custom', async () => {
|
|
68
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
69
|
+
const chartKey = testUtils.getChartKey()
|
|
70
|
+
await testUtils.createTestChartWithTables(chartKey, user.secretKey)
|
|
71
|
+
const tableBookingConfig = TableBookingConfig.custom({ T1: 'BY_TABLE', T2: 'BY_SEAT' })
|
|
72
|
+
|
|
73
|
+
const events = await client.events.createMultiple(chartKey, [
|
|
74
|
+
Events.eventCreationParams(null, tableBookingConfig)
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
expect(events[0].key).toBeTruthy()
|
|
78
|
+
expect(events[0].tableBookingConfig).toEqual(tableBookingConfig)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('supports tableBookingConfig inherit', async () => {
|
|
82
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
83
|
+
const chartKey = testUtils.getChartKey()
|
|
84
|
+
await testUtils.createTestChartWithTables(chartKey, user.secretKey)
|
|
85
|
+
|
|
86
|
+
const events = await client.events.createMultiple(chartKey, [
|
|
87
|
+
Events.eventCreationParams(null, TableBookingConfig.inherit())
|
|
88
|
+
])
|
|
89
|
+
|
|
90
|
+
expect(events[0].key).toBeTruthy()
|
|
91
|
+
expect(events[0].tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('it supports a social distancing ruleset key', async () => {
|
|
95
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
96
|
+
const chart = await client.charts.create()
|
|
97
|
+
const rulesets = { ruleset1: SocialDistancingRuleset.ruleBased('My ruleset').build() }
|
|
98
|
+
await client.charts.saveSocialDistancingRulesets(chart.key, rulesets)
|
|
99
|
+
|
|
100
|
+
const events = await client.events.createMultiple(chart.key, [
|
|
101
|
+
Events.eventCreationParams(null, null, 'ruleset1')
|
|
102
|
+
])
|
|
103
|
+
|
|
104
|
+
expect(events[0].socialDistancingRulesetKey).toBe('ruleset1')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('it supports object categories', async () => {
|
|
108
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
109
|
+
const chartKey = testUtils.getChartKey()
|
|
110
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
111
|
+
|
|
112
|
+
const events = await client.events.createMultiple(chartKey, [
|
|
113
|
+
Events.eventCreationParams(null, null, null, { 'A-1': 10 })
|
|
114
|
+
])
|
|
115
|
+
|
|
116
|
+
expect(events[0].objectCategories).toEqual({ 'A-1': 10 })
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
test('it supports categories', async () => {
|
|
120
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
121
|
+
const chartKey = testUtils.getChartKey()
|
|
122
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
123
|
+
|
|
124
|
+
const eventCategory = new Category('eventCat1', 'Event Level Category', '#AAABBB')
|
|
125
|
+
|
|
126
|
+
const events = await client.events.createMultiple(chartKey, [
|
|
127
|
+
Events.eventCreationParams(null, null, null, null, [eventCategory])
|
|
128
|
+
])
|
|
129
|
+
|
|
130
|
+
expect(events[0].categories.length).toEqual(4) // 3 from sampleChart.json, 1 event level category
|
|
131
|
+
expect(events[0].categories.filter(cat => cat.key === 'eventCat1').length).toEqual(1)
|
|
132
|
+
expect(events[0].categories.filter(cat => cat.key === 'eventCat1')[0].label).toEqual('Event Level Category')
|
|
133
|
+
expect(events[0].categories.filter(cat => cat.key === 'eventCat1')[0].color).toEqual('#AAABBB')
|
|
134
|
+
})
|
|
@@ -21,13 +21,13 @@ test('should filter subaccounts ', async () => {
|
|
|
21
21
|
test('should filter subaccounts with special characters', async () => {
|
|
22
22
|
const { client } = await testUtils.createTestUserAndClient()
|
|
23
23
|
let i = 0
|
|
24
|
-
await testUtils.createArray(
|
|
24
|
+
await testUtils.createArray(10, () => client.subaccounts.create('test-/@/' + i++))
|
|
25
25
|
const retrievedSubaccountKeys = []
|
|
26
26
|
for await (const subaccount of client.subaccounts.listAll('test-/@/1')) {
|
|
27
27
|
retrievedSubaccountKeys.push(subaccount.secretKey)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
expect(retrievedSubaccountKeys.length).toEqual(
|
|
30
|
+
expect(retrievedSubaccountKeys.length).toEqual(1)
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
test('should filter with no results ', async () => {
|
package/tests/testUtils.js
CHANGED
|
@@ -81,14 +81,14 @@ module.exports = {
|
|
|
81
81
|
return uuidv4() + '@mailinator.com'
|
|
82
82
|
},
|
|
83
83
|
|
|
84
|
-
createArray (length, fn) {
|
|
84
|
+
async createArray (length, fn) {
|
|
85
85
|
const array = []
|
|
86
86
|
|
|
87
87
|
for (let i = 0; i < length; ++i) {
|
|
88
|
-
array.push(fn())
|
|
88
|
+
array.push(await fn())
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return array
|
|
92
92
|
},
|
|
93
93
|
|
|
94
94
|
deferred () {
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
name: 'Publish release'
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v2
|
|
12
|
-
- uses: actions/setup-node@v1
|
|
13
|
-
with:
|
|
14
|
-
node-version: 18
|
|
15
|
-
registry-url: https://registry.npmjs.org/
|
|
16
|
-
- run: yarn install
|
|
17
|
-
- run: yarn publish
|
|
18
|
-
env:
|
|
19
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/releasing.md
DELETED