firebase-rest-firestore 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -11,6 +11,7 @@ Firebase Firestore REST API client for Edge runtime environments like Cloudflare
11
11
  - Simple and intuitive API
12
12
  - Explicit configuration without hidden environment variable dependencies
13
13
  - Firebase Admin SDK compatible interface (v0.2.0+)
14
+ - Lazy configuration validation for Next.js compatibility (v0.2.1+)
14
15
 
15
16
  ## Installation
16
17
 
@@ -458,6 +459,7 @@ Firebase Firestore REST API クライアントは、Cloudflare Workers や Verce
458
459
  - シンプルで直感的な API
459
460
  - 環境変数に依存しない明示的な設定
460
461
  - Firebase Admin SDK compatible interface (v0.2.0+)
462
+ - Next.js 互換性のための遅延設定検証 (v0.2.1+)
461
463
 
462
464
  ## インストール
463
465
 
package/dist/client.d.ts CHANGED
@@ -6,11 +6,17 @@ export declare class FirestoreClient {
6
6
  private token;
7
7
  private tokenExpiry;
8
8
  private config;
9
+ private configChecked;
9
10
  /**
10
11
  * コンストラクタ
11
12
  * @param config Firestore設定オブジェクト
12
13
  */
13
14
  constructor(config: FirestoreConfig);
15
+ /**
16
+ * 設定パラメータをチェック
17
+ * @private
18
+ */
19
+ private checkConfig;
14
20
  /**
15
21
  * 認証トークンを取得(キャッシュあり)
16
22
  */
package/dist/client.js CHANGED
@@ -16,7 +16,19 @@ class FirestoreClient {
16
16
  constructor(config) {
17
17
  this.token = null;
18
18
  this.tokenExpiry = 0;
19
+ this.configChecked = false;
19
20
  this.config = config;
21
+ // ビルド時にはチェックを行わない
22
+ // 実際の操作時に遅延チェックを行う
23
+ }
24
+ /**
25
+ * 設定パラメータをチェック
26
+ * @private
27
+ */
28
+ checkConfig() {
29
+ if (this.configChecked) {
30
+ return;
31
+ }
20
32
  // 必須パラメータのチェック
21
33
  const requiredParams = [
22
34
  "projectId",
@@ -27,11 +39,14 @@ class FirestoreClient {
27
39
  if (missingParams.length > 0) {
28
40
  throw new Error(`Missing required Firestore configuration parameters: ${missingParams.join(", ")}`);
29
41
  }
42
+ this.configChecked = true;
30
43
  }
31
44
  /**
32
45
  * 認証トークンを取得(キャッシュあり)
33
46
  */
34
47
  async getToken() {
48
+ // 操作前に設定をチェック
49
+ this.checkConfig();
35
50
  const now = Date.now();
36
51
  // トークンが期限切れか未取得の場合は新しく取得
37
52
  if (!this.token || now >= this.tokenExpiry) {
@@ -47,6 +62,7 @@ class FirestoreClient {
47
62
  * @returns CollectionReferenceインスタンス
48
63
  */
49
64
  collection(path) {
65
+ // 設定チェックは実際の操作時に行われる
50
66
  return new CollectionReference(this, path);
51
67
  }
52
68
  /**
@@ -55,6 +71,7 @@ class FirestoreClient {
55
71
  * @returns DocumentReferenceインスタンス
56
72
  */
57
73
  doc(path) {
74
+ // 設定チェックは実際の操作時に行われる
58
75
  const parts = path.split("/");
59
76
  if (parts.length % 2 === 0) {
60
77
  throw new Error("Invalid document path. Document path must point to a document, not a collection.");
@@ -70,6 +87,8 @@ class FirestoreClient {
70
87
  * @returns 作成されたドキュメント
71
88
  */
72
89
  async create(collectionName, data) {
90
+ // 操作前に設定をチェック
91
+ this.checkConfig();
73
92
  const url = (0, path_1.getFirestoreBasePath)(this.config.projectId, collectionName);
74
93
  const firestoreData = (0, converter_1.convertToFirestoreDocument)(data);
75
94
  const token = await this.getToken();
@@ -94,6 +113,8 @@ class FirestoreClient {
94
113
  * @returns 取得したドキュメント(存在しない場合はnull)
95
114
  */
96
115
  async get(collectionName, documentId) {
116
+ // 操作前に設定をチェック
117
+ this.checkConfig();
97
118
  const url = `${(0, path_1.getFirestoreBasePath)(this.config.projectId, collectionName)}/${documentId}`;
98
119
  const token = await this.getToken();
99
120
  const response = await fetch(url, {
@@ -119,6 +140,8 @@ class FirestoreClient {
119
140
  * @returns 更新されたドキュメント
120
141
  */
121
142
  async update(collectionName, documentId, data) {
143
+ // 操作前に設定をチェック
144
+ this.checkConfig();
122
145
  const url = `${(0, path_1.getFirestoreBasePath)(this.config.projectId, collectionName)}/${documentId}`;
123
146
  const firestoreData = (0, converter_1.convertToFirestoreDocument)(data);
124
147
  const token = await this.getToken();
@@ -143,6 +166,8 @@ class FirestoreClient {
143
166
  * @returns 削除成功時はtrue
144
167
  */
145
168
  async delete(collectionName, documentId) {
169
+ // 操作前に設定をチェック
170
+ this.checkConfig();
146
171
  const url = `${(0, path_1.getFirestoreBasePath)(this.config.projectId, collectionName)}/${documentId}`;
147
172
  const token = await this.getToken();
148
173
  const response = await fetch(url, {
@@ -163,6 +188,8 @@ class FirestoreClient {
163
188
  * @returns 検索結果のドキュメント配列
164
189
  */
165
190
  async query(collectionName, options = {}) {
191
+ // 操作前に設定をチェック
192
+ this.checkConfig();
166
193
  const url = `${(0, path_1.getFirestoreBasePath)(this.config.projectId, collectionName)}:runQuery`;
167
194
  // クエリ構築
168
195
  const structuredQuery = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-rest-firestore",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Firebase Firestore REST API client for Edge runtime environments",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,10 +37,10 @@
37
37
  },
38
38
  "repository": {
39
39
  "type": "git",
40
- "url": "git+https://github.com/yourusername/firebase-rest-firestore.git"
40
+ "url": "git+https://github.com/nabettu/firebase-rest-firestore.git"
41
41
  },
42
42
  "bugs": {
43
- "url": "https://github.com/yourusername/firebase-rest-firestore/issues"
43
+ "url": "https://github.com/nabettu/firebase-rest-firestore/issues"
44
44
  },
45
- "homepage": "https://github.com/yourusername/firebase-rest-firestore#readme"
45
+ "homepage": "https://github.com/nabettu/firebase-rest-firestore#readme"
46
46
  }