/
var
/
www
/
greso.tech
/
server
/
nsm
/
node_modules
/
@google-cloud
/
firestore
/
build
/
src
/
/var/www/greso.tech/server/nsm/node_modules/@google-cloud/firestore/build/src
mkdir
upload
Name
Size
Mode
Actions
v1/
-
0755
rm
v1beta1/
-
0755
rm
backoff.d.ts
5547
0644
edit
dl
rm
backoff.js
7650
0644
edit
dl
rm
bulk-writer.d.ts
19230
0644
edit
dl
rm
bulk-writer.js
36112
0644
edit
dl
rm
bundle.d.ts
835
0644
edit
dl
rm
bundle.js
8427
0644
edit
dl
rm
collection-group.d.ts
3602
0644
edit
dl
rm
collection-group.js
4553
0644
edit
dl
rm
convert.d.ts
2776
0644
edit
dl
rm
convert.js
7168
0644
edit
dl
rm
document-change.d.ts
5033
0644
edit
dl
rm
document-change.js
5284
0644
edit
dl
rm
document-reader.d.ts
1842
0644
edit
dl
rm
document-reader.js
5394
0644
edit
dl
rm
document.d.ts
18149
0644
edit
dl
rm
document.js
30404
0644
edit
dl
rm
field-value.d.ts
8598
0644
edit
dl
rm
field-value.js
13884
0644
edit
dl
rm
filter.d.ts
6832
0644
edit
dl
rm
filter.js
6973
0644
edit
dl
rm
geo-point.d.ts
2644
0644
edit
dl
rm
geo-point.js
3217
0644
edit
dl
rm
index.d.ts
38229
0644
edit
dl
rm
index.js
63443
0644
edit
dl
rm
logger.d.ts
1310
0644
edit
dl
rm
logger.js
2112
0644
edit
dl
rm
order.d.ts
1096
0644
edit
dl
rm
order.js
7525
0644
edit
dl
rm
path.d.ts
12118
0644
edit
dl
rm
path.js
18995
0644
edit
dl
rm
pool.d.ts
4432
0644
edit
dl
rm
pool.js
10116
0644
edit
dl
rm
query-partition.d.ts
4011
0644
edit
dl
rm
query-partition.js
5761
0644
edit
dl
rm
rate-limiter.d.ts
3015
0644
edit
dl
rm
rate-limiter.js
5850
0644
edit
dl
rm
recursive-delete.d.ts
5714
0644
edit
dl
rm
recursive-delete.js
10040
0644
edit
dl
rm
reference.d.ts
53096
0644
edit
dl
rm
reference.js
103221
0644
edit
dl
rm
serializer.d.ts
2942
0644
edit
dl
rm
serializer.js
12817
0644
edit
dl
rm
status-code.d.ts
1121
0644
edit
dl
rm
status-code.js
712
0644
edit
dl
rm
timestamp.d.ts
6987
0644
edit
dl
rm
timestamp.js
9697
0644
edit
dl
rm
transaction.d.ts
10098
0644
edit
dl
rm
transaction.js
19139
0644
edit
dl
rm
types.d.ts
3992
0644
edit
dl
rm
types.js
1387
0644
edit
dl
rm
util.d.ts
4066
0644
edit
dl
rm
util.js
7373
0644
edit
dl
rm
validate.d.ts
6527
0644
edit
dl
rm
validate.js
12314
0644
edit
dl
rm
watch.d.ts
9738
0644
edit
dl
rm
watch.js
24988
0644
edit
dl
rm
write-batch.d.ts
10521
0644
edit
dl
rm
write-batch.js
27233
0644
edit
dl
rm
Edit:
/var/www/greso.tech/server/nsm/node_modules/@google-cloud/firestore/build/src/bundle.js
(8427B)
"use strict"; // Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.BundleBuilder = void 0; const document_1 = require("./document"); const reference_1 = require("./reference"); const timestamp_1 = require("./timestamp"); const validate_1 = require("./validate"); const BUNDLE_VERSION = 1; /** * Builds a Firestore data bundle with results from the given document and query snapshots. */ class BundleBuilder { constructor(bundleId) { this.bundleId = bundleId; // Resulting documents for the bundle, keyed by full document path. this.documents = new Map(); // Named queries saved in the bundle, keyed by query name. this.namedQueries = new Map(); // The latest read time among all bundled documents and queries. this.latestReadTime = new timestamp_1.Timestamp(0, 0); } /** * Adds a Firestore document snapshot or query snapshot to the bundle. * Both the documents data and the query read time will be included in the bundle. * * @param {DocumentSnapshot | string} documentOrName A document snapshot to add or a name of a query. * @param {Query=} querySnapshot A query snapshot to add to the bundle, if provided. * @returns {BundleBuilder} This instance. * * @example * ``` * const bundle = firestore.bundle('data-bundle'); * const docSnapshot = await firestore.doc('abc/123').get(); * const querySnapshot = await firestore.collection('coll').get(); * * const bundleBuffer = bundle.add(docSnapshot) // Add a document * .add('coll-query', querySnapshot) // Add a named query. * .build() * // Save `bundleBuffer` to CDN or stream it to clients. * ``` */ add(documentOrName, querySnapshot) { // eslint-disable-next-line prefer-rest-params (0, validate_1.validateMinNumberOfArguments)('BundleBuilder.add', arguments, 1); // eslint-disable-next-line prefer-rest-params (0, validate_1.validateMaxNumberOfArguments)('BundleBuilder.add', arguments, 2); if (arguments.length === 1) { validateDocumentSnapshot('documentOrName', documentOrName); this.addBundledDocument(documentOrName); } else { (0, validate_1.validateString)('documentOrName', documentOrName); validateQuerySnapshot('querySnapshot', querySnapshot); this.addNamedQuery(documentOrName, querySnapshot); } return this; } addBundledDocument(snap, queryName) { const originalDocument = this.documents.get(snap.ref.path); const originalQueries = originalDocument === null || originalDocument === void 0 ? void 0 : originalDocument.metadata.queries; // Update with document built from `snap` because it is newer. if (!originalDocument || timestamp_1.Timestamp.fromProto(originalDocument.metadata.readTime) < snap.readTime) { const docProto = snap.toDocumentProto(); this.documents.set(snap.ref.path, { document: snap.exists ? docProto : undefined, metadata: { name: docProto.name, readTime: snap.readTime.toProto().timestampValue, exists: snap.exists, }, }); } // Update `queries` to include both original and `queryName`. const newDocument = this.documents.get(snap.ref.path); newDocument.metadata.queries = originalQueries || []; if (queryName) { newDocument.metadata.queries.push(queryName); } if (snap.readTime > this.latestReadTime) { this.latestReadTime = snap.readTime; } } addNamedQuery(name, querySnap) { if (this.namedQueries.has(name)) { throw new Error(`Query name conflict: ${name} has already been added.`); } this.namedQueries.set(name, { name, bundledQuery: querySnap.query._toBundledQuery(), readTime: querySnap.readTime.toProto().timestampValue, }); for (const snap of querySnap.docs) { this.addBundledDocument(snap, name); } if (querySnap.readTime > this.latestReadTime) { this.latestReadTime = querySnap.readTime; } } /** * Converts a IBundleElement to a Buffer whose content is the length prefixed JSON representation * of the element. * @private * @internal */ elementToLengthPrefixedBuffer(bundleElement) { // Convert to a valid proto message object then take its JSON representation. // This take cares of stuff like converting internal byte array fields // to Base64 encodings. // We lazy-load the Proto file to reduce cold-start times. const message = require('../protos/firestore_v1_proto_api') .firestore.BundleElement.fromObject(bundleElement) .toJSON(); const buffer = Buffer.from(JSON.stringify(message), 'utf-8'); const lengthBuffer = Buffer.from(buffer.length.toString()); return Buffer.concat([lengthBuffer, buffer]); } build() { let bundleBuffer = Buffer.alloc(0); for (const namedQuery of this.namedQueries.values()) { bundleBuffer = Buffer.concat([ bundleBuffer, this.elementToLengthPrefixedBuffer({ namedQuery }), ]); } for (const bundledDocument of this.documents.values()) { const documentMetadata = bundledDocument.metadata; bundleBuffer = Buffer.concat([ bundleBuffer, this.elementToLengthPrefixedBuffer({ documentMetadata }), ]); // Write to the bundle if document exists. const document = bundledDocument.document; if (document) { bundleBuffer = Buffer.concat([ bundleBuffer, this.elementToLengthPrefixedBuffer({ document }), ]); } } const metadata = { id: this.bundleId, createTime: this.latestReadTime.toProto().timestampValue, version: BUNDLE_VERSION, totalDocuments: this.documents.size, totalBytes: bundleBuffer.length, }; // Prepends the metadata element to the bundleBuffer: `bundleBuffer` is the second argument to `Buffer.concat`. bundleBuffer = Buffer.concat([ this.elementToLengthPrefixedBuffer({ metadata }), bundleBuffer, ]); return bundleBuffer; } } exports.BundleBuilder = BundleBuilder; /** * Convenient class to hold both the metadata and the actual content of a document to be bundled. * @private * @internal */ class BundledDocument { constructor(metadata, document) { this.metadata = metadata; this.document = document; } } /** * Validates that 'value' is DocumentSnapshot. * * @private * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. */ function validateDocumentSnapshot(arg, value) { if (!(value instanceof document_1.DocumentSnapshot)) { throw new Error((0, validate_1.invalidArgumentMessage)(arg, 'DocumentSnapshot')); } } /** * Validates that 'value' is QuerySnapshot. * * @private * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. */ function validateQuerySnapshot(arg, value) { if (!(value instanceof reference_1.QuerySnapshot)) { throw new Error((0, validate_1.invalidArgumentMessage)(arg, 'QuerySnapshot')); } } //# sourceMappingURL=bundle.js.map
Save
cmd:
run