@onesignal/onesignal-vue3 2.0.0 → 2.1.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/os_probot_metadata.js +58 -0
- package/.github/set_response_times.js +47 -0
- package/.github/workflows/release.yml +40 -0
- package/.github/workflows/set_response_time.yml +32 -0
- package/.releaserc.json +133 -0
- package/CHANGELOG.md +7 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +90 -49
- package/dist/index.js.map +1 -1
- package/index.ts +169 -109
- package/package.json +7 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/action"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Based on probot-metadata - https://github.com/probot/metadata
|
|
5
|
+
*/
|
|
6
|
+
const regex = /\n\n<!-- probot = (.*) -->/
|
|
7
|
+
|
|
8
|
+
const octokit = new Octokit()
|
|
9
|
+
|
|
10
|
+
module.exports = (context, issue = null) => {
|
|
11
|
+
console.log(context)
|
|
12
|
+
const prefix = "onesignal-probot"
|
|
13
|
+
|
|
14
|
+
if (!issue) issue = context.payload.issue
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
async get (key = null) {
|
|
18
|
+
let body = issue.body
|
|
19
|
+
|
|
20
|
+
if (!body) {
|
|
21
|
+
body = (await octokit.issues.get(issue)).data.body || ''
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const match = body.match(regex)
|
|
25
|
+
|
|
26
|
+
if (match) {
|
|
27
|
+
const data = JSON.parse(match[1])[prefix]
|
|
28
|
+
return key ? data && data[key] : data
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
async set (key, value) {
|
|
33
|
+
let body = issue.body
|
|
34
|
+
let data = {}
|
|
35
|
+
|
|
36
|
+
if (!body) body = (await octokit.issues.get(issue)).data.body || ''
|
|
37
|
+
|
|
38
|
+
body = body.replace(regex, (_, json) => {
|
|
39
|
+
data = JSON.parse(json)
|
|
40
|
+
return ''
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
if (!data[prefix]) data[prefix] = {}
|
|
44
|
+
|
|
45
|
+
if (typeof key === 'object') {
|
|
46
|
+
Object.assign(data[prefix], key)
|
|
47
|
+
} else {
|
|
48
|
+
data[prefix][key] = value
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
body = `${body}\n\n<!-- probot = ${JSON.stringify(data)} -->`
|
|
52
|
+
|
|
53
|
+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/")
|
|
54
|
+
const issue_number = context.payload.issue.number
|
|
55
|
+
return octokit.issues.update({ owner, repo, issue_number, body })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function calcResponseTimeForIssueCreatedAt(createdAt) {
|
|
2
|
+
const issueOpenedDate = new Date(createdAt);
|
|
3
|
+
const issueTriagedDate = new Date();
|
|
4
|
+
const businessDaysResponseTime = calcBusinessDaysBetweenDates(issueOpenedDate, issueTriagedDate);
|
|
5
|
+
return businessDaysResponseTime;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function calcBusinessDaysBetweenDates(openedDate, triagedDate) {
|
|
9
|
+
let differenceInWeeks, responseTime;
|
|
10
|
+
if (triagedDate < openedDate)
|
|
11
|
+
return -1; // error code if dates transposed
|
|
12
|
+
let openedDay = openedDate.getDay(); // day of week
|
|
13
|
+
let triagedDay = triagedDate.getDay();
|
|
14
|
+
openedDay = (openedDay == 0) ? 7 : openedDay; // change Sunday from 0 to 7
|
|
15
|
+
triagedDay = (triagedDay == 0) ? 7 : triagedDay;
|
|
16
|
+
openedDay = (openedDay > 5) ? 5 : openedDay; // only count weekdays
|
|
17
|
+
triagedDay = (triagedDay > 5) ? 5 : triagedDay;
|
|
18
|
+
// calculate differnece in weeks (1000mS * 60sec * 60min * 24hrs * 7 days = 604800000)
|
|
19
|
+
differenceInWeeks = Math.floor((triagedDate.getTime() - openedDate.getTime()) / 604800000);
|
|
20
|
+
if (openedDay < triagedDay) { //Equal to makes it reduce 5 days
|
|
21
|
+
responseTime = (differenceInWeeks * 5) + (triagedDay - openedDay);
|
|
22
|
+
}
|
|
23
|
+
else if (openedDay == triagedDay) {
|
|
24
|
+
responseTime = differenceInWeeks * 5;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
responseTime = ((differenceInWeeks + 1) * 5) - (openedDay - triagedDay);
|
|
28
|
+
}
|
|
29
|
+
return (responseTime);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = async(context, osmetadata) => {
|
|
33
|
+
const foundResponseTime = await osmetadata(context).get('response_time_in_business_days');
|
|
34
|
+
if (foundResponseTime) {
|
|
35
|
+
const foundString = "already found response time in business days: " + foundResponseTime
|
|
36
|
+
console.log(foundString);
|
|
37
|
+
return foundString;
|
|
38
|
+
}
|
|
39
|
+
if (context.payload.comment && context.payload.comment.author_association != "MEMBER" && context.payload.comment.author_association != "OWNER" && context.payload.comment.author_association != "CONTRIBUTOR") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const businessDaysResponseTime = calcResponseTimeForIssueCreatedAt(context.payload.issue.created_at);
|
|
43
|
+
console.log("response time in business days: " + businessDaysResponseTime);
|
|
44
|
+
const result = osmetadata(context, context.payload.issue).set('response_time_in_business_days', businessDaysResponseTime)
|
|
45
|
+
console.log("osmetadata update result: " + result);
|
|
46
|
+
return "set response time in business days: " + businessDaysResponseTime;
|
|
47
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
release:
|
|
9
|
+
name: Release
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
issues: write
|
|
14
|
+
pull-requests: write
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
|
|
21
|
+
- name: Setup Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: 'lts/*'
|
|
25
|
+
registry-url: 'https://registry.npmjs.org'
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: yarn install
|
|
28
|
+
- name: Release
|
|
29
|
+
env:
|
|
30
|
+
GITHUB_TOKEN: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
|
|
31
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_WEB_SHIM_PUSH_TOKEN }}
|
|
32
|
+
NPM_TOKEN: ${{ secrets.NPM_WEB_SHIM_PUSH_TOKEN }}
|
|
33
|
+
run: |
|
|
34
|
+
npx -p semantic-release \
|
|
35
|
+
-p @semantic-release/changelog \
|
|
36
|
+
-p @semantic-release/git \
|
|
37
|
+
-p @semantic-release/github \
|
|
38
|
+
-p @semantic-release/npm \
|
|
39
|
+
-p conventional-changelog-conventionalcommits \
|
|
40
|
+
semantic-release
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Set Response Time
|
|
2
|
+
on:
|
|
3
|
+
issue_comment:
|
|
4
|
+
types:
|
|
5
|
+
- created
|
|
6
|
+
issues:
|
|
7
|
+
types:
|
|
8
|
+
- closed
|
|
9
|
+
jobs:
|
|
10
|
+
calculate:
|
|
11
|
+
name: set reponse time for the issue
|
|
12
|
+
if: github.event.issue.pull_request == null
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
issues: write
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
with:
|
|
19
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
+
- run: npm install @octokit/action
|
|
21
|
+
- uses: actions/github-script@v6
|
|
22
|
+
id: set-time
|
|
23
|
+
with:
|
|
24
|
+
result-encoding: string
|
|
25
|
+
script: |
|
|
26
|
+
const os_probot_metadata = require('./.github/os_probot_metadata.js')
|
|
27
|
+
const set_response_time = require('./.github/set_response_times.js')
|
|
28
|
+
return await set_response_time(context, os_probot_metadata)
|
|
29
|
+
env:
|
|
30
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
+
- name: Get result
|
|
32
|
+
run: echo "${{steps.set-time.outputs.result}}" >> $GITHUB_STEP_SUMMARY
|
package/.releaserc.json
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"branches": [
|
|
3
|
+
"main"
|
|
4
|
+
],
|
|
5
|
+
"tagFormat": "${version}",
|
|
6
|
+
"plugins": [
|
|
7
|
+
[
|
|
8
|
+
"@semantic-release/commit-analyzer",
|
|
9
|
+
{
|
|
10
|
+
"releaseRules": [
|
|
11
|
+
{
|
|
12
|
+
"breaking": true,
|
|
13
|
+
"release": "minor"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "feat",
|
|
17
|
+
"release": "minor"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "fix",
|
|
21
|
+
"release": "patch"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "docs",
|
|
25
|
+
"release": "patch"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "perf",
|
|
29
|
+
"release": "patch"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "refactor",
|
|
33
|
+
"release": "patch"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "style",
|
|
37
|
+
"release": "patch"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "test",
|
|
41
|
+
"release": "patch"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "build",
|
|
45
|
+
"release": "patch"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"type": "ci",
|
|
49
|
+
"release": "patch"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "chore",
|
|
53
|
+
"scope": "deps",
|
|
54
|
+
"release": "patch"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
"@semantic-release/release-notes-generator",
|
|
61
|
+
{
|
|
62
|
+
"preset": "conventionalcommits",
|
|
63
|
+
"writerOpts": {
|
|
64
|
+
"types": [
|
|
65
|
+
{
|
|
66
|
+
"type": "feat",
|
|
67
|
+
"section": "Features"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"type": "fix",
|
|
71
|
+
"section": "Bug Fixes"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"type": "docs",
|
|
75
|
+
"section": "Documentation",
|
|
76
|
+
"hidden": false
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "deps",
|
|
80
|
+
"section": "Dependency Updates",
|
|
81
|
+
"hidden": false
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"type": "chore",
|
|
85
|
+
"hidden": true
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "style",
|
|
89
|
+
"hidden": true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "refactor",
|
|
93
|
+
"hidden": true
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "perf",
|
|
97
|
+
"hidden": true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"type": "test",
|
|
101
|
+
"hidden": true
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
"@semantic-release/changelog",
|
|
109
|
+
{
|
|
110
|
+
"changelogFile": "CHANGELOG.md",
|
|
111
|
+
"changelogTitle": "# Changelog"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
"@semantic-release/npm",
|
|
116
|
+
{
|
|
117
|
+
"pkgRoot": "."
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
"@semantic-release/git",
|
|
122
|
+
{
|
|
123
|
+
"assets": [
|
|
124
|
+
"dist/**",
|
|
125
|
+
"package.json",
|
|
126
|
+
"CHANGELOG.md"
|
|
127
|
+
],
|
|
128
|
+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes} [skip ci]"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"@semantic-release/github"
|
|
132
|
+
]
|
|
133
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.1.0](https://github.com/OneSignal/onesignal-vue3/compare/2.0.1...2.1.0) (2025-03-18)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* sync with web-shim-codegen v3.0.1 ([ce65df3](https://github.com/OneSignal/onesignal-vue3/commit/ce65df3d95781939b291ca79fed9639f29bf8a3e)), closes [#143](https://github.com/OneSignal/onesignal-vue3/issues/143)
|
package/dist/index.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ interface IOSNotification {
|
|
|
84
84
|
* If this value is the same as existing notification, it will replace it
|
|
85
85
|
* Can be set when creating the notification with "Web Push Topic" on the dashboard
|
|
86
86
|
* or web_push_topic from the REST API.
|
|
87
|
-
|
|
87
|
+
*/
|
|
88
88
|
readonly topic?: string;
|
|
89
89
|
/**
|
|
90
90
|
* Custom object that was sent with the notification;
|
|
@@ -142,6 +142,13 @@ interface NotificationClickEvent {
|
|
|
142
142
|
readonly notification: IOSNotification;
|
|
143
143
|
readonly result: NotificationClickResult;
|
|
144
144
|
}
|
|
145
|
+
declare type UserChangeEvent = {
|
|
146
|
+
current: UserNamespaceProperties;
|
|
147
|
+
};
|
|
148
|
+
declare type UserNamespaceProperties = {
|
|
149
|
+
onesignalId: string | undefined;
|
|
150
|
+
externalId: string | undefined;
|
|
151
|
+
};
|
|
145
152
|
interface IInitObject {
|
|
146
153
|
appId: string;
|
|
147
154
|
subdomainName?: string;
|
|
@@ -155,12 +162,13 @@ interface IInitObject {
|
|
|
155
162
|
autoRegister?: boolean;
|
|
156
163
|
notificationClickHandlerMatch?: string;
|
|
157
164
|
notificationClickHandlerAction?: string;
|
|
165
|
+
path?: string;
|
|
158
166
|
serviceWorkerParam?: {
|
|
159
167
|
scope: string;
|
|
160
168
|
};
|
|
161
169
|
serviceWorkerPath?: string;
|
|
170
|
+
serviceWorkerOverrideForTypical?: boolean;
|
|
162
171
|
serviceWorkerUpdaterPath?: string;
|
|
163
|
-
path?: string;
|
|
164
172
|
allowLocalhostAsSecureOrigin?: boolean;
|
|
165
173
|
[key: string]: any;
|
|
166
174
|
}
|
|
@@ -203,6 +211,8 @@ interface IOneSignalSession {
|
|
|
203
211
|
sendUniqueOutcome(outcomeName: string): Promise<void>;
|
|
204
212
|
}
|
|
205
213
|
interface IOneSignalUser {
|
|
214
|
+
onesignalId: string | undefined;
|
|
215
|
+
externalId: string | undefined;
|
|
206
216
|
PushSubscription: IOneSignalPushSubscription;
|
|
207
217
|
addAlias(label: string, id: string): void;
|
|
208
218
|
addAliases(aliases: {
|
|
@@ -220,6 +230,13 @@ interface IOneSignalUser {
|
|
|
220
230
|
}): void;
|
|
221
231
|
removeTag(key: string): void;
|
|
222
232
|
removeTags(keys: string[]): void;
|
|
233
|
+
getTags(): {
|
|
234
|
+
[key: string]: string;
|
|
235
|
+
};
|
|
236
|
+
addEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
|
|
237
|
+
removeEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
|
|
238
|
+
setLanguage(language: string): void;
|
|
239
|
+
getLanguage(): string;
|
|
223
240
|
}
|
|
224
241
|
interface IOneSignalPushSubscription {
|
|
225
242
|
id: string | null | undefined;
|