firebase-rest-firestore 1.1.2 → 1.5.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/dist/cjs/client.d.ts +417 -0
- package/dist/cjs/client.js +1078 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +1 -1
- package/dist/{index.js → cjs/index.js} +1 -2
- package/dist/{types.d.ts → cjs/types.d.ts} +4 -0
- package/dist/cjs/utils/auth.d.ts +13 -0
- package/dist/{utils → cjs/utils}/auth.js +14 -10
- package/dist/cjs/utils/config.d.ts +6 -0
- package/dist/{utils → cjs/utils}/config.js +0 -12
- package/dist/cjs/utils/path.d.ts +73 -0
- package/dist/cjs/utils/path.js +176 -0
- package/dist/esm/client.d.ts +417 -0
- package/dist/esm/client.js +1066 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/types.d.ts +69 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/auth.d.ts +13 -0
- package/dist/esm/utils/auth.js +57 -0
- package/dist/esm/utils/config.d.ts +6 -0
- package/dist/esm/utils/config.js +11 -0
- package/dist/esm/utils/converter.d.ts +27 -0
- package/dist/esm/utils/converter.js +107 -0
- package/dist/esm/utils/path.d.ts +73 -0
- package/dist/esm/utils/path.js +169 -0
- package/dist/types/client.d.ts +417 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/types.d.ts +69 -0
- package/dist/types/utils/auth.d.ts +13 -0
- package/dist/types/utils/config.d.ts +6 -0
- package/dist/types/utils/converter.d.ts +27 -0
- package/dist/types/utils/path.d.ts +73 -0
- package/package.json +18 -5
- package/dist/client.d.ts +0 -381
- package/dist/client.js +0 -878
- package/dist/utils/auth.d.ts +0 -13
- package/dist/utils/config.d.ts +0 -13
- package/dist/utils/path.d.ts +0 -14
- package/dist/utils/path.js +0 -27
- /package/dist/{types.js → cjs/types.js} +0 -0
- /package/dist/{utils → cjs/utils}/converter.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/converter.js +0 -0
package/dist/client.d.ts
DELETED
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
import { FirestoreConfig, QueryOptions } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Firestoreクライアントクラス
|
|
4
|
-
*/
|
|
5
|
-
export declare class FirestoreClient {
|
|
6
|
-
private token;
|
|
7
|
-
private tokenExpiry;
|
|
8
|
-
private config;
|
|
9
|
-
private configChecked;
|
|
10
|
-
/**
|
|
11
|
-
* コンストラクタ
|
|
12
|
-
* @param config Firestore設定オブジェクト
|
|
13
|
-
*/
|
|
14
|
-
constructor(config: FirestoreConfig);
|
|
15
|
-
/**
|
|
16
|
-
* 設定パラメータをチェック
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
private checkConfig;
|
|
20
|
-
/**
|
|
21
|
-
* 認証トークンを取得(キャッシュあり)
|
|
22
|
-
*/
|
|
23
|
-
private getToken;
|
|
24
|
-
/**
|
|
25
|
-
* コレクションリファレンスを取得
|
|
26
|
-
* @param path コレクションパス
|
|
27
|
-
* @returns CollectionReferenceインスタンス
|
|
28
|
-
*/
|
|
29
|
-
collection(path: string): CollectionReference;
|
|
30
|
-
/**
|
|
31
|
-
* ドキュメントリファレンスを取得
|
|
32
|
-
* @param path ドキュメントパス
|
|
33
|
-
* @returns DocumentReferenceインスタンス
|
|
34
|
-
*/
|
|
35
|
-
doc(path: string): DocumentReference;
|
|
36
|
-
/**
|
|
37
|
-
* コレクショングループリファレンスを取得
|
|
38
|
-
* @param path コレクショングループのID
|
|
39
|
-
* @returns CollectionGroupインスタンス
|
|
40
|
-
*/
|
|
41
|
-
collectionGroup(path: string): CollectionGroup;
|
|
42
|
-
/**
|
|
43
|
-
* Firestoreにドキュメントを追加
|
|
44
|
-
* @param collectionName コレクション名
|
|
45
|
-
* @param data 追加するデータ
|
|
46
|
-
* @returns 追加されたドキュメント
|
|
47
|
-
*/
|
|
48
|
-
add(collectionName: string, data: Record<string, any>): Promise<Record<string, any> & {
|
|
49
|
-
id: string;
|
|
50
|
-
}>;
|
|
51
|
-
/**
|
|
52
|
-
* ドキュメントを取得
|
|
53
|
-
* @param collectionName コレクション名
|
|
54
|
-
* @param documentId ドキュメントID
|
|
55
|
-
* @returns 取得したドキュメント(存在しない場合はnull)
|
|
56
|
-
*/
|
|
57
|
-
get(collectionName: string, documentId: string): Promise<(Record<string, any> & {
|
|
58
|
-
id: string;
|
|
59
|
-
}) | null>;
|
|
60
|
-
/**
|
|
61
|
-
* ドキュメントを更新
|
|
62
|
-
* @param collectionName コレクション名
|
|
63
|
-
* @param documentId ドキュメントID
|
|
64
|
-
* @param data 更新するデータ
|
|
65
|
-
* @returns 更新されたドキュメント
|
|
66
|
-
*/
|
|
67
|
-
update(collectionName: string, documentId: string, data: Record<string, any>): Promise<Record<string, any> & {
|
|
68
|
-
id: string;
|
|
69
|
-
}>;
|
|
70
|
-
/**
|
|
71
|
-
* ドキュメントを削除
|
|
72
|
-
* @param collectionName コレクション名
|
|
73
|
-
* @param documentId ドキュメントID
|
|
74
|
-
* @returns 削除成功時はtrue
|
|
75
|
-
*/
|
|
76
|
-
delete(collectionName: string, documentId: string): Promise<boolean>;
|
|
77
|
-
/**
|
|
78
|
-
* コレクションのドキュメントを検索
|
|
79
|
-
* @param collectionPath コレクションパス
|
|
80
|
-
* @param options クエリオプション
|
|
81
|
-
* @param allDescendants 子孫コレクションを含むかどうか
|
|
82
|
-
* @returns 検索結果のドキュメント配列
|
|
83
|
-
*/
|
|
84
|
-
query(collectionPath: string, options: QueryOptions | undefined, allDescendants: boolean): Promise<(Record<string, any> & {
|
|
85
|
-
id: string;
|
|
86
|
-
})[]>;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* コレクションリファレンスクラス
|
|
90
|
-
*/
|
|
91
|
-
export declare class CollectionReference {
|
|
92
|
-
private client;
|
|
93
|
-
private path;
|
|
94
|
-
private _queryConstraints;
|
|
95
|
-
constructor(client: FirestoreClient, path: string);
|
|
96
|
-
/**
|
|
97
|
-
* すべての子孫コレクションを含むかどうか
|
|
98
|
-
*/
|
|
99
|
-
get allDescendants(): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* ドキュメントリファレンスを取得
|
|
102
|
-
* @param documentPath ドキュメントID(省略時は自動生成)
|
|
103
|
-
* @returns DocumentReferenceインスタンス
|
|
104
|
-
*/
|
|
105
|
-
doc(documentPath?: string): DocumentReference;
|
|
106
|
-
/**
|
|
107
|
-
* ドキュメントを追加(IDは自動生成)
|
|
108
|
-
* @param data ドキュメントデータ
|
|
109
|
-
* @returns 作成されたドキュメントのリファレンス
|
|
110
|
-
*/
|
|
111
|
-
add(data: Record<string, any>): Promise<DocumentReference>;
|
|
112
|
-
/**
|
|
113
|
-
* フィルター条件を追加
|
|
114
|
-
* @param fieldPath フィールドパス
|
|
115
|
-
* @param opStr 演算子
|
|
116
|
-
* @param value 値
|
|
117
|
-
* @returns Queryインスタンス
|
|
118
|
-
*/
|
|
119
|
-
where(fieldPath: string, opStr: string, value: any): Query;
|
|
120
|
-
/**
|
|
121
|
-
* 並べ替え条件を追加
|
|
122
|
-
* @param fieldPath フィールドパス
|
|
123
|
-
* @param directionStr 並べ替え方向('asc'または'desc')
|
|
124
|
-
* @returns Queryインスタンス
|
|
125
|
-
*/
|
|
126
|
-
orderBy(fieldPath: string, directionStr?: "asc" | "desc"): Query;
|
|
127
|
-
/**
|
|
128
|
-
* 取得件数の制限を設定
|
|
129
|
-
* @param limit 最大件数
|
|
130
|
-
* @returns Queryインスタンス
|
|
131
|
-
*/
|
|
132
|
-
limit(limit: number): Query;
|
|
133
|
-
/**
|
|
134
|
-
* スキップ件数を設定
|
|
135
|
-
* @param offset スキップ件数
|
|
136
|
-
* @returns Queryインスタンス
|
|
137
|
-
*/
|
|
138
|
-
offset(offset: number): Query;
|
|
139
|
-
/**
|
|
140
|
-
* クエリを実行
|
|
141
|
-
* @returns QuerySnapshotインスタンス
|
|
142
|
-
*/
|
|
143
|
-
get(): Promise<QuerySnapshot>;
|
|
144
|
-
/**
|
|
145
|
-
* ランダムなIDを生成
|
|
146
|
-
* @returns ランダムなID
|
|
147
|
-
*/
|
|
148
|
-
private _generateId;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* ドキュメントリファレンスクラス
|
|
152
|
-
*/
|
|
153
|
-
export declare class DocumentReference {
|
|
154
|
-
private client;
|
|
155
|
-
private collectionPath;
|
|
156
|
-
private docId;
|
|
157
|
-
constructor(client: FirestoreClient, collectionPath: string, docId: string);
|
|
158
|
-
/**
|
|
159
|
-
* ドキュメントIDを取得
|
|
160
|
-
*/
|
|
161
|
-
get id(): string;
|
|
162
|
-
/**
|
|
163
|
-
* ドキュメントのパスを取得
|
|
164
|
-
*/
|
|
165
|
-
get path(): string;
|
|
166
|
-
/**
|
|
167
|
-
* サブコレクションを取得
|
|
168
|
-
* @param collectionPath サブコレクション名
|
|
169
|
-
* @returns CollectionReferenceインスタンス
|
|
170
|
-
*/
|
|
171
|
-
collection(collectionPath: string): CollectionReference;
|
|
172
|
-
/**
|
|
173
|
-
* ドキュメントを取得
|
|
174
|
-
* @returns DocumentSnapshotインスタンス
|
|
175
|
-
*/
|
|
176
|
-
get(): Promise<DocumentSnapshot>;
|
|
177
|
-
/**
|
|
178
|
-
* ドキュメントを作成または上書き
|
|
179
|
-
* @param data ドキュメントデータ
|
|
180
|
-
* @param options オプション(mergeは現在サポートされていません)
|
|
181
|
-
* @returns WriteResultインスタンス
|
|
182
|
-
*/
|
|
183
|
-
set(data: Record<string, any>, options?: {
|
|
184
|
-
merge?: boolean;
|
|
185
|
-
}): Promise<WriteResult>;
|
|
186
|
-
/**
|
|
187
|
-
* ドキュメントを更新
|
|
188
|
-
* @param data 更新データ
|
|
189
|
-
* @returns WriteResultインスタンス
|
|
190
|
-
*/
|
|
191
|
-
update(data: Record<string, any>): Promise<WriteResult>;
|
|
192
|
-
/**
|
|
193
|
-
* ドキュメントを削除
|
|
194
|
-
* @returns WriteResultインスタンス
|
|
195
|
-
*/
|
|
196
|
-
delete(): Promise<WriteResult>;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* コレクショングループ
|
|
200
|
-
*/
|
|
201
|
-
export declare class CollectionGroup {
|
|
202
|
-
private client;
|
|
203
|
-
private path;
|
|
204
|
-
private _queryConstraints;
|
|
205
|
-
constructor(client: FirestoreClient, path: string);
|
|
206
|
-
/**
|
|
207
|
-
* すべての子孫コレクションを含むかどうか
|
|
208
|
-
*/
|
|
209
|
-
get allDescendants(): boolean;
|
|
210
|
-
/**
|
|
211
|
-
* フィルター条件を追加
|
|
212
|
-
* @param fieldPath フィールドパス
|
|
213
|
-
* @param opStr 演算子
|
|
214
|
-
* @param value 値
|
|
215
|
-
* @returns Queryインスタンス
|
|
216
|
-
*/
|
|
217
|
-
where(fieldPath: string, opStr: string, value: any): Query;
|
|
218
|
-
/**
|
|
219
|
-
* 並べ替え条件を追加
|
|
220
|
-
* @param fieldPath フィールドパス
|
|
221
|
-
* @param directionStr 並べ替え方向('asc'または'desc')
|
|
222
|
-
* @returns Queryインスタンス
|
|
223
|
-
*/
|
|
224
|
-
orderBy(fieldPath: string, directionStr?: "asc" | "desc"): Query;
|
|
225
|
-
/**
|
|
226
|
-
* 取得件数の制限を設定
|
|
227
|
-
* @param limit 最大件数
|
|
228
|
-
* @returns Queryインスタンス
|
|
229
|
-
*/
|
|
230
|
-
limit(limit: number): Query;
|
|
231
|
-
/**
|
|
232
|
-
* スキップ件数を設定
|
|
233
|
-
* @param offset スキップ件数
|
|
234
|
-
* @returns Queryインスタンス
|
|
235
|
-
*/
|
|
236
|
-
offset(offset: number): Query;
|
|
237
|
-
/**
|
|
238
|
-
* クエリを実行
|
|
239
|
-
* @returns QuerySnapshotインスタンス
|
|
240
|
-
*/
|
|
241
|
-
get(): Promise<QuerySnapshot>;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* クエリクラス
|
|
245
|
-
*/
|
|
246
|
-
export declare class Query {
|
|
247
|
-
private client;
|
|
248
|
-
private collectionPath;
|
|
249
|
-
private allDescendants;
|
|
250
|
-
_queryConstraints: {
|
|
251
|
-
where: Array<{
|
|
252
|
-
field: string;
|
|
253
|
-
op: string;
|
|
254
|
-
value: any;
|
|
255
|
-
}>;
|
|
256
|
-
orderBy?: string;
|
|
257
|
-
orderDirection?: string;
|
|
258
|
-
limit?: number;
|
|
259
|
-
offset?: number;
|
|
260
|
-
};
|
|
261
|
-
constructor(client: FirestoreClient, collectionPath: string, constraints: {
|
|
262
|
-
where: Array<{
|
|
263
|
-
field: string;
|
|
264
|
-
op: string;
|
|
265
|
-
value: any;
|
|
266
|
-
}>;
|
|
267
|
-
orderBy?: string;
|
|
268
|
-
orderDirection?: string;
|
|
269
|
-
limit?: number;
|
|
270
|
-
offset?: number;
|
|
271
|
-
}, allDescendants: boolean);
|
|
272
|
-
/**
|
|
273
|
-
* フィルター条件を追加
|
|
274
|
-
* @param fieldPath フィールドパス
|
|
275
|
-
* @param opStr 演算子
|
|
276
|
-
* @param value 値
|
|
277
|
-
* @returns Queryインスタンス
|
|
278
|
-
*/
|
|
279
|
-
where(fieldPath: string, opStr: string, value: any): Query;
|
|
280
|
-
/**
|
|
281
|
-
* 並べ替え条件を追加
|
|
282
|
-
* @param fieldPath フィールドパス
|
|
283
|
-
* @param directionStr 並べ替え方向('asc'または'desc')
|
|
284
|
-
* @returns Queryインスタンス
|
|
285
|
-
*/
|
|
286
|
-
orderBy(fieldPath: string, directionStr?: "asc" | "desc"): Query;
|
|
287
|
-
/**
|
|
288
|
-
* 取得件数の制限を設定
|
|
289
|
-
* @param limit 最大件数
|
|
290
|
-
* @returns Queryインスタンス
|
|
291
|
-
*/
|
|
292
|
-
limit(limit: number): Query;
|
|
293
|
-
/**
|
|
294
|
-
* スキップ件数を設定
|
|
295
|
-
* @param offset スキップ件数
|
|
296
|
-
* @returns Queryインスタンス
|
|
297
|
-
*/
|
|
298
|
-
offset(offset: number): Query;
|
|
299
|
-
/**
|
|
300
|
-
* クエリを実行
|
|
301
|
-
* @returns QuerySnapshotインスタンス
|
|
302
|
-
*/
|
|
303
|
-
get(): Promise<QuerySnapshot>;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* クエリ結果クラス
|
|
307
|
-
*/
|
|
308
|
-
export declare class QuerySnapshot {
|
|
309
|
-
private _docs;
|
|
310
|
-
constructor(results: Array<Record<string, any>>);
|
|
311
|
-
/**
|
|
312
|
-
* 結果のドキュメント配列
|
|
313
|
-
*/
|
|
314
|
-
get docs(): DocumentSnapshot[];
|
|
315
|
-
/**
|
|
316
|
-
* 結果が空かどうか
|
|
317
|
-
*/
|
|
318
|
-
get empty(): boolean;
|
|
319
|
-
/**
|
|
320
|
-
* 結果の件数
|
|
321
|
-
*/
|
|
322
|
-
get size(): number;
|
|
323
|
-
/**
|
|
324
|
-
* 各ドキュメントに対してコールバックを実行
|
|
325
|
-
* @param callback 各ドキュメントに対して実行するコールバック関数
|
|
326
|
-
*/
|
|
327
|
-
forEach(callback: (result: DocumentSnapshot) => void): void;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* ドキュメントスナップショットクラス
|
|
331
|
-
*/
|
|
332
|
-
export declare class DocumentSnapshot {
|
|
333
|
-
private _id;
|
|
334
|
-
private _data;
|
|
335
|
-
constructor(id: string, data: Record<string, any> | null);
|
|
336
|
-
/**
|
|
337
|
-
* ドキュメントID
|
|
338
|
-
*/
|
|
339
|
-
get id(): string;
|
|
340
|
-
/**
|
|
341
|
-
* ドキュメントが存在するかどうか
|
|
342
|
-
*/
|
|
343
|
-
get exists(): boolean;
|
|
344
|
-
/**
|
|
345
|
-
* ドキュメントデータを取得
|
|
346
|
-
* @returns ドキュメントデータ(存在しない場合はundefined)
|
|
347
|
-
*/
|
|
348
|
-
data(): Record<string, any> | undefined;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* 書き込み結果クラス
|
|
352
|
-
*/
|
|
353
|
-
export declare class WriteResult {
|
|
354
|
-
/**
|
|
355
|
-
* 書き込み時刻
|
|
356
|
-
*/
|
|
357
|
-
readonly writeTime: Date;
|
|
358
|
-
constructor();
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* 新しいFirestoreクライアントインスタンスを作成
|
|
362
|
-
* @param config Firestore設定オブジェクト
|
|
363
|
-
* @returns FirestoreClientインスタンス
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* // デフォルトデータベースに接続
|
|
367
|
-
* const db = createFirestoreClient({
|
|
368
|
-
* projectId: 'your-project-id',
|
|
369
|
-
* privateKey: 'your-private-key',
|
|
370
|
-
* clientEmail: 'your-client-email'
|
|
371
|
-
* });
|
|
372
|
-
*
|
|
373
|
-
* // 異なる名前のデータベースに接続
|
|
374
|
-
* const customDb = createFirestoreClient({
|
|
375
|
-
* projectId: 'your-project-id',
|
|
376
|
-
* privateKey: 'your-private-key',
|
|
377
|
-
* clientEmail: 'your-client-email',
|
|
378
|
-
* databaseId: 'your-database-id'
|
|
379
|
-
* });
|
|
380
|
-
*/
|
|
381
|
-
export declare function createFirestoreClient(config: FirestoreConfig): FirestoreClient;
|