Skip to content

Commit 82ae658

Browse files
Use package class instead of link name and package name
1 parent 3757c3d commit 82ae658

11 files changed

+58
-116
lines changed

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
Provides links for working with [`@firebase/messaging`](https://www.npmjs.com/package/@firebase/messaging)
66

77
[**Documentation**](https://deep-foundation.github.io/firebase-push-notification/)
8-
9-
[**List of links**](https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html)
10-
118
# Usage
129
## Setup
1310
### Service Account
@@ -39,15 +36,15 @@ You can use `SyncTextFile` from [`@deep-foundation/core`](https://www.npmjs.com/
3936
To receive messages on Client read [Firebase Cloud Messaging Documentation](https://firebase.google.com/docs/cloud-messaging)
4037

4138

42-
[`ServiceAccount`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#ServiceAccount
43-
[`UsesServiceAccount`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#UsesServiceAccount
44-
[`WebPushCertificate`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#WebPushCertificate
45-
[`UsesWebPushCertificate`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#UsesWebPushCertificate
39+
[`ServiceAccount`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#ServiceAccount
40+
[`UsesServiceAccount`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#UsesServiceAccount
41+
[`WebPushCertificate`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#WebPushCertificate
42+
[`UsesWebPushCertificate`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#UsesWebPushCertificate
4643
[`Device`]: https://deep-foundation.github.io/capacitor-device/enums/CapacitorDeviceContains.html#Device
47-
[`DeviceRegistrationToken`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#DeviceRegistrationToken
48-
[`PushNotification`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#PushNotification
49-
[`PushNotificationTitle`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#PushNotificationTitle
50-
[`PushNotificationBody`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#PushNotificationBody
51-
[`PushNotificationImageUrl`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#PushNotificationImageUrl
52-
[`PushNotificationIconUrl`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#PushNotificationIconUrl
53-
[`Notify`]: https://deep-foundation.github.io/firebase-push-notification/enums/LinkName.html#Notify
44+
[`DeviceRegistrationToken`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#DeviceRegistrationToken
45+
[`PushNotification`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#PushNotification
46+
[`PushNotificationTitle`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#PushNotificationTitle
47+
[`PushNotificationBody`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#PushNotificationBody
48+
[`PushNotificationImageUrl`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#PushNotificationImageUrl
49+
[`PushNotificationIconUrl`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#PushNotificationIconUrl
50+
[`Notify`]: https://deep-foundation.github.io/firebase-push-notification/classes/Package.html#Notify

src/get-device-registration-token-insert-serial-operations.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import {
22
DeepClient,
33
SerialOperation,
44
} from '@deep-foundation/deeplinks/imports/client';
5-
import { LinkName } from './link-name';
6-
import { PACKAGE_NAME } from './package-name';
75
import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
6+
import { Package } from './package';
87

98
/**
10-
* Gets serial operations to insert {@link LinkName.DeviceRegistrationToken}
9+
* Gets serial operations to insert {@link Package.DeviceRegistrationToken}
1110
*
1211
* @example
13-
* #### Insert {@link LinkName.DeviceRegistrationToken}
12+
* #### Insert {@link Package.DeviceRegistrationToken}
1413
```ts
1514
const {serialOperations, linkIds} = await getDeviceRegistrationTokenInsertSerialOperations({
1615
deep
@@ -19,7 +18,7 @@ import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
1918
operations: serialOperations
2019
})
2120
```
22-
* #### Insert {@link LinkName.DeviceRegistrationToken} with reserved link id
21+
* #### Insert {@link Package.DeviceRegistrationToken} with reserved link id
2322
```ts
2423
const reservedLinkIds = await deep.reserve(2);
2524
const deviceRegistrationTokenLinkId = reservedLinkIds.pop();
@@ -50,6 +49,7 @@ export async function getDeviceRegistrationTokenInsertSerialOperations(
5049
containValue,
5150
containerLinkId,
5251
} = param;
52+
const $package = new Package({deep});
5353
const reservedLinkIds = await getReservedLinkIds();
5454
const { containLinkId, deviceRegistrationTokenLinkId } = reservedLinkIds;
5555
const typeLinkIds = await getTypeLinkIds();
@@ -137,7 +137,7 @@ export async function getDeviceRegistrationTokenInsertSerialOperations(
137137
(await deep.id('@deep-foundation/core', 'Contain')),
138138
deviceRegistrationTokenTypeLinkId:
139139
param.typeLinkIds?.deviceRegistrationTokenTypeLinkId ||
140-
(await deep.id(PACKAGE_NAME, LinkName[LinkName.DeviceRegistrationToken])),
140+
await $package.DeviceRegistrationToken.id(),
141141
};
142142
return result;
143143
}

src/get-device-registration-token-value-update-serial-operations.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ import {
22
DeepClient,
33
SerialOperation,
44
} from '@deep-foundation/deeplinks/imports/client';
5-
import { LinkName } from './link-name';
6-
import { PACKAGE_NAME } from './package-name';
75
import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
86
import { MutationInputValue } from '@deep-foundation/deeplinks/imports/client_types';
97
import { Link } from '@deep-foundation/deeplinks/imports/minilinks';
108

119
/**
12-
* Gets serial operations to update {@link LinkName.DeviceRegistrationToken}
10+
* Gets serial operations to update {@link Package.DeviceRegistrationToken}
1311
*
1412
* @example
15-
* #### Update {@link LinkName.DeviceRegistrationToken}
13+
* #### Update {@link Package.DeviceRegistrationToken}
1614
```ts
1715
const {serialOperations, linkIds} = await getDeviceRegistrationTokenValueUpdateSerialOperations({
1816
deep,

src/get-push-notification-insert-serial-operations.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ import {
22
DeepClient,
33
SerialOperation,
44
} from '@deep-foundation/deeplinks/imports/client';
5-
import { LinkName } from './link-name';
6-
import { PACKAGE_NAME } from './package-name';
75
import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
86
import { PushNotification } from './push-notification';
7+
import { Package } from './package';
98

109
/**
11-
* Gets serial operations to insert {@link LinkName.PushNotification}
10+
* Gets serial operations to insert {@link Package.PushNotification}
1211
*
1312
* @example
14-
* #### Insert {@link LinkName.PushNotification}
13+
* #### Insert {@link Package.PushNotification}
1514
```ts
1615
const {serialOperations, linkIds} = await getPushNotificationInsertSerialOperations({
1716
deep
@@ -20,7 +19,7 @@ import { PushNotification } from './push-notification';
2019
operations: serialOperations
2120
})
2221
```
23-
* #### Insert {@link LinkName.PushNotification} with reserved link id
22+
* #### Insert {@link Package.PushNotification} with reserved link id
2423
```ts
2524
const reservedLinkIds = await deep.reserve(2);
2625
const pushNotificationLinkId = reservedLinkIds.pop();
@@ -51,6 +50,7 @@ export async function getPushNotificationInsertSerialOperations(
5150
containValue,
5251
containerLinkId,
5352
} = param;
53+
const $package = new Package({deep});
5454
const reservedLinkIds = await getReservedLinkIds();
5555
const { containLinkId, pushNotificationLinkId } = reservedLinkIds;
5656
const typeLinkIds = await getTypeLinkIds();
@@ -138,7 +138,7 @@ export async function getPushNotificationInsertSerialOperations(
138138
(await deep.id('@deep-foundation/core', 'Contain')),
139139
pushNotificationTypeLinkId:
140140
param.typeLinkIds?.pushNotificationTypeLinkId ||
141-
(await deep.id(PACKAGE_NAME, LinkName[LinkName.PushNotification])),
141+
await $package.PushNotification.id(),
142142
};
143143
return result;
144144
}

src/get-push-notification-value-update-serial-operations.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ import {
22
DeepClient,
33
SerialOperation,
44
} from '@deep-foundation/deeplinks/imports/client';
5-
import { LinkName } from './link-name';
6-
import { PACKAGE_NAME } from './package-name';
75
import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
86
import { MutationInputValue } from '@deep-foundation/deeplinks/imports/client_types';
97
import { Link } from '@deep-foundation/deeplinks/imports/minilinks';
108
import { PushNotification } from './push-notification';
119

1210
/**
13-
* Gets serial operations to update {@link LinkName.PushNotification}
11+
* Gets serial operations to update {@link Package.PushNotification}
1412
*
1513
* @example
16-
* #### Update {@link LinkName.PushNotification}
14+
* #### Update {@link Package.PushNotification}
1715
```ts
1816
const {serialOperations, linkIds} = await getPushNotificationValueUpdateSerialOperations({
1917
deep,

src/get-push-notification.ts

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { DeepClient } from '@deep-foundation/deeplinks/imports/client';
2-
import { PACKAGE_NAME } from './package-name';
32
import { PushNotification } from './push-notification';
4-
import { LinkName } from './link-name';
5-
3+
import { Package } from './package';
64
/**
75
* Gets push notification from deep
86
*
@@ -21,36 +19,10 @@ export async function getPushNotification({
2119
deep,
2220
pushNotificationLinkId,
2321
}: GetPushNotificationParam): Promise<GetPushNotificationResult> {
24-
const titleTypeLinkId = await deep.id(
25-
PACKAGE_NAME,
26-
LinkName[
27-
LinkName.PushNotificationTitle
28-
]
29-
);
30-
const bodyTypeLinkId = await deep.id(
31-
PACKAGE_NAME,
32-
LinkName[
33-
LinkName.PushNotificationBody
34-
]
35-
);
36-
const imageUrlTypeLinkId = await deep.id(
37-
PACKAGE_NAME,
38-
LinkName[
39-
LinkName.PushNotificationImageUrl
40-
]
41-
);
42-
const iconUrlTypeLinkId = await deep.id(
43-
PACKAGE_NAME,
44-
LinkName[
45-
LinkName.PushNotificationIconUrl
46-
]
47-
);
48-
const pushNotificationTreeLinkId = await deep.id(
49-
PACKAGE_NAME,
50-
LinkName[
51-
LinkName.PushNotificationTree
52-
]
53-
);
22+
const $package = new Package({ deep });
23+
const titleTypeLinkId = await $package.PushNotificationTitle.id();
24+
const bodyTypeLinkId = await $package.PushNotificationBody.id();
25+
const pushNotificationTreeLinkId = await $package.PushNotificationTree.id();
5426

5527
const { data: linksDownToParentPushNotificationMp } = await deep.select(
5628
{
@@ -82,18 +54,9 @@ export async function getPushNotification({
8254
throw new Error(`A link with type ##${bodyTypeLinkId} is not found`);
8355
}
8456

85-
const linkWithImageUrl = linksDownToParentPushNotificationMp.find(
86-
(link) => link.type_id === imageUrlTypeLinkId
87-
);
88-
const linkWithIconUrl = linksDownToParentPushNotificationMp.find(
89-
(link) => link.type_id === iconUrlTypeLinkId
90-
);
91-
9257
return {
9358
title: linkWithTitle?.to.value.value,
9459
body: linkWithBody.to.value.value,
95-
image: linkWithImageUrl?.to.value?.value,
96-
icon: linkWithIconUrl?.to.value?.value,
9760
};
9861
}
9962

src/get-service-account-insert-serial-operations.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import {
22
DeepClient,
33
SerialOperation,
44
} from '@deep-foundation/deeplinks/imports/client';
5-
import { LinkName } from './link-name';
6-
import { PACKAGE_NAME } from './package-name';
75
import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
6+
import { Package } from './package';
87

98
/**
10-
* Gets serial operations to insert {@link LinkName.ServiceAccount}
9+
* Gets serial operations to insert {@link Package.ServiceAccount}
1110
*
1211
* @example
13-
* #### Insert {@link LinkName.ServiceAccount}
12+
* #### Insert {@link Package.ServiceAccount}
1413
```ts
1514
const {serialOperations, linkIds} = await getServiceAccountInsertSerialOperations({
1615
deep
@@ -19,7 +18,7 @@ import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
1918
operations: serialOperations
2019
})
2120
```
22-
* #### Insert {@link LinkName.ServiceAccount} with reserved link id
21+
* #### Insert {@link Package.ServiceAccount} with reserved link id
2322
```ts
2423
const reservedLinkIds = await deep.reserve(2);
2524
const serviceAccountLinkId = reservedLinkIds.pop();
@@ -51,6 +50,7 @@ export async function getServiceAccountInsertSerialOperations(
5150
valueForContainForUsesServiceAccount,
5251
shouldMakeActive = false
5352
} = param;
53+
const $package = new Package({deep});
5454
const containerLinkId = param.containerLinkId !== null ? param.containerLinkId ?? deep.linkId : null;
5555
const reservedLinkIds = await getReservedLinkIds();
5656
const { containForServiceAccountLinkId, serviceAccountLinkId, usesServiceAccountLinkId,containForUsesServiceAccountLinkId } = reservedLinkIds;
@@ -188,10 +188,10 @@ export async function getServiceAccountInsertSerialOperations(
188188
(await deep.id('@deep-foundation/core', 'Contain')),
189189
serviceAccountTypeLinkId:
190190
param.typeLinkIds?.serviceAccountTypeLinkId ||
191-
(await deep.id(PACKAGE_NAME, LinkName[LinkName.ServiceAccount])),
191+
await $package.ServiceAccount.id(),
192192
usesServiceAccountTypeLinkId:
193193
param.typeLinkIds?.usesServiceAccountTypeLinkId ||
194-
(await deep.id(PACKAGE_NAME, LinkName[LinkName.UsesServiceAccount])),
194+
await $package.UsesServiceAccount.id(),
195195
};
196196
return result;
197197
}
@@ -253,21 +253,21 @@ export interface GetServiceAccountInsertSerialOperationsParam {
253253
*/
254254
containerLinkId?: number | undefined | null;
255255
/**
256-
* Value for the contain link for {@link LinkName.ServiceAccount}
256+
* Value for the contain link for {@link Package.ServiceAccount}
257257
*
258258
* @remarks
259259
* If {@link GetServiceAccountInsertSerialOperationsParam.containerLinkId} is null, this will be ignored
260260
*/
261261
valueForContainForServiceAccount?: string | undefined;
262262
/**
263-
* Value for the contain link for {@link LinkName.UsesServiceAccount}
263+
* Value for the contain link for {@link Package.UsesServiceAccount}
264264
*
265265
* @remarks
266266
* If {@link GetServiceAccountInsertSerialOperationsParam.containerLinkId} is null, this will be ignored
267267
*/
268268
valueForContainForUsesServiceAccount?: string | undefined;
269269
/**
270-
* If true, the link will be made active by creating a {@link LinkName.UsesServiceAccount} link pointing to it
270+
* If true, the link will be made active by creating a {@link Package.UsesServiceAccount} link pointing to it
271271
*
272272
* @defaultValue false
273273
*/

src/get-service-account-value-update-serial-operations.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ import {
22
DeepClient,
33
SerialOperation,
44
} from '@deep-foundation/deeplinks/imports/client';
5-
import { LinkName } from './link-name';
6-
import { PACKAGE_NAME } from './package-name';
75
import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
86
import { MutationInputValue } from '@deep-foundation/deeplinks/imports/client_types';
97
import { Link } from '@deep-foundation/deeplinks/imports/minilinks';
108

119
/**
12-
* Gets serial operations to update {@link LinkName.ServiceAccount}
10+
* Gets serial operations to update {@link Package.ServiceAccount}
1311
*
1412
* @example
15-
* #### Update {@link LinkName.ServiceAccount}
13+
* #### Update {@link Package.ServiceAccount}
1614
```ts
1715
const {serialOperations, linkIds} = await getServiceAccountValueUpdateSerialOperations({
1816
deep,

src/get-web-push-certificate-insert-serial-operations.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import {
22
DeepClient,
33
SerialOperation,
44
} from '@deep-foundation/deeplinks/imports/client';
5-
import { LinkName } from './link-name';
6-
import { PACKAGE_NAME } from './package-name';
75
import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
6+
import { Package } from './package';
87

98
/**
10-
* Gets serial operations to insert {@link LinkName.WebPushCertificate}
9+
* Gets serial operations to insert {@link Package.WebPushCertificate}
1110
*
1211
* @example
13-
* #### Insert {@link LinkName.WebPushCertificate}
12+
* #### Insert {@link Package.WebPushCertificate}
1413
```ts
1514
const {serialOperations, linkIds} = await getWebPushCertificateInsertSerialOperations({
1615
deep
@@ -19,7 +18,7 @@ import { createSerialOperation } from '@deep-foundation/deeplinks/imports/gql';
1918
operations: serialOperations
2019
})
2120
```
22-
* #### Insert {@link LinkName.WebPushCertificate} with reserved link id
21+
* #### Insert {@link Package.WebPushCertificate} with reserved link id
2322
```ts
2423
const reservedLinkIds = await deep.reserve(2);
2524
const webPushCertificateLinkId = reservedLinkIds.pop();
@@ -51,6 +50,7 @@ export async function getWebPushCertificateInsertSerialOperations(
5150
valueForContainForUsesWebPushCertificate,
5251
shouldMakeActive = false
5352
} = param;
53+
const $package = new Package({deep});
5454
const containerLinkId = param.containerLinkId !== null ? param.containerLinkId ?? deep.linkId : null;
5555
const reservedLinkIds = await getReservedLinkIds();
5656
const { containForWebPushCertificateLinkId: containLinkId, webPushCertificateLinkId, usesWebPushCertificateLinkId,containForUsesWebPushCertificateLinkId } = reservedLinkIds;
@@ -188,10 +188,10 @@ export async function getWebPushCertificateInsertSerialOperations(
188188
(await deep.id('@deep-foundation/core', 'Contain')),
189189
webPushCertificateTypeLinkId:
190190
param.typeLinkIds?.webPushCertificateTypeLinkId ||
191-
(await deep.id(PACKAGE_NAME, LinkName[LinkName.WebPushCertificate])),
191+
await $package.WebPushCertificate.id(),
192192
usesWebPushCertificateTypeLinkId:
193193
param.typeLinkIds?.usesWebPushCertificateTypeLinkId ||
194-
(await deep.id(PACKAGE_NAME, LinkName[LinkName.UsesWebPushCertificate])),
194+
await $package.UsesWebPushCertificate.id(),
195195
};
196196
return result;
197197
}
@@ -267,7 +267,7 @@ export interface GetWebPushCertificateInsertSerialOperationsParam {
267267
*/
268268
valueForContainForUsesWebPushCertificate?: string | undefined;
269269
/**
270-
* If true, the link will be made active by creating a {@link LinkName.UsesServiceAccount} link pointing to it
270+
* If true, the link will be made active by creating a {@link Package.UsesServiceAccount} link pointing to it
271271
*
272272
* @defaultValue false
273273
*/

0 commit comments

Comments
 (0)