@digitraffic/common 2024.1.10-1 → 2024.1.23-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.
- package/dist/aws/infra/api/{handler-factory.d.ts → handler-factory.d.mts} +2 -2
- package/dist/aws/infra/api/{handler-factory.js → handler-factory.mjs} +5 -10
- package/dist/aws/infra/api/{integration.d.ts → integration.d.mts} +1 -1
- package/dist/aws/infra/api/{integration.js → integration.mjs} +10 -14
- package/dist/aws/infra/api/{response.d.ts → response.d.mts} +2 -3
- package/dist/aws/infra/api/{response.js → response.mjs} +26 -31
- package/dist/aws/infra/api/{responses.d.ts → responses.d.mts} +2 -3
- package/dist/aws/infra/api/responses.mjs +78 -0
- package/dist/aws/infra/api/{static-integration.d.ts → static-integration.d.mts} +1 -1
- package/dist/aws/infra/api/{static-integration.js → static-integration.mjs} +8 -12
- package/dist/aws/infra/canaries/{canary-alarm.d.ts → canary-alarm.d.mts} +1 -1
- package/dist/aws/infra/canaries/canary-alarm.mjs +20 -0
- package/dist/aws/infra/canaries/canary-keys.mjs +4 -0
- package/dist/aws/infra/canaries/canary-parameters.mjs +2 -0
- package/dist/aws/infra/canaries/{canary-role.js → canary-role.mjs} +9 -13
- package/dist/aws/infra/canaries/{canary.d.ts → canary.d.mts} +2 -2
- package/dist/aws/infra/canaries/canary.mjs +26 -0
- package/dist/aws/infra/canaries/{database-canary.d.ts → database-canary.d.mts} +3 -3
- package/dist/aws/infra/canaries/{database-canary.js → database-canary.mjs} +9 -13
- package/dist/aws/infra/canaries/{database-checker.d.ts → database-checker.d.mts} +1 -1
- package/dist/aws/infra/canaries/{database-checker.js → database-checker.mjs} +12 -18
- package/dist/aws/infra/canaries/{url-canary.d.ts → url-canary.d.mts} +4 -4
- package/dist/aws/infra/canaries/{url-canary.js → url-canary.mjs} +9 -13
- package/dist/aws/infra/canaries/{url-checker.d.ts → url-checker.d.mts} +2 -2
- package/dist/aws/infra/canaries/{url-checker.js → url-checker.mjs} +35 -42
- package/dist/aws/infra/{documentation.js → documentation.mjs} +9 -17
- package/dist/aws/infra/{import-util.js → import-util.mjs} +11 -19
- package/dist/aws/infra/scheduler.mjs +27 -0
- package/dist/aws/infra/{security-rule.js → security-rule.mjs} +5 -9
- package/dist/aws/infra/{sqs-integration.d.ts → sqs-integration.d.mts} +1 -2
- package/dist/aws/infra/{sqs-integration.js → sqs-integration.mjs} +12 -16
- package/dist/aws/infra/{sqs-queue.d.ts → sqs-queue.d.mts} +1 -1
- package/dist/aws/infra/{sqs-queue.js → sqs-queue.mjs} +33 -41
- package/dist/aws/infra/stack/{lambda-configs.d.ts → lambda-configs.d.mts} +2 -2
- package/dist/aws/infra/stack/{lambda-configs.js → lambda-configs.mjs} +15 -21
- package/dist/aws/infra/stack/{monitoredfunction.d.ts → monitoredfunction.d.mts} +3 -3
- package/dist/aws/infra/stack/{monitoredfunction.js → monitoredfunction.mjs} +20 -28
- package/dist/aws/infra/stack/{parameters.d.ts → parameters.d.mts} +1 -1
- package/dist/aws/infra/stack/{parameters.js → parameters.mjs} +6 -11
- package/dist/aws/infra/stack/{rest_apis.d.ts → rest_apis.d.mts} +3 -3
- package/dist/aws/infra/stack/{rest_apis.js → rest_apis.mjs} +42 -55
- package/dist/aws/infra/stack/{stack-checking-aspect.d.ts → stack-checking-aspect.d.mts} +1 -1
- package/dist/aws/infra/stack/{stack-checking-aspect.js → stack-checking-aspect.mjs} +25 -32
- package/dist/aws/infra/stack/{stack.d.ts → stack.d.mts} +3 -4
- package/dist/aws/infra/stack/stack.mjs +63 -0
- package/dist/aws/infra/stack/{subscription.d.ts → subscription.d.mts} +2 -2
- package/dist/aws/infra/stack/{subscription.js → subscription.mjs} +6 -11
- package/dist/aws/infra/stacks/{db-dns-stack.d.ts → db-dns-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/db-dns-stack.mjs +60 -0
- package/dist/aws/infra/stacks/{db-proxy-stack.d.ts → db-proxy-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/db-proxy-stack.mjs +73 -0
- package/dist/aws/infra/stacks/{db-stack.d.ts → db-stack.d.mts} +3 -4
- package/dist/aws/infra/stacks/{db-stack.js → db-stack.mjs} +31 -35
- package/dist/aws/infra/stacks/intra-stack-configuration.mjs +2 -0
- package/dist/aws/infra/stacks/{network-stack.d.ts → network-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/network-stack.mjs +40 -0
- package/dist/aws/infra/{usage-plans.js → usage-plans.mjs} +3 -8
- package/dist/aws/runtime/apikey.mjs +9 -0
- package/dist/aws/runtime/{digitraffic-integration-response.d.ts → digitraffic-integration-response.d.mts} +1 -1
- package/dist/aws/runtime/digitraffic-integration-response.mjs +24 -0
- package/dist/aws/runtime/{dt-logger-default.d.ts → dt-logger-default.d.mts} +2 -2
- package/dist/aws/runtime/dt-logger-default.mjs +6 -0
- package/dist/aws/runtime/{dt-logger.d.ts → dt-logger.d.mts} +1 -1
- package/dist/aws/runtime/{dt-logger.js → dt-logger.mjs} +4 -11
- package/dist/aws/runtime/{environment.js → environment.mjs} +4 -8
- package/dist/aws/runtime/{messaging.js → messaging.mjs} +2 -6
- package/dist/aws/runtime/{s3.js → s3.mjs} +4 -8
- package/dist/aws/runtime/secrets/{dbsecret.d.ts → dbsecret.d.mts} +1 -1
- package/dist/aws/runtime/secrets/{dbsecret.js → dbsecret.mjs} +6 -10
- package/dist/aws/runtime/secrets/proxy-holder.mjs +24 -0
- package/dist/aws/runtime/secrets/rds-holder.mjs +24 -0
- package/dist/aws/runtime/secrets/{secret-holder.d.ts → secret-holder.d.mts} +1 -1
- package/dist/aws/runtime/secrets/{secret-holder.js → secret-holder.mjs} +14 -19
- package/dist/aws/runtime/secrets/{secret.js → secret.mjs} +8 -12
- package/dist/aws/types/errors.mjs +12 -0
- package/dist/aws/types/{lambda-response.js → lambda-response.mjs} +4 -11
- package/dist/aws/types/{mediatypes.js → mediatypes.mjs} +3 -6
- package/dist/aws/types/model-with-reference.mjs +2 -0
- package/dist/aws/types/proxytypes.mjs +2 -0
- package/dist/aws/types/tags.mjs +4 -0
- package/dist/database/{cached.d.ts → cached.d.mts} +1 -1
- package/dist/database/{cached.js → cached.mjs} +10 -15
- package/dist/database/{database.d.ts → database.d.mts} +1 -1
- package/dist/database/{database.js → database.mjs} +17 -24
- package/dist/database/{last-updated.d.ts → last-updated.d.mts} +1 -1
- package/dist/database/{last-updated.js → last-updated.mjs} +9 -18
- package/dist/database/models.mjs +2 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +2 -0
- package/dist/marine/{id_utils.js → id_utils.mjs} +4 -10
- package/dist/marine/rtz.mjs +2 -0
- package/dist/test/{asserter.js → asserter.mjs} +2 -6
- package/dist/test/{db-testutils.d.ts → db-testutils.d.mts} +1 -1
- package/dist/test/db-testutils.mjs +29 -0
- package/dist/test/{httpserver.js → httpserver.mjs} +11 -15
- package/dist/test/secrets-manager.mjs +34 -0
- package/dist/test/testutils.mjs +33 -0
- package/dist/types/async-timeout-error.mjs +6 -0
- package/dist/types/aws-env.mjs +2 -0
- package/dist/types/either.mjs +2 -0
- package/dist/types/http-error.mjs +7 -0
- package/dist/types/input-error.mjs +3 -0
- package/dist/types/language.mjs +7 -0
- package/dist/types/{nullable.d.ts → nullable.d.mts} +1 -1
- package/dist/types/nullable.mjs +2 -0
- package/dist/types/{traffictype.js → traffictype.mjs} +3 -6
- package/dist/types/urn.mjs +2 -0
- package/dist/types/util-types.mjs +2 -0
- package/dist/types/validator.mjs +9 -0
- package/dist/utils/{api-model.d.ts → api-model.d.mts} +1 -1
- package/dist/utils/{api-model.js → api-model.mjs} +18 -28
- package/dist/utils/{base64.d.ts → base64.d.mts} +1 -1
- package/dist/utils/base64.mjs +16 -0
- package/dist/utils/date-utils.mjs +44 -0
- package/dist/utils/geojson-types.mjs +13 -0
- package/dist/utils/{geometry.js → geometry.mjs} +16 -49
- package/dist/utils/{logging.d.ts → logging.d.mts} +1 -1
- package/dist/utils/{logging.js → logging.mjs} +9 -14
- package/dist/utils/{retry.js → retry.mjs} +22 -27
- package/dist/utils/slack.mjs +23 -0
- package/dist/utils/{utils.d.ts → utils.d.mts} +2 -2
- package/dist/utils/{utils.js → utils.mjs} +15 -30
- package/package.json +99 -10
- package/src/aws/infra/api/{handler-factory.ts → handler-factory.mts} +3 -3
- package/src/aws/infra/api/{integration.ts → integration.mts} +2 -2
- package/src/aws/infra/api/{response.ts → response.mts} +3 -3
- package/src/aws/infra/api/{responses.ts → responses.mts} +4 -4
- package/src/aws/infra/api/{static-integration.ts → static-integration.mts} +2 -2
- package/src/aws/infra/canaries/Synthetics.d.mts +21 -0
- package/src/aws/infra/canaries/{canary-alarm.ts → canary-alarm.mts} +1 -1
- package/src/aws/infra/canaries/{canary.ts → canary.mts} +3 -3
- package/src/aws/infra/canaries/{database-canary.ts → database-canary.mts} +3 -3
- package/src/aws/infra/canaries/{database-checker.ts → database-checker.mts} +7 -10
- package/src/aws/infra/canaries/{url-canary.ts → url-canary.mts} +6 -6
- package/src/aws/infra/canaries/{url-checker.ts → url-checker.mts} +9 -29
- package/src/aws/infra/{sqs-integration.ts → sqs-integration.mts} +1 -1
- package/src/aws/infra/{sqs-queue.ts → sqs-queue.mts} +3 -6
- package/src/aws/infra/stack/{lambda-configs.ts → lambda-configs.mts} +2 -2
- package/src/aws/infra/stack/{monitoredfunction.ts → monitoredfunction.mts} +4 -4
- package/src/aws/infra/stack/{parameters.ts → parameters.mts} +1 -1
- package/src/aws/infra/stack/{rest_apis.ts → rest_apis.mts} +6 -6
- package/src/aws/infra/stack/{stack-checking-aspect.ts → stack-checking-aspect.mts} +1 -1
- package/src/aws/infra/stack/{stack.ts → stack.mts} +4 -5
- package/src/aws/infra/stack/{subscription.ts → subscription.mts} +2 -2
- package/src/aws/infra/stacks/{db-dns-stack.ts → db-dns-stack.mts} +4 -4
- package/src/aws/infra/stacks/{db-proxy-stack.ts → db-proxy-stack.mts} +5 -5
- package/src/aws/infra/stacks/{db-stack.ts → db-stack.mts} +5 -5
- package/src/aws/infra/stacks/{network-stack.ts → network-stack.mts} +3 -3
- package/src/aws/runtime/{digitraffic-integration-response.ts → digitraffic-integration-response.mts} +2 -2
- package/src/aws/runtime/{dt-logger-default.ts → dt-logger-default.mts} +2 -2
- package/src/aws/runtime/secrets/{dbsecret.ts → dbsecret.mts} +1 -1
- package/src/aws/runtime/secrets/node-ttl.d.mts +12 -0
- package/src/aws/runtime/secrets/{proxy-holder.ts → proxy-holder.mts} +4 -4
- package/src/aws/runtime/secrets/{rds-holder.ts → rds-holder.mts} +4 -4
- package/src/aws/runtime/secrets/{secret-holder.ts → secret-holder.mts} +8 -9
- package/src/aws/runtime/secrets/{secret.ts → secret.mts} +2 -2
- package/src/database/{cached.ts → cached.mts} +4 -2
- package/src/database/{database.ts → database.mts} +6 -6
- package/src/database/{last-updated.ts → last-updated.mts} +1 -1
- package/src/index.mts +2 -0
- package/src/test/{db-testutils.ts → db-testutils.mts} +2 -2
- package/src/test/{secrets-manager.ts → secrets-manager.mts} +3 -3
- package/src/types/{nullable.ts → nullable.mts} +1 -1
- package/src/utils/{api-model.ts → api-model.mts} +1 -1
- package/src/utils/{geometry.ts → geometry.mts} +5 -3
- package/src/utils/{logging.ts → logging.mts} +2 -2
- package/src/utils/{retry.ts → retry.mts} +3 -3
- package/src/utils/{slack.ts → slack.mts} +2 -2
- package/src/utils/{utils.ts → utils.mts} +3 -3
- package/dist/aws/infra/api/responses.js +0 -84
- package/dist/aws/infra/canaries/canary-alarm.js +0 -24
- package/dist/aws/infra/canaries/canary-keys.js +0 -7
- package/dist/aws/infra/canaries/canary-parameters.js +0 -3
- package/dist/aws/infra/canaries/canary.js +0 -30
- package/dist/aws/infra/scheduler.js +0 -31
- package/dist/aws/infra/stack/stack.js +0 -67
- package/dist/aws/infra/stacks/db-dns-stack.js +0 -64
- package/dist/aws/infra/stacks/db-proxy-stack.js +0 -77
- package/dist/aws/infra/stacks/intra-stack-configuration.js +0 -3
- package/dist/aws/infra/stacks/network-stack.js +0 -44
- package/dist/aws/runtime/apikey.js +0 -13
- package/dist/aws/runtime/digitraffic-integration-response.js +0 -28
- package/dist/aws/runtime/dt-logger-default.js +0 -9
- package/dist/aws/runtime/secrets/proxy-holder.js +0 -28
- package/dist/aws/runtime/secrets/rds-holder.js +0 -28
- package/dist/aws/types/errors.js +0 -16
- package/dist/aws/types/model-with-reference.js +0 -3
- package/dist/aws/types/proxytypes.js +0 -3
- package/dist/aws/types/tags.js +0 -7
- package/dist/database/models.js +0 -3
- package/dist/marine/rtz.js +0 -3
- package/dist/test/db-testutils.js +0 -34
- package/dist/test/secrets-manager.js +0 -62
- package/dist/test/testutils.js +0 -44
- package/dist/types/async-timeout-error.js +0 -10
- package/dist/types/aws-env.js +0 -3
- package/dist/types/either.js +0 -3
- package/dist/types/http-error.js +0 -11
- package/dist/types/input-error.js +0 -7
- package/dist/types/language.js +0 -10
- package/dist/types/nullable.js +0 -3
- package/dist/types/urn.js +0 -3
- package/dist/types/util-types.js +0 -3
- package/dist/types/validator.js +0 -14
- package/dist/utils/base64.js +0 -21
- package/dist/utils/date-utils.js +0 -51
- package/dist/utils/geojson-types.js +0 -18
- package/dist/utils/slack.js +0 -30
- /package/dist/aws/infra/canaries/{canary-keys.d.ts → canary-keys.d.mts} +0 -0
- /package/dist/aws/infra/canaries/{canary-parameters.d.ts → canary-parameters.d.mts} +0 -0
- /package/dist/aws/infra/canaries/{canary-role.d.ts → canary-role.d.mts} +0 -0
- /package/dist/aws/infra/{documentation.d.ts → documentation.d.mts} +0 -0
- /package/dist/aws/infra/{import-util.d.ts → import-util.d.mts} +0 -0
- /package/dist/aws/infra/{scheduler.d.ts → scheduler.d.mts} +0 -0
- /package/dist/aws/infra/{security-rule.d.ts → security-rule.d.mts} +0 -0
- /package/dist/aws/infra/stacks/{intra-stack-configuration.d.ts → intra-stack-configuration.d.mts} +0 -0
- /package/dist/aws/infra/{usage-plans.d.ts → usage-plans.d.mts} +0 -0
- /package/dist/aws/runtime/{apikey.d.ts → apikey.d.mts} +0 -0
- /package/dist/aws/runtime/{environment.d.ts → environment.d.mts} +0 -0
- /package/dist/aws/runtime/{messaging.d.ts → messaging.d.mts} +0 -0
- /package/dist/aws/runtime/{s3.d.ts → s3.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{proxy-holder.d.ts → proxy-holder.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{rds-holder.d.ts → rds-holder.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{secret.d.ts → secret.d.mts} +0 -0
- /package/dist/aws/types/{errors.d.ts → errors.d.mts} +0 -0
- /package/dist/aws/types/{lambda-response.d.ts → lambda-response.d.mts} +0 -0
- /package/dist/aws/types/{mediatypes.d.ts → mediatypes.d.mts} +0 -0
- /package/dist/aws/types/{model-with-reference.d.ts → model-with-reference.d.mts} +0 -0
- /package/dist/aws/types/{proxytypes.d.ts → proxytypes.d.mts} +0 -0
- /package/dist/aws/types/{tags.d.ts → tags.d.mts} +0 -0
- /package/dist/database/{models.d.ts → models.d.mts} +0 -0
- /package/dist/marine/{id_utils.d.ts → id_utils.d.mts} +0 -0
- /package/dist/marine/{rtz.d.ts → rtz.d.mts} +0 -0
- /package/dist/test/{asserter.d.ts → asserter.d.mts} +0 -0
- /package/dist/test/{httpserver.d.ts → httpserver.d.mts} +0 -0
- /package/dist/test/{secrets-manager.d.ts → secrets-manager.d.mts} +0 -0
- /package/dist/test/{testutils.d.ts → testutils.d.mts} +0 -0
- /package/dist/types/{async-timeout-error.d.ts → async-timeout-error.d.mts} +0 -0
- /package/dist/types/{aws-env.d.ts → aws-env.d.mts} +0 -0
- /package/dist/types/{either.d.ts → either.d.mts} +0 -0
- /package/dist/types/{http-error.d.ts → http-error.d.mts} +0 -0
- /package/dist/types/{input-error.d.ts → input-error.d.mts} +0 -0
- /package/dist/types/{language.d.ts → language.d.mts} +0 -0
- /package/dist/types/{traffictype.d.ts → traffictype.d.mts} +0 -0
- /package/dist/types/{urn.d.ts → urn.d.mts} +0 -0
- /package/dist/types/{util-types.d.ts → util-types.d.mts} +0 -0
- /package/dist/types/{validator.d.ts → validator.d.mts} +0 -0
- /package/dist/utils/{date-utils.d.ts → date-utils.d.mts} +0 -0
- /package/dist/utils/{geojson-types.d.ts → geojson-types.d.mts} +0 -0
- /package/dist/utils/{geometry.d.ts → geometry.d.mts} +0 -0
- /package/dist/utils/{retry.d.ts → retry.d.mts} +0 -0
- /package/dist/utils/{slack.d.ts → slack.d.mts} +0 -0
- /package/src/@types/geojson-validation/{index.d.ts → index.d.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-keys.ts → canary-keys.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-parameters.ts → canary-parameters.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-role.ts → canary-role.mts} +0 -0
- /package/src/aws/infra/{documentation.ts → documentation.mts} +0 -0
- /package/src/aws/infra/{import-util.ts → import-util.mts} +0 -0
- /package/src/aws/infra/{scheduler.ts → scheduler.mts} +0 -0
- /package/src/aws/infra/{security-rule.ts → security-rule.mts} +0 -0
- /package/src/aws/infra/stacks/{intra-stack-configuration.ts → intra-stack-configuration.mts} +0 -0
- /package/src/aws/infra/{usage-plans.ts → usage-plans.mts} +0 -0
- /package/src/aws/runtime/{apikey.ts → apikey.mts} +0 -0
- /package/src/aws/runtime/{dt-logger.ts → dt-logger.mts} +0 -0
- /package/src/aws/runtime/{environment.ts → environment.mts} +0 -0
- /package/src/aws/runtime/{messaging.ts → messaging.mts} +0 -0
- /package/src/aws/runtime/{s3.ts → s3.mts} +0 -0
- /package/src/aws/types/{errors.ts → errors.mts} +0 -0
- /package/src/aws/types/{lambda-response.ts → lambda-response.mts} +0 -0
- /package/src/aws/types/{mediatypes.ts → mediatypes.mts} +0 -0
- /package/src/aws/types/{model-with-reference.ts → model-with-reference.mts} +0 -0
- /package/src/aws/types/{proxytypes.ts → proxytypes.mts} +0 -0
- /package/src/aws/types/{tags.ts → tags.mts} +0 -0
- /package/src/database/{models.ts → models.mts} +0 -0
- /package/src/marine/{id_utils.ts → id_utils.mts} +0 -0
- /package/src/marine/{rtz.ts → rtz.mts} +0 -0
- /package/src/test/{asserter.ts → asserter.mts} +0 -0
- /package/src/test/{httpserver.ts → httpserver.mts} +0 -0
- /package/src/test/{testutils.ts → testutils.mts} +0 -0
- /package/src/types/{async-timeout-error.ts → async-timeout-error.mts} +0 -0
- /package/src/types/{aws-env.ts → aws-env.mts} +0 -0
- /package/src/types/{either.ts → either.mts} +0 -0
- /package/src/types/{http-error.ts → http-error.mts} +0 -0
- /package/src/types/{input-error.ts → input-error.mts} +0 -0
- /package/src/types/{language.ts → language.mts} +0 -0
- /package/src/types/{traffictype.ts → traffictype.mts} +0 -0
- /package/src/types/{urn.ts → urn.mts} +0 -0
- /package/src/types/{util-types.ts → util-types.mts} +0 -0
- /package/src/types/{validator.ts → validator.mts} +0 -0
- /package/src/utils/{base64.ts → base64.mts} +0 -0
- /package/src/utils/{date-utils.ts → date-utils.mts} +0 -0
- /package/src/utils/{geojson-types.ts → geojson-types.mts} +0 -0
@@ -1,19 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const dt_logger_default_1 = require("../aws/runtime/dt-logger-default");
|
6
|
-
const logging_1 = require("../utils/logging");
|
7
|
-
var DatabaseEnvironmentKeys;
|
1
|
+
import { getEnvVariable, getEnvVariableOrElse } from "../utils/utils.mjs";
|
2
|
+
import { logger } from "../aws/runtime/dt-logger-default.mjs";
|
3
|
+
import { logException } from "../utils/logging.mjs";
|
4
|
+
export var DatabaseEnvironmentKeys;
|
8
5
|
(function (DatabaseEnvironmentKeys) {
|
9
6
|
DatabaseEnvironmentKeys["DB_USER"] = "DB_USER";
|
10
7
|
DatabaseEnvironmentKeys["DB_PASS"] = "DB_PASS";
|
11
8
|
DatabaseEnvironmentKeys["DB_URI"] = "DB_URI";
|
12
9
|
DatabaseEnvironmentKeys["DB_RO_URI"] = "DB_RO_URI";
|
13
10
|
DatabaseEnvironmentKeys["DB_APPLICATION"] = "DB_APPLICATION";
|
14
|
-
})(DatabaseEnvironmentKeys || (
|
15
|
-
|
16
|
-
const pgp =
|
11
|
+
})(DatabaseEnvironmentKeys || (DatabaseEnvironmentKeys = {}));
|
12
|
+
const pgpImport = await import("pg-promise");
|
13
|
+
const pgp = pgpImport.default();
|
17
14
|
// convert numeric types to number instead of string
|
18
15
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
19
16
|
pgp.pg.types.setTypeParser(pgp.pg.types.builtins.INT8, (value) => {
|
@@ -39,30 +36,26 @@ pgp.pg.types.setTypeParser(pgp.pg.types.builtins.NUMERIC, (value) => {
|
|
39
36
|
* @param url Connection URL
|
40
37
|
* @param options pg-promise options
|
41
38
|
*/
|
42
|
-
function initDbConnection(username, password, applicationName, url, options) {
|
39
|
+
export function initDbConnection(username, password, applicationName, url, options) {
|
43
40
|
const finalUrl = `postgresql://${username}:${password}@${url}?application_name=${applicationName}`;
|
44
41
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
45
42
|
return pgp(finalUrl, options);
|
46
43
|
}
|
47
|
-
|
48
|
-
function inTransaction(fn) {
|
44
|
+
export function inTransaction(fn) {
|
49
45
|
return inDatabase((db) => db.tx((t) => fn(t)));
|
50
46
|
}
|
51
|
-
|
52
|
-
function inDatabase(fn) {
|
47
|
+
export function inDatabase(fn) {
|
53
48
|
return doInDatabase(false, fn);
|
54
49
|
}
|
55
|
-
|
56
|
-
function inDatabaseReadonly(fn) {
|
50
|
+
export function inDatabaseReadonly(fn) {
|
57
51
|
return doInDatabase(true, fn);
|
58
52
|
}
|
59
|
-
exports.inDatabaseReadonly = inDatabaseReadonly;
|
60
53
|
async function doInDatabase(readonly, fn) {
|
61
|
-
const db_application =
|
54
|
+
const db_application = getEnvVariableOrElse(DatabaseEnvironmentKeys.DB_APPLICATION, "unknown-cdk-application");
|
62
55
|
const db_uri = readonly
|
63
|
-
?
|
64
|
-
:
|
65
|
-
const db = initDbConnection(
|
56
|
+
? getEnvVariable(DatabaseEnvironmentKeys.DB_RO_URI)
|
57
|
+
: getEnvVariable(DatabaseEnvironmentKeys.DB_URI);
|
58
|
+
const db = initDbConnection(getEnvVariable(DatabaseEnvironmentKeys.DB_USER), getEnvVariable(DatabaseEnvironmentKeys.DB_PASS), db_application, db_uri);
|
66
59
|
try {
|
67
60
|
// deallocate all prepared statements to allow for connection pooling
|
68
61
|
// DISCARD instead of DEALLOCATE as it didn't always clean all prepared statements
|
@@ -70,11 +63,11 @@ async function doInDatabase(readonly, fn) {
|
|
70
63
|
return await fn(db);
|
71
64
|
}
|
72
65
|
catch (e) {
|
73
|
-
|
66
|
+
logException(logger, e);
|
74
67
|
throw e;
|
75
68
|
}
|
76
69
|
finally {
|
77
70
|
await db.$pool.end();
|
78
71
|
}
|
79
72
|
}
|
80
|
-
//# sourceMappingURL=database.
|
73
|
+
//# sourceMappingURL=database.mjs.map
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.updateUpdatedTimestamp = exports.getUpdatedTimestamp = exports.updateLastUpdatedWithSubtype = exports.updateLastUpdated = exports.getLastUpdatedWithSubtype = exports.getLastUpdated = exports.DataType = void 0;
|
4
|
-
var DataType;
|
1
|
+
export var DataType;
|
5
2
|
(function (DataType) {
|
6
3
|
DataType["VS_DATEX2"] = "VS_DATEX2";
|
7
4
|
DataType["COUNTING_SITES_DATA"] = "COUNTING_SITES_DATA";
|
@@ -10,47 +7,41 @@ var DataType;
|
|
10
7
|
DataType["MAINTENANCE_TRACKING_DATA_CHECKED"] = "MAINTENANCE_TRACKING_DATA_CHECKED";
|
11
8
|
DataType["PERMIT_DATA"] = "PERMIT_DATA";
|
12
9
|
DataType["PERMIT_DATA_CHECK"] = "PERMIT_DATA_CHECK";
|
13
|
-
})(DataType || (
|
10
|
+
})(DataType || (DataType = {}));
|
14
11
|
const UNSET_SUBTYPE = "-";
|
15
|
-
function getLastUpdated(db, datatype) {
|
12
|
+
export function getLastUpdated(db, datatype) {
|
16
13
|
return db.oneOrNone("select updated from data_updated where data_type=$(datatype) and subtype=$(subtype)", {
|
17
14
|
datatype: datatype,
|
18
15
|
subtype: UNSET_SUBTYPE,
|
19
16
|
}, (x) => x?.updated ?? null);
|
20
17
|
}
|
21
|
-
|
22
|
-
function getLastUpdatedWithSubtype(db, datatype, subtype) {
|
18
|
+
export function getLastUpdatedWithSubtype(db, datatype, subtype) {
|
23
19
|
return db.oneOrNone("SELECT updated FROM data_updated WHERE data_type=$(datatype) AND subtype=$(subtype)", {
|
24
20
|
datatype: datatype,
|
25
21
|
subtype: subtype,
|
26
22
|
}, (x) => x?.updated ?? null);
|
27
23
|
}
|
28
|
-
|
29
|
-
function updateLastUpdated(db, datatype, updated) {
|
24
|
+
export function updateLastUpdated(db, datatype, updated) {
|
30
25
|
return db.none(`insert into data_updated(id, data_type, updated)
|
31
26
|
values(nextval('seq_data_updated'), $(datatype), $(updated))
|
32
27
|
on conflict (data_type, subtype)
|
33
28
|
do update set updated = $(updated)`, { updated, datatype });
|
34
29
|
}
|
35
|
-
|
36
|
-
function updateLastUpdatedWithSubtype(db, datatype, subtype, updated) {
|
30
|
+
export function updateLastUpdatedWithSubtype(db, datatype, subtype, updated) {
|
37
31
|
return db.none(`insert into data_updated(id, data_type, subtype, updated)
|
38
32
|
values(nextval('seq_data_updated'), $(datatype), $(subtype), $(updated))
|
39
33
|
on conflict (data_type, subtype)
|
40
34
|
do update set updated = $(updated)`, { updated, subtype, datatype });
|
41
35
|
}
|
42
|
-
|
43
|
-
function getUpdatedTimestamp(db, datatype) {
|
36
|
+
export function getUpdatedTimestamp(db, datatype) {
|
44
37
|
return db.oneOrNone("select updated_time as updated from updated_timestamp where updated_name=$(datatype)", {
|
45
38
|
datatype: datatype,
|
46
39
|
}, (x) => x?.updated ?? null);
|
47
40
|
}
|
48
|
-
|
49
|
-
function updateUpdatedTimestamp(db, datatype, date, by = "") {
|
41
|
+
export function updateUpdatedTimestamp(db, datatype, date, by = "") {
|
50
42
|
return db.none(`insert into updated_timestamp(updated_name, updated_time, updated_by)
|
51
43
|
values($(datatype), $(date), $(by))
|
52
44
|
on conflict (updated_name)
|
53
45
|
do update set updated_time = $(date), updated_by = $(by)`, { date, datatype, by });
|
54
46
|
}
|
55
|
-
|
56
|
-
//# sourceMappingURL=last-updated.js.map
|
47
|
+
//# sourceMappingURL=last-updated.mjs.map
|
package/dist/index.d.mts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export { DigitrafficStack } from "./aws/infra/stack/stack.mjs";
|
package/dist/index.mjs
ADDED
@@ -1,10 +1,6 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isValidLOCODE = exports.isValidMMSI = exports.isValidIMO = void 0;
|
4
|
-
function isValidIMO(imo) {
|
1
|
+
export function isValidIMO(imo) {
|
5
2
|
return imo >= 1000000 && imo <= 9999999 && imoChecksumIsValid(imo);
|
6
3
|
}
|
7
|
-
exports.isValidIMO = isValidIMO;
|
8
4
|
function imoChecksumIsValid(imo) {
|
9
5
|
const imoStr = imo.toString();
|
10
6
|
const imoDigit1 = Number(imoStr[0]);
|
@@ -21,13 +17,11 @@ function imoChecksumIsValid(imo) {
|
|
21
17
|
}
|
22
18
|
return checkResult;
|
23
19
|
}
|
24
|
-
function isValidMMSI(mmsi) {
|
20
|
+
export function isValidMMSI(mmsi) {
|
25
21
|
return mmsi >= 100000000 && mmsi <= 999999999;
|
26
22
|
}
|
27
|
-
exports.isValidMMSI = isValidMMSI;
|
28
23
|
const LocodePattern = /^FI[A-Z]{3}$/i;
|
29
|
-
function isValidLOCODE(locode) {
|
24
|
+
export function isValidLOCODE(locode) {
|
30
25
|
return LocodePattern.test(locode);
|
31
26
|
}
|
32
|
-
|
33
|
-
//# sourceMappingURL=id_utils.js.map
|
27
|
+
//# sourceMappingURL=id_utils.mjs.map
|
@@ -1,10 +1,7 @@
|
|
1
|
-
"use strict";
|
2
1
|
/**
|
3
2
|
* A simple asserter-class for writing canaries without dependency to testing-libraries.
|
4
3
|
*/
|
5
|
-
|
6
|
-
exports.Asserter = void 0;
|
7
|
-
class Asserter {
|
4
|
+
export class Asserter {
|
8
5
|
static assertEquals(value, expected) {
|
9
6
|
if (value != expected) {
|
10
7
|
throw new Error(`Given value ${value} was not expected ${expected}`);
|
@@ -41,5 +38,4 @@ class Asserter {
|
|
41
38
|
expect(expected - value).toBeLessThanOrEqual(delta);
|
42
39
|
}
|
43
40
|
}
|
44
|
-
|
45
|
-
//# sourceMappingURL=asserter.js.map
|
41
|
+
//# sourceMappingURL=asserter.mjs.map
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { DTDatabase } from "../database/database";
|
1
|
+
import { DTDatabase } from "../database/database.mjs";
|
2
2
|
export declare function assertCount(db: DTDatabase, sql: string, count: number): Promise<void>;
|
3
3
|
export declare function dbTestBase(fn: (db: DTDatabase) => void, truncateFn: (db: DTDatabase) => Promise<void>, dbUser: string, dbPass: string, dbUri: string): () => void;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { DatabaseEnvironmentKeys, initDbConnection, } from "../database/database.mjs";
|
2
|
+
export async function assertCount(db, sql, count) {
|
3
|
+
await db.one(sql).then((x) => expect(x.count).toEqual(count));
|
4
|
+
}
|
5
|
+
export function dbTestBase(fn, truncateFn, dbUser, dbPass, dbUri) {
|
6
|
+
const theDbUri = process.env.DB_URI ?? dbUri;
|
7
|
+
console.log(`Test database URI: ${theDbUri}`);
|
8
|
+
return () => {
|
9
|
+
const db = initDbConnection(dbUser, dbPass, "test", theDbUri, {
|
10
|
+
noWarnings: true, // ignore duplicate connection warning for tests
|
11
|
+
});
|
12
|
+
beforeAll(async () => {
|
13
|
+
process.env[DatabaseEnvironmentKeys.DB_USER] = dbUser;
|
14
|
+
process.env[DatabaseEnvironmentKeys.DB_PASS] = dbPass;
|
15
|
+
process.env[DatabaseEnvironmentKeys.DB_URI] = theDbUri;
|
16
|
+
process.env[DatabaseEnvironmentKeys.DB_RO_URI] = theDbUri;
|
17
|
+
await truncateFn(db);
|
18
|
+
});
|
19
|
+
afterAll(async () => {
|
20
|
+
await truncateFn(db);
|
21
|
+
await db.$pool.end();
|
22
|
+
});
|
23
|
+
beforeEach(async () => {
|
24
|
+
await truncateFn(db);
|
25
|
+
});
|
26
|
+
fn(db);
|
27
|
+
};
|
28
|
+
}
|
29
|
+
//# sourceMappingURL=db-testutils.mjs.map
|
@@ -1,14 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const
|
5
|
-
const url_1 = require("url");
|
6
|
-
exports.ERROR_NO_MATCH = "NO MATCH";
|
7
|
-
exports.ERRORCODE_NOT_FOUND = 404;
|
1
|
+
import { createServer } from "http";
|
2
|
+
import { parse } from "url";
|
3
|
+
export const ERROR_NO_MATCH = "NO MATCH";
|
4
|
+
export const ERRORCODE_NOT_FOUND = 404;
|
8
5
|
/**
|
9
6
|
* A mock HTTP server created for testing connections from a Lambda to an outside integration
|
10
7
|
*/
|
11
|
-
class TestHttpServer {
|
8
|
+
export class TestHttpServer {
|
12
9
|
constructor() {
|
13
10
|
this.debug = false;
|
14
11
|
this.messageStack = [];
|
@@ -23,14 +20,14 @@ class TestHttpServer {
|
|
23
20
|
this.debug = debug;
|
24
21
|
this.messageStack = [];
|
25
22
|
this.debuglog(`Starting test server on port ${port}`);
|
26
|
-
this.server =
|
23
|
+
this.server = createServer((req, res) => {
|
27
24
|
this.debuglog("Mapped urls: ");
|
28
25
|
Object.keys(props).forEach((k) => this.debuglog(k));
|
29
26
|
if (!req.url) {
|
30
27
|
throw new Error("Missing request url!");
|
31
28
|
}
|
32
29
|
this.debuglog(`Received request to url ${req.url} ..`);
|
33
|
-
const path =
|
30
|
+
const path = parse(req.url).pathname;
|
34
31
|
if (!path) {
|
35
32
|
throw new Error("Missing path from request!");
|
36
33
|
}
|
@@ -56,9 +53,9 @@ class TestHttpServer {
|
|
56
53
|
req.on("end", () => {
|
57
54
|
// assume sent data is in JSON format
|
58
55
|
this.messageStack[this.messageStack.length] =
|
59
|
-
|
60
|
-
res.writeHead(
|
61
|
-
res.end(
|
56
|
+
ERROR_NO_MATCH;
|
57
|
+
res.writeHead(ERRORCODE_NOT_FOUND);
|
58
|
+
res.end(ERROR_NO_MATCH);
|
62
59
|
});
|
63
60
|
}
|
64
61
|
});
|
@@ -81,5 +78,4 @@ class TestHttpServer {
|
|
81
78
|
}
|
82
79
|
}
|
83
80
|
}
|
84
|
-
|
85
|
-
//# sourceMappingURL=httpserver.js.map
|
81
|
+
//# sourceMappingURL=httpserver.mjs.map
|
@@ -0,0 +1,34 @@
|
|
1
|
+
const AWS = await import("aws-sdk");
|
2
|
+
import * as sinon from "sinon";
|
3
|
+
import { EnvKeys } from "../aws/runtime/environment.mjs";
|
4
|
+
import { setEnvVariable } from "../utils/utils.mjs";
|
5
|
+
setEnvVariable(EnvKeys.AWS_REGION, "eu-west-1");
|
6
|
+
const secretValue = sinon.stub();
|
7
|
+
/**
|
8
|
+
* Stub Secrets Manager for tests. You must call this
|
9
|
+
* before you instantiate Secrets Manager(this might happen when you import the function that uses Secrets Manager).
|
10
|
+
*
|
11
|
+
* To mock the actual secret, call mockSecret()
|
12
|
+
*/
|
13
|
+
export function stubSecretsManager() {
|
14
|
+
const smStub = {
|
15
|
+
getSecretValue: secretValue,
|
16
|
+
};
|
17
|
+
sinon.stub(AWS, "SecretsManager").returns(smStub);
|
18
|
+
return smStub.getSecretValue;
|
19
|
+
}
|
20
|
+
export function mockSecret(secret) {
|
21
|
+
if (!secret) {
|
22
|
+
secretValue.returns({
|
23
|
+
promise: sinon.stub().returns({}),
|
24
|
+
});
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
secretValue.returns({
|
28
|
+
promise: sinon.stub().returns({
|
29
|
+
SecretString: JSON.stringify(secret),
|
30
|
+
}),
|
31
|
+
});
|
32
|
+
}
|
33
|
+
}
|
34
|
+
//# sourceMappingURL=secrets-manager.mjs.map
|
@@ -0,0 +1,33 @@
|
|
1
|
+
export function randomString() {
|
2
|
+
return Math.random().toString(36).substring(2);
|
3
|
+
}
|
4
|
+
export function getRandomNumber(min, max) {
|
5
|
+
return Math.random() * (max - min) + min;
|
6
|
+
}
|
7
|
+
export function getRandomNumberAsString(min, max) {
|
8
|
+
return getRandomNumber(min, max).toString();
|
9
|
+
}
|
10
|
+
export function getRandomInteger(min, max) {
|
11
|
+
return Math.round(getRandomNumber(min, max));
|
12
|
+
}
|
13
|
+
export function getRandomIntegerAsString(min, max) {
|
14
|
+
return Math.round(getRandomInteger(min, max)).toString();
|
15
|
+
}
|
16
|
+
export function getRandomBigInt(min, max) {
|
17
|
+
return BigInt(getRandomInteger(min, max));
|
18
|
+
}
|
19
|
+
export function randomBoolean() {
|
20
|
+
return Math.random() < 0.5;
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* Returns a new copy of an array, shuffled using Math.random()
|
24
|
+
* @param array Array
|
25
|
+
*/
|
26
|
+
export function shuffle(array) {
|
27
|
+
// pretty fast way to copy an array, not necessarily the fastest
|
28
|
+
const newArray = array.slice(0);
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
30
|
+
newArray.sort((x) => 0.5 - Math.random());
|
31
|
+
return newArray;
|
32
|
+
}
|
33
|
+
//# sourceMappingURL=testutils.mjs.map
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.TrafficType = void 0;
|
4
|
-
var TrafficType;
|
1
|
+
export var TrafficType;
|
5
2
|
(function (TrafficType) {
|
6
3
|
TrafficType["ROAD"] = "Road";
|
7
4
|
TrafficType["MARINE"] = "Marine";
|
@@ -9,5 +6,5 @@ var TrafficType;
|
|
9
6
|
TrafficType["AVIATION"] = "Aviation";
|
10
7
|
TrafficType["MCP"] = "MCP";
|
11
8
|
TrafficType["OTHER"] = "Other";
|
12
|
-
})(TrafficType || (
|
13
|
-
//# sourceMappingURL=traffictype.
|
9
|
+
})(TrafficType || (TrafficType = {}));
|
10
|
+
//# sourceMappingURL=traffictype.mjs.map
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export const MIN_YEAR = 1900;
|
2
|
+
export const MAX_YEAR = 2100;
|
3
|
+
export function validateYear(year, minYear = MIN_YEAR, maxYear = MAX_YEAR) {
|
4
|
+
return year >= minYear && year <= maxYear;
|
5
|
+
}
|
6
|
+
export function validateMonth(month) {
|
7
|
+
return month > 0 && month < 13;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=validator.mjs.map
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { RestApi, Model, JsonSchema, RequestValidator, JsonSchemaType, JsonSchemaVersion } from 'aws-cdk-lib/aws-apigateway';
|
2
|
-
import { ModelWithReference } from "../aws/types/model-with-reference";
|
2
|
+
import { ModelWithReference } from "../aws/types/model-with-reference.mjs";
|
3
3
|
/**
|
4
4
|
* Get a reference to an OpenAPI model object in a REST API.
|
5
5
|
* Can be used to supply a reference to properties of a GeoJSON feature.
|
@@ -1,29 +1,24 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.geojsonSchema = exports.featureSchema = exports.createArraySchema = exports.addSimpleServiceModel = exports.addServiceModel = exports.addDefaultValidator = exports.getModelReference = void 0;
|
4
|
-
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
1
|
+
import { JsonSchemaType, JsonSchemaVersion, } from 'aws-cdk-lib/aws-apigateway';
|
5
2
|
/**
|
6
3
|
* Get a reference to an OpenAPI model object in a REST API.
|
7
4
|
* Can be used to supply a reference to properties of a GeoJSON feature.
|
8
5
|
* @param modelId Id of the referenced object
|
9
6
|
* @param restApiId Id of the REST API
|
10
7
|
*/
|
11
|
-
function getModelReference(modelId, restApiId) {
|
8
|
+
export function getModelReference(modelId, restApiId) {
|
12
9
|
return `https://apigateway.amazonaws.com/restapis/${restApiId}/models/${modelId}`;
|
13
10
|
}
|
14
|
-
exports.getModelReference = getModelReference;
|
15
11
|
/**
|
16
12
|
* Adds a request validator to a REST API to enforce request parameters/body requirements.
|
17
13
|
* https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html
|
18
14
|
* @param api REST API
|
19
15
|
*/
|
20
|
-
function addDefaultValidator(api) {
|
16
|
+
export function addDefaultValidator(api) {
|
21
17
|
return api.addRequestValidator('DefaultValidator', {
|
22
18
|
validateRequestParameters: true,
|
23
19
|
validateRequestBody: true,
|
24
20
|
});
|
25
21
|
}
|
26
|
-
exports.addDefaultValidator = addDefaultValidator;
|
27
22
|
/**
|
28
23
|
* Adds a JSON Schema model to an API Gateway API. Can be used later to generate OpenAPI specifications.
|
29
24
|
* This method adds a schema for _a single object._
|
@@ -32,7 +27,7 @@ exports.addDefaultValidator = addDefaultValidator;
|
|
32
27
|
* @param schema JSON Schema
|
33
28
|
* @return ModelWithReference A model object with a reference to an API Gateway model object.
|
34
29
|
*/
|
35
|
-
function addServiceModel(modelName, api, schema) {
|
30
|
+
export function addServiceModel(modelName, api, schema) {
|
36
31
|
const mwr = api.addModel(modelName, {
|
37
32
|
contentType: 'application/json',
|
38
33
|
modelName,
|
@@ -41,7 +36,6 @@ function addServiceModel(modelName, api, schema) {
|
|
41
36
|
mwr.modelReference = getModelReference(mwr.modelId, api.restApiId);
|
42
37
|
return mwr;
|
43
38
|
}
|
44
|
-
exports.addServiceModel = addServiceModel;
|
45
39
|
/**
|
46
40
|
* Add an empty JSON schema model to an API Gateway API.
|
47
41
|
* Usable for example if the incoming data is in XML format but some template transformation is necessary.
|
@@ -49,42 +43,40 @@ exports.addServiceModel = addServiceModel;
|
|
49
43
|
* @param api
|
50
44
|
* @param contentType
|
51
45
|
*/
|
52
|
-
function addSimpleServiceModel(modelName, api, contentType = 'application/xml') {
|
46
|
+
export function addSimpleServiceModel(modelName, api, contentType = 'application/xml') {
|
53
47
|
return api.addModel(modelName, {
|
54
48
|
contentType,
|
55
49
|
modelName,
|
56
50
|
schema: {},
|
57
51
|
});
|
58
52
|
}
|
59
|
-
exports.addSimpleServiceModel = addSimpleServiceModel;
|
60
53
|
/**
|
61
54
|
* Adds a JSON Schema model to an API Gateway API. Can be used later to generate OpenAPI specifications.
|
62
55
|
* This method adds a schema for _an array._
|
63
56
|
* @param model
|
64
57
|
* @param api
|
65
58
|
*/
|
66
|
-
function createArraySchema(model, api) {
|
59
|
+
export function createArraySchema(model, api) {
|
67
60
|
return {
|
68
|
-
type:
|
61
|
+
type: JsonSchemaType.ARRAY,
|
69
62
|
items: {
|
70
63
|
ref: getModelReference(model.modelId, api.restApiId),
|
71
64
|
},
|
72
65
|
};
|
73
66
|
}
|
74
|
-
exports.createArraySchema = createArraySchema;
|
75
67
|
/**
|
76
68
|
* Creates a JSON Schema for a GeoJSON Feature. Can be used to generate OpenAPI descriptions.
|
77
69
|
* @param modelReference Reference to a model object
|
78
70
|
*/
|
79
|
-
function featureSchema(modelReference) {
|
71
|
+
export function featureSchema(modelReference) {
|
80
72
|
return {
|
81
|
-
schema:
|
82
|
-
type:
|
73
|
+
schema: JsonSchemaVersion.DRAFT4,
|
74
|
+
type: JsonSchemaType.OBJECT,
|
83
75
|
description: 'GeoJson Feature',
|
84
76
|
required: ['type', 'properties', 'geometry'],
|
85
77
|
properties: {
|
86
78
|
type: {
|
87
|
-
type:
|
79
|
+
type: JsonSchemaType.STRING,
|
88
80
|
description: 'Feature',
|
89
81
|
enum: ['Feature'],
|
90
82
|
},
|
@@ -92,32 +84,31 @@ function featureSchema(modelReference) {
|
|
92
84
|
ref: modelReference,
|
93
85
|
},
|
94
86
|
geometry: {
|
95
|
-
type:
|
87
|
+
type: JsonSchemaType.OBJECT,
|
96
88
|
description: 'GeoJSON geometry',
|
97
89
|
},
|
98
90
|
},
|
99
91
|
};
|
100
92
|
}
|
101
|
-
exports.featureSchema = featureSchema;
|
102
93
|
/**
|
103
94
|
*
|
104
95
|
* Creates a JSON Schema for a GeoJSON Feature Collection. Can be used to generate OpenAPI descriptions.
|
105
96
|
* @param modelReference Reference to a model object, in this case Features.
|
106
97
|
*/
|
107
|
-
function geojsonSchema(modelReference) {
|
98
|
+
export function geojsonSchema(modelReference) {
|
108
99
|
return {
|
109
|
-
schema:
|
110
|
-
type:
|
100
|
+
schema: JsonSchemaVersion.DRAFT4,
|
101
|
+
type: JsonSchemaType.OBJECT,
|
111
102
|
description: 'GeoJson FeatureCollection',
|
112
103
|
required: ['type', 'features'],
|
113
104
|
properties: {
|
114
105
|
type: {
|
115
|
-
type:
|
106
|
+
type: JsonSchemaType.STRING,
|
116
107
|
description: 'FeatureCollection',
|
117
108
|
enum: ['FeatureCollection'],
|
118
109
|
},
|
119
110
|
features: {
|
120
|
-
type:
|
111
|
+
type: JsonSchemaType.ARRAY,
|
121
112
|
items: {
|
122
113
|
ref: modelReference,
|
123
114
|
},
|
@@ -125,5 +116,4 @@ function geojsonSchema(modelReference) {
|
|
125
116
|
},
|
126
117
|
};
|
127
118
|
}
|
128
|
-
|
129
|
-
//# sourceMappingURL=api-model.js.map
|
119
|
+
//# sourceMappingURL=api-model.mjs.map
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* Decode given string from base64 to ascii
|
3
|
+
* @param str string
|
4
|
+
*/
|
5
|
+
export function decodeBase64ToAscii(str) {
|
6
|
+
return decodeBase64(str, 'ascii');
|
7
|
+
}
|
8
|
+
/**
|
9
|
+
* Decode given string from base64 to given encoding
|
10
|
+
* @param str
|
11
|
+
* @param encoding
|
12
|
+
*/
|
13
|
+
export function decodeBase64(str, encoding) {
|
14
|
+
return Buffer.from(str, 'base64').toString(encoding);
|
15
|
+
}
|
16
|
+
//# sourceMappingURL=base64.mjs.map
|