UNPKG

@mathrunet/masamune

Version:

Manages packages for the server portion (NodeJS) of the Masamune framework.

91 lines 4.06 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateWallet = updateWallet; const path = __importStar(require("path")); const admin = __importStar(require("firebase-admin")); /** * The amount of money in the in-app wallet is added to the in-app wallet due to in-app purchases. In-app wallet information is stored in a form that overwrites user data. * * アプリ内課金によるアプリ内ウォレットの金額の加算を行います。アプリ内ウォレットの情報はユーザーデータに上書きされる形で保存されます。 * * @param {String} targetDocumentFieldPath * The path, including the key, of the field in the document that stores the in-app wallet information. * * アプリ内ウォレット情報を保存するドキュメント内のフィールドのキーを含めたパス。 * * @param {number} value * Value of the amount to be added. * * 加算する金額の値。 * * @param {String} transactionId * Specify the ID of the log. * * ログのIDを指定します。 * * @param {[key: string]: any} transactionData * Log data to be updated. * * 更新するログデータ。 */ function updateWallet(_a) { return __awaiter(this, arguments, void 0, function* ({ targetDocumentFieldPath, value, transactionId, transactionData, firestoreInstance, }) { const update = {}; const key = path.basename(targetDocumentFieldPath); const parent = targetDocumentFieldPath.replace(`/${key}`, ""); const uid = path.basename(parent); const FieldValue = admin.firestore.FieldValue; update[key] = FieldValue.increment(value); update["@uid"] = uid; update["@time"] = new Date(); yield firestoreInstance.doc(parent).set(update, { merge: true, }); yield firestoreInstance.doc(`${parent}/transaction/${transactionId}`).set(transactionData, { merge: true, }); }); } //# sourceMappingURL=update_wallet.js.map