From 008412c65911e27f1c782e60192f91443a12294b Mon Sep 17 00:00:00 2001 From: James Bourne Date: Mon, 29 Jul 2024 15:51:08 +0200 Subject: [PATCH 1/4] fix: MEC-1030 upgrade to cimg/base:current Automated PR from multi-gitter on behalf of Team Mechagodzilla to replace deprecated `cimg/base:latest` with `cimg/base:current` --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2c79eb3b..fb8152ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: lint-and-test: docker: - - image: "cimg/base:stable" + - image: "cimg/base:current" parameters: node-version: type: string @@ -35,7 +35,7 @@ jobs: build: docker: - - image: "cimg/base:stable" + - image: "cimg/base:current" steps: - checkout - node/install: @@ -47,7 +47,7 @@ jobs: lint-commits: docker: - - image: "cimg/base:stable" + - image: "cimg/base:current" steps: - checkout - node/install: @@ -57,7 +57,7 @@ jobs: semantic-release: docker: - - image: "cimg/base:stable" + - image: "cimg/base:current" steps: - checkout - vault/get-secrets: From 33cda141c6f185c3cad9a9383bac74799bad9f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Sieros=C5=82awska?= Date: Wed, 31 Jul 2024 17:37:44 +0200 Subject: [PATCH 2/4] feat: add types for resource events (#675) --- src/requests/typings/function.ts | 23 +++++++++++++++++- src/requests/typings/resources.ts | 39 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/requests/typings/resources.ts diff --git a/src/requests/typings/function.ts b/src/requests/typings/function.ts index 331f98bd..5c9c1add 100644 --- a/src/requests/typings/function.ts +++ b/src/requests/typings/function.ts @@ -16,6 +16,14 @@ import { ScheduledActionProps, TaskProps, } from 'contentful-management' +import { + RESOURCES_SEARCH_EVENT, + RESOURCES_LOOKUP_EVENT, + type ResourcesLookupRequest, + type ResourcesLookupResponse, + type ResourcesSearchRequest, + type ResourcesSearchResponse, +} from './resources' const GRAPHQL_FIELD_MAPPING_EVENT = 'graphql.field.mapping' const GRAPHQL_QUERY_EVENT = 'graphql.query' @@ -180,9 +188,22 @@ type FunctionEventHandlers = { event: AppEventRequest response: AppEventTransformationResponse } + [RESOURCES_SEARCH_EVENT]: { + event: ResourcesSearchRequest + response: ResourcesSearchResponse + } + [RESOURCES_LOOKUP_EVENT]: { + event: ResourcesLookupRequest + response: ResourcesLookupResponse + } } -export type FunctionEvent = GraphQLFieldTypeMappingRequest | GraphQLQueryRequest | AppEventRequest +export type FunctionEvent = + | GraphQLFieldTypeMappingRequest + | GraphQLQueryRequest + | AppEventRequest + | ResourcesSearchRequest + | ResourcesLookupRequest export type FunctionEventType = keyof FunctionEventHandlers /** diff --git a/src/requests/typings/resources.ts b/src/requests/typings/resources.ts new file mode 100644 index 00000000..4cedff1c --- /dev/null +++ b/src/requests/typings/resources.ts @@ -0,0 +1,39 @@ +export const RESOURCES_SEARCH_EVENT = 'resources.search' +export const RESOURCES_LOOKUP_EVENT = 'resources.lookup' + +export type ResourcesSearchRequest = { + type: 'resources.search' + resourceType: string + query: string + limit?: number + pages?: { + nextCursor: string + } +} + +export type ResourcesSearchResponse = Record> = { + items: S[] + pages: { + nextCursor?: string + } +} + +type Scalar = string | number | boolean + +export type ResourcesLookupRequest = Record> = + { + type: 'resources.lookup' + lookupBy: L + resourceType: string + limit?: number + pages?: { + nextCursor: string + } + } + +export type ResourcesLookupResponse = Record> = { + items: L[] + pages: { + nextCursor?: string + } +} From 59ce5f5db02854dbe9e76f5a3f9829e8bf69cd8b Mon Sep 17 00:00:00 2001 From: "contentful-automation[bot]" <100587065+contentful-automation[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:39:08 +0000 Subject: [PATCH 3/4] chore(release): 3.6.0 [skip ci] # [3.6.0](https://github.com/contentful/node-apps-toolkit/compare/v3.5.0...v3.6.0) (2024-07-31) ### Features * add types for resource events ([#675](https://github.com/contentful/node-apps-toolkit/issues/675)) ([b8fed5b](https://github.com/contentful/node-apps-toolkit/commit/b8fed5b809cb0562982259fbbb13aad6037386fe)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a6ec23..4680321c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [3.6.0](https://github.com/contentful/node-apps-toolkit/compare/v3.5.0...v3.6.0) (2024-07-31) + + +### Features + +* add types for resource events ([#675](https://github.com/contentful/node-apps-toolkit/issues/675)) ([b8fed5b](https://github.com/contentful/node-apps-toolkit/commit/b8fed5b809cb0562982259fbbb13aad6037386fe)) + # [3.5.0](https://github.com/contentful/node-apps-toolkit/compare/v3.4.2...v3.5.0) (2024-07-25) diff --git a/package-lock.json b/package-lock.json index c826fcd5..91d330dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentful/node-apps-toolkit", - "version": "3.5.0", + "version": "3.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentful/node-apps-toolkit", - "version": "3.5.0", + "version": "3.6.0", "license": "MIT", "dependencies": { "@types/debug": "^4.1.5", diff --git a/package.json b/package.json index f3d490dd..ce9dee00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentful/node-apps-toolkit", - "version": "3.5.0", + "version": "3.6.0", "description": "A collection of helpers and utilities for creating NodeJS Contentful Apps", "main": "lib/index.js", "engines": { From f841505d955d18453025e6239faaa9b7e9df2b67 Mon Sep 17 00:00:00 2001 From: Mitch Goudy Date: Wed, 31 Jul 2024 15:02:14 -0600 Subject: [PATCH 4/4] log path --- src/keys/get-management-token.spec.ts | 3 +++ test/integration/keys.test.ts | 5 ++++- test/make-private-keys.sh | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/keys/get-management-token.spec.ts b/src/keys/get-management-token.spec.ts index 201e2a5e..591947bb 100644 --- a/src/keys/get-management-token.spec.ts +++ b/src/keys/get-management-token.spec.ts @@ -37,6 +37,9 @@ describe('getManagementToken', () => { const httpClient = { post } as unknown as HttpClient const getManagementToken = createGetManagementToken(logger, httpClient, defaultCache) + console.log('dirname is ', __dirname) + console.log('dirname is ', path.dirname(__dirname)) + console.log('Private Key Location:', path.join(__dirname, '..', '..', 'keys', 'key.pem')) const result = await getManagementToken(PRIVATE_KEY, DEFAULT_OPTIONS) assert.deepStrictEqual(result, mockToken) diff --git a/test/integration/keys.test.ts b/test/integration/keys.test.ts index ba658b81..6b19b4d1 100644 --- a/test/integration/keys.test.ts +++ b/test/integration/keys.test.ts @@ -24,7 +24,10 @@ describe('Keys Utilities', () => { throw new Error('Missing Environment setup') } - const privateKey = fs.readFileSync(path.join(__dirname, '..', '..', 'keys', 'key.pem'), 'utf-8') + const privateKeyPath = path.join(__dirname, '..', '..', 'keys', 'key.pem') + console.log(fs.readdirSync(path.dirname(privateKeyPath))) + + const privateKey = fs.readFileSync(privateKeyPath, 'utf-8') const token = await getManagementToken(privateKey, { appInstallationId, diff --git a/test/make-private-keys.sh b/test/make-private-keys.sh index 2f48200e..f7884cd6 100644 --- a/test/make-private-keys.sh +++ b/test/make-private-keys.sh @@ -3,4 +3,6 @@ mkdir -p keys openssl req -x509 -newkey rsa:4096 -nodes -batch -noout -keyout keys/key.pem -openssl rsa -in keys/key.pem -pubout -outform DER -out keys/key.der.pub \ No newline at end of file +openssl rsa -in keys/key.pem -pubout -outform DER -out keys/key.der.pub +echo "Newly created private and public keys:" +ls -l keys \ No newline at end of file