@mathrunet/masamune 0.0.6 → 0.0.8

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,3 +1,25 @@
1
+ ## [0.0.8](https://github.com/mathrunet/node_masamune/compare/v0.0.7...v0.0.8) (2023-01-17)
2
+
3
+
4
+ ### docs
5
+
6
+ * ReadMe creation. ([6f91ba9](https://github.com/mathrunet/node_masamune/commit/6f91ba97d8c8e3f7d41a6299d95e51a69b90fe1c))
7
+
8
+ ### fix
9
+
10
+ * Changed the function name of notification. ([c1a152c](https://github.com/mathrunet/node_masamune/commit/c1a152cd3398325a7149bf4a852fe368088e4f16))
11
+
12
+
13
+
14
+ ## [0.0.7](https://github.com/mathrunet/node_masamune/compare/v0.0.6...v0.0.7) (2023-01-11)
15
+
16
+
17
+ ### fix
18
+
19
+ * The array type was wrong, so it was corrected. ([befbc78](https://github.com/mathrunet/node_masamune/commit/befbc784dc25202d65b6f51b4cd6584cd7e7c57f))
20
+
21
+
22
+
1
23
  ## [0.0.6](https://github.com/mathrunet/node_masamune/compare/v0.0.5...v0.0.6) (2023-01-11)
2
24
 
3
25
 
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020, mathru (https://mathru.net)
1
+ Copyright (c) 2023, mathru (https://mathru.net)
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -19,4 +19,37 @@
19
19
 
20
20
  [[YouTube]](https://www.youtube.com/c/mathrunetchannel) | [[Packages]](https://pub.dev/publishers/mathru.net/packages) | [[Twitter]](https://twitter.com/mathru) | [[LinkedIn]](https://www.linkedin.com/in/mathrunet/)
21
21
 
22
- ---
22
+ ---
23
+
24
+ Just load the package in index.ts and pass the predefined data to the methods to implement the server side.
25
+
26
+ Also, [katana_functions_firebase](https://pub.dev/packages/katana_functions_firebase/score) can be used to execute server-side functions from methods defined on the client side, allowing for safe implementation.
27
+
28
+ # Installation
29
+
30
+ Install the following packages
31
+
32
+ ```bash
33
+ npm install @mathrunet/masamune
34
+ ```
35
+
36
+ # Implementation
37
+
38
+ Import the package as follows and pass the value of `exports` and the list of functions you wish to define to the `deploy` function.
39
+
40
+ ```dart
41
+ import * as m from "@mathrunet/masamune";
42
+
43
+ // Define [m.Functions.xxxx] for the functions to be added to Functions.
44
+ //
45
+ // Functionsに追加する機能を[m.Functions.xxxx]を定義してください。
46
+ m.deploy(
47
+ exports,
48
+ [
49
+ // Function for PUSH Notification.
50
+ m.Functions.notification,
51
+ ],
52
+ );
53
+ ```
54
+
55
+ Functions passed to deploy are deployed to Cloud Functions for Firebase.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ const functions = __importStar(require("firebase-functions"));
36
+ const admin = __importStar(require("firebase-admin"));
37
+ /**
38
+ * Define the process for PUSH notification.
39
+ *
40
+ * PUSH通知を行うための処理を定義します。
41
+ *
42
+ * @param title
43
+ * The title of the notice should be listed.
44
+ *
45
+ * 通知タイトルを記載します。
46
+ *
47
+ * @param body
48
+ * The contents of the notice will be described.
49
+ *
50
+ * 通知内容を記載します。
51
+ *
52
+ * @param channel_id
53
+ * Describe ChannelId for Android.
54
+ *
55
+ * Android向けのChannelIdを記載します。
56
+ *
57
+ * @param data
58
+ * Specify the data to be placed on the notification.
59
+ *
60
+ * 通知に乗せるデータを指定します。
61
+ *
62
+ * @param token
63
+ * Specifies the FCM token.
64
+ *
65
+ * FCMトークンを指定します。
66
+ *
67
+ * @param topic
68
+ * Specifies the topic of the FCM.
69
+ *
70
+ * FCMのトピックを指定します。
71
+ */
72
+ module.exports = functions.region("asia-northeast1").https.onCall((query) => __awaiter(void 0, void 0, void 0, function* () {
73
+ try {
74
+ const title = query.title;
75
+ const body = query.body;
76
+ const channelId = query.channel_id;
77
+ const data = query.data;
78
+ const token = query.token;
79
+ const topic = query.topic;
80
+ if (token === undefined || topic === undefined) {
81
+ throw new functions.https.HttpsError("invalid-argument", "Either [token] or [topic] must be specified.");
82
+ }
83
+ const res = yield admin.messaging().send({
84
+ notification: {
85
+ title: title,
86
+ body: body,
87
+ },
88
+ android: {
89
+ priority: "high",
90
+ notification: {
91
+ title: title,
92
+ body: body,
93
+ clickAction: "FLUTTER_NOTIFICATION_CLICK",
94
+ channelId: channelId,
95
+ },
96
+ },
97
+ data: data,
98
+ token: token,
99
+ topic: topic,
100
+ });
101
+ return {
102
+ success: true,
103
+ message_id: res,
104
+ };
105
+ }
106
+ catch (err) {
107
+ console.log(err);
108
+ throw err;
109
+ }
110
+ }));
111
+ //# sourceMappingURL=send_notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send_notification.js","sourceRoot":"","sources":["../../src/functions/send_notification.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAChD,sDAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7D,CAAO,KAAK,EAAE,EAAE;IACZ,IAAI;QACA,MAAM,KAAK,GAAG,KAAK,CAAC,KAAe,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAc,CAAC;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,UAAgC,CAAC;QACzD,MAAM,IAAI,GAAG,KAAK,CAAC,IAA6C,CAAC;QACjE,MAAM,KAAK,GAAG,KAAK,CAAC,KAA2B,CAAC;QAChD,MAAM,KAAK,GAAG,KAAK,CAAC,KAA2B,CAAC;QAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;YAC5C,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,8CAA8C,CAAC,CAAC;SAC5G;QACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC,IAAI,CACpC;YACI,YAAY,EAAE;gBACV,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,IAAI;aACb;YACD,OAAO,EAAE;gBACL,QAAQ,EAAE,MAAM;gBAChB,YAAY,EAAE;oBACV,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,IAAI;oBACV,WAAW,EAAE,4BAA4B;oBACzC,SAAS,EAAE,SAAS;iBACvB;aACJ;YACD,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,KAAK;SACf,CACJ,CAAC;QACF,OAAO;YACH,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAClB,CAAC;KACL;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,GAAG,CAAC;KACb;AACL,CAAC,CAAA,CACJ,CAAC"}
@@ -10,5 +10,5 @@ export declare const Functions: {
10
10
  *
11
11
  * PUSH通知を送信するためのFunction。
12
12
  */
13
- readonly notification: data.FunctionsData;
13
+ readonly sendNotification: data.FunctionsData;
14
14
  };
package/dist/functions.js CHANGED
@@ -36,6 +36,6 @@ exports.Functions = {
36
36
  *
37
37
  * PUSH通知を送信するためのFunction。
38
38
  */
39
- notification: new data.FunctionsData("notification", require("./functions/notification")),
39
+ sendNotification: new data.FunctionsData("send_notification", require("./functions/send_notification")),
40
40
  };
41
41
  //# sourceMappingURL=functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6C;AAE7C;;;;GAIG;AACU,QAAA,SAAS,GAAG;IACvB;;;;OAIG;IACH,YAAY,EAAE,IAAI,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;CACjF,CAAC"}
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6C;AAE7C;;;;GAIG;AACU,QAAA,SAAS,GAAG;IACvB;;;;OAIG;IACH,gBAAgB,EAAE,IAAI,IAAI,CAAC,aAAa,CAAC,mBAAmB,EAAE,OAAO,CAAC,+BAA+B,CAAC,CAAC;CAC/F,CAAC"}
package/dist/index.d.ts CHANGED
@@ -16,4 +16,4 @@ export * from "./lib/functions_data";
16
16
  *
17
17
  * [Functions]で定義された要素を配列として渡します。渡されたメソッドがデプロイされます。
18
18
  */
19
- export declare function deploy(exports: any, deployFunctions: [data.FunctionsData]): void;
19
+ export declare function deploy(exports: any, deployFunctions: data.FunctionsData[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mathrunet/masamune",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Manages packages for the server portion (NodeJS) of the Masamune framework.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",