@unchainedshop/cockpit-api 1.0.25 → 1.0.26

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.
@@ -0,0 +1,33 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 16
18
+ - run: npm ci
19
+ - run: npm test
20
+
21
+ publish-npm:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-node@v3
27
+ with:
28
+ node-version: 16
29
+ registry-url: https://registry.npmjs.org/
30
+ - run: npm ci
31
+ - run: npm publish
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/cockpit-api",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "A package to interact with the Cockpit CMS API, including functionalities to handle GraphQL requests and various CMS content manipulations.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://unchained.shop",
package/src/api.ts CHANGED
@@ -102,8 +102,6 @@ export const FixImagePaths = (replacements: any, tenant?: string) => {
102
102
  const fixedDataString = rawResponseDataString
103
103
  // fixes asset paths
104
104
  .replace(/"path":"\//g, `"path":"${url}/storage/uploads/`)
105
- .replace(/src=\\"\/storage/gi, `src=\\"${url}/storage`)
106
- .replace(/href=\\"\/storage/gi, `href=\\"${url}/storage`)
107
105
  .replace(/src=\\"(\/\:[^:]+\/)?storage/gi, `src=\\"${cockpitURL.origin}/$1storage`)
108
106
  .replace(/href=\\"(\/\:[^:]+\/)?storage/gi, `href=\\"${cockpitURL.origin}/$1storage`)
109
107
  .replace(pattern, (match) => replacements[match])
@@ -135,8 +133,7 @@ const handleErrorAndLog = (e: Error) => {
135
133
 
136
134
  export const CockpitAPI = async (tenant?: string) => {
137
135
  if (!COCKPIT_GRAPHQL_ENDPOINT) throw Error("COCKPIT_GRAPHQL_ENDPOINT is not set")
138
- const secretName = ["COCKPIT_SECRET", tenant].filter(Boolean).join("_");
139
- const token = process.env[secretName];
136
+
140
137
 
141
138
  const buildUrl = (path: string, { locale = "de", queryParams = {} } = {}) => {
142
139
  const normalizedLocale = locale === "de" ? "default" : locale;
@@ -168,6 +165,8 @@ export const CockpitAPI = async (tenant?: string) => {
168
165
  const headers = options?.headers ?? {};
169
166
 
170
167
  if (useAdminAccess) {
168
+ const secretName = ["COCKPIT_SECRET", tenant].filter(Boolean).join("_");
169
+ const token = process.env[secretName];
171
170
  headers["API-Key"] = token;
172
171
  }
173
172