@glissandoo/lib 1.53.8 → 1.54.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/helpers/errors.d.ts +0 -11
- package/models/Instrument/group.js +2 -6
- package/package.json +1 -1
- package/helpers/firestore.d.ts +0 -11
- package/helpers/firestore.js +0 -196
package/helpers/errors.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CustomInstrumentId } from './instruments';
|
|
2
1
|
export declare enum HttpsErrorMessages {
|
|
3
2
|
InvalidGroup = "error.group.noValid",
|
|
4
3
|
InvalidGroupRemoveAdmin = "error.group.oneAdmin",
|
|
@@ -59,13 +58,3 @@ export declare enum HttpsErrorMessages {
|
|
|
59
58
|
PlayersWithCustomInstrumentsToBeDeleted = "error.group.playersWithCustomInstrumentsToBeDeleted",
|
|
60
59
|
ThemesWithCustomInstrumentsToBeDeleted = "error.group.themesWithCustomInstrumentsToBeDeleted"
|
|
61
60
|
}
|
|
62
|
-
export interface HttpsErrorDetails extends Record<HttpsErrorMessages, unknown> {
|
|
63
|
-
[HttpsErrorMessages.ThemesWithCustomInstrumentsToBeDeleted]: {
|
|
64
|
-
themeId: string;
|
|
65
|
-
customInstruments: CustomInstrumentId[];
|
|
66
|
-
}[];
|
|
67
|
-
[HttpsErrorMessages.PlayersWithCustomInstrumentsToBeDeleted]: {
|
|
68
|
-
playerId: string;
|
|
69
|
-
customMainInstrument: CustomInstrumentId;
|
|
70
|
-
}[];
|
|
71
|
-
}
|
|
@@ -17,14 +17,10 @@ class GroupInstrument extends _1.default {
|
|
|
17
17
|
return GroupInstrument.isCustom(this.id);
|
|
18
18
|
}
|
|
19
19
|
get name() {
|
|
20
|
-
return GroupInstrument.isCustom(this.id)
|
|
21
|
-
? this.groupInstruments[this.id].name
|
|
22
|
-
: super.name;
|
|
20
|
+
return GroupInstrument.isCustom(this.id) ? this.groupInstruments[this.id].name : super.name;
|
|
23
21
|
}
|
|
24
22
|
get icon() {
|
|
25
|
-
return GroupInstrument.isCustom(this.id)
|
|
26
|
-
? this.groupInstruments[this.id].icon
|
|
27
|
-
: super.icon;
|
|
23
|
+
return GroupInstrument.isCustom(this.id) ? this.groupInstruments[this.id].icon : super.icon;
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
exports.default = GroupInstrument;
|
package/package.json
CHANGED
package/helpers/firestore.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as firestore from '../types/firestore';
|
|
2
|
-
/** Create a DocumentSnapshot. */
|
|
3
|
-
export declare function makeDocumentSnapshot(
|
|
4
|
-
/** Key-value pairs representing data in the document, pass in `{}` to mock the snapshot of
|
|
5
|
-
* a document that doesn't exist.
|
|
6
|
-
*/
|
|
7
|
-
data: {
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
},
|
|
10
|
-
/** Full path of the reference (e.g. 'users/alovelace') */
|
|
11
|
-
refPath: string, project: string): firestore.DocumentSnapshot<firestore.DocumentData>;
|
package/helpers/firestore.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.makeDocumentSnapshot = void 0;
|
|
27
|
-
const lodash_1 = require("lodash");
|
|
28
|
-
const firestore = __importStar(require("../types/firestore"));
|
|
29
|
-
const firebase = __importStar(require("firebase-admin"));
|
|
30
|
-
/** @internal */
|
|
31
|
-
function testApp() {
|
|
32
|
-
if (typeof testApp.singleton === 'undefined') {
|
|
33
|
-
testApp.init();
|
|
34
|
-
}
|
|
35
|
-
return testApp.singleton;
|
|
36
|
-
}
|
|
37
|
-
/** @internal */
|
|
38
|
-
(function (testApp) {
|
|
39
|
-
testApp.init = () => (testApp.singleton = new testApp.App());
|
|
40
|
-
class App {
|
|
41
|
-
constructor() {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
getApp() {
|
|
45
|
-
if (typeof this.appSingleton === 'undefined') {
|
|
46
|
-
const config = process.env.FIREBASE_CONFIG
|
|
47
|
-
? JSON.parse(process.env.FIREBASE_CONFIG)
|
|
48
|
-
: {};
|
|
49
|
-
this.appSingleton = firebase.initializeApp(config,
|
|
50
|
-
// Give this app a name so it does not conflict with apps that user initialized.
|
|
51
|
-
'firebase-functions-test');
|
|
52
|
-
}
|
|
53
|
-
return this.appSingleton;
|
|
54
|
-
}
|
|
55
|
-
deleteApp() {
|
|
56
|
-
if (this.appSingleton) {
|
|
57
|
-
void this.appSingleton.delete();
|
|
58
|
-
delete this.appSingleton;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
testApp.App = App;
|
|
63
|
-
})(testApp || (testApp = {}));
|
|
64
|
-
/** @internal */
|
|
65
|
-
function objectToValueProto(data) {
|
|
66
|
-
const encodeHelper = (val) => {
|
|
67
|
-
if (typeof val === 'string') {
|
|
68
|
-
return {
|
|
69
|
-
stringValue: val,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (typeof val === 'boolean') {
|
|
73
|
-
return {
|
|
74
|
-
booleanValue: val,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (typeof val === 'number') {
|
|
78
|
-
if (val % 1 === 0) {
|
|
79
|
-
return {
|
|
80
|
-
integerValue: val,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
doubleValue: val,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (val instanceof Date) {
|
|
88
|
-
return {
|
|
89
|
-
timestampValue: val.toISOString(),
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
if (val instanceof Array) {
|
|
93
|
-
const encodedElements = [];
|
|
94
|
-
for (const elem of val) {
|
|
95
|
-
const enc = encodeHelper(elem);
|
|
96
|
-
if (enc) {
|
|
97
|
-
encodedElements.push(enc);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
arrayValue: {
|
|
102
|
-
values: encodedElements,
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (val === null) {
|
|
107
|
-
// TODO: Look this up. This is a google.protobuf.NulLValue,
|
|
108
|
-
// and everything in google.protobuf has a customized JSON encoder.
|
|
109
|
-
// OTOH, Firestore's generated .d.ts files don't take this into
|
|
110
|
-
// account and have the default proto layout.
|
|
111
|
-
return {
|
|
112
|
-
nullValue: 'NULL_VALUE',
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (val instanceof Buffer || val instanceof Uint8Array) {
|
|
116
|
-
return {
|
|
117
|
-
bytesValue: val,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if (val instanceof firestore.DocumentReference) {
|
|
121
|
-
const projectId = (0, lodash_1.get)(val, '_referencePath.projectId');
|
|
122
|
-
const database = (0, lodash_1.get)(val, '_referencePath.databaseId');
|
|
123
|
-
const referenceValue = [
|
|
124
|
-
'projects',
|
|
125
|
-
projectId,
|
|
126
|
-
'databases',
|
|
127
|
-
database,
|
|
128
|
-
val.path,
|
|
129
|
-
].join('/');
|
|
130
|
-
return { referenceValue };
|
|
131
|
-
}
|
|
132
|
-
if (val instanceof firestore.Timestamp) {
|
|
133
|
-
return {
|
|
134
|
-
timestampValue: val.toDate().toISOString(),
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
if (val instanceof firestore.GeoPoint) {
|
|
138
|
-
return {
|
|
139
|
-
geoPointValue: {
|
|
140
|
-
latitude: val.latitude,
|
|
141
|
-
longitude: val.longitude,
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
if ((0, lodash_1.isPlainObject)(val)) {
|
|
146
|
-
if (!val)
|
|
147
|
-
return;
|
|
148
|
-
return {
|
|
149
|
-
mapValue: {
|
|
150
|
-
fields: objectToValueProto(val),
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
throw new Error('Cannot encode to a Firestore Value');
|
|
155
|
-
};
|
|
156
|
-
return (0, lodash_1.mapValues)(data, encodeHelper);
|
|
157
|
-
}
|
|
158
|
-
function dateToTimestampProto(timeString) {
|
|
159
|
-
if (typeof timeString === 'undefined') {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const date = new Date(timeString);
|
|
163
|
-
const seconds = Math.floor(date.getTime() / 1000);
|
|
164
|
-
let nanos = 0;
|
|
165
|
-
if (timeString.length > 20) {
|
|
166
|
-
const nanoString = timeString.substring(20, timeString.length - 1);
|
|
167
|
-
const trailingZeroes = 9 - nanoString.length;
|
|
168
|
-
nanos = parseInt(nanoString, 10) * Math.pow(10, trailingZeroes);
|
|
169
|
-
}
|
|
170
|
-
return { seconds, nanos };
|
|
171
|
-
}
|
|
172
|
-
/** Create a DocumentSnapshot. */
|
|
173
|
-
function makeDocumentSnapshot(
|
|
174
|
-
/** Key-value pairs representing data in the document, pass in `{}` to mock the snapshot of
|
|
175
|
-
* a document that doesn't exist.
|
|
176
|
-
*/
|
|
177
|
-
data,
|
|
178
|
-
/** Full path of the reference (e.g. 'users/alovelace') */
|
|
179
|
-
refPath, project) {
|
|
180
|
-
const firestoreService = firebase.firestore(testApp().getApp());
|
|
181
|
-
const resource = `projects/${project}/databases/(default)/documents/${refPath}`;
|
|
182
|
-
const proto = (0, lodash_1.isEmpty)(data)
|
|
183
|
-
? resource
|
|
184
|
-
: {
|
|
185
|
-
fields: objectToValueProto(data),
|
|
186
|
-
createTime: dateToTimestampProto(new Date().toISOString()),
|
|
187
|
-
updateTime: dateToTimestampProto(new Date().toISOString()),
|
|
188
|
-
name: resource,
|
|
189
|
-
};
|
|
190
|
-
const readTimeProto = dateToTimestampProto(new Date().toISOString());
|
|
191
|
-
/* eslint-disable */
|
|
192
|
-
// @ts-ignore
|
|
193
|
-
return firestoreService.snapshot_(proto, readTimeProto, 'json');
|
|
194
|
-
/* eslint-enable */
|
|
195
|
-
}
|
|
196
|
-
exports.makeDocumentSnapshot = makeDocumentSnapshot;
|