pg-mvc-service 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/AwsS3Client.js +34 -12
- package/dist/index.js +2 -2
- package/index.d.ts +14 -0
- package/package.json +1 -1
- package/src/clients/AwsS3Client.ts +15 -7
- package/src/index.ts +1 -1
|
@@ -136,7 +136,8 @@ class AwsS3Client {
|
|
|
136
136
|
}
|
|
137
137
|
getText(path, fileName) {
|
|
138
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
var _a;
|
|
139
|
+
var _a, e_1, _b, _c;
|
|
140
|
+
var _d;
|
|
140
141
|
try {
|
|
141
142
|
const command = new client_s3_1.GetObjectCommand({
|
|
142
143
|
Bucket: this.bucketName,
|
|
@@ -146,18 +147,39 @@ class AwsS3Client {
|
|
|
146
147
|
if (res.Body === undefined) {
|
|
147
148
|
throw new Error(`Failed to get text data. Response body is undefined.`);
|
|
148
149
|
}
|
|
149
|
-
if (((
|
|
150
|
+
if (((_d = res.ContentType) === null || _d === void 0 ? void 0 : _d.startsWith('text/')) === false) {
|
|
150
151
|
throw new Error(`Cannot get text data from non-text file. ContentType: ${res.ContentType}`);
|
|
151
152
|
}
|
|
152
153
|
// v3ではBodyがReadableStreamなので、変換が必要
|
|
153
|
-
const stream = res.Body;
|
|
154
|
-
const reader = stream.getReader();
|
|
155
154
|
const chunks = [];
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
if (res.Body && typeof res.Body === 'object' && 'getReader' in res.Body) {
|
|
156
|
+
// ReadableStreamの場合
|
|
157
|
+
const stream = res.Body;
|
|
158
|
+
const reader = stream.getReader();
|
|
159
|
+
while (true) {
|
|
160
|
+
const { done, value } = yield reader.read();
|
|
161
|
+
if (done)
|
|
162
|
+
break;
|
|
163
|
+
chunks.push(value);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
try {
|
|
168
|
+
// Node.js Readableの場合
|
|
169
|
+
for (var _e = true, _f = __asyncValues(res.Body), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) {
|
|
170
|
+
_c = _g.value;
|
|
171
|
+
_e = false;
|
|
172
|
+
const chunk = _c;
|
|
173
|
+
chunks.push(chunk);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
177
|
+
finally {
|
|
178
|
+
try {
|
|
179
|
+
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
|
|
180
|
+
}
|
|
181
|
+
finally { if (e_1) throw e_1.error; }
|
|
182
|
+
}
|
|
161
183
|
}
|
|
162
184
|
const buffer = Buffer.concat(chunks);
|
|
163
185
|
return buffer.toString('utf-8');
|
|
@@ -183,7 +205,7 @@ class AwsS3Client {
|
|
|
183
205
|
}
|
|
184
206
|
getDataFronJson(path, fileName) {
|
|
185
207
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
var _a,
|
|
208
|
+
var _a, e_2, _b, _c;
|
|
187
209
|
const command = new client_s3_1.GetObjectCommand({
|
|
188
210
|
Bucket: this.bucketName,
|
|
189
211
|
Key: this.makeKey(path, fileName),
|
|
@@ -205,12 +227,12 @@ class AwsS3Client {
|
|
|
205
227
|
chunks.push(chunk);
|
|
206
228
|
}
|
|
207
229
|
}
|
|
208
|
-
catch (
|
|
230
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
209
231
|
finally {
|
|
210
232
|
try {
|
|
211
233
|
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
212
234
|
}
|
|
213
|
-
finally { if (
|
|
235
|
+
finally { if (e_2) throw e_2.error; }
|
|
214
236
|
}
|
|
215
237
|
const buffer = Buffer.concat(chunks);
|
|
216
238
|
const jsonString = buffer.toString('utf-8');
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rollback = exports.migrate = exports.MigrateDatabase = exports.MigrateTable = exports.createTableDoc = exports.TableModel = exports.ResponseType = exports.RequestType = exports.EncryptClient = exports.StringClient = exports.Base64Client = exports.AwsS3Client = exports.createSwagger = exports.
|
|
3
|
+
exports.rollback = exports.migrate = exports.MigrateDatabase = exports.MigrateTable = exports.createTableDoc = exports.TableModel = exports.ResponseType = exports.RequestType = exports.EncryptClient = exports.StringClient = exports.Base64Client = exports.AwsS3Client = exports.createSwagger = exports.UnprocessableException = exports.DbConflictException = exports.ForbiddenException = exports.InputErrorException = exports.AuthException = exports.MaintenanceException = exports.Service = void 0;
|
|
4
4
|
var Service_1 = require("./Service");
|
|
5
5
|
Object.defineProperty(exports, "Service", { enumerable: true, get: function () { return Service_1.Service; } });
|
|
6
6
|
var Exception_1 = require("./exceptions/Exception");
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "AuthException", { enumerable: true, get: functio
|
|
|
9
9
|
Object.defineProperty(exports, "InputErrorException", { enumerable: true, get: function () { return Exception_1.InputErrorException; } });
|
|
10
10
|
Object.defineProperty(exports, "ForbiddenException", { enumerable: true, get: function () { return Exception_1.ForbiddenException; } });
|
|
11
11
|
Object.defineProperty(exports, "DbConflictException", { enumerable: true, get: function () { return Exception_1.DbConflictException; } });
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "UnprocessableException", { enumerable: true, get: function () { return Exception_1.UnprocessableException; } });
|
|
13
13
|
var Swagger_1 = require("./documents/Swagger");
|
|
14
14
|
Object.defineProperty(exports, "createSwagger", { enumerable: true, get: function () { return Swagger_1.createSwagger; } });
|
|
15
15
|
var AwsS3Client_1 = require("./clients/AwsS3Client");
|
package/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { Base64Client } from './src/clients/Base64Client';
|
|
|
8
8
|
import { StringClient } from './src/clients/StringClient';
|
|
9
9
|
import { EncryptClient } from './src/clients/EncryptClient';
|
|
10
10
|
|
|
11
|
+
export { AwsS3Client } from './src/clients/AwsS3Client';
|
|
12
|
+
|
|
11
13
|
// models class
|
|
12
14
|
import ValidateClient from './src/models/ValidateClient';
|
|
13
15
|
|
|
@@ -138,6 +140,18 @@ declare module 'pg-mvc-service' {
|
|
|
138
140
|
constructor(message?: string);
|
|
139
141
|
}
|
|
140
142
|
|
|
143
|
+
export class DbConflictException extends Error {
|
|
144
|
+
private errorId: string;
|
|
145
|
+
get ErrorId(): string;
|
|
146
|
+
constructor(errorId: string, message?: string);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export class UnprocessableException extends Error {
|
|
150
|
+
private errorId: string;
|
|
151
|
+
get ErrorId(): string;
|
|
152
|
+
constructor(errorId: string, message?: string);
|
|
153
|
+
}
|
|
154
|
+
|
|
141
155
|
export type TSqlValue = string | number | boolean | Date | null | Array<string | null> | Array<number | null> | Array<Date | null> | Array<Boolean | null>;
|
|
142
156
|
|
|
143
157
|
// column type
|
package/package.json
CHANGED
|
@@ -147,14 +147,22 @@ export class AwsS3Client {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// v3ではBodyがReadableStreamなので、変換が必要
|
|
150
|
-
const stream = res.Body as ReadableStream;
|
|
151
|
-
const reader = stream.getReader();
|
|
152
150
|
const chunks: Uint8Array[] = [];
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
151
|
+
if (res.Body && typeof res.Body === 'object' && 'getReader' in res.Body) {
|
|
152
|
+
// ReadableStreamの場合
|
|
153
|
+
const stream = res.Body as ReadableStream;
|
|
154
|
+
const reader = stream.getReader();
|
|
155
|
+
|
|
156
|
+
while (true) {
|
|
157
|
+
const { done, value } = await reader.read();
|
|
158
|
+
if (done) break;
|
|
159
|
+
chunks.push(value);
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
// Node.js Readableの場合
|
|
163
|
+
for await (const chunk of res.Body as any) {
|
|
164
|
+
chunks.push(chunk);
|
|
165
|
+
}
|
|
158
166
|
}
|
|
159
167
|
|
|
160
168
|
const buffer = Buffer.concat(chunks);
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Service } from './Service';
|
|
2
|
-
export { MaintenanceException, AuthException, InputErrorException, ForbiddenException, DbConflictException, UnprocessableException
|
|
2
|
+
export { MaintenanceException, AuthException, InputErrorException, ForbiddenException, DbConflictException, UnprocessableException } from './exceptions/Exception';
|
|
3
3
|
export { createSwagger } from './documents/Swagger';
|
|
4
4
|
export { AwsS3Client } from './clients/AwsS3Client';
|
|
5
5
|
export { Base64Client } from './clients/Base64Client';
|