@fyrestack/server 0.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/LICENSE +21 -0
- package/dist/index.cjs +197 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +167 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Thomas Klaner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let firebase_admin_firestore = require("firebase-admin/firestore");
|
|
25
|
+
firebase_admin_firestore = __toESM(firebase_admin_firestore);
|
|
26
|
+
let __fyrestack_database = require("@fyrestack/database");
|
|
27
|
+
__fyrestack_database = __toESM(__fyrestack_database);
|
|
28
|
+
|
|
29
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
|
|
30
|
+
function _typeof(o) {
|
|
31
|
+
"@babel/helpers - typeof";
|
|
32
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
33
|
+
return typeof o$1;
|
|
34
|
+
} : function(o$1) {
|
|
35
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
36
|
+
}, _typeof(o);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPrimitive.js
|
|
41
|
+
function toPrimitive(t, r) {
|
|
42
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
43
|
+
var e = t[Symbol.toPrimitive];
|
|
44
|
+
if (void 0 !== e) {
|
|
45
|
+
var i = e.call(t, r || "default");
|
|
46
|
+
if ("object" != _typeof(i)) return i;
|
|
47
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
48
|
+
}
|
|
49
|
+
return ("string" === r ? String : Number)(t);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPropertyKey.js
|
|
54
|
+
function toPropertyKey(t) {
|
|
55
|
+
var i = toPrimitive(t, "string");
|
|
56
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/defineProperty.js
|
|
61
|
+
function _defineProperty(e, r, t) {
|
|
62
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
63
|
+
value: t,
|
|
64
|
+
enumerable: !0,
|
|
65
|
+
configurable: !0,
|
|
66
|
+
writable: !0
|
|
67
|
+
}) : e[r] = t, e;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/objectSpread2.js
|
|
72
|
+
function ownKeys(e, r) {
|
|
73
|
+
var t = Object.keys(e);
|
|
74
|
+
if (Object.getOwnPropertySymbols) {
|
|
75
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
76
|
+
r && (o = o.filter(function(r$1) {
|
|
77
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
78
|
+
})), t.push.apply(t, o);
|
|
79
|
+
}
|
|
80
|
+
return t;
|
|
81
|
+
}
|
|
82
|
+
function _objectSpread2(e) {
|
|
83
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
84
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
85
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
86
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
87
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
88
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return e;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/index.ts
|
|
96
|
+
/**
|
|
97
|
+
* Wraps a Firebase Admin DocumentReference to match our interface
|
|
98
|
+
*/
|
|
99
|
+
function wrapDocumentReference(docRef) {
|
|
100
|
+
return {
|
|
101
|
+
id: docRef.id,
|
|
102
|
+
path: docRef.path,
|
|
103
|
+
async get() {
|
|
104
|
+
const snapshot = await docRef.get();
|
|
105
|
+
return {
|
|
106
|
+
id: snapshot.id,
|
|
107
|
+
exists: snapshot.exists,
|
|
108
|
+
data: () => snapshot.exists ? snapshot.data() : void 0
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
async set(data) {
|
|
112
|
+
await docRef.set(data);
|
|
113
|
+
},
|
|
114
|
+
async update(data) {
|
|
115
|
+
await docRef.update(data);
|
|
116
|
+
},
|
|
117
|
+
async delete() {
|
|
118
|
+
await docRef.delete();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Wraps a Firebase Admin Query to match our QueryReference interface
|
|
124
|
+
*/
|
|
125
|
+
function wrapQueryReference(queryRef) {
|
|
126
|
+
return {
|
|
127
|
+
where(field, op, value) {
|
|
128
|
+
return wrapQueryReference(queryRef.where(field, op, value));
|
|
129
|
+
},
|
|
130
|
+
orderBy(field, direction) {
|
|
131
|
+
return wrapQueryReference(queryRef.orderBy(field, direction));
|
|
132
|
+
},
|
|
133
|
+
limit(count) {
|
|
134
|
+
return wrapQueryReference(queryRef.limit(count));
|
|
135
|
+
},
|
|
136
|
+
startAt(...values) {
|
|
137
|
+
return wrapQueryReference(queryRef.startAt(...values));
|
|
138
|
+
},
|
|
139
|
+
startAfter(...values) {
|
|
140
|
+
return wrapQueryReference(queryRef.startAfter(...values));
|
|
141
|
+
},
|
|
142
|
+
endAt(...values) {
|
|
143
|
+
return wrapQueryReference(queryRef.endAt(...values));
|
|
144
|
+
},
|
|
145
|
+
endBefore(...values) {
|
|
146
|
+
return wrapQueryReference(queryRef.endBefore(...values));
|
|
147
|
+
},
|
|
148
|
+
async get() {
|
|
149
|
+
const snapshot = await queryRef.get();
|
|
150
|
+
return {
|
|
151
|
+
docs: snapshot.docs.map((docSnap) => ({
|
|
152
|
+
id: docSnap.id,
|
|
153
|
+
exists: docSnap.exists,
|
|
154
|
+
data: () => docSnap.data()
|
|
155
|
+
})),
|
|
156
|
+
empty: snapshot.empty,
|
|
157
|
+
size: snapshot.size
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Wraps a Firebase Admin CollectionReference to match our interface
|
|
164
|
+
*/
|
|
165
|
+
function wrapCollectionReference(collectionRef) {
|
|
166
|
+
return _objectSpread2(_objectSpread2({}, wrapQueryReference(collectionRef)), {}, {
|
|
167
|
+
path: collectionRef.path,
|
|
168
|
+
doc(id) {
|
|
169
|
+
return wrapDocumentReference(id ? collectionRef.doc(id) : collectionRef.doc());
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Creates a FirestoreAdapter from a Firebase Admin Firestore instance
|
|
175
|
+
*/
|
|
176
|
+
function createServerAdapter(firestore) {
|
|
177
|
+
return {
|
|
178
|
+
collection(path) {
|
|
179
|
+
return wrapCollectionReference(firestore.collection(path));
|
|
180
|
+
},
|
|
181
|
+
doc(path) {
|
|
182
|
+
return wrapDocumentReference(firestore.doc(path));
|
|
183
|
+
},
|
|
184
|
+
serverTimestamp() {
|
|
185
|
+
return firebase_admin_firestore.FieldValue.serverTimestamp();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
exports.createServerAdapter = createServerAdapter;
|
|
192
|
+
Object.defineProperty(exports, 'setFirestoreAdapter', {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function () {
|
|
195
|
+
return __fyrestack_database.setFirestoreAdapter;
|
|
196
|
+
}
|
|
197
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Firestore } from "firebase-admin/firestore";
|
|
2
|
+
import { FirestoreAdapter, setFirestoreAdapter } from "@fyrestack/database";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a FirestoreAdapter from a Firebase Admin Firestore instance
|
|
8
|
+
*/
|
|
9
|
+
declare function createServerAdapter(firestore: Firestore): FirestoreAdapter;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createServerAdapter, setFirestoreAdapter };
|
|
12
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;iBAqHgB,mBAAA,YAA+B,YAAY"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Firestore } from "firebase-admin/firestore";
|
|
2
|
+
import { FirestoreAdapter, setFirestoreAdapter } from "@fyrestack/database";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a FirestoreAdapter from a Firebase Admin Firestore instance
|
|
8
|
+
*/
|
|
9
|
+
declare function createServerAdapter(firestore: Firestore): FirestoreAdapter;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createServerAdapter, setFirestoreAdapter };
|
|
12
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;iBAqHgB,mBAAA,YAA+B,YAAY"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { FieldValue } from "firebase-admin/firestore";
|
|
2
|
+
import { setFirestoreAdapter } from "@fyrestack/database";
|
|
3
|
+
|
|
4
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
|
|
5
|
+
function _typeof(o) {
|
|
6
|
+
"@babel/helpers - typeof";
|
|
7
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
8
|
+
return typeof o$1;
|
|
9
|
+
} : function(o$1) {
|
|
10
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
11
|
+
}, _typeof(o);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPrimitive.js
|
|
16
|
+
function toPrimitive(t, r) {
|
|
17
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
18
|
+
var e = t[Symbol.toPrimitive];
|
|
19
|
+
if (void 0 !== e) {
|
|
20
|
+
var i = e.call(t, r || "default");
|
|
21
|
+
if ("object" != _typeof(i)) return i;
|
|
22
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
23
|
+
}
|
|
24
|
+
return ("string" === r ? String : Number)(t);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPropertyKey.js
|
|
29
|
+
function toPropertyKey(t) {
|
|
30
|
+
var i = toPrimitive(t, "string");
|
|
31
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/defineProperty.js
|
|
36
|
+
function _defineProperty(e, r, t) {
|
|
37
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
38
|
+
value: t,
|
|
39
|
+
enumerable: !0,
|
|
40
|
+
configurable: !0,
|
|
41
|
+
writable: !0
|
|
42
|
+
}) : e[r] = t, e;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/objectSpread2.js
|
|
47
|
+
function ownKeys(e, r) {
|
|
48
|
+
var t = Object.keys(e);
|
|
49
|
+
if (Object.getOwnPropertySymbols) {
|
|
50
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
51
|
+
r && (o = o.filter(function(r$1) {
|
|
52
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
53
|
+
})), t.push.apply(t, o);
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
}
|
|
57
|
+
function _objectSpread2(e) {
|
|
58
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
59
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
60
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
61
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
62
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
63
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/index.ts
|
|
71
|
+
/**
|
|
72
|
+
* Wraps a Firebase Admin DocumentReference to match our interface
|
|
73
|
+
*/
|
|
74
|
+
function wrapDocumentReference(docRef) {
|
|
75
|
+
return {
|
|
76
|
+
id: docRef.id,
|
|
77
|
+
path: docRef.path,
|
|
78
|
+
async get() {
|
|
79
|
+
const snapshot = await docRef.get();
|
|
80
|
+
return {
|
|
81
|
+
id: snapshot.id,
|
|
82
|
+
exists: snapshot.exists,
|
|
83
|
+
data: () => snapshot.exists ? snapshot.data() : void 0
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
async set(data) {
|
|
87
|
+
await docRef.set(data);
|
|
88
|
+
},
|
|
89
|
+
async update(data) {
|
|
90
|
+
await docRef.update(data);
|
|
91
|
+
},
|
|
92
|
+
async delete() {
|
|
93
|
+
await docRef.delete();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Wraps a Firebase Admin Query to match our QueryReference interface
|
|
99
|
+
*/
|
|
100
|
+
function wrapQueryReference(queryRef) {
|
|
101
|
+
return {
|
|
102
|
+
where(field, op, value) {
|
|
103
|
+
return wrapQueryReference(queryRef.where(field, op, value));
|
|
104
|
+
},
|
|
105
|
+
orderBy(field, direction) {
|
|
106
|
+
return wrapQueryReference(queryRef.orderBy(field, direction));
|
|
107
|
+
},
|
|
108
|
+
limit(count) {
|
|
109
|
+
return wrapQueryReference(queryRef.limit(count));
|
|
110
|
+
},
|
|
111
|
+
startAt(...values) {
|
|
112
|
+
return wrapQueryReference(queryRef.startAt(...values));
|
|
113
|
+
},
|
|
114
|
+
startAfter(...values) {
|
|
115
|
+
return wrapQueryReference(queryRef.startAfter(...values));
|
|
116
|
+
},
|
|
117
|
+
endAt(...values) {
|
|
118
|
+
return wrapQueryReference(queryRef.endAt(...values));
|
|
119
|
+
},
|
|
120
|
+
endBefore(...values) {
|
|
121
|
+
return wrapQueryReference(queryRef.endBefore(...values));
|
|
122
|
+
},
|
|
123
|
+
async get() {
|
|
124
|
+
const snapshot = await queryRef.get();
|
|
125
|
+
return {
|
|
126
|
+
docs: snapshot.docs.map((docSnap) => ({
|
|
127
|
+
id: docSnap.id,
|
|
128
|
+
exists: docSnap.exists,
|
|
129
|
+
data: () => docSnap.data()
|
|
130
|
+
})),
|
|
131
|
+
empty: snapshot.empty,
|
|
132
|
+
size: snapshot.size
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Wraps a Firebase Admin CollectionReference to match our interface
|
|
139
|
+
*/
|
|
140
|
+
function wrapCollectionReference(collectionRef) {
|
|
141
|
+
return _objectSpread2(_objectSpread2({}, wrapQueryReference(collectionRef)), {}, {
|
|
142
|
+
path: collectionRef.path,
|
|
143
|
+
doc(id) {
|
|
144
|
+
return wrapDocumentReference(id ? collectionRef.doc(id) : collectionRef.doc());
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Creates a FirestoreAdapter from a Firebase Admin Firestore instance
|
|
150
|
+
*/
|
|
151
|
+
function createServerAdapter(firestore) {
|
|
152
|
+
return {
|
|
153
|
+
collection(path) {
|
|
154
|
+
return wrapCollectionReference(firestore.collection(path));
|
|
155
|
+
},
|
|
156
|
+
doc(path) {
|
|
157
|
+
return wrapDocumentReference(firestore.doc(path));
|
|
158
|
+
},
|
|
159
|
+
serverTimestamp() {
|
|
160
|
+
return FieldValue.serverTimestamp();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
export { createServerAdapter, setFirestoreAdapter };
|
|
167
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Firebase Admin SDK Adapter for FyreStack\n *\n * Implements the FirestoreAdapter interface using firebase-admin\n * for server-side (Node.js) applications.\n */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport type { Firestore } from 'firebase-admin/firestore';\nimport { FieldValue } from 'firebase-admin/firestore';\n\nimport type {\n CollectionReference,\n DocumentReference,\n DocumentSnapshot,\n FirestoreAdapter,\n OrderByDirection,\n QueryReference,\n QuerySnapshot,\n ServerTimestampSentinel,\n WhereFilterOp,\n} from '@fyrestack/database';\n\n/**\n * Wraps a Firebase Admin DocumentReference to match our interface\n */\nfunction wrapDocumentReference<T>(\n docRef: FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>,\n): DocumentReference<T> {\n return {\n id: docRef.id,\n path: docRef.path,\n async get(): Promise<DocumentSnapshot<T>> {\n const snapshot = await docRef.get();\n return {\n id: snapshot.id,\n exists: snapshot.exists,\n data: () => (snapshot.exists ? (snapshot.data() as T) : undefined),\n };\n },\n async set(data: T): Promise<void> {\n await docRef.set(data as FirebaseFirestore.DocumentData);\n },\n async update(data: Record<string, unknown>): Promise<void> {\n await docRef.update(data);\n },\n async delete(): Promise<void> {\n await docRef.delete();\n },\n };\n}\n\n/**\n * Wraps a Firebase Admin Query to match our QueryReference interface\n */\nfunction wrapQueryReference<T>(\n queryRef: FirebaseFirestore.Query<FirebaseFirestore.DocumentData>,\n): QueryReference<T> {\n return {\n where(field: string, op: WhereFilterOp, value: unknown): QueryReference<T> {\n return wrapQueryReference(queryRef.where(field, op, value));\n },\n orderBy(field: string, direction?: OrderByDirection): QueryReference<T> {\n return wrapQueryReference(queryRef.orderBy(field, direction));\n },\n limit(count: number): QueryReference<T> {\n return wrapQueryReference(queryRef.limit(count));\n },\n startAt(...values: unknown[]): QueryReference<T> {\n return wrapQueryReference(queryRef.startAt(...values));\n },\n startAfter(...values: unknown[]): QueryReference<T> {\n return wrapQueryReference(queryRef.startAfter(...values));\n },\n endAt(...values: unknown[]): QueryReference<T> {\n return wrapQueryReference(queryRef.endAt(...values));\n },\n endBefore(...values: unknown[]): QueryReference<T> {\n return wrapQueryReference(queryRef.endBefore(...values));\n },\n async get(): Promise<QuerySnapshot<T>> {\n const snapshot = await queryRef.get();\n return {\n docs: snapshot.docs.map((docSnap) => ({\n id: docSnap.id,\n exists: docSnap.exists,\n data: () => docSnap.data() as T,\n })),\n empty: snapshot.empty,\n size: snapshot.size,\n };\n },\n };\n}\n\n/**\n * Wraps a Firebase Admin CollectionReference to match our interface\n */\nfunction wrapCollectionReference<T>(\n collectionRef: FirebaseFirestore.CollectionReference<FirebaseFirestore.DocumentData>,\n): CollectionReference<T> {\n const queryRef = wrapQueryReference<T>(collectionRef);\n\n return {\n ...queryRef,\n path: collectionRef.path,\n doc(id?: string): DocumentReference<T> {\n const docRef = id ? collectionRef.doc(id) : collectionRef.doc();\n return wrapDocumentReference<T>(docRef);\n },\n };\n}\n\n/**\n * Creates a FirestoreAdapter from a Firebase Admin Firestore instance\n */\nexport function createServerAdapter(firestore: Firestore): FirestoreAdapter {\n return {\n collection<T>(path: string): CollectionReference<T> {\n const collectionRef = firestore.collection(path);\n return wrapCollectionReference<T>(collectionRef);\n },\n doc<T>(path: string): DocumentReference<T> {\n const docRef = firestore.doc(path);\n return wrapDocumentReference<T>(docRef);\n },\n serverTimestamp(): ServerTimestampSentinel {\n return FieldValue.serverTimestamp() as unknown as ServerTimestampSentinel;\n },\n };\n}\n\nexport { setFirestoreAdapter } from '@fyrestack/database';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,sBACP,QACsB;AACtB,QAAO;EACL,IAAI,OAAO;EACX,MAAM,OAAO;EACb,MAAM,MAAoC;GACxC,MAAM,WAAW,MAAM,OAAO,KAAK;AACnC,UAAO;IACL,IAAI,SAAS;IACb,QAAQ,SAAS;IACjB,YAAa,SAAS,SAAU,SAAS,MAAM,GAAS;IACzD;;EAEH,MAAM,IAAI,MAAwB;AAChC,SAAM,OAAO,IAAI,KAAuC;;EAE1D,MAAM,OAAO,MAA8C;AACzD,SAAM,OAAO,OAAO,KAAK;;EAE3B,MAAM,SAAwB;AAC5B,SAAM,OAAO,QAAQ;;EAExB;;;;;AAMH,SAAS,mBACP,UACmB;AACnB,QAAO;EACL,MAAM,OAAe,IAAmB,OAAmC;AACzE,UAAO,mBAAmB,SAAS,MAAM,OAAO,IAAI,MAAM,CAAC;;EAE7D,QAAQ,OAAe,WAAiD;AACtE,UAAO,mBAAmB,SAAS,QAAQ,OAAO,UAAU,CAAC;;EAE/D,MAAM,OAAkC;AACtC,UAAO,mBAAmB,SAAS,MAAM,MAAM,CAAC;;EAElD,QAAQ,GAAG,QAAsC;AAC/C,UAAO,mBAAmB,SAAS,QAAQ,GAAG,OAAO,CAAC;;EAExD,WAAW,GAAG,QAAsC;AAClD,UAAO,mBAAmB,SAAS,WAAW,GAAG,OAAO,CAAC;;EAE3D,MAAM,GAAG,QAAsC;AAC7C,UAAO,mBAAmB,SAAS,MAAM,GAAG,OAAO,CAAC;;EAEtD,UAAU,GAAG,QAAsC;AACjD,UAAO,mBAAmB,SAAS,UAAU,GAAG,OAAO,CAAC;;EAE1D,MAAM,MAAiC;GACrC,MAAM,WAAW,MAAM,SAAS,KAAK;AACrC,UAAO;IACL,MAAM,SAAS,KAAK,KAAK,aAAa;KACpC,IAAI,QAAQ;KACZ,QAAQ,QAAQ;KAChB,YAAY,QAAQ,MAAM;KAC3B,EAAE;IACH,OAAO,SAAS;IAChB,MAAM,SAAS;IAChB;;EAEJ;;;;;AAMH,SAAS,wBACP,eACwB;AAGxB,0CAFiB,mBAAsB,cAAc;EAInD,MAAM,cAAc;EACpB,IAAI,IAAmC;AAErC,UAAO,sBADQ,KAAK,cAAc,IAAI,GAAG,GAAG,cAAc,KAAK,CACxB;;;;;;;AAQ7C,SAAgB,oBAAoB,WAAwC;AAC1E,QAAO;EACL,WAAc,MAAsC;AAElD,UAAO,wBADe,UAAU,WAAW,KAAK,CACA;;EAElD,IAAO,MAAoC;AAEzC,UAAO,sBADQ,UAAU,IAAI,KAAK,CACK;;EAEzC,kBAA2C;AACzC,UAAO,WAAW,iBAAiB;;EAEtC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fyrestack/server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Firebase Admin SDK adapter for FyreStack",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "FyreStack",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/fyrestack/fyrestack.git",
|
|
10
|
+
"directory": "packages/server"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"fyrestack",
|
|
14
|
+
"firebase",
|
|
15
|
+
"firebase-admin",
|
|
16
|
+
"firestore",
|
|
17
|
+
"nodejs"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"type": "module",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": {
|
|
30
|
+
"types": "./dist/index.d.mts",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/index.d.cts",
|
|
35
|
+
"default": "./dist/index.cjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"firebase-admin": "^13.0.2",
|
|
42
|
+
"@fyrestack/database": "0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"tsdown": "^0.18.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsdown",
|
|
49
|
+
"dev": "tsdown --watch"
|
|
50
|
+
}
|
|
51
|
+
}
|