@digitraffic/common 2025.9.12-2 → 2025.9.22-1

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.
@@ -7,6 +7,7 @@ export function mockKyResponse(status, body) {
7
7
  return Object.assign(promise, {
8
8
  arrayBuffer: () => response.arrayBuffer(),
9
9
  blob: () => response.blob(),
10
+ // eslint-disable-next-line deprecation/deprecation
10
11
  formData: () => response.formData(),
11
12
  json: () => response.json(),
12
13
  text: () => response.text(),
@@ -42,6 +42,10 @@ export declare class AclBuilder {
42
42
  withCountDigitrafficUserIpAndUriPath(limit: number | undefined): this;
43
43
  withCountAnonymousUserIp(limit: number | undefined): this;
44
44
  withCountAnonymousUserIpAndUriPath(limit: number | undefined): this;
45
+ /**
46
+ * Block requests with a query string larger than the specified size.
47
+ */
48
+ withQueryStringSizeRestriction(limit: number): this;
45
49
  _isCustomResponseBodyKeySet(key: string): boolean;
46
50
  _addThrottleResponseBody(customResponseBodyKey: string, limit: number): void;
47
51
  build(): CfnWebACL;
@@ -184,6 +184,31 @@ export class AclBuilder {
184
184
  }
185
185
  return this.withThrottleRule(`CountRuleIPQueryWithAnonymousUser${limit}`, limit, false, true);
186
186
  }
187
+ /**
188
+ * Block requests with a query string larger than the specified size.
189
+ */
190
+ withQueryStringSizeRestriction(limit) {
191
+ this._blockRules.push({
192
+ name: "QueryStringSizeRestriction",
193
+ action: { block: {} },
194
+ statement: {
195
+ sizeConstraintStatement: {
196
+ fieldToMatch: {
197
+ queryString: {},
198
+ },
199
+ comparisonOperator: "GT",
200
+ size: limit,
201
+ textTransformations: [{ priority: 0, type: "NONE" }],
202
+ },
203
+ },
204
+ visibilityConfig: {
205
+ sampledRequestsEnabled: true,
206
+ cloudWatchMetricsEnabled: true,
207
+ metricName: "QueryStringSizeRestriction",
208
+ },
209
+ });
210
+ return this;
211
+ }
187
212
  _isCustomResponseBodyKeySet(key) {
188
213
  return key in this._customResponseBodies;
189
214
  }
@@ -40,8 +40,8 @@ export declare const InternalServerErrorResponseTemplate: {
40
40
  "application/json": string;
41
41
  };
42
42
  export declare class DigitrafficMethodResponse {
43
- static response(statusCode: string, model: IModel, mediaType: MediaType, disableCors?: boolean, deprecation?: boolean): MethodResponse;
44
- static response200(model: IModel, mediaType?: MediaType): MethodResponse;
43
+ static response(statusCode: string, model: IModel, mediaType: MediaType, disableCors?: boolean, deprecation?: boolean, sunset?: boolean): MethodResponse;
44
+ static response200(model: IModel, mediaType?: MediaType, deprecation?: boolean, sunset?: boolean): MethodResponse;
45
45
  static response500(model?: IModel, mediaType?: MediaType): MethodResponse;
46
46
  static response400(model?: IModel, mediaType?: MediaType): MethodResponse;
47
47
  }
@@ -88,7 +88,7 @@ export const InternalServerErrorResponseTemplate = {
88
88
  [MediaType.APPLICATION_JSON]: InternalServerErrorResponse,
89
89
  };
90
90
  export class DigitrafficMethodResponse {
91
- static response(statusCode, model, mediaType, disableCors = false, deprecation = false) {
91
+ static response(statusCode, model, mediaType, disableCors = false, deprecation = false, sunset = false) {
92
92
  return {
93
93
  statusCode,
94
94
  responseModels: {
@@ -100,13 +100,15 @@ export class DigitrafficMethodResponse {
100
100
  }),
101
101
  ...(deprecation && {
102
102
  "method.response.header.Deprecation": true,
103
+ }),
104
+ ...(sunset && {
103
105
  "method.response.header.Sunset": true,
104
106
  }),
105
107
  },
106
108
  };
107
109
  }
108
- static response200(model, mediaType = MediaType.APPLICATION_JSON) {
109
- return DigitrafficMethodResponse.response("200", model, mediaType, false);
110
+ static response200(model, mediaType = MediaType.APPLICATION_JSON, deprecation = false, sunset = false) {
111
+ return DigitrafficMethodResponse.response("200", model, mediaType, false, deprecation, sunset);
110
112
  }
111
113
  static response500(model = Model.EMPTY_MODEL, mediaType = MediaType.APPLICATION_JSON) {
112
114
  return DigitrafficMethodResponse.response("500", model, mediaType, false);
@@ -78,6 +78,7 @@ export class UrlChecker {
78
78
  }
79
79
  expect403WithoutApiKey(url, mediaType) {
80
80
  if (!this.requestOptions.headers ||
81
+ !(API_KEY_HEADER in this.requestOptions.headers) ||
81
82
  !this.requestOptions.headers[API_KEY_HEADER]) {
82
83
  logger.error({
83
84
  method: "UrlChecker.expect403WithoutApiKey",
@@ -21,6 +21,11 @@ export declare class DigitrafficRestApi extends RestApi {
21
21
  exportEndpoint(): void;
22
22
  /** Export end point and given api key to Parameter store */
23
23
  exportEndpoint(apiKeyId: string): void;
24
+ /**
25
+ * @param apiKeyId
26
+ * @param apiKeyName
27
+ * @deprecated Uses deprecated createUsagePlan that creates randomized API key names, use createUsagePlanV2 instead
28
+ */
24
29
  createUsagePlan(apiKeyId: string, apiKeyName: string): string;
25
30
  createUsagePlanV2(apiName: string, apiKey?: string): string;
26
31
  addJsonModel(modelName: string, schema: JsonSchema): ModelWithReference;
@@ -60,16 +60,24 @@ export class DigitrafficRestApi extends RestApi {
60
60
  }
61
61
  apiKeyId = firstKey;
62
62
  }
63
+ // eslint-disable-next-line no-new
63
64
  new StringParameter(this._stack, "export.endpoint", {
64
65
  parameterName: `/digitraffic/${this._stack.configuration.shortName}/endpointUrl`,
65
66
  stringValue: this.url,
66
67
  });
68
+ // eslint-disable-next-line no-new
67
69
  new StringParameter(this._stack, "export.apiKeyId", {
68
70
  parameterName: `/digitraffic/${this._stack.configuration.shortName}/apiKeyId`,
69
71
  stringValue: apiKeyId,
70
72
  });
71
73
  }
74
+ /**
75
+ * @param apiKeyId
76
+ * @param apiKeyName
77
+ * @deprecated Uses deprecated createUsagePlan that creates randomized API key names, use createUsagePlanV2 instead
78
+ */
72
79
  createUsagePlan(apiKeyId, apiKeyName) {
80
+ // eslint-disable-next-line deprecation/deprecation
73
81
  const newKeyId = createUsagePlan(this, apiKeyId, apiKeyName).keyId;
74
82
  this.apiKeyIds.push(newKeyId);
75
83
  return newKeyId;
@@ -8,7 +8,6 @@ export var DataType;
8
8
  DataType["PERMIT_DATA_CHECK"] = "PERMIT_DATA_CHECK";
9
9
  })(DataType || (DataType = {}));
10
10
  const UNSET_SUBTYPE = "-";
11
- // eslint-disable-next-line @rushstack/no-new-null
12
11
  export function getLastUpdated(db, datatype) {
13
12
  return db.oneOrNone("select updated from data_updated where data_type=$(datatype) and subtype=$(subtype)", {
14
13
  datatype: datatype,
@@ -33,7 +32,6 @@ export function updateLastUpdatedWithSubtype(db, datatype, subtype, updated) {
33
32
  on conflict (data_type, subtype)
34
33
  do update set updated = $(updated)`, { updated, subtype, datatype });
35
34
  }
36
- // eslint-disable-next-line @rushstack/no-new-null
37
35
  export function getUpdatedTimestamp(db, datatype) {
38
36
  return db.oneOrNone("select updated_time as updated from updated_timestamp where updated_name=$(datatype)", {
39
37
  datatype: datatype,