@shisyamo4131/air-firebase-v2-client-adapter 2.0.3 → 2.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/error.js +15 -0
- package/index.js +45 -0
- package/package.json +7 -2
package/error.js
CHANGED
|
@@ -131,6 +131,21 @@ export const ERRORS = {
|
|
|
131
131
|
message: "Firestore not initialized",
|
|
132
132
|
userMessage: "データベースが初期化されていません",
|
|
133
133
|
},
|
|
134
|
+
SYSTEM_FUNCTIONS_NOT_INITIALIZED: {
|
|
135
|
+
code: "SYSTEM_FUNCTIONS_NOT_INITIALIZED",
|
|
136
|
+
message: "Functions instance is not initialized.",
|
|
137
|
+
userMessage: "functionsが初期化されていません",
|
|
138
|
+
},
|
|
139
|
+
SYSTEM_GEOPOINT_NOT_INITIALIZED: {
|
|
140
|
+
code: "SYSTEM_GEOPOINT_NOT_INITIALIZED",
|
|
141
|
+
message: "GeoPoint class is not initialized.",
|
|
142
|
+
userMessage: "GeoPointクラスが初期化されていません",
|
|
143
|
+
},
|
|
144
|
+
SYSTEM_HTTPS_CALLABLE_NOT_INITIALIZED: {
|
|
145
|
+
code: "SYSTEM_HTTPS_CALLABLE_NOT_INITIALIZED",
|
|
146
|
+
message: "httpsCallable function is not initialized.",
|
|
147
|
+
userMessage: "httpsCallable関数が初期化されていません",
|
|
148
|
+
},
|
|
134
149
|
SYSTEM_UNKNOWN_ERROR: {
|
|
135
150
|
code: "SYSTEM/UNKNOWN_ERROR",
|
|
136
151
|
message: "unknown error occurred",
|
package/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* アプリ側で使用する FireModel のアダプターです。
|
|
3
3
|
* FireModel に Firestore に対する CRUD 機能を注入します。
|
|
4
|
+
*
|
|
5
|
+
* @update 2025-12-29 - Added GeoPoint import and httpsCallable import.
|
|
4
6
|
*/
|
|
5
7
|
import {
|
|
6
8
|
collection,
|
|
@@ -15,8 +17,10 @@ import {
|
|
|
15
17
|
collectionGroup,
|
|
16
18
|
onSnapshot,
|
|
17
19
|
getFirestore,
|
|
20
|
+
GeoPoint, // 2025-12-29 added
|
|
18
21
|
} from "firebase/firestore";
|
|
19
22
|
import { getAuth } from "firebase/auth";
|
|
23
|
+
import { getFunctions, httpsCallable } from "firebase/functions"; // 2025-12-29 added
|
|
20
24
|
import { ClientAdapterError, ERRORS } from "./error.js";
|
|
21
25
|
|
|
22
26
|
/*****************************************************************************
|
|
@@ -27,10 +31,16 @@ import { ClientAdapterError, ERRORS } from "./error.js";
|
|
|
27
31
|
class ClientAdapter {
|
|
28
32
|
static firestore = null;
|
|
29
33
|
static auth = null;
|
|
34
|
+
static functions = null; // 2025-12-29 added
|
|
35
|
+
static GeoPoint = null; // 2025-12-29 added
|
|
36
|
+
static httpsCallable = null; // 2025-12-29 added
|
|
30
37
|
|
|
31
38
|
constructor() {
|
|
32
39
|
ClientAdapter.firestore = getFirestore();
|
|
33
40
|
ClientAdapter.auth = getAuth();
|
|
41
|
+
ClientAdapter.functions = getFunctions(); // 2025-12-29 added
|
|
42
|
+
ClientAdapter.GeoPoint = GeoPoint; // 2025-12-29 added
|
|
43
|
+
ClientAdapter.httpsCallable = httpsCallable; // 2025-12-29 added
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
get type() {
|
|
@@ -68,6 +78,39 @@ class ClientAdapter {
|
|
|
68
78
|
return ClientAdapter.firestore;
|
|
69
79
|
}
|
|
70
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Returns the Functions instance.
|
|
83
|
+
* - 2025-12-29 added
|
|
84
|
+
*/
|
|
85
|
+
get functions() {
|
|
86
|
+
if (!ClientAdapter.functions) {
|
|
87
|
+
throw new ClientAdapterError(ERRORS.SYSTEM_FUNCTIONS_NOT_INITIALIZED);
|
|
88
|
+
}
|
|
89
|
+
return ClientAdapter.functions;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns the GeoPoint class.
|
|
94
|
+
* - 2025-12-29 added
|
|
95
|
+
*/
|
|
96
|
+
get GeoPoint() {
|
|
97
|
+
if (!ClientAdapter.GeoPoint) {
|
|
98
|
+
throw new ClientAdapterError(ERRORS.SYSTEM_GEOPOINT_NOT_INITIALIZED);
|
|
99
|
+
}
|
|
100
|
+
return ClientAdapter.GeoPoint;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the httpsCallable function.
|
|
105
|
+
* - 2025-12-29 added
|
|
106
|
+
*/
|
|
107
|
+
get httpsCallable() {
|
|
108
|
+
if (!ClientAdapter.httpsCallable) {
|
|
109
|
+
throw new ClientAdapterError(ERRORS.SYSTEM_HTTPSCALLABLE_NOT_INITIALIZED);
|
|
110
|
+
}
|
|
111
|
+
return ClientAdapter.httpsCallable;
|
|
112
|
+
}
|
|
113
|
+
|
|
71
114
|
/**
|
|
72
115
|
* 指定されたドキュメントIDからFirestoreのドキュメント参照を取得します。
|
|
73
116
|
* - コンバーターを適用したDocumentReferenceを返します。
|
|
@@ -992,6 +1035,8 @@ class ClientAdapter {
|
|
|
992
1035
|
queryConstraints.push(...this.createQueries(options));
|
|
993
1036
|
} else if (Array.isArray(constraints)) {
|
|
994
1037
|
queryConstraints.push(...this.createQueries(constraints));
|
|
1038
|
+
} else if (constraints == null || constraints === undefined) {
|
|
1039
|
+
return this.docs;
|
|
995
1040
|
} else {
|
|
996
1041
|
throw new ClientAdapterError(ERRORS.VALIDATION_INVALID_CONSTRAINTS);
|
|
997
1042
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shisyamo4131/air-firebase-v2-client-adapter",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "client adapter for FireModel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -27,12 +27,17 @@
|
|
|
27
27
|
"dev:publish": "npm version prerelease --preid=dev && npm publish --tag dev",
|
|
28
28
|
"release:patch": "npm version patch && npm publish",
|
|
29
29
|
"release:minor": "npm version minor && npm publish",
|
|
30
|
-
"release:major": "npm version major && npm publish"
|
|
30
|
+
"release:major": "npm version major && npm publish",
|
|
31
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
31
32
|
},
|
|
32
33
|
"publishConfig": {
|
|
33
34
|
"access": "public"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"firebase": "^10.0.0 || ^11.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@jest/globals": "^30.2.0",
|
|
41
|
+
"jest": "^30.2.0"
|
|
37
42
|
}
|
|
38
43
|
}
|