@pristine-ts/aws 0.0.255 → 0.0.257
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/lib/cjs/clients/clients.js +1 -0
- package/dist/lib/cjs/clients/clients.js.map +1 -1
- package/dist/lib/cjs/clients/cloudfront.client.js +127 -0
- package/dist/lib/cjs/clients/cloudfront.client.js.map +1 -0
- package/dist/lib/cjs/interfaces/cloudfront-client.interface.js +3 -0
- package/dist/lib/cjs/interfaces/cloudfront-client.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/interfaces.js +1 -0
- package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/dist/lib/esm/clients/clients.js +1 -0
- package/dist/lib/esm/clients/clients.js.map +1 -1
- package/dist/lib/esm/clients/cloudfront.client.js +124 -0
- package/dist/lib/esm/clients/cloudfront.client.js.map +1 -0
- package/dist/lib/esm/interfaces/cloudfront-client.interface.js +2 -0
- package/dist/lib/esm/interfaces/cloudfront-client.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/interfaces.js +1 -0
- package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
- package/dist/types/clients/clients.d.ts +1 -0
- package/dist/types/clients/cloudfront.client.d.ts +46 -0
- package/dist/types/interfaces/cloudfront-client.interface.d.ts +31 -0
- package/dist/types/interfaces/interfaces.d.ts +1 -0
- package/package.json +8 -7
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./cloudformation.client"), exports);
|
|
18
|
+
__exportStar(require("./cloudfront.client"), exports);
|
|
18
19
|
__exportStar(require("./dynamodb.client"), exports);
|
|
19
20
|
__exportStar(require("./event-bridge.client"), exports);
|
|
20
21
|
__exportStar(require("./s3.client"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../../../src/clients/clients.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oDAAkC;AAClC,wDAAsC;AACtC,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../../../src/clients/clients.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,sDAAoC;AACpC,oDAAkC;AAClC,wDAAsC;AACtC,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B"}
|
|
@@ -0,0 +1,127 @@
|
|
|
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.CloudfrontClient = void 0;
|
|
25
|
+
const tsyringe_1 = require("tsyringe");
|
|
26
|
+
const common_1 = require("@pristine-ts/common");
|
|
27
|
+
const aws_module_keyname_1 = require("../aws.module.keyname");
|
|
28
|
+
const client_cloudfront_1 = require("@aws-sdk/client-cloudfront");
|
|
29
|
+
const uuid_1 = require("uuid");
|
|
30
|
+
/**
|
|
31
|
+
* The client to use to interact with AWS Cloudformation. It is a wrapper around the Cloudfront of @aws-sdk/client-cloudfront.
|
|
32
|
+
* It is tagged so it can be injected using CloudfrontClientInterface.
|
|
33
|
+
* AWS documentation https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudfront/
|
|
34
|
+
*/
|
|
35
|
+
let CloudfrontClient = class CloudfrontClient {
|
|
36
|
+
/**
|
|
37
|
+
* The client to use to interact with AWS CloudFront. It is a wrapper around the CloudFrontClient of @aws-sdk/client-cloudfront.
|
|
38
|
+
* @param logHandler The log handler used to output logs.
|
|
39
|
+
* @param region The aws region for which the client will be used.
|
|
40
|
+
*/
|
|
41
|
+
constructor(logHandler, region) {
|
|
42
|
+
this.logHandler = logHandler;
|
|
43
|
+
this.region = region;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the instantiated CloudFrontClient from the @aws-sdk/client-cloudfront
|
|
47
|
+
*/
|
|
48
|
+
getClient() {
|
|
49
|
+
var _a;
|
|
50
|
+
return this.client = (_a = this.client) !== null && _a !== void 0 ? _a : new client_cloudfront_1.CloudFrontClient({ region: this.region });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Allows you to manually set the config if needed.
|
|
54
|
+
* @param config
|
|
55
|
+
*/
|
|
56
|
+
setClient(config) {
|
|
57
|
+
this.client = new client_cloudfront_1.CloudFrontClient(config);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Invalidates all the provided paths.
|
|
61
|
+
*
|
|
62
|
+
* @param distributionId
|
|
63
|
+
* @param paths
|
|
64
|
+
*/
|
|
65
|
+
invalidate(distributionId, paths) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
this.logHandler.debug("CloudFront CLIENT - Invalidating", { distributionId, paths }, aws_module_keyname_1.AwsModuleKeyname);
|
|
68
|
+
const command = new client_cloudfront_1.CreateInvalidationCommand({
|
|
69
|
+
DistributionId: distributionId,
|
|
70
|
+
InvalidationBatch: {
|
|
71
|
+
Paths: {
|
|
72
|
+
Items: paths,
|
|
73
|
+
Quantity: paths.length,
|
|
74
|
+
},
|
|
75
|
+
CallerReference: (0, uuid_1.v4)(),
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
const response = yield this.getClient().send(command);
|
|
80
|
+
if (response === undefined) {
|
|
81
|
+
throw new Error("Unknown error invalidating the CloudFront distribution");
|
|
82
|
+
}
|
|
83
|
+
return response;
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
this.logHandler.error("Error invalidating cloudfront", { error: e }, aws_module_keyname_1.AwsModuleKeyname);
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the status of the invalidation
|
|
93
|
+
*
|
|
94
|
+
* @param distributionId
|
|
95
|
+
* @param invalidationId
|
|
96
|
+
*/
|
|
97
|
+
getInvalidation(distributionId, invalidationId) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
this.logHandler.debug("CloudFront CLIENT - Get Invalidating", { distributionId, invalidationId }, aws_module_keyname_1.AwsModuleKeyname);
|
|
100
|
+
const command = new client_cloudfront_1.GetInvalidationCommand({
|
|
101
|
+
DistributionId: distributionId,
|
|
102
|
+
Id: invalidationId,
|
|
103
|
+
});
|
|
104
|
+
try {
|
|
105
|
+
const response = yield this.getClient().send(command);
|
|
106
|
+
if (response === undefined) {
|
|
107
|
+
throw new Error("Unknown error invalidating the CloudFront distribution");
|
|
108
|
+
}
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
this.logHandler.error("Error getting invalidation from cloudfront", { error: e }, aws_module_keyname_1.AwsModuleKeyname);
|
|
113
|
+
throw e;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
CloudfrontClient = __decorate([
|
|
119
|
+
(0, common_1.tag)("CloudfrontClientInterface"),
|
|
120
|
+
(0, common_1.moduleScoped)(aws_module_keyname_1.AwsModuleKeyname),
|
|
121
|
+
(0, tsyringe_1.injectable)(),
|
|
122
|
+
__param(0, (0, tsyringe_1.inject)("LogHandlerInterface")),
|
|
123
|
+
__param(1, (0, tsyringe_1.inject)("%pristine.aws.region%")),
|
|
124
|
+
__metadata("design:paramtypes", [Object, String])
|
|
125
|
+
], CloudfrontClient);
|
|
126
|
+
exports.CloudfrontClient = CloudfrontClient;
|
|
127
|
+
//# sourceMappingURL=cloudfront.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudfront.client.js","sourceRoot":"","sources":["../../../../src/clients/cloudfront.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAE5C,gDAAsD;AACtD,8DAAuD;AACvD,kEAImC;AAGnC,+BAAoC;AAEpC;;;;GAIG;AAII,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAQzB;;;;OAIG;IACH,YACoD,UAA+B,EACvC,MAAc;QADN,eAAU,GAAV,UAAU,CAAqB;QACvC,WAAM,GAAN,MAAM,CAAQ;IAE1D,CAAC;IAED;;OAEG;IACH,SAAS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AAc,EAAC,EAAE,qCAAgB,CAAC,CAAC;YAClH,MAAM,OAAO,GAAG,IAAI,0CAAsB,CAAC;gBACvC,cAAc,EAAE,cAAc;gBAC9B,EAAE,EAAE,cAAc;aACrB,CAAC,CAAA;YAEF,IAAI;gBACA,MAAM,QAAQ,GAA0B,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAE7E,IAAG,QAAQ,KAAK,SAAS,EAAE;oBACvB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;iBAC7E;gBAED,OAAO,QAAQ,CAAC;aACnB;YAAC,OAAO,CAAC,EAAE;gBACR,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,EAAE,qCAAgB,CAAC,CAAC;gBAClG,MAAM,CAAC,CAAC;aACX;QACL,CAAC;KAAA;CACJ,CAAA;AA5FY,gBAAgB;IAH5B,IAAA,YAAG,EAAC,2BAA2B,CAAC;IAChC,IAAA,qBAAY,EAAC,qCAAgB,CAAC;IAC9B,IAAA,qBAAU,GAAE;IAeJ,WAAA,IAAA,iBAAM,EAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,IAAA,iBAAM,EAAC,uBAAuB,CAAC,CAAA;;GAf3B,gBAAgB,CA4F5B;AA5FY,4CAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudfront-client.interface.js","sourceRoot":"","sources":["../../../../src/interfaces/cloudfront-client.interface.ts"],"names":[],"mappings":""}
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./cloudformation-client.interface"), exports);
|
|
18
|
+
__exportStar(require("./cloudfront-client.interface"), exports);
|
|
18
19
|
__exportStar(require("./dynamodb-client.interface"), exports);
|
|
19
20
|
__exportStar(require("./event-bridge-client.interface"), exports);
|
|
20
21
|
__exportStar(require("./s3-client.interface"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,8DAA4C;AAC5C,kEAAgD;AAChD,wDAAsC;AACtC,yDAAuC;AACvC,yDAAuC"}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,gEAA8C;AAC9C,8DAA4C;AAC5C,kEAAgD;AAChD,wDAAsC;AACtC,yDAAuC;AACvC,yDAAuC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../../../src/clients/clients.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../../../src/clients/clients.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
import { inject, injectable } from "tsyringe";
|
|
23
|
+
import { moduleScoped, tag } from "@pristine-ts/common";
|
|
24
|
+
import { AwsModuleKeyname } from "../aws.module.keyname";
|
|
25
|
+
import { CloudFrontClient as AWSCloudFrontClient, CreateInvalidationCommand, GetInvalidationCommand } from "@aws-sdk/client-cloudfront";
|
|
26
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
27
|
+
/**
|
|
28
|
+
* The client to use to interact with AWS Cloudformation. It is a wrapper around the Cloudfront of @aws-sdk/client-cloudfront.
|
|
29
|
+
* It is tagged so it can be injected using CloudfrontClientInterface.
|
|
30
|
+
* AWS documentation https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudfront/
|
|
31
|
+
*/
|
|
32
|
+
let CloudfrontClient = class CloudfrontClient {
|
|
33
|
+
/**
|
|
34
|
+
* The client to use to interact with AWS CloudFront. It is a wrapper around the CloudFrontClient of @aws-sdk/client-cloudfront.
|
|
35
|
+
* @param logHandler The log handler used to output logs.
|
|
36
|
+
* @param region The aws region for which the client will be used.
|
|
37
|
+
*/
|
|
38
|
+
constructor(logHandler, region) {
|
|
39
|
+
this.logHandler = logHandler;
|
|
40
|
+
this.region = region;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the instantiated CloudFrontClient from the @aws-sdk/client-cloudfront
|
|
44
|
+
*/
|
|
45
|
+
getClient() {
|
|
46
|
+
var _a;
|
|
47
|
+
return this.client = (_a = this.client) !== null && _a !== void 0 ? _a : new AWSCloudFrontClient({ region: this.region });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Allows you to manually set the config if needed.
|
|
51
|
+
* @param config
|
|
52
|
+
*/
|
|
53
|
+
setClient(config) {
|
|
54
|
+
this.client = new AWSCloudFrontClient(config);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Invalidates all the provided paths.
|
|
58
|
+
*
|
|
59
|
+
* @param distributionId
|
|
60
|
+
* @param paths
|
|
61
|
+
*/
|
|
62
|
+
invalidate(distributionId, paths) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
this.logHandler.debug("CloudFront CLIENT - Invalidating", { distributionId, paths }, AwsModuleKeyname);
|
|
65
|
+
const command = new CreateInvalidationCommand({
|
|
66
|
+
DistributionId: distributionId,
|
|
67
|
+
InvalidationBatch: {
|
|
68
|
+
Paths: {
|
|
69
|
+
Items: paths,
|
|
70
|
+
Quantity: paths.length,
|
|
71
|
+
},
|
|
72
|
+
CallerReference: uuidv4(),
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
try {
|
|
76
|
+
const response = yield this.getClient().send(command);
|
|
77
|
+
if (response === undefined) {
|
|
78
|
+
throw new Error("Unknown error invalidating the CloudFront distribution");
|
|
79
|
+
}
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
this.logHandler.error("Error invalidating cloudfront", { error: e }, AwsModuleKeyname);
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the status of the invalidation
|
|
90
|
+
*
|
|
91
|
+
* @param distributionId
|
|
92
|
+
* @param invalidationId
|
|
93
|
+
*/
|
|
94
|
+
getInvalidation(distributionId, invalidationId) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
this.logHandler.debug("CloudFront CLIENT - Get Invalidating", { distributionId, invalidationId }, AwsModuleKeyname);
|
|
97
|
+
const command = new GetInvalidationCommand({
|
|
98
|
+
DistributionId: distributionId,
|
|
99
|
+
Id: invalidationId,
|
|
100
|
+
});
|
|
101
|
+
try {
|
|
102
|
+
const response = yield this.getClient().send(command);
|
|
103
|
+
if (response === undefined) {
|
|
104
|
+
throw new Error("Unknown error invalidating the CloudFront distribution");
|
|
105
|
+
}
|
|
106
|
+
return response;
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
this.logHandler.error("Error getting invalidation from cloudfront", { error: e }, AwsModuleKeyname);
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
CloudfrontClient = __decorate([
|
|
116
|
+
tag("CloudfrontClientInterface"),
|
|
117
|
+
moduleScoped(AwsModuleKeyname),
|
|
118
|
+
injectable(),
|
|
119
|
+
__param(0, inject("LogHandlerInterface")),
|
|
120
|
+
__param(1, inject("%pristine.aws.region%")),
|
|
121
|
+
__metadata("design:paramtypes", [Object, String])
|
|
122
|
+
], CloudfrontClient);
|
|
123
|
+
export { CloudfrontClient };
|
|
124
|
+
//# sourceMappingURL=cloudfront.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudfront.client.js","sourceRoot":"","sources":["../../../../src/clients/cloudfront.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAC,YAAY,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACH,gBAAgB,IAAI,mBAAmB,EAEvC,yBAAyB,EAA4B,sBAAsB,EAC9E,MAAM,4BAA4B,CAAA;AAGnC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;GAIG;AAII,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAQzB;;;;OAIG;IACH,YACoD,UAA+B,EACvC,MAAc;QADN,eAAU,GAAV,UAAU,CAAqB;QACvC,WAAM,GAAN,MAAM,CAAQ;IAE1D,CAAC;IAED;;OAEG;IACH,SAAS;;QACL,OAAO,IAAI,CAAC,MAAM,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,mBAAmB,CAAC,EAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC,CAAC;IACvF,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,MAA8B;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACG,UAAU,CAAC,cAAsB,EAAE,KAAe;;YACpD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAC,cAAc,EAAE,KAAK,EAAC,EAAE,gBAAgB,CAAC,CAAC;YACrG,MAAM,OAAO,GAAG,IAAI,yBAAyB,CAAC;gBAC1C,cAAc,EAAE,cAAc;gBAC9B,iBAAiB,EAAE;oBAC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,CAAC;aACX;QACL,CAAC;KAAA;CACJ,CAAA;AA5FY,gBAAgB;IAH5B,GAAG,CAAC,2BAA2B,CAAC;IAChC,YAAY,CAAC,gBAAgB,CAAC;IAC9B,UAAU,EAAE;IAeJ,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;;GAf3B,gBAAgB,CA4F5B;SA5FY,gBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudfront-client.interface.js","sourceRoot":"","sources":["../../../../src/interfaces/cloudfront-client.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LogHandlerInterface } from "@pristine-ts/logging";
|
|
2
|
+
import { CloudFrontClient as AWSCloudFrontClient, CloudFrontClientConfig, CreateInvalidationResult, GetInvalidationResult } from "@aws-sdk/client-cloudfront";
|
|
3
|
+
import { CloudfrontClientInterface } from "../interfaces/cloudfront-client.interface";
|
|
4
|
+
/**
|
|
5
|
+
* The client to use to interact with AWS Cloudformation. It is a wrapper around the Cloudfront of @aws-sdk/client-cloudfront.
|
|
6
|
+
* It is tagged so it can be injected using CloudfrontClientInterface.
|
|
7
|
+
* AWS documentation https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudfront/
|
|
8
|
+
*/
|
|
9
|
+
export declare class CloudfrontClient implements CloudfrontClientInterface {
|
|
10
|
+
private readonly logHandler;
|
|
11
|
+
region: string;
|
|
12
|
+
/**
|
|
13
|
+
* The instantiated client from the @aws-sdk/client-cloudfront library.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
private client;
|
|
17
|
+
/**
|
|
18
|
+
* The client to use to interact with AWS CloudFront. It is a wrapper around the CloudFrontClient of @aws-sdk/client-cloudfront.
|
|
19
|
+
* @param logHandler The log handler used to output logs.
|
|
20
|
+
* @param region The aws region for which the client will be used.
|
|
21
|
+
*/
|
|
22
|
+
constructor(logHandler: LogHandlerInterface, region: string);
|
|
23
|
+
/**
|
|
24
|
+
* Returns the instantiated CloudFrontClient from the @aws-sdk/client-cloudfront
|
|
25
|
+
*/
|
|
26
|
+
getClient(): AWSCloudFrontClient;
|
|
27
|
+
/**
|
|
28
|
+
* Allows you to manually set the config if needed.
|
|
29
|
+
* @param config
|
|
30
|
+
*/
|
|
31
|
+
setClient(config: CloudFrontClientConfig): void;
|
|
32
|
+
/**
|
|
33
|
+
* Invalidates all the provided paths.
|
|
34
|
+
*
|
|
35
|
+
* @param distributionId
|
|
36
|
+
* @param paths
|
|
37
|
+
*/
|
|
38
|
+
invalidate(distributionId: string, paths: string[]): Promise<CreateInvalidationResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the status of the invalidation
|
|
41
|
+
*
|
|
42
|
+
* @param distributionId
|
|
43
|
+
* @param invalidationId
|
|
44
|
+
*/
|
|
45
|
+
getInvalidation(distributionId: string, invalidationId: string): Promise<GetInvalidationResult>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CloudFrontClient as AWSCloudFrontClient, CloudFrontClientConfig } from "@aws-sdk/client-cloudfront/dist-types/CloudFrontClient";
|
|
2
|
+
import { CreateInvalidationResult, GetInvalidationResult } from "@aws-sdk/client-cloudfront";
|
|
3
|
+
/**
|
|
4
|
+
* The CloudfrontClientInterface Interface defines the methods that a Cloudfront client must implement.
|
|
5
|
+
* When injecting the Cloudfront client the 'CloudfrontClientInterface' tag should be used.
|
|
6
|
+
*/
|
|
7
|
+
export interface CloudfrontClientInterface {
|
|
8
|
+
/**
|
|
9
|
+
* Returns the instantiated CloudFrontClient from the @aws-sdk/client-cloudfront
|
|
10
|
+
*/
|
|
11
|
+
getClient(): AWSCloudFrontClient;
|
|
12
|
+
/**
|
|
13
|
+
* Allows you to manually set the config if needed.
|
|
14
|
+
* @param config
|
|
15
|
+
*/
|
|
16
|
+
setClient(config: CloudFrontClientConfig): any;
|
|
17
|
+
/**
|
|
18
|
+
* Invalidates all the provided paths.
|
|
19
|
+
*
|
|
20
|
+
* @param distributionId
|
|
21
|
+
* @param paths
|
|
22
|
+
*/
|
|
23
|
+
invalidate(distributionId: string, paths: string[]): Promise<CreateInvalidationResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the status of the invalidation
|
|
26
|
+
*
|
|
27
|
+
* @param distributionId
|
|
28
|
+
* @param invalidationId
|
|
29
|
+
*/
|
|
30
|
+
getInvalidation(distributionId: string, invalidationId: string): Promise<GetInvalidationResult>;
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/aws",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.257",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/aws.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/aws.module.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@aws-sdk/client-cloudformation": "^3.211.0",
|
|
21
|
+
"@aws-sdk/client-cloudfront": "^3.211.0",
|
|
21
22
|
"@aws-sdk/client-dynamodb": "^3.211.0",
|
|
22
23
|
"@aws-sdk/client-eventbridge": "^3.211.0",
|
|
23
24
|
"@aws-sdk/client-s3": "^3.211.0",
|
|
@@ -28,11 +29,11 @@
|
|
|
28
29
|
"@awslabs-community-fork/dynamodb-data-mapper": "^0.7.9",
|
|
29
30
|
"@awslabs-community-fork/dynamodb-data-marshaller": "^0.7.9",
|
|
30
31
|
"@awslabs-community-fork/dynamodb-expressions": "^0.7.9",
|
|
31
|
-
"@pristine-ts/common": "^0.0.
|
|
32
|
-
"@pristine-ts/core": "^0.0.
|
|
33
|
-
"@pristine-ts/logging": "^0.0.
|
|
34
|
-
"@pristine-ts/networking": "^0.0.
|
|
35
|
-
"@pristine-ts/security": "^0.0.
|
|
32
|
+
"@pristine-ts/common": "^0.0.257",
|
|
33
|
+
"@pristine-ts/core": "^0.0.257",
|
|
34
|
+
"@pristine-ts/logging": "^0.0.257",
|
|
35
|
+
"@pristine-ts/networking": "^0.0.257",
|
|
36
|
+
"@pristine-ts/security": "^0.0.257"
|
|
36
37
|
},
|
|
37
38
|
"publishConfig": {
|
|
38
39
|
"access": "public"
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"src/*.{js,ts}"
|
|
72
73
|
]
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e0e3e99351869c29e3761ceadd13c801e9bf14bf"
|
|
75
76
|
}
|