@digitraffic/common 2025.7.30-2 → 2025.8.21-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.
@@ -100,7 +100,7 @@ export class DigitrafficIntegration {
100
100
  }
101
101
  else if (parameter.type === "multivaluequerystring") {
102
102
  // make multivaluequerystring values to array
103
- parameterAssignments.push(`#set($tmp = $paramMap.put('_${parameter.name}', $util.parseJson($method.request.multivaluequerystring['${parameter.name}'])))`);
103
+ parameterAssignments.push(`#set($tmp = $paramMap.put('_${parameter.name}', $method.request.multivaluequerystring.${parameter.name}))`);
104
104
  }
105
105
  else if (parameter.type === "path") {
106
106
  parameterAssignments.push(`#set($tmp = $paramMap.put('${parameter.name}', $util.escapeJavaScript($input.params().path['${parameter.name}'])))`);
@@ -112,8 +112,7 @@ export class DigitrafficIntegration {
112
112
  parameterAssignments.push(`#set($tmp = $paramMap.put('${parameter.name}', $util.escapeJavaScript($params['${parameter.name}'])))`);
113
113
  }
114
114
  });
115
- // parameters starting with _ will be handled as json, and will not be in quotes
116
- // (for example multivalueparameters)
115
+ // parameters starting with _ will be handled as multivalue querystring
117
116
  return {
118
117
  [MediaType.APPLICATION_JSON]: `
119
118
  #set($paramMap = {})
@@ -123,10 +122,10 @@ ${this._passAllQueryParameters ? VELOCITY_ALL_PARAMS : ""}
123
122
  ${this._passBody ? VELOCITY_PASS_BODY : ""}
124
123
  {
125
124
  #foreach($paramName in $paramMap.keySet())
126
- #if( $paramName[0] != '_')
125
+ #if( $paramName.substring(0, 1) != '_')
127
126
  "$paramName":"$paramMap.get($paramName)" #if($foreach.hasNext),\n#end
128
127
  #else
129
- "$paramName.substring(1)":$paramMap.get($paramName) #if($foreach.hasNext),\n#end
128
+ "$paramName.substring(1)": [#foreach($val in $paramMap.get($paramName))"$util.escapeJavaScript($val)"#if($foreach.hasNext),#end#end] #if($foreach.hasNext),\n#end
130
129
  #end
131
130
  #end
132
131
  }`,
@@ -14,8 +14,13 @@ export declare const PUBLIC_REST_API_CORS_CONFIG: {
14
14
  export declare class DigitrafficRestApi extends RestApi {
15
15
  readonly apiKeyIds: string[];
16
16
  readonly enableDocumentation: boolean;
17
+ private readonly _stack;
17
18
  constructor(stack: DigitrafficStack, apiId: string, apiName: string, allowFromIpAddresses?: string[] | undefined, config?: Partial<RestApiProps>);
18
19
  hostname(): string;
20
+ /** Export end point and api key to Parameter store */
21
+ exportEndpoint(): void;
22
+ /** Export end point and given api key to Parameter store */
23
+ exportEndpoint(apiKeyId: string): void;
19
24
  createUsagePlan(apiKeyId: string, apiKeyName: string): string;
20
25
  createUsagePlanV2(apiName: string, apiKey?: string): string;
21
26
  addJsonModel(modelName: string, schema: JsonSchema): ModelWithReference;
@@ -4,6 +4,7 @@ import { getModelReference } from "../../../utils/api-model.js";
4
4
  import { MediaType } from "../../types/mediatypes.js";
5
5
  import { createDefaultUsagePlan, createUsagePlan } from "../usage-plans.js";
6
6
  import { set } from "lodash-es";
7
+ import { StringParameter } from "aws-cdk-lib/aws-ssm";
7
8
  export const PUBLIC_REST_API_CORS_CONFIG = {
8
9
  defaultCorsPreflightOptions: {
9
10
  allowOrigins: Cors.ALL_ORIGINS,
@@ -21,6 +22,7 @@ export const PUBLIC_REST_API_CORS_CONFIG = {
21
22
  export class DigitrafficRestApi extends RestApi {
22
23
  apiKeyIds;
23
24
  enableDocumentation;
25
+ _stack;
24
26
  constructor(stack, apiId, apiName, allowFromIpAddresses, config) {
25
27
  const policyDocument = allowFromIpAddresses === null || allowFromIpAddresses === undefined
26
28
  ? createDefaultPolicyDocument()
@@ -38,6 +40,7 @@ export class DigitrafficRestApi extends RestApi {
38
40
  ...config,
39
41
  };
40
42
  super(stack, apiId, apiConfig);
43
+ this._stack = stack;
41
44
  this.apiKeyIds = [];
42
45
  this.enableDocumentation =
43
46
  stack.configuration.stackFeatures?.enableDocumentation ?? true;
@@ -46,6 +49,26 @@ export class DigitrafficRestApi extends RestApi {
46
49
  hostname() {
47
50
  return `${this.restApiId}.execute-api.${this.stack.region}.amazonaws.com`;
48
51
  }
52
+ exportEndpoint(apiKeyId) {
53
+ const firstKey = this.apiKeyIds[0];
54
+ if (!apiKeyId) {
55
+ if (this.apiKeyIds.length > 1) {
56
+ throw new Error("Multiple apikeys, configure which to export");
57
+ }
58
+ if (!firstKey) {
59
+ throw new Error("No apikeys to export");
60
+ }
61
+ apiKeyId = firstKey;
62
+ }
63
+ new StringParameter(this._stack, "export.endpoint", {
64
+ parameterName: `/digitraffic/${this._stack.configuration.shortName}/endpointUrl`,
65
+ stringValue: this.url,
66
+ });
67
+ new StringParameter(this._stack, "export.apiKeyId", {
68
+ parameterName: `/digitraffic/${this._stack.configuration.shortName}/apiKeyId`,
69
+ stringValue: apiKeyId,
70
+ });
71
+ }
49
72
  createUsagePlan(apiKeyId, apiKeyName) {
50
73
  const newKeyId = createUsagePlan(this, apiKeyId, apiKeyName).keyId;
51
74
  this.apiKeyIds.push(newKeyId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2025.7.30-2",
3
+ "version": "2025.8.21-1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "repository": {
@@ -105,43 +105,43 @@
105
105
  "./dist/aws/runtime/digitraffic-integration-response": "./dist/aws/runtime/digitraffic-integration-response.js"
106
106
  },
107
107
  "peerDependencies": {
108
- "@aws-sdk/client-api-gateway": "^3.835.0",
109
- "@aws-sdk/client-s3": "^3.835.0",
110
- "@aws-sdk/client-secrets-manager": "^3.835.0",
111
- "@aws-sdk/client-sns": "^3.835.0",
112
- "@aws-sdk/lib-storage": "^3.835.0",
113
- "@date-fns/tz": "^1.2.0",
114
- "@smithy/node-http-handler": "^4.0.6",
115
- "@smithy/fetch-http-handler": "^5.0.4",
116
- "aws-cdk-lib": "^2.202.0",
108
+ "@aws-sdk/client-api-gateway": "^3.864.0",
109
+ "@aws-sdk/client-s3": "^3.864.0",
110
+ "@aws-sdk/client-secrets-manager": "^3.864.0",
111
+ "@aws-sdk/client-sns": "^3.864.0",
112
+ "@aws-sdk/lib-storage": "^3.864.0",
113
+ "@date-fns/tz": "^1.4.1",
114
+ "@smithy/node-http-handler": "^4.1.1",
115
+ "@smithy/fetch-http-handler": "^5.1.1",
116
+ "aws-cdk-lib": "^2.211.0",
117
117
  "change-case": "^5.4.4",
118
118
  "constructs": "^10.4.2",
119
119
  "date-fns": "^4.1.0",
120
120
  "geojson-validation": "^1.0.2",
121
- "ky": "^1.8.1",
121
+ "ky": "^1.8.2",
122
122
  "lodash-es": "^4.17.21",
123
- "pg-native": "^3.5.1",
124
- "pg-promise": "^11.14.0",
125
- "pg-query-stream": "4.8.1",
126
- "zod": "^3.25.67"
123
+ "pg-native": "^3.5.2",
124
+ "pg-promise": "^11.15.0",
125
+ "pg-query-stream": "4.10.3",
126
+ "zod": "^3.25.76"
127
127
  },
128
128
  "devDependencies": {
129
- "@aws-sdk/client-api-gateway": "^3.835.0",
130
- "@aws-sdk/client-s3": "^3.837.0",
131
- "@aws-sdk/client-secrets-manager": "^3.835.0",
132
- "@aws-sdk/client-sns": "^3.835.0",
133
- "@aws-sdk/lib-storage": "^3.837.0",
134
- "@date-fns/tz": "^1.2.0",
129
+ "@aws-sdk/client-api-gateway": "^3.864.0",
130
+ "@aws-sdk/client-s3": "^3.864.0",
131
+ "@aws-sdk/client-secrets-manager": "^3.864.0",
132
+ "@aws-sdk/client-sns": "^3.864.0",
133
+ "@aws-sdk/lib-storage": "^3.864.0",
134
+ "@date-fns/tz": "^1.4.1",
135
135
  "@digitraffic/eslint-config": "^3.1.1",
136
- "@jest/globals": "^30.0.3",
136
+ "@jest/globals": "^30.0.5",
137
137
  "@rushstack/eslint-config": "^3.7.1",
138
- "@rushstack/heft": "^0.74.0",
139
- "@rushstack/heft-jest-plugin": "^0.16.9",
138
+ "@rushstack/heft": "^0.74.2",
139
+ "@rushstack/heft-jest-plugin": "^0.16.11",
140
140
  "@rushstack/heft-lint-plugin": "^0.5.37",
141
- "@rushstack/heft-typescript-plugin": "^0.9.8",
142
- "@smithy/fetch-http-handler": "5.0.4",
143
- "@smithy/types": "^4.3.1",
144
- "@types/aws-lambda": "8.10.150",
141
+ "@rushstack/heft-typescript-plugin": "^0.9.11",
142
+ "@smithy/fetch-http-handler": "5.1.1",
143
+ "@smithy/types": "^4.3.2",
144
+ "@types/aws-lambda": "8.10.152",
145
145
  "@types/etag": "^1.8.4",
146
146
  "@types/geojson": "7946.0.16",
147
147
  "@types/geojson-validation": "^1.0.3",
@@ -151,7 +151,7 @@
151
151
  "@types/node": "22.15.23",
152
152
  "@typescript-eslint/eslint-plugin": "^7.14.1",
153
153
  "@typescript-eslint/parser": "^7.18.0",
154
- "aws-cdk-lib": "^2.201.0",
154
+ "aws-cdk-lib": "^2.211.0",
155
155
  "aws-sdk": "^2.1692.0",
156
156
  "change-case": "^5.4.4",
157
157
  "constructs": "^10.4.2",
@@ -161,20 +161,20 @@
161
161
  "eslint-plugin-deprecation": "^3.0.0",
162
162
  "etag": "^1.8.1",
163
163
  "geojson-validation": "^1.0.2",
164
- "jest": "^30.0.3",
164
+ "jest": "^30.0.5",
165
165
  "jest-junit": "^16.0.0",
166
- "ky": "^1.8.1",
167
- "lefthook": "^1.11.14",
166
+ "ky": "^1.8.2",
167
+ "lefthook": "^1.12.3",
168
168
  "lodash": "^4.17.21",
169
169
  "lodash-es": "^4.17.21",
170
170
  "madge": "^8.0.0",
171
- "pg-native": "^3.5.0",
172
- "pg-promise": "^11.14.0",
171
+ "pg-native": "^3.5.2",
172
+ "pg-promise": "^11.15.0",
173
173
  "rimraf": "^6.0.1",
174
- "ts-jest": "^29.4.0",
174
+ "ts-jest": "^29.4.1",
175
175
  "typescript": "^5.8.3",
176
176
  "velocityjs": "^2.1.5",
177
- "zod": "^3.25.64"
177
+ "zod": "^3.25.76"
178
178
  },
179
179
  "scripts": {
180
180
  "build": "heft build --clean",