@pristine-ts/gcp-functions 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/enums/enums.js +19 -0
- package/dist/lib/cjs/enums/enums.js.map +1 -0
- package/dist/lib/cjs/enums/gcp-functions-event-type.enum.js +17 -0
- package/dist/lib/cjs/enums/gcp-functions-event-type.enum.js.map +1 -0
- package/dist/lib/cjs/enums/gcp-functions-events-handling-strategy.enum.js +15 -0
- package/dist/lib/cjs/enums/gcp-functions-events-handling-strategy.enum.js.map +1 -0
- package/dist/lib/cjs/event-payloads/cloud-function-gen-1-http.event-payload.js +19 -0
- package/dist/lib/cjs/event-payloads/cloud-function-gen-1-http.event-payload.js.map +1 -0
- package/dist/lib/cjs/event-payloads/cloud-function-gen-2-http.event-payload.js +21 -0
- package/dist/lib/cjs/event-payloads/cloud-function-gen-2-http.event-payload.js.map +1 -0
- package/dist/lib/cjs/event-payloads/cloud-run-http.event-payload.js +19 -0
- package/dist/lib/cjs/event-payloads/cloud-run-http.event-payload.js.map +1 -0
- package/dist/lib/cjs/event-payloads/event-payloads.js +20 -0
- package/dist/lib/cjs/event-payloads/event-payloads.js.map +1 -0
- package/dist/lib/cjs/event-response-payloads/event-response-payloads.js +18 -0
- package/dist/lib/cjs/event-response-payloads/event-response-payloads.js.map +1 -0
- package/dist/lib/cjs/event-response-payloads/gcp-functions-http.event-response-payload.js +23 -0
- package/dist/lib/cjs/event-response-payloads/gcp-functions-http.event-response-payload.js.map +1 -0
- package/dist/lib/cjs/gcp-functions.configuration-keys.js +14 -0
- package/dist/lib/cjs/gcp-functions.configuration-keys.js.map +1 -0
- package/dist/lib/cjs/gcp-functions.module.js +62 -0
- package/dist/lib/cjs/gcp-functions.module.js.map +1 -0
- package/dist/lib/cjs/gcp-functions.module.keyname.js +5 -0
- package/dist/lib/cjs/gcp-functions.module.keyname.js.map +1 -0
- package/dist/lib/cjs/mappers/base-gcp-http-event.mapper.js +106 -0
- package/dist/lib/cjs/mappers/base-gcp-http-event.mapper.js.map +1 -0
- package/dist/lib/cjs/mappers/cloud-function-gen-1-http-event.mapper.js +100 -0
- package/dist/lib/cjs/mappers/cloud-function-gen-1-http-event.mapper.js.map +1 -0
- package/dist/lib/cjs/mappers/cloud-function-gen-2-http-event.mapper.js +121 -0
- package/dist/lib/cjs/mappers/cloud-function-gen-2-http-event.mapper.js.map +1 -0
- package/dist/lib/cjs/mappers/cloud-run-http-event.mapper.js +85 -0
- package/dist/lib/cjs/mappers/cloud-run-http-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/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/lib/esm/enums/enums.js +3 -0
- package/dist/lib/esm/enums/enums.js.map +1 -0
- package/dist/lib/esm/enums/gcp-functions-event-type.enum.js +14 -0
- package/dist/lib/esm/enums/gcp-functions-event-type.enum.js.map +1 -0
- package/dist/lib/esm/enums/gcp-functions-events-handling-strategy.enum.js +12 -0
- package/dist/lib/esm/enums/gcp-functions-events-handling-strategy.enum.js.map +1 -0
- package/dist/lib/esm/event-payloads/cloud-function-gen-1-http.event-payload.js +15 -0
- package/dist/lib/esm/event-payloads/cloud-function-gen-1-http.event-payload.js.map +1 -0
- package/dist/lib/esm/event-payloads/cloud-function-gen-2-http.event-payload.js +17 -0
- package/dist/lib/esm/event-payloads/cloud-function-gen-2-http.event-payload.js.map +1 -0
- package/dist/lib/esm/event-payloads/cloud-run-http.event-payload.js +15 -0
- package/dist/lib/esm/event-payloads/cloud-run-http.event-payload.js.map +1 -0
- package/dist/lib/esm/event-payloads/event-payloads.js +4 -0
- package/dist/lib/esm/event-payloads/event-payloads.js.map +1 -0
- package/dist/lib/esm/event-response-payloads/event-response-payloads.js +2 -0
- package/dist/lib/esm/event-response-payloads/event-response-payloads.js.map +1 -0
- package/dist/lib/esm/event-response-payloads/gcp-functions-http.event-response-payload.js +19 -0
- package/dist/lib/esm/event-response-payloads/gcp-functions-http.event-response-payload.js.map +1 -0
- package/dist/lib/esm/gcp-functions.configuration-keys.js +11 -0
- package/dist/lib/esm/gcp-functions.configuration-keys.js.map +1 -0
- package/dist/lib/esm/gcp-functions.module.js +45 -0
- package/dist/lib/esm/gcp-functions.module.js.map +1 -0
- package/dist/lib/esm/gcp-functions.module.keyname.js +2 -0
- package/dist/lib/esm/gcp-functions.module.keyname.js.map +1 -0
- package/dist/lib/esm/mappers/base-gcp-http-event.mapper.js +102 -0
- package/dist/lib/esm/mappers/base-gcp-http-event.mapper.js.map +1 -0
- package/dist/lib/esm/mappers/cloud-function-gen-1-http-event.mapper.js +97 -0
- package/dist/lib/esm/mappers/cloud-function-gen-1-http-event.mapper.js.map +1 -0
- package/dist/lib/esm/mappers/cloud-function-gen-2-http-event.mapper.js +118 -0
- package/dist/lib/esm/mappers/cloud-function-gen-2-http-event.mapper.js.map +1 -0
- package/dist/lib/esm/mappers/cloud-run-http-event.mapper.js +82 -0
- package/dist/lib/esm/mappers/cloud-run-http-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/tsconfig.tsbuildinfo +1 -0
- package/dist/types/enums/enums.d.ts +2 -0
- package/dist/types/enums/gcp-functions-event-type.enum.d.ts +12 -0
- package/dist/types/enums/gcp-functions-events-handling-strategy.enum.d.ts +10 -0
- package/dist/types/event-payloads/cloud-function-gen-1-http.event-payload.d.ts +20 -0
- package/dist/types/event-payloads/cloud-function-gen-2-http.event-payload.d.ts +32 -0
- package/dist/types/event-payloads/cloud-run-http.event-payload.d.ts +20 -0
- package/dist/types/event-payloads/event-payloads.d.ts +3 -0
- package/dist/types/event-response-payloads/event-response-payloads.d.ts +1 -0
- package/dist/types/event-response-payloads/gcp-functions-http.event-response-payload.d.ts +20 -0
- package/dist/types/gcp-functions.configuration-keys.d.ts +31 -0
- package/dist/types/gcp-functions.module.d.ts +8 -0
- package/dist/types/gcp-functions.module.keyname.d.ts +1 -0
- package/dist/types/mappers/base-gcp-http-event.mapper.d.ts +37 -0
- package/dist/types/mappers/cloud-function-gen-1-http-event.mapper.d.ts +26 -0
- package/dist/types/mappers/cloud-function-gen-2-http-event.mapper.d.ts +27 -0
- package/dist/types/mappers/cloud-run-http-event.mapper.d.ts +23 -0
- package/dist/types/mappers/mappers.d.ts +4 -0
- package/package.json +67 -0
- package/readme.md +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./gcp-functions-event-type.enum"), exports);
|
|
18
|
+
__exportStar(require("./gcp-functions-events-handling-strategy.enum"), exports);
|
|
19
|
+
//# 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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GcpFunctionsEventTypeEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Event types emitted by the GCP-Functions HTTP mappers. Used for both internal event
|
|
6
|
+
* tagging and for reverse-mapping dispatch.
|
|
7
|
+
*/
|
|
8
|
+
var GcpFunctionsEventTypeEnum;
|
|
9
|
+
(function (GcpFunctionsEventTypeEnum) {
|
|
10
|
+
/** Gen 1 HTTP-triggered Cloud Function. Express-style req/res shape. */
|
|
11
|
+
GcpFunctionsEventTypeEnum["CloudFunctionGen1HttpEvent"] = "GCP_CLOUD_FUNCTION_GEN_1_HTTP_EVENT";
|
|
12
|
+
/** Gen 2 Cloud Function (Cloud Run under the hood) delivering a CloudEvent over HTTP. */
|
|
13
|
+
GcpFunctionsEventTypeEnum["CloudFunctionGen2HttpEvent"] = "GCP_CLOUD_FUNCTION_GEN_2_HTTP_EVENT";
|
|
14
|
+
/** Cloud Run-hosted service receiving raw HTTP. */
|
|
15
|
+
GcpFunctionsEventTypeEnum["CloudRunHttpEvent"] = "GCP_CLOUD_RUN_HTTP_EVENT";
|
|
16
|
+
})(GcpFunctionsEventTypeEnum || (exports.GcpFunctionsEventTypeEnum = GcpFunctionsEventTypeEnum = {}));
|
|
17
|
+
//# sourceMappingURL=gcp-functions-event-type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp-functions-event-type.enum.js","sourceRoot":"","sources":["../../../../src/enums/gcp-functions-event-type.enum.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,yBAOX;AAPD,WAAY,yBAAyB;IACnC,wEAAwE;IACxE,+FAAkE,CAAA;IAClE,yFAAyF;IACzF,+FAAkE,CAAA;IAClE,mDAAmD;IACnD,2EAA8C,CAAA;AAChD,CAAC,EAPW,yBAAyB,yCAAzB,yBAAyB,QAOpC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GcpFunctionsEventsHandlingStrategyEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handling strategies for incoming HTTP events. Mirrors
|
|
6
|
+
* `ApiGatewayEventsHandlingStrategyEnum` in `@pristine-ts/aws-api-gateway`.
|
|
7
|
+
*/
|
|
8
|
+
var GcpFunctionsEventsHandlingStrategyEnum;
|
|
9
|
+
(function (GcpFunctionsEventsHandlingStrategyEnum) {
|
|
10
|
+
/** Surface the raw event payload as the Pristine event body. */
|
|
11
|
+
GcpFunctionsEventsHandlingStrategyEnum["Event"] = "EVENT";
|
|
12
|
+
/** Map the HTTP shape into a Pristine `Request` so controllers can route on it. */
|
|
13
|
+
GcpFunctionsEventsHandlingStrategyEnum["Request"] = "REQUEST";
|
|
14
|
+
})(GcpFunctionsEventsHandlingStrategyEnum || (exports.GcpFunctionsEventsHandlingStrategyEnum = GcpFunctionsEventsHandlingStrategyEnum = {}));
|
|
15
|
+
//# sourceMappingURL=gcp-functions-events-handling-strategy.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp-functions-events-handling-strategy.enum.js","sourceRoot":"","sources":["../../../../src/enums/gcp-functions-events-handling-strategy.enum.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,sCAKX;AALD,WAAY,sCAAsC;IAChD,gEAAgE;IAChE,yDAAe,CAAA;IACf,mFAAmF;IACnF,6DAAmB,CAAA;AACrB,CAAC,EALW,sCAAsC,sDAAtC,sCAAsC,QAKjD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudFunctionGen1HttpEventPayload = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The event payload for a Gen 1 HTTP-triggered Cloud Function, surfaced when the
|
|
6
|
+
* handling strategy is `Event`. Gen 1 HTTP functions receive an Express-like raw
|
|
7
|
+
* request shape: this payload captures it verbatim plus a parsed body if available.
|
|
8
|
+
*/
|
|
9
|
+
class CloudFunctionGen1HttpEventPayload {
|
|
10
|
+
constructor(method, url, path) {
|
|
11
|
+
this.headers = {};
|
|
12
|
+
this.query = {};
|
|
13
|
+
this.method = method;
|
|
14
|
+
this.url = url;
|
|
15
|
+
this.path = path;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.CloudFunctionGen1HttpEventPayload = CloudFunctionGen1HttpEventPayload;
|
|
19
|
+
//# sourceMappingURL=cloud-function-gen-1-http.event-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-function-gen-1-http.event-payload.js","sourceRoot":"","sources":["../../../../src/event-payloads/cloud-function-gen-1-http.event-payload.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,iCAAiC;IAU5C,YAAY,MAAc,EAAE,GAAW,EAAE,IAAY;QANrD,YAAO,GAAyC,EAAE,CAAC;QACnD,UAAK,GAAyC,EAAE,CAAC;QAM/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAfD,8EAeC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudFunctionGen2HttpEventPayload = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The event payload for a Gen 2 Cloud Function delivered as a CloudEvent over HTTP.
|
|
6
|
+
* Surfaced when the handling strategy is `Event`.
|
|
7
|
+
*
|
|
8
|
+
* Gen 2 functions can receive either:
|
|
9
|
+
* - A direct HTTP request (then `CloudFunctionGen1` shape applies — they're
|
|
10
|
+
* interchangeable for plain HTTP-triggered functions), OR
|
|
11
|
+
* - A CloudEvent envelope, which is what this payload represents. The CloudEvent
|
|
12
|
+
* attributes arrive as `ce-*` HTTP headers; `data` is in the body.
|
|
13
|
+
*/
|
|
14
|
+
class CloudFunctionGen2HttpEventPayload {
|
|
15
|
+
constructor() {
|
|
16
|
+
/** The raw HTTP headers, in case consumers need extra context. */
|
|
17
|
+
this.headers = {};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.CloudFunctionGen2HttpEventPayload = CloudFunctionGen2HttpEventPayload;
|
|
21
|
+
//# sourceMappingURL=cloud-function-gen-2-http.event-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-function-gen-2-http.event-payload.js","sourceRoot":"","sources":["../../../../src/event-payloads/cloud-function-gen-2-http.event-payload.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,MAAa,iCAAiC;IAA9C;QAiBE,kEAAkE;QAClE,YAAO,GAAyC,EAAE,CAAC;IACrD,CAAC;CAAA;AAnBD,8EAmBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudRunHttpEventPayload = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The event payload for a Cloud Run HTTP request, surfaced when the handling
|
|
6
|
+
* strategy is `Event`. Same shape as Gen 1 (both are raw HTTP), but kept as a
|
|
7
|
+
* distinct class so downstream handlers can differentiate via `instanceof`.
|
|
8
|
+
*/
|
|
9
|
+
class CloudRunHttpEventPayload {
|
|
10
|
+
constructor(method, url, path) {
|
|
11
|
+
this.headers = {};
|
|
12
|
+
this.query = {};
|
|
13
|
+
this.method = method;
|
|
14
|
+
this.url = url;
|
|
15
|
+
this.path = path;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.CloudRunHttpEventPayload = CloudRunHttpEventPayload;
|
|
19
|
+
//# sourceMappingURL=cloud-run-http.event-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-run-http.event-payload.js","sourceRoot":"","sources":["../../../../src/event-payloads/cloud-run-http.event-payload.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,wBAAwB;IAUnC,YAAY,MAAc,EAAE,GAAW,EAAE,IAAY;QANrD,YAAO,GAAyC,EAAE,CAAC;QACnD,UAAK,GAAyC,EAAE,CAAC;QAM/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAfD,4DAeC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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-function-gen-1-http.event-payload"), exports);
|
|
18
|
+
__exportStar(require("./cloud-function-gen-2-http.event-payload"), exports);
|
|
19
|
+
__exportStar(require("./cloud-run-http.event-payload"), exports);
|
|
20
|
+
//# sourceMappingURL=event-payloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-payloads.js","sourceRoot":"","sources":["../../../../src/event-payloads/event-payloads.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4EAA0D;AAC1D,4EAA0D;AAC1D,iEAA+C"}
|
|
@@ -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("./gcp-functions-http.event-response-payload"), exports);
|
|
18
|
+
//# sourceMappingURL=event-response-payloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-response-payloads.js","sourceRoot":"","sources":["../../../../src/event-response-payloads/event-response-payloads.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8EAA4D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GcpFunctionsHttpEventResponsePayload = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Response payload returned by the GCP-Functions HTTP mappers' reverse mapping.
|
|
6
|
+
* The entry-point shim (a Cloud Function `(req, res) => ...` handler or a Cloud Run
|
|
7
|
+
* `http.Server` listener) reads this and translates it to the host response.
|
|
8
|
+
*
|
|
9
|
+
* Shape matches what Cloud Functions / Cloud Run expect: status code, headers,
|
|
10
|
+
* body, and an `isBase64Encoded` flag for binary responses.
|
|
11
|
+
*/
|
|
12
|
+
class GcpFunctionsHttpEventResponsePayload {
|
|
13
|
+
constructor(statusCode, body) {
|
|
14
|
+
this.statusCode = statusCode;
|
|
15
|
+
/** Response headers (single-value). */
|
|
16
|
+
this.headers = {};
|
|
17
|
+
/** Whether the body is base64-encoded (set when the original response body was binary). */
|
|
18
|
+
this.isBase64Encoded = false;
|
|
19
|
+
this.body = body;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.GcpFunctionsHttpEventResponsePayload = GcpFunctionsHttpEventResponsePayload;
|
|
23
|
+
//# sourceMappingURL=gcp-functions-http.event-response-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp-functions-http.event-response-payload.js","sourceRoot":"","sources":["../../../../src/event-response-payloads/gcp-functions-http.event-response-payload.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,MAAa,oCAAoC;IAU/C,YAA4B,UAAkB,EAAE,IAAa;QAAjC,eAAU,GAAV,UAAU,CAAQ;QAT9C,uCAAuC;QACvC,YAAO,GAA8B,EAAE,CAAC;QAExC,2FAA2F;QAC3F,oBAAe,GAAY,KAAK,CAAC;QAM/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAbD,oFAaC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GcpFunctionsConfigurationKeys = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Typed configuration keys for `@pristine-ts/gcp-functions`. Use these constants with
|
|
6
|
+
* `@injectConfig` for autocomplete + rename safety, instead of typing the parameter
|
|
7
|
+
* name as a string.
|
|
8
|
+
*/
|
|
9
|
+
exports.GcpFunctionsConfigurationKeys = {
|
|
10
|
+
CloudFunctionGen1HandlingStrategy: "pristine.gcp-functions.cloudFunctionGen1.handlingStrategy",
|
|
11
|
+
CloudFunctionGen2HandlingStrategy: "pristine.gcp-functions.cloudFunctionGen2.handlingStrategy",
|
|
12
|
+
CloudRunHandlingStrategy: "pristine.gcp-functions.cloudRun.handlingStrategy",
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=gcp-functions.configuration-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp-functions.configuration-keys.js","sourceRoot":"","sources":["../../../src/gcp-functions.configuration-keys.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACU,QAAA,6BAA6B,GAAG;IAC3C,iCAAiC,EAAE,2DAA2D;IAC9F,iCAAiC,EAAE,2DAA2D;IAC9F,wBAAwB,EAAE,kDAAkD;CACpE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
exports.GcpFunctionsModule = void 0;
|
|
18
|
+
const core_1 = require("@pristine-ts/core");
|
|
19
|
+
const networking_1 = require("@pristine-ts/networking");
|
|
20
|
+
const configuration_1 = require("@pristine-ts/configuration");
|
|
21
|
+
const gcp_functions_module_keyname_1 = require("./gcp-functions.module.keyname");
|
|
22
|
+
const gcp_functions_events_handling_strategy_enum_1 = require("./enums/gcp-functions-events-handling-strategy.enum");
|
|
23
|
+
__exportStar(require("./enums/enums"), exports);
|
|
24
|
+
__exportStar(require("./event-payloads/event-payloads"), exports);
|
|
25
|
+
__exportStar(require("./event-response-payloads/event-response-payloads"), exports);
|
|
26
|
+
__exportStar(require("./mappers/mappers"), exports);
|
|
27
|
+
__exportStar(require("./gcp-functions.module.keyname"), exports);
|
|
28
|
+
__exportStar(require("./gcp-functions.configuration-keys"), exports);
|
|
29
|
+
exports.GcpFunctionsModule = {
|
|
30
|
+
keyname: gcp_functions_module_keyname_1.GcpFunctionsModuleKeyname,
|
|
31
|
+
configurationDefinitions: [
|
|
32
|
+
{
|
|
33
|
+
parameterName: gcp_functions_module_keyname_1.GcpFunctionsModuleKeyname + ".cloudFunctionGen1.handlingStrategy",
|
|
34
|
+
isRequired: false,
|
|
35
|
+
defaultValue: gcp_functions_events_handling_strategy_enum_1.GcpFunctionsEventsHandlingStrategyEnum.Request,
|
|
36
|
+
defaultResolvers: [
|
|
37
|
+
new configuration_1.EnumResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_GCP_FUNCTIONS_CLOUD_FUNCTION_GEN_1_HANDLING_STRATEGY"), gcp_functions_events_handling_strategy_enum_1.GcpFunctionsEventsHandlingStrategyEnum),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
parameterName: gcp_functions_module_keyname_1.GcpFunctionsModuleKeyname + ".cloudFunctionGen2.handlingStrategy",
|
|
42
|
+
isRequired: false,
|
|
43
|
+
defaultValue: gcp_functions_events_handling_strategy_enum_1.GcpFunctionsEventsHandlingStrategyEnum.Event,
|
|
44
|
+
defaultResolvers: [
|
|
45
|
+
new configuration_1.EnumResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_GCP_FUNCTIONS_CLOUD_FUNCTION_GEN_2_HANDLING_STRATEGY"), gcp_functions_events_handling_strategy_enum_1.GcpFunctionsEventsHandlingStrategyEnum),
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
parameterName: gcp_functions_module_keyname_1.GcpFunctionsModuleKeyname + ".cloudRun.handlingStrategy",
|
|
50
|
+
isRequired: false,
|
|
51
|
+
defaultValue: gcp_functions_events_handling_strategy_enum_1.GcpFunctionsEventsHandlingStrategyEnum.Request,
|
|
52
|
+
defaultResolvers: [
|
|
53
|
+
new configuration_1.EnumResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_GCP_FUNCTIONS_CLOUD_RUN_HANDLING_STRATEGY"), gcp_functions_events_handling_strategy_enum_1.GcpFunctionsEventsHandlingStrategyEnum),
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
importModules: [
|
|
58
|
+
core_1.CoreModule,
|
|
59
|
+
networking_1.NetworkingModule,
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=gcp-functions.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp-functions.module.js","sourceRoot":"","sources":["../../../src/gcp-functions.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,4CAA6C;AAC7C,wDAAyD;AACzD,8DAAqF;AACrF,iFAAyE;AACzE,qHAA2G;AAE3G,gDAA8B;AAC9B,kEAAgD;AAChD,oFAAkE;AAClE,oDAAkC;AAElC,iEAA+C;AAC/C,qEAAmD;AAEtC,QAAA,kBAAkB,GAAoB;IACjD,OAAO,EAAE,wDAAyB;IAClC,wBAAwB,EAAE;QACxB;YACE,aAAa,EAAE,wDAAyB,GAAG,qCAAqC;YAChF,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,oFAAsC,CAAC,OAAO;YAC5D,gBAAgB,EAAE;gBAChB,IAAI,4BAAY,CACd,IAAI,2CAA2B,CAAC,+DAA+D,CAAC,EAChG,oFAAsC,CACvC;aACF;SACF;QACD;YACE,aAAa,EAAE,wDAAyB,GAAG,qCAAqC;YAChF,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,oFAAsC,CAAC,KAAK;YAC1D,gBAAgB,EAAE;gBAChB,IAAI,4BAAY,CACd,IAAI,2CAA2B,CAAC,+DAA+D,CAAC,EAChG,oFAAsC,CACvC;aACF;SACF;QACD;YACE,aAAa,EAAE,wDAAyB,GAAG,4BAA4B;YACvE,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,oFAAsC,CAAC,OAAO;YAC5D,gBAAgB,EAAE;gBAChB,IAAI,4BAAY,CACd,IAAI,2CAA2B,CAAC,oDAAoD,CAAC,EACrF,oFAAsC,CACvC;aACF;SACF;KACF;IACD,aAAa,EAAE;QACb,iBAAU;QACV,6BAAgB;KACjB;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp-functions.module.keyname.js","sourceRoot":"","sources":["../../../src/gcp-functions.module.keyname.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GAAW,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseGcpHttpEventMapper = void 0;
|
|
4
|
+
const common_1 = require("@pristine-ts/common");
|
|
5
|
+
const gcp_functions_http_event_response_payload_1 = require("../event-response-payloads/gcp-functions-http.event-response-payload");
|
|
6
|
+
/**
|
|
7
|
+
* Shared base for the three GCP-Functions HTTP mappers. Mirrors
|
|
8
|
+
* `BaseApiEventMapper` in `@pristine-ts/aws-api-gateway`.
|
|
9
|
+
*/
|
|
10
|
+
class BaseGcpHttpEventMapper {
|
|
11
|
+
mapHttpMethod(method) {
|
|
12
|
+
switch ((method !== null && method !== void 0 ? method : "").toLowerCase()) {
|
|
13
|
+
case "get":
|
|
14
|
+
return common_1.HttpMethod.Get;
|
|
15
|
+
case "post":
|
|
16
|
+
return common_1.HttpMethod.Post;
|
|
17
|
+
case "put":
|
|
18
|
+
return common_1.HttpMethod.Put;
|
|
19
|
+
case "patch":
|
|
20
|
+
return common_1.HttpMethod.Patch;
|
|
21
|
+
case "delete":
|
|
22
|
+
return common_1.HttpMethod.Delete;
|
|
23
|
+
case "options":
|
|
24
|
+
return common_1.HttpMethod.Options;
|
|
25
|
+
default:
|
|
26
|
+
return common_1.HttpMethod.Get;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Extracts the URL path from a raw URL (which may include query string).
|
|
31
|
+
*/
|
|
32
|
+
extractPath(url) {
|
|
33
|
+
if (!url) {
|
|
34
|
+
return "/";
|
|
35
|
+
}
|
|
36
|
+
const queryIdx = url.indexOf("?");
|
|
37
|
+
return queryIdx >= 0 ? url.substring(0, queryIdx) : url;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Converts a Pristine `Response` (or arbitrary handler return value) into the
|
|
41
|
+
* `GcpFunctionsHttpEventResponsePayload` shape that the entry-point shim returns to
|
|
42
|
+
* Cloud Functions / Cloud Run.
|
|
43
|
+
*/
|
|
44
|
+
toResponsePayload(eventResponse, logHandler) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (eventResponse.response instanceof gcp_functions_http_event_response_payload_1.GcpFunctionsHttpEventResponsePayload) {
|
|
47
|
+
return eventResponse.response;
|
|
48
|
+
}
|
|
49
|
+
if (eventResponse.response instanceof common_1.Response) {
|
|
50
|
+
let body = eventResponse.response.body;
|
|
51
|
+
if (body !== null && body !== undefined && typeof body === "object") {
|
|
52
|
+
try {
|
|
53
|
+
body = JSON.stringify(body);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
logHandler.error("BaseGcpHttpEventMapper: Could not stringify response body.", {
|
|
57
|
+
highlights: { errorMessage: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : "Unknown error" },
|
|
58
|
+
extra: { error: e },
|
|
59
|
+
eventId: eventResponse.event.id,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const payload = new gcp_functions_http_event_response_payload_1.GcpFunctionsHttpEventResponsePayload(eventResponse.response.status, body);
|
|
64
|
+
if (eventResponse.response.headers) {
|
|
65
|
+
payload.headers = eventResponse.response.headers;
|
|
66
|
+
}
|
|
67
|
+
payload.isBase64Encoded = false;
|
|
68
|
+
return payload;
|
|
69
|
+
}
|
|
70
|
+
return new gcp_functions_http_event_response_payload_1.GcpFunctionsHttpEventResponsePayload(200, eventResponse.response);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Hydrates a Pristine `Request` from raw HTTP fields. Shared by the Gen 1 and
|
|
74
|
+
* Cloud Run mappers (both deliver raw HTTP).
|
|
75
|
+
*/
|
|
76
|
+
toPristineRequest(method, url, headers, body, eventId) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const path = this.extractPath(url);
|
|
79
|
+
const request = new common_1.Request(this.mapHttpMethod(method), path, eventId);
|
|
80
|
+
request.setHeaders(this.flattenHeaders(headers !== null && headers !== void 0 ? headers : {}));
|
|
81
|
+
request.body = body;
|
|
82
|
+
request.rawBody = typeof body === "string" ? body : (body !== undefined && body !== null ? JSON.stringify(body) : undefined);
|
|
83
|
+
request.id = (_a = request.getHeader("x-pristine-request-id")) !== null && _a !== void 0 ? _a : request.id;
|
|
84
|
+
request.groupId = (_b = request.getHeader("x-pristine-event-group-id")) !== null && _b !== void 0 ? _b : request.groupId;
|
|
85
|
+
return request;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Lowercases keys and collapses single-element arrays so downstream code can read
|
|
89
|
+
* headers consistently as `string`.
|
|
90
|
+
*/
|
|
91
|
+
flattenHeaders(headers) {
|
|
92
|
+
const flat = {};
|
|
93
|
+
for (const key of Object.keys(headers)) {
|
|
94
|
+
const value = headers[key];
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
flat[key.toLowerCase()] = value.join(",");
|
|
97
|
+
}
|
|
98
|
+
else if (value !== undefined && value !== null) {
|
|
99
|
+
flat[key.toLowerCase()] = String(value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return flat;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.BaseGcpHttpEventMapper = BaseGcpHttpEventMapper;
|
|
106
|
+
//# sourceMappingURL=base-gcp-http-event.mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-gcp-http-event.mapper.js","sourceRoot":"","sources":["../../../../src/mappers/base-gcp-http-event.mapper.ts"],"names":[],"mappings":";;;AAAA,gDAAkE;AAGlE,oIAA0H;AAE1H;;;GAGG;AACH,MAAa,sBAAsB;IACvB,aAAa,CAAC,MAAc;QACpC,QAAQ,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YACrC,KAAK,KAAK;gBACR,OAAO,mBAAU,CAAC,GAAG,CAAC;YACxB,KAAK,MAAM;gBACT,OAAO,mBAAU,CAAC,IAAI,CAAC;YACzB,KAAK,KAAK;gBACR,OAAO,m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