@pristine-ts/gcp 2.0.16
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 +201 -0
- package/dist/lib/cjs/clients/clients.js +22 -0
- package/dist/lib/cjs/clients/clients.js.map +1 -0
- package/dist/lib/cjs/clients/cloud-storage.client.js +189 -0
- package/dist/lib/cjs/clients/cloud-storage.client.js.map +1 -0
- package/dist/lib/cjs/clients/eventarc.client.js +146 -0
- package/dist/lib/cjs/clients/eventarc.client.js.map +1 -0
- package/dist/lib/cjs/clients/firestore.client.js +238 -0
- package/dist/lib/cjs/clients/firestore.client.js.map +1 -0
- package/dist/lib/cjs/clients/pub-sub.client.js +97 -0
- package/dist/lib/cjs/clients/pub-sub.client.js.map +1 -0
- package/dist/lib/cjs/clients/secret-manager.client.js +118 -0
- package/dist/lib/cjs/clients/secret-manager.client.js.map +1 -0
- package/dist/lib/cjs/decorators/decorators.js +18 -0
- package/dist/lib/cjs/decorators/decorators.js.map +1 -0
- package/dist/lib/cjs/decorators/dynamic-collection-name.decorator.js +33 -0
- package/dist/lib/cjs/decorators/dynamic-collection-name.decorator.js.map +1 -0
- package/dist/lib/cjs/enums/cloud-storage-event-type.enum.js +16 -0
- package/dist/lib/cjs/enums/cloud-storage-event-type.enum.js.map +1 -0
- package/dist/lib/cjs/enums/cloud-storage-presigned-operation-type.enum.js +13 -0
- package/dist/lib/cjs/enums/cloud-storage-presigned-operation-type.enum.js.map +1 -0
- package/dist/lib/cjs/enums/enums.js +22 -0
- package/dist/lib/cjs/enums/enums.js.map +1 -0
- package/dist/lib/cjs/enums/eventarc-event-type.enum.js +12 -0
- package/dist/lib/cjs/enums/eventarc-event-type.enum.js.map +1 -0
- package/dist/lib/cjs/enums/firestore-event-type.enum.js +16 -0
- package/dist/lib/cjs/enums/firestore-event-type.enum.js.map +1 -0
- package/dist/lib/cjs/enums/pub-sub-event-type.enum.js +13 -0
- package/dist/lib/cjs/enums/pub-sub-event-type.enum.js.map +1 -0
- package/dist/lib/cjs/errors/errors.js +20 -0
- package/dist/lib/cjs/errors/errors.js.map +1 -0
- package/dist/lib/cjs/errors/eventarc-publish.error.js +17 -0
- package/dist/lib/cjs/errors/eventarc-publish.error.js.map +1 -0
- package/dist/lib/cjs/errors/get-secret.error.js +17 -0
- package/dist/lib/cjs/errors/get-secret.error.js.map +1 -0
- package/dist/lib/cjs/errors/pub-sub-publish.error.js +19 -0
- package/dist/lib/cjs/errors/pub-sub-publish.error.js.map +1 -0
- package/dist/lib/cjs/event-payloads/cloud-storage.event-payload.js +11 -0
- package/dist/lib/cjs/event-payloads/cloud-storage.event-payload.js.map +1 -0
- package/dist/lib/cjs/event-payloads/event-payloads.js +21 -0
- package/dist/lib/cjs/event-payloads/event-payloads.js.map +1 -0
- package/dist/lib/cjs/event-payloads/eventarc.event-payload.js +11 -0
- package/dist/lib/cjs/event-payloads/eventarc.event-payload.js.map +1 -0
- package/dist/lib/cjs/event-payloads/firestore.event-payload.js +11 -0
- package/dist/lib/cjs/event-payloads/firestore.event-payload.js.map +1 -0
- package/dist/lib/cjs/event-payloads/pub-sub.event-payload.js +17 -0
- package/dist/lib/cjs/event-payloads/pub-sub.event-payload.js.map +1 -0
- package/dist/lib/cjs/gcp.configuration-keys.js +20 -0
- package/dist/lib/cjs/gcp.configuration-keys.js.map +1 -0
- package/dist/lib/cjs/gcp.module.js +76 -0
- package/dist/lib/cjs/gcp.module.js.map +1 -0
- package/dist/lib/cjs/gcp.module.keyname.js +5 -0
- package/dist/lib/cjs/gcp.module.keyname.js.map +1 -0
- package/dist/lib/cjs/interfaces/client-options.interface.js +3 -0
- package/dist/lib/cjs/interfaces/client-options.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/cloud-storage-client.interface.js +3 -0
- package/dist/lib/cjs/interfaces/cloud-storage-client.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/eventarc-client.interface.js +3 -0
- package/dist/lib/cjs/interfaces/eventarc-client.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/firestore-client.interface.js +3 -0
- package/dist/lib/cjs/interfaces/firestore-client.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/interfaces.js +23 -0
- package/dist/lib/cjs/interfaces/interfaces.js.map +1 -0
- package/dist/lib/cjs/interfaces/pub-sub-client.interface.js +3 -0
- package/dist/lib/cjs/interfaces/pub-sub-client.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/secret-manager-client.interface.js +3 -0
- package/dist/lib/cjs/interfaces/secret-manager-client.interface.js.map +1 -0
- package/dist/lib/cjs/mappers/cloud-storage-event.mapper.js +87 -0
- package/dist/lib/cjs/mappers/cloud-storage-event.mapper.js.map +1 -0
- package/dist/lib/cjs/mappers/eventarc-event.mapper.js +84 -0
- package/dist/lib/cjs/mappers/eventarc-event.mapper.js.map +1 -0
- package/dist/lib/cjs/mappers/firestore-event.mapper.js +78 -0
- package/dist/lib/cjs/mappers/firestore-event.mapper.js.map +1 -0
- package/dist/lib/cjs/mappers/mappers.js +21 -0
- package/dist/lib/cjs/mappers/mappers.js.map +1 -0
- package/dist/lib/cjs/mappers/pub-sub-event.mapper.js +78 -0
- package/dist/lib/cjs/mappers/pub-sub-event.mapper.js.map +1 -0
- package/dist/lib/cjs/models/dynamic-collection-name.model.js +11 -0
- package/dist/lib/cjs/models/dynamic-collection-name.model.js.map +1 -0
- package/dist/lib/cjs/models/eventarc-message.model.js +10 -0
- package/dist/lib/cjs/models/eventarc-message.model.js.map +1 -0
- package/dist/lib/cjs/models/models.js +20 -0
- package/dist/lib/cjs/models/models.js.map +1 -0
- package/dist/lib/cjs/models/pub-sub-message-sent-confirmation.model.js +11 -0
- package/dist/lib/cjs/models/pub-sub-message-sent-confirmation.model.js.map +1 -0
- package/dist/lib/cjs/models/pub-sub-message.model.js +11 -0
- package/dist/lib/cjs/models/pub-sub-message.model.js.map +1 -0
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/lib/esm/clients/clients.js +6 -0
- package/dist/lib/esm/clients/clients.js.map +1 -0
- package/dist/lib/esm/clients/cloud-storage.client.js +186 -0
- package/dist/lib/esm/clients/cloud-storage.client.js.map +1 -0
- package/dist/lib/esm/clients/eventarc.client.js +110 -0
- package/dist/lib/esm/clients/eventarc.client.js.map +1 -0
- package/dist/lib/esm/clients/firestore.client.js +235 -0
- package/dist/lib/esm/clients/firestore.client.js.map +1 -0
- package/dist/lib/esm/clients/pub-sub.client.js +94 -0
- package/dist/lib/esm/clients/pub-sub.client.js.map +1 -0
- package/dist/lib/esm/clients/secret-manager.client.js +115 -0
- package/dist/lib/esm/clients/secret-manager.client.js.map +1 -0
- package/dist/lib/esm/decorators/decorators.js +2 -0
- package/dist/lib/esm/decorators/decorators.js.map +1 -0
- package/dist/lib/esm/decorators/dynamic-collection-name.decorator.js +29 -0
- package/dist/lib/esm/decorators/dynamic-collection-name.decorator.js.map +1 -0
- package/dist/lib/esm/enums/cloud-storage-event-type.enum.js +13 -0
- package/dist/lib/esm/enums/cloud-storage-event-type.enum.js.map +1 -0
- package/dist/lib/esm/enums/cloud-storage-presigned-operation-type.enum.js +10 -0
- package/dist/lib/esm/enums/cloud-storage-presigned-operation-type.enum.js.map +1 -0
- package/dist/lib/esm/enums/enums.js +6 -0
- package/dist/lib/esm/enums/enums.js.map +1 -0
- package/dist/lib/esm/enums/eventarc-event-type.enum.js +9 -0
- package/dist/lib/esm/enums/eventarc-event-type.enum.js.map +1 -0
- package/dist/lib/esm/enums/firestore-event-type.enum.js +13 -0
- package/dist/lib/esm/enums/firestore-event-type.enum.js.map +1 -0
- package/dist/lib/esm/enums/pub-sub-event-type.enum.js +10 -0
- package/dist/lib/esm/enums/pub-sub-event-type.enum.js.map +1 -0
- package/dist/lib/esm/errors/errors.js +4 -0
- package/dist/lib/esm/errors/errors.js.map +1 -0
- package/dist/lib/esm/errors/eventarc-publish.error.js +13 -0
- package/dist/lib/esm/errors/eventarc-publish.error.js.map +1 -0
- package/dist/lib/esm/errors/get-secret.error.js +13 -0
- package/dist/lib/esm/errors/get-secret.error.js.map +1 -0
- package/dist/lib/esm/errors/pub-sub-publish.error.js +15 -0
- package/dist/lib/esm/errors/pub-sub-publish.error.js.map +1 -0
- package/dist/lib/esm/event-payloads/cloud-storage.event-payload.js +7 -0
- package/dist/lib/esm/event-payloads/cloud-storage.event-payload.js.map +1 -0
- package/dist/lib/esm/event-payloads/event-payloads.js +5 -0
- package/dist/lib/esm/event-payloads/event-payloads.js.map +1 -0
- package/dist/lib/esm/event-payloads/eventarc.event-payload.js +7 -0
- package/dist/lib/esm/event-payloads/eventarc.event-payload.js.map +1 -0
- package/dist/lib/esm/event-payloads/firestore.event-payload.js +7 -0
- package/dist/lib/esm/event-payloads/firestore.event-payload.js.map +1 -0
- package/dist/lib/esm/event-payloads/pub-sub.event-payload.js +13 -0
- package/dist/lib/esm/event-payloads/pub-sub.event-payload.js.map +1 -0
- package/dist/lib/esm/gcp.configuration-keys.js +17 -0
- package/dist/lib/esm/gcp.configuration-keys.js.map +1 -0
- package/dist/lib/esm/gcp.module.js +59 -0
- package/dist/lib/esm/gcp.module.js.map +1 -0
- package/dist/lib/esm/gcp.module.keyname.js +2 -0
- package/dist/lib/esm/gcp.module.keyname.js.map +1 -0
- package/dist/lib/esm/interfaces/client-options.interface.js +2 -0
- package/dist/lib/esm/interfaces/client-options.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/cloud-storage-client.interface.js +2 -0
- package/dist/lib/esm/interfaces/cloud-storage-client.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/eventarc-client.interface.js +2 -0
- package/dist/lib/esm/interfaces/eventarc-client.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/firestore-client.interface.js +2 -0
- package/dist/lib/esm/interfaces/firestore-client.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/interfaces.js +7 -0
- package/dist/lib/esm/interfaces/interfaces.js.map +1 -0
- package/dist/lib/esm/interfaces/pub-sub-client.interface.js +2 -0
- package/dist/lib/esm/interfaces/pub-sub-client.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/secret-manager-client.interface.js +2 -0
- package/dist/lib/esm/interfaces/secret-manager-client.interface.js.map +1 -0
- package/dist/lib/esm/mappers/cloud-storage-event.mapper.js +84 -0
- package/dist/lib/esm/mappers/cloud-storage-event.mapper.js.map +1 -0
- package/dist/lib/esm/mappers/eventarc-event.mapper.js +81 -0
- package/dist/lib/esm/mappers/eventarc-event.mapper.js.map +1 -0
- package/dist/lib/esm/mappers/firestore-event.mapper.js +75 -0
- package/dist/lib/esm/mappers/firestore-event.mapper.js.map +1 -0
- package/dist/lib/esm/mappers/mappers.js +5 -0
- package/dist/lib/esm/mappers/mappers.js.map +1 -0
- package/dist/lib/esm/mappers/pub-sub-event.mapper.js +75 -0
- package/dist/lib/esm/mappers/pub-sub-event.mapper.js.map +1 -0
- package/dist/lib/esm/models/dynamic-collection-name.model.js +7 -0
- package/dist/lib/esm/models/dynamic-collection-name.model.js.map +1 -0
- package/dist/lib/esm/models/eventarc-message.model.js +6 -0
- package/dist/lib/esm/models/eventarc-message.model.js.map +1 -0
- package/dist/lib/esm/models/models.js +4 -0
- package/dist/lib/esm/models/models.js.map +1 -0
- package/dist/lib/esm/models/pub-sub-message-sent-confirmation.model.js +7 -0
- package/dist/lib/esm/models/pub-sub-message-sent-confirmation.model.js.map +1 -0
- package/dist/lib/esm/models/pub-sub-message.model.js +7 -0
- package/dist/lib/esm/models/pub-sub-message.model.js.map +1 -0
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/types/clients/clients.d.ts +5 -0
- package/dist/types/clients/cloud-storage.client.d.ts +26 -0
- package/dist/types/clients/eventarc.client.d.ts +26 -0
- package/dist/types/clients/firestore.client.d.ts +47 -0
- package/dist/types/clients/pub-sub.client.d.ts +23 -0
- package/dist/types/clients/secret-manager.client.d.ts +24 -0
- package/dist/types/decorators/decorators.d.ts +1 -0
- package/dist/types/decorators/dynamic-collection-name.decorator.d.ts +22 -0
- package/dist/types/enums/cloud-storage-event-type.enum.d.ts +11 -0
- package/dist/types/enums/cloud-storage-presigned-operation-type.enum.d.ts +8 -0
- package/dist/types/enums/enums.d.ts +5 -0
- package/dist/types/enums/eventarc-event-type.enum.d.ts +7 -0
- package/dist/types/enums/firestore-event-type.enum.d.ts +11 -0
- package/dist/types/enums/pub-sub-event-type.enum.d.ts +8 -0
- package/dist/types/errors/errors.d.ts +3 -0
- package/dist/types/errors/eventarc-publish.error.d.ts +8 -0
- package/dist/types/errors/get-secret.error.d.ts +8 -0
- package/dist/types/errors/pub-sub-publish.error.d.ts +14 -0
- package/dist/types/event-payloads/cloud-storage.event-payload.d.ts +55 -0
- package/dist/types/event-payloads/event-payloads.d.ts +4 -0
- package/dist/types/event-payloads/eventarc.event-payload.d.ts +39 -0
- package/dist/types/event-payloads/firestore.event-payload.d.ts +43 -0
- package/dist/types/event-payloads/pub-sub.event-payload.d.ts +37 -0
- package/dist/types/gcp.configuration-keys.d.ts +35 -0
- package/dist/types/gcp.module.d.ts +11 -0
- package/dist/types/gcp.module.keyname.d.ts +1 -0
- package/dist/types/interfaces/client-options.interface.d.ts +19 -0
- package/dist/types/interfaces/cloud-storage-client.interface.d.ts +14 -0
- package/dist/types/interfaces/eventarc-client.interface.d.ts +5 -0
- package/dist/types/interfaces/firestore-client.interface.d.ts +27 -0
- package/dist/types/interfaces/interfaces.d.ts +6 -0
- package/dist/types/interfaces/pub-sub-client.interface.d.ts +8 -0
- package/dist/types/interfaces/secret-manager-client.interface.d.ts +9 -0
- package/dist/types/mappers/cloud-storage-event.mapper.d.ts +22 -0
- package/dist/types/mappers/eventarc-event.mapper.d.ts +22 -0
- package/dist/types/mappers/firestore-event.mapper.d.ts +17 -0
- package/dist/types/mappers/mappers.d.ts +4 -0
- package/dist/types/mappers/pub-sub-event.mapper.d.ts +23 -0
- package/dist/types/models/dynamic-collection-name.model.d.ts +8 -0
- package/dist/types/models/eventarc-message.model.d.ts +25 -0
- package/dist/types/models/models.d.ts +3 -0
- package/dist/types/models/pub-sub-message-sent-confirmation.model.d.ts +7 -0
- package/dist/types/models/pub-sub-message.model.d.ts +21 -0
- package/package.json +72 -0
- package/readme.md +32 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.FirestoreClient = void 0;
|
|
26
|
+
const tsyringe_1 = require("tsyringe");
|
|
27
|
+
const common_1 = require("@pristine-ts/common");
|
|
28
|
+
const firestore_1 = require("@google-cloud/firestore");
|
|
29
|
+
const gcp_module_keyname_1 = require("../gcp.module.keyname");
|
|
30
|
+
const gcp_configuration_keys_1 = require("../gcp.configuration-keys");
|
|
31
|
+
/**
|
|
32
|
+
* Client for Google Cloud Firestore (Native mode). Provides typed CRUD against a
|
|
33
|
+
* model class plus a `findBySecondaryIndex` for indexed field-equality lookups.
|
|
34
|
+
*
|
|
35
|
+
* Document↔object mapping uses the class name (lowercased) as the collection key;
|
|
36
|
+
* fields are persisted verbatim via property copy. A typed decorator-based mapper
|
|
37
|
+
* (`@firestoreCollection` / `@firestoreField`) is a future extension.
|
|
38
|
+
*/
|
|
39
|
+
let FirestoreClient = class FirestoreClient {
|
|
40
|
+
constructor(logHandler, projectId) {
|
|
41
|
+
this.logHandler = logHandler;
|
|
42
|
+
this.projectId = projectId;
|
|
43
|
+
}
|
|
44
|
+
getClient() {
|
|
45
|
+
var _a;
|
|
46
|
+
return this.client = (_a = this.client) !== null && _a !== void 0 ? _a : new firestore_1.Firestore({ projectId: this.projectId });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the Firestore collection name for a model class — the class name
|
|
50
|
+
* lowercased.
|
|
51
|
+
*/
|
|
52
|
+
getCollectionName(classType) {
|
|
53
|
+
return classType.name.toLowerCase();
|
|
54
|
+
}
|
|
55
|
+
get(classType, id) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const collection = this.getCollectionName(classType);
|
|
58
|
+
this.logHandler.debug("FirestoreClient: Getting document.", { extra: { collection, id } });
|
|
59
|
+
try {
|
|
60
|
+
const snapshot = yield this.getClient().collection(collection).doc(id).get();
|
|
61
|
+
if (snapshot.exists === false) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const instance = new classType();
|
|
65
|
+
Object.assign(instance, snapshot.data());
|
|
66
|
+
return instance;
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
this.logHandler.error("FirestoreClient: Error getting document.", { extra: { error: e, collection, id } });
|
|
70
|
+
throw e;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
list(classType, options) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
var _a;
|
|
77
|
+
const collection = this.getCollectionName(classType);
|
|
78
|
+
this.logHandler.debug("FirestoreClient: Listing documents.", { extra: { collection, options } });
|
|
79
|
+
try {
|
|
80
|
+
let query = this.getClient().collection(collection).limit((_a = options === null || options === void 0 ? void 0 : options.limit) !== null && _a !== void 0 ? _a : 100);
|
|
81
|
+
if ((options === null || options === void 0 ? void 0 : options.startAfter) !== undefined) {
|
|
82
|
+
query = query.startAfter(options.startAfter);
|
|
83
|
+
}
|
|
84
|
+
const snapshot = yield query.get();
|
|
85
|
+
return snapshot.docs.map((doc) => {
|
|
86
|
+
const instance = new classType();
|
|
87
|
+
Object.assign(instance, doc.data());
|
|
88
|
+
return instance;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
this.logHandler.error("FirestoreClient: Error listing documents.", { extra: { error: e, collection } });
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
create(item) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const collection = this.getCollectionName(item.constructor);
|
|
100
|
+
const id = item.id;
|
|
101
|
+
this.logHandler.debug("FirestoreClient: Creating document.", { extra: { collection, id } });
|
|
102
|
+
try {
|
|
103
|
+
const docRef = id ? this.getClient().collection(collection).doc(id) : this.getClient().collection(collection).doc();
|
|
104
|
+
yield docRef.create(Object.assign({}, item));
|
|
105
|
+
item.id = docRef.id;
|
|
106
|
+
return item;
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
this.logHandler.error("FirestoreClient: Error creating document.", { extra: { error: e, collection, id } });
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
update(item) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
const collection = this.getCollectionName(item.constructor);
|
|
117
|
+
const id = item.id;
|
|
118
|
+
this.logHandler.debug("FirestoreClient: Updating document.", { extra: { collection, id } });
|
|
119
|
+
try {
|
|
120
|
+
yield this.getClient().collection(collection).doc(id).update(Object.assign({}, item));
|
|
121
|
+
return item;
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
this.logHandler.error("FirestoreClient: Error updating document.", { extra: { error: e, collection, id } });
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
save(item) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const collection = this.getCollectionName(item.constructor);
|
|
132
|
+
const id = item.id;
|
|
133
|
+
this.logHandler.debug("FirestoreClient: Saving (upsert) document.", { extra: { collection, id } });
|
|
134
|
+
try {
|
|
135
|
+
const docRef = id ? this.getClient().collection(collection).doc(id) : this.getClient().collection(collection).doc();
|
|
136
|
+
yield docRef.set(Object.assign({}, item), { merge: true });
|
|
137
|
+
item.id = docRef.id;
|
|
138
|
+
return item;
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
this.logHandler.error("FirestoreClient: Error saving document.", { extra: { error: e, collection, id } });
|
|
142
|
+
throw e;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
delete(classType, id) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const collection = this.getCollectionName(classType);
|
|
149
|
+
this.logHandler.debug("FirestoreClient: Deleting document.", { extra: { collection, id } });
|
|
150
|
+
try {
|
|
151
|
+
yield this.getClient().collection(collection).doc(id).delete();
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
this.logHandler.error("FirestoreClient: Error deleting document.", { extra: { error: e, collection, id } });
|
|
155
|
+
throw e;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Find documents by a field-equality predicate. Firestore requires a composite index
|
|
161
|
+
* for compound queries; for the single-field case this returns immediately.
|
|
162
|
+
*/
|
|
163
|
+
findBySecondaryIndex(classType, field, value, options) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
var _a;
|
|
166
|
+
const collection = this.getCollectionName(classType);
|
|
167
|
+
this.logHandler.debug("FirestoreClient: Find by index.", { extra: { collection, field, value, options } });
|
|
168
|
+
try {
|
|
169
|
+
const snapshot = yield this.getClient()
|
|
170
|
+
.collection(collection)
|
|
171
|
+
.where(field, "==", value)
|
|
172
|
+
.limit((_a = options === null || options === void 0 ? void 0 : options.limit) !== null && _a !== void 0 ? _a : 100)
|
|
173
|
+
.get();
|
|
174
|
+
return snapshot.docs.map((doc) => {
|
|
175
|
+
const instance = new classType();
|
|
176
|
+
Object.assign(instance, doc.data());
|
|
177
|
+
return instance;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
this.logHandler.error("FirestoreClient: Error in findBySecondaryIndex.", { extra: { error: e, collection, field } });
|
|
182
|
+
throw e;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
exports.FirestoreClient = FirestoreClient;
|
|
188
|
+
__decorate([
|
|
189
|
+
(0, common_1.traced)(),
|
|
190
|
+
__metadata("design:type", Function),
|
|
191
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
192
|
+
__metadata("design:returntype", Promise)
|
|
193
|
+
], FirestoreClient.prototype, "get", null);
|
|
194
|
+
__decorate([
|
|
195
|
+
(0, common_1.traced)(),
|
|
196
|
+
__metadata("design:type", Function),
|
|
197
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
198
|
+
__metadata("design:returntype", Promise)
|
|
199
|
+
], FirestoreClient.prototype, "list", null);
|
|
200
|
+
__decorate([
|
|
201
|
+
(0, common_1.traced)(),
|
|
202
|
+
__metadata("design:type", Function),
|
|
203
|
+
__metadata("design:paramtypes", [typeof (_a = typeof T !== "undefined" && T) === "function" ? _a : Object]),
|
|
204
|
+
__metadata("design:returntype", Promise)
|
|
205
|
+
], FirestoreClient.prototype, "create", null);
|
|
206
|
+
__decorate([
|
|
207
|
+
(0, common_1.traced)(),
|
|
208
|
+
__metadata("design:type", Function),
|
|
209
|
+
__metadata("design:paramtypes", [typeof (_b = typeof T !== "undefined" && T) === "function" ? _b : Object]),
|
|
210
|
+
__metadata("design:returntype", Promise)
|
|
211
|
+
], FirestoreClient.prototype, "update", null);
|
|
212
|
+
__decorate([
|
|
213
|
+
(0, common_1.traced)(),
|
|
214
|
+
__metadata("design:type", Function),
|
|
215
|
+
__metadata("design:paramtypes", [typeof (_c = typeof T !== "undefined" && T) === "function" ? _c : Object]),
|
|
216
|
+
__metadata("design:returntype", Promise)
|
|
217
|
+
], FirestoreClient.prototype, "save", null);
|
|
218
|
+
__decorate([
|
|
219
|
+
(0, common_1.traced)(),
|
|
220
|
+
__metadata("design:type", Function),
|
|
221
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
222
|
+
__metadata("design:returntype", Promise)
|
|
223
|
+
], FirestoreClient.prototype, "delete", null);
|
|
224
|
+
__decorate([
|
|
225
|
+
(0, common_1.traced)(),
|
|
226
|
+
__metadata("design:type", Function),
|
|
227
|
+
__metadata("design:paramtypes", [Object, String, Object, Object]),
|
|
228
|
+
__metadata("design:returntype", Promise)
|
|
229
|
+
], FirestoreClient.prototype, "findBySecondaryIndex", null);
|
|
230
|
+
exports.FirestoreClient = FirestoreClient = __decorate([
|
|
231
|
+
(0, common_1.tag)("FirestoreClientInterface"),
|
|
232
|
+
(0, common_1.moduleScoped)(gcp_module_keyname_1.GcpModuleKeyname),
|
|
233
|
+
(0, tsyringe_1.injectable)(),
|
|
234
|
+
__param(0, (0, tsyringe_1.inject)("LogHandlerInterface")),
|
|
235
|
+
__param(1, (0, common_1.injectConfig)(gcp_configuration_keys_1.GcpConfigurationKeys.ProjectId)),
|
|
236
|
+
__metadata("design:paramtypes", [Object, String])
|
|
237
|
+
], FirestoreClient);
|
|
238
|
+
//# sourceMappingURL=firestore.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore.client.js","sourceRoot":"","sources":["../../../../src/clients/firestore.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gDAA4E;AAE5E,uDAAkD;AAClD,8DAAuD;AACvD,sEAA+D;AAG/D;;;;;;;GAOG;AAII,IAAM,eAAe,GAArB,MAAM,eAAe;IAG1B,YACkD,UAA+B,EAChB,SAAiB;QADhC,eAAU,GAAV,UAAU,CAAqB;QAChB,cAAS,GAAT,SAAS,CAAQ;IAElF,CAAC;IAED,SAAS;;QACP,OAAO,IAAI,CAAC,MAAM,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,qBAAS,CAAC,EAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAC,CAAC,CAAC;IACjF,CAAC;IAED;;;OAGG;IACK,iBAAiB,CAAI,SAAuB;QAClD,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAGK,GAAG,CAAI,SAAuB,EAAE,EAAU;;YAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YACrD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAC,KAAK,EAAE,EAAC,UAAU,EAAE,EAAE,EAAC,EAAC,CAAC,CAAC;YACvF,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,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oBAAD,CAAC;;6CAWtB;AAGK;IADL,IAAA,eAAM,GAAE;;yDACW,CAAC,oBAAD,CAAC;;2CAapB;AAGK;IADL,IAAA,eAAM,GAAE;;;;6CAUR;AAOK;IADL,IAAA,eAAM,GAAE;;;;2DAmBR;0BA7IU,eAAe;IAH3B,IAAA,YAAG,EAAC,0BAA0B,CAAC;IAC/B,IAAA,qBAAY,EAAC,qCAAgB,CAAC;IAC9B,IAAA,qBAAU,GAAE;IAKR,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,qBAAY,EAAC,6CAAoB,CAAC,SAAS,CAAC,CAAA;;GALpC,eAAe,CA8I3B"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.PubSubClient = void 0;
|
|
25
|
+
const tsyringe_1 = require("tsyringe");
|
|
26
|
+
const common_1 = require("@pristine-ts/common");
|
|
27
|
+
const pubsub_1 = require("@google-cloud/pubsub");
|
|
28
|
+
const gcp_module_keyname_1 = require("../gcp.module.keyname");
|
|
29
|
+
const gcp_configuration_keys_1 = require("../gcp.configuration-keys");
|
|
30
|
+
const pub_sub_message_model_1 = require("../models/pub-sub-message.model");
|
|
31
|
+
const pub_sub_publish_error_1 = require("../errors/pub-sub-publish.error");
|
|
32
|
+
/**
|
|
33
|
+
* Client for Google Cloud Pub/Sub. Mirrors `SqsClient` (publish-side) and the topic
|
|
34
|
+
* half of EventBridge in `@pristine-ts/aws`.
|
|
35
|
+
*/
|
|
36
|
+
let PubSubClient = class PubSubClient {
|
|
37
|
+
constructor(logHandler, projectId) {
|
|
38
|
+
this.logHandler = logHandler;
|
|
39
|
+
this.projectId = projectId;
|
|
40
|
+
}
|
|
41
|
+
getClient() {
|
|
42
|
+
var _a;
|
|
43
|
+
return this.client = (_a = this.client) !== null && _a !== void 0 ? _a : new pubsub_1.PubSub({ projectId: this.projectId });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Publishes a single message to a topic. `topic` accepts either a bare topic name
|
|
47
|
+
* (e.g. `"my-topic"`) or a fully-qualified resource name
|
|
48
|
+
* (`"projects/my-proj/topics/my-topic"`).
|
|
49
|
+
*/
|
|
50
|
+
publish(topic, message, options) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
this.logHandler.debug("PubSubClient: Publishing message.", {
|
|
53
|
+
extra: { topic, attributes: message.attributes, orderingKey: message.orderingKey },
|
|
54
|
+
eventId: options === null || options === void 0 ? void 0 : options.eventId,
|
|
55
|
+
eventGroupId: options === null || options === void 0 ? void 0 : options.eventGroupId,
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
const data = typeof message.data === "string" ? Buffer.from(message.data) : message.data;
|
|
59
|
+
const messageId = yield this.getClient().topic(topic).publishMessage({
|
|
60
|
+
data,
|
|
61
|
+
attributes: message.attributes,
|
|
62
|
+
orderingKey: message.orderingKey,
|
|
63
|
+
});
|
|
64
|
+
this.logHandler.debug("PubSubClient: Message published.", {
|
|
65
|
+
extra: { topic, messageId },
|
|
66
|
+
eventId: options === null || options === void 0 ? void 0 : options.eventId,
|
|
67
|
+
eventGroupId: options === null || options === void 0 ? void 0 : options.eventGroupId,
|
|
68
|
+
});
|
|
69
|
+
return { messageId };
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this.logHandler.error("PubSubClient: Failed to publish message.", {
|
|
73
|
+
extra: { error, topic, attributes: message.attributes },
|
|
74
|
+
eventId: options === null || options === void 0 ? void 0 : options.eventId,
|
|
75
|
+
eventGroupId: options === null || options === void 0 ? void 0 : options.eventGroupId,
|
|
76
|
+
});
|
|
77
|
+
throw new pub_sub_publish_error_1.PubSubPublishError(error, topic, message.attributes);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.PubSubClient = PubSubClient;
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, common_1.traced)(),
|
|
85
|
+
__metadata("design:type", Function),
|
|
86
|
+
__metadata("design:paramtypes", [String, pub_sub_message_model_1.PubSubMessageModel, Object]),
|
|
87
|
+
__metadata("design:returntype", Promise)
|
|
88
|
+
], PubSubClient.prototype, "publish", null);
|
|
89
|
+
exports.PubSubClient = PubSubClient = __decorate([
|
|
90
|
+
(0, common_1.tag)("PubSubClientInterface"),
|
|
91
|
+
(0, common_1.moduleScoped)(gcp_module_keyname_1.GcpModuleKeyname),
|
|
92
|
+
(0, tsyringe_1.injectable)(),
|
|
93
|
+
__param(0, (0, tsyringe_1.inject)("LogHandlerInterface")),
|
|
94
|
+
__param(1, (0, common_1.injectConfig)(gcp_configuration_keys_1.GcpConfigurationKeys.ProjectId)),
|
|
95
|
+
__metadata("design:paramtypes", [Object, String])
|
|
96
|
+
], PubSubClient);
|
|
97
|
+
//# sourceMappingURL=pub-sub.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pub-sub.client.js","sourceRoot":"","sources":["../../../../src/clients/pub-sub.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gDAA4E;AAE5E,iDAA4C;AAC5C,8DAAuD;AACvD,sEAA+D;AAE/D,2EAAmE;AAEnE,2EAAmE;AAGnE;;;GAGG;AAII,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGvB,YACkD,UAA+B,EAChB,SAAiB;QADhC,eAAU,GAAV,UAAU,CAAqB;QAChB,cAAS,GAAT,SAAS,CAAQ;IAElF,CAAC;IAED,SAAS;;QACP,OAAO,IAAI,CAAC,MAAM,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,eAAM,CAAC,EAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAC,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IAEG,OAAO,CACX,KAAa,EACb,OAA2B,EAC3B,OAA4C;;YAE5C,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,mCAAmC,EAAE;gBACzD,KAAK,EAAE,EAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAC;gBAChF,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO;gBACzB,YAAY,E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,IAAA,eAAM,GAAE;;6CAGE,0CAAkB;;2CA6B5B;uBAlDU,YAAY;IAHxB,IAAA,YAAG,EAAC,uBAAuB,CAAC;IAC5B,IAAA,qBAAY,EAAC,qCAAgB,CAAC;IAC9B,IAAA,qBAAU,GAAE;IAKR,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,qBAAY,EAAC,6CAAoB,CAAC,SAAS,CAAC,CAAA;;GALpC,YAAY,CAmDxB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.SecretManagerClient = void 0;
|
|
25
|
+
const tsyringe_1 = require("tsyringe");
|
|
26
|
+
const common_1 = require("@pristine-ts/common");
|
|
27
|
+
const secret_manager_1 = require("@google-cloud/secret-manager");
|
|
28
|
+
const gcp_module_keyname_1 = require("../gcp.module.keyname");
|
|
29
|
+
const gcp_configuration_keys_1 = require("../gcp.configuration-keys");
|
|
30
|
+
const get_secret_error_1 = require("../errors/get-secret.error");
|
|
31
|
+
/**
|
|
32
|
+
* Client for Google Cloud Secret Manager. Mirrors `SecretsManagerClient`.
|
|
33
|
+
*
|
|
34
|
+
* `secretName` accepts either a bare secret id (e.g. `"my-secret"`, in which case the
|
|
35
|
+
* latest version of the secret in the configured project is fetched) or a fully
|
|
36
|
+
* qualified version resource name
|
|
37
|
+
* (`"projects/p/secrets/my-secret/versions/latest"`).
|
|
38
|
+
*/
|
|
39
|
+
let SecretManagerClient = class SecretManagerClient {
|
|
40
|
+
constructor(logHandler, projectId) {
|
|
41
|
+
this.logHandler = logHandler;
|
|
42
|
+
this.projectId = projectId;
|
|
43
|
+
}
|
|
44
|
+
getClient() {
|
|
45
|
+
var _a;
|
|
46
|
+
return this.client = (_a = this.client) !== null && _a !== void 0 ? _a : new secret_manager_1.SecretManagerServiceClient();
|
|
47
|
+
}
|
|
48
|
+
toVersionResourceName(secretName) {
|
|
49
|
+
if (secretName.startsWith("projects/")) {
|
|
50
|
+
return secretName;
|
|
51
|
+
}
|
|
52
|
+
return `projects/${this.projectId}/secrets/${secretName}/versions/latest`;
|
|
53
|
+
}
|
|
54
|
+
getSecret(secretName, options) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
var _a;
|
|
57
|
+
const name = this.toVersionResourceName(secretName);
|
|
58
|
+
try {
|
|
59
|
+
const [version] = yield this.getClient().accessSecretVersion({ name });
|
|
60
|
+
const payload = (_a = version.payload) === null || _a === void 0 ? void 0 : _a.data;
|
|
61
|
+
if (!payload) {
|
|
62
|
+
const message = `SecretManagerClient: No value for this parameter: '${secretName}'.`;
|
|
63
|
+
this.logHandler.error(message, { extra: { secretName } });
|
|
64
|
+
throw new get_secret_error_1.GetSecretError(message);
|
|
65
|
+
}
|
|
66
|
+
const secretString = Buffer.isBuffer(payload) ? payload.toString("utf-8") : Buffer.from(payload).toString("utf-8");
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(secretString);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
const message = `SecretManagerClient: Couldn't parse the secret as a JSON object: '${secretName}'.`;
|
|
72
|
+
this.logHandler.error(message, { extra: { secretName } });
|
|
73
|
+
throw new get_secret_error_1.GetSecretError(message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
if (e instanceof get_secret_error_1.GetSecretError) {
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
this.logHandler.error("SecretManagerClient: Error accessing secret.", { extra: { error: e, secretName } });
|
|
81
|
+
throw new get_secret_error_1.GetSecretError(`SecretManagerClient: Error accessing secret '${secretName}': ${e.message}`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
getSecretKey(secretName, key, options) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const secret = yield this.getSecret(secretName, options);
|
|
88
|
+
if (secret.hasOwnProperty(key) === false) {
|
|
89
|
+
const message = `SecretManagerClient: Cannot find jsonKey '${key}' in the secret: '${secretName}'.`;
|
|
90
|
+
this.logHandler.error(message, { extra: { secretName, key } });
|
|
91
|
+
throw new get_secret_error_1.GetSecretError(message);
|
|
92
|
+
}
|
|
93
|
+
return secret[key];
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.SecretManagerClient = SecretManagerClient;
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, common_1.traced)(),
|
|
100
|
+
__metadata("design:type", Function),
|
|
101
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
102
|
+
__metadata("design:returntype", Promise)
|
|
103
|
+
], SecretManagerClient.prototype, "getSecret", null);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, common_1.traced)(),
|
|
106
|
+
__metadata("design:type", Function),
|
|
107
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
108
|
+
__metadata("design:returntype", Promise)
|
|
109
|
+
], SecretManagerClient.prototype, "getSecretKey", null);
|
|
110
|
+
exports.SecretManagerClient = SecretManagerClient = __decorate([
|
|
111
|
+
(0, common_1.tag)("SecretManagerClientInterface"),
|
|
112
|
+
(0, common_1.moduleScoped)(gcp_module_keyname_1.GcpModuleKeyname),
|
|
113
|
+
(0, tsyringe_1.injectable)(),
|
|
114
|
+
__param(0, (0, tsyringe_1.inject)("LogHandlerInterface")),
|
|
115
|
+
__param(1, (0, common_1.injectConfig)(gcp_configuration_keys_1.GcpConfigurationKeys.ProjectId)),
|
|
116
|
+
__metadata("design:paramtypes", [Object, String])
|
|
117
|
+
], SecretManagerClient);
|
|
118
|
+
//# sourceMappingURL=secret-manager.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-manager.client.js","sourceRoot":"","sources":["../../../../src/clients/secret-manager.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,gDAA4E;AAE5E,iEAAwE;AACxE,8DAAuD;AACvD,sEAA+D;AAG/D,iEAA0D;AAE1D;;;;;;;GAOG;AAII,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG9B,YACkD,UAA+B,EAChB,SAAiB;QADhC,eAAU,GAAV,UAAU,CAAqB;QAChB,cAAS,GAAT,SAAS,CAAQ;IAElF,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B;IAH/B,IAAA,YAAG,EAAC,8BAA8B,CAAC;IACnC,IAAA,qBAAY,EAAC,qCAAgB,CAAC;IAC9B,IAAA,qBAAU,GAAE;IAKR,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,qBAAY,EAAC,6CAAoB,CAAC,SAAS,CAAC,CAAA;;GALpC,mBAAmB,CA0D/B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dynamic-collection-name.decorator"), exports);
|
|
18
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/decorators/decorators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamicCollectionName = exports.dynamicCollectionNameRegistry = exports.FirestoreCollection = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Symbol used to stamp the resolved Firestore collection name onto a class prototype.
|
|
6
|
+
* Mirrors `DynamoDbTable` from `@awslabs-community-fork/dynamodb-data-mapper`.
|
|
7
|
+
*/
|
|
8
|
+
exports.FirestoreCollection = Symbol("FirestoreCollection");
|
|
9
|
+
/**
|
|
10
|
+
* The registry where the Firestore collection names are saved.
|
|
11
|
+
*/
|
|
12
|
+
exports.dynamicCollectionNameRegistry = [];
|
|
13
|
+
/**
|
|
14
|
+
* This decorator is placed on a class that will be used with Firestore.
|
|
15
|
+
* It registers the class against a configuration token name; during `GcpModule.afterInit`,
|
|
16
|
+
* the token is resolved from the DI container (or from an environment variable as a
|
|
17
|
+
* fallback) and the resulting collection name is stamped onto the class prototype under
|
|
18
|
+
* the `FirestoreCollection` symbol.
|
|
19
|
+
*
|
|
20
|
+
* Mirrors `@dynamicTableName` in `@pristine-ts/aws`.
|
|
21
|
+
*
|
|
22
|
+
* @param name The container token whose value is the Firestore collection name.
|
|
23
|
+
*/
|
|
24
|
+
const dynamicCollectionName = (name) => {
|
|
25
|
+
return (constructor) => {
|
|
26
|
+
exports.dynamicCollectionNameRegistry.push({
|
|
27
|
+
tokenName: name,
|
|
28
|
+
classConstructor: constructor,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.dynamicCollectionName = dynamicCollectionName;
|
|
33
|
+
//# sourceMappingURL=dynamic-collection-name.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-collection-name.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/dynamic-collection-name.decorator.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,mBAAmB,GAAkB,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAEhF;;GAEG;AACU,QAAA,6BAA6B,GAAiC,EAAE,CAAC;AAE9E;;;;;;;;;;GAUG;AACI,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,EAAE;IACpD,OAAO,CAAC,WAAgB,EAAE,EAAE;QAC1B,qCAA6B,CAAC,IAAI,CAAC;YACjC,SAAS,EAAE,IAAI;YACf,gBAAgB,EAAE,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudStorageEventType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Event types coming from GCP Cloud Storage object change events delivered via CloudEvents.
|
|
6
|
+
* CloudEvent `type` values map 1:1 with these enum values.
|
|
7
|
+
*/
|
|
8
|
+
var CloudStorageEventType;
|
|
9
|
+
(function (CloudStorageEventType) {
|
|
10
|
+
CloudStorageEventType["UnknownCloudStorageEvent"] = "UnknownCloudStorageEvent";
|
|
11
|
+
CloudStorageEventType["ObjectFinalized"] = "google.cloud.storage.object.v1.finalized";
|
|
12
|
+
CloudStorageEventType["ObjectDeleted"] = "google.cloud.storage.object.v1.deleted";
|
|
13
|
+
CloudStorageEventType["ObjectArchived"] = "google.cloud.storage.object.v1.archived";
|
|
14
|
+
CloudStorageEventType["ObjectMetadataUpdated"] = "google.cloud.storage.object.v1.metadataUpdated";
|
|
15
|
+
})(CloudStorageEventType || (exports.CloudStorageEventType = CloudStorageEventType = {}));
|
|
16
|
+
//# sourceMappingURL=cloud-storage-event-type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-storage-event-type.enum.js","sourceRoot":"","sources":["../../../../src/enums/cloud-storage-event-type.enum.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,qBAMX;AAND,WAAY,qBAAqB;IAC/B,8EAAqD,CAAA;IACrD,qFAA4D,CAAA;IAC5D,iFAAwD,CAAA;IACxD,mFAA0D,CAAA;IAC1D,iGAAwE,CAAA;AAC1E,CAAC,EANW,qBAAqB,qCAArB,qBAAqB,QAMhC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudStoragePresignedOperationTypeEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The operation a signed URL grants on a Cloud Storage object. Mirrors
|
|
6
|
+
* `S3PresignedOperationTypeEnum` in `@pristine-ts/aws`.
|
|
7
|
+
*/
|
|
8
|
+
var CloudStoragePresignedOperationTypeEnum;
|
|
9
|
+
(function (CloudStoragePresignedOperationTypeEnum) {
|
|
10
|
+
CloudStoragePresignedOperationTypeEnum["Read"] = "read";
|
|
11
|
+
CloudStoragePresignedOperationTypeEnum["Write"] = "write";
|
|
12
|
+
})(CloudStoragePresignedOperationTypeEnum || (exports.CloudStoragePresignedOperationTypeEnum = CloudStoragePresignedOperationTypeEnum = {}));
|
|
13
|
+
//# sourceMappingURL=cloud-storage-presigned-operation-type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-storage-presigned-operation-type.enum.js","sourceRoot":"","sources":["../../../../src/enums/cloud-storage-presigned-operation-type.enum.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,sCAGX;AAHD,WAAY,sCAAsC;IAChD,uDAAa,CAAA;IACb,yDAAe,CAAA;AACjB,CAAC,EAHW,sCAAsC,sDAAtC,sCAAsC,QAGjD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cloud-storage-event-type.enum"), exports);
|
|
18
|
+
__exportStar(require("./cloud-storage-presigned-operation-type.enum"), exports);
|
|
19
|
+
__exportStar(require("./eventarc-event-type.enum"), exports);
|
|
20
|
+
__exportStar(require("./firestore-event-type.enum"), exports);
|
|
21
|
+
__exportStar(require("./pub-sub-event-type.enum"), exports);
|
|
22
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,gFAA8D;AAC9D,6DAA2C;AAC3C,8DAA4C;AAC5C,4DAA0C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventarcEventType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Event types from Eventarc / generic CloudEvents that aren't claimed by a more
|
|
6
|
+
* specific mapper. The mapper falls through to `EventarcEvent`.
|
|
7
|
+
*/
|
|
8
|
+
var EventarcEventType;
|
|
9
|
+
(function (EventarcEventType) {
|
|
10
|
+
EventarcEventType["EventarcEvent"] = "EVENTARC_EVENT";
|
|
11
|
+
})(EventarcEventType || (exports.EventarcEventType = EventarcEventType = {}));
|
|
12
|
+
//# sourceMappingURL=eventarc-event-type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventarc-event-type.enum.js","sourceRoot":"","sources":["../../../../src/enums/eventarc-event-type.enum.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,qDAAgC,CAAA;AAClC,CAAC,EAFW,iBAAiB,iCAAjB,iBAAiB,QAE5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirestoreEventType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Event types coming from GCP Firestore document change events delivered via CloudEvents.
|
|
6
|
+
* CloudEvent `type` values map 1:1 with these enum values.
|
|
7
|
+
*/
|
|
8
|
+
var FirestoreEventType;
|
|
9
|
+
(function (FirestoreEventType) {
|
|
10
|
+
FirestoreEventType["UnknownFirestoreEvent"] = "UnknownFirestoreEvent";
|
|
11
|
+
FirestoreEventType["DocumentCreated"] = "google.cloud.firestore.document.v1.created";
|
|
12
|
+
FirestoreEventType["DocumentUpdated"] = "google.cloud.firestore.document.v1.updated";
|
|
13
|
+
FirestoreEventType["DocumentDeleted"] = "google.cloud.firestore.document.v1.deleted";
|
|
14
|
+
FirestoreEventType["DocumentWritten"] = "google.cloud.firestore.document.v1.written";
|
|
15
|
+
})(FirestoreEventType || (exports.FirestoreEventType = FirestoreEventType = {}));
|
|
16
|
+
//# sourceMappingURL=firestore-event-type.enum.js.map
|